package
1.4.0-rc.2
Repository: https://github.com/iotaledger/wasp.git
Documentation: pkg.go.dev

# README

Go API client for client

REST API for the Wasp node

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 1
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Generation

  • Install newest OpenAPI Generator binary
  • Run an up to date Wasp node
  • Execute openapi-generator-cli generate -i http://localhost:9090/doc/swagger.json -g go --package-name=client

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import "github.com/iotaledger/wasp/clients/apiclient"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), apiclient.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), apiclient.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), apiclient.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), apiclient.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to http://localhost:9090

ClassMethodHTTP requestDescription
AuthApiAuthInfoGet /auth/infoGet information about the current authentication mode
AuthApiAuthenticatePost /authAuthenticate towards the node
ChainsApiActivateChainPost /v1/chains/{chainID}/activateActivate a chain
ChainsApiAddAccessNodePut /v1/chains/{chainID}/access-node/{peer}Configure a trusted node to be an access node.
ChainsApiDeactivateChainPost /v1/chains/{chainID}/deactivateDeactivate a chain
ChainsApiGetChainInfoGet /v1/chains/{chainID}Get information about a specific chain
ChainsApiGetChainsGet /v1/chainsGet a list of all chains
ChainsApiGetCommitteeInfoGet /v1/chains/{chainID}/committeeGet information about the deployed committee
ChainsApiGetContractsGet /v1/chains/{chainID}/contractsGet all available chain contracts
ChainsApiGetRequestIDFromEVMTransactionIDGet /v1/chains/{chainID}/evm/tx/{txHash}Get the ISC request ID for the given Ethereum transaction hash
ChainsApiGetStateValueGet /v1/chains/{chainID}/state/{stateKey}Fetch the raw value associated with the given key in the chain state
ChainsApiRemoveAccessNodeDelete /v1/chains/{chainID}/access-node/{peer}Remove an access node.
ChainsApiSetChainRecordPost /v1/chains/{chainID}/chainrecordSets the chain record.
ChainsApiV1ChainsChainIDEvmGetGet /v1/chains/{chainID}/evmEthereum JSON-RPC
ChainsApiV1ChainsChainIDEvmWsGetGet /v1/chains/{chainID}/evm/wsEthereum JSON-RPC (Websocket transport)
CorecontractsApiAccountsGetAccountBalanceGet /v1/chains/{chainID}/core/accounts/account/{agentID}/balanceGet all assets belonging to an account
CorecontractsApiAccountsGetAccountFoundriesGet /v1/chains/{chainID}/core/accounts/account/{agentID}/foundriesGet all foundries owned by an account
CorecontractsApiAccountsGetAccountNFTIDsGet /v1/chains/{chainID}/core/accounts/account/{agentID}/nftsGet all NFT ids belonging to an account
CorecontractsApiAccountsGetAccountNonceGet /v1/chains/{chainID}/core/accounts/account/{agentID}/nonceGet the current nonce of an account
CorecontractsApiAccountsGetAccountsGet /v1/chains/{chainID}/core/accountsGet a list of all accounts
CorecontractsApiAccountsGetFoundryOutputGet /v1/chains/{chainID}/core/accounts/foundry_output/{serialNumber}Get the foundry output
CorecontractsApiAccountsGetNFTDataGet /v1/chains/{chainID}/core/accounts/nftdata/{nftID}Get the NFT data by an ID
CorecontractsApiAccountsGetNativeTokenIDRegistryGet /v1/chains/{chainID}/core/accounts/token_registryGet a list of all registries
CorecontractsApiAccountsGetTotalAssetsGet /v1/chains/{chainID}/core/accounts/total_assetsGet all stored assets
CorecontractsApiBlobsGetAllBlobsGet /v1/chains/{chainID}/core/blobsGet all stored blobs
CorecontractsApiBlobsGetBlobInfoGet /v1/chains/{chainID}/core/blobs/{blobHash}Get all fields of a blob
CorecontractsApiBlobsGetBlobValueGet /v1/chains/{chainID}/core/blobs/{blobHash}/data/{fieldKey}Get the value of the supplied field (key)
CorecontractsApiBlocklogGetBlockInfoGet /v1/chains/{chainID}/core/blocklog/blocks/{blockIndex}Get the block info of a certain block index
CorecontractsApiBlocklogGetControlAddressesGet /v1/chains/{chainID}/core/blocklog/controladdressesGet the control addresses
CorecontractsApiBlocklogGetEventsOfBlockGet /v1/chains/{chainID}/core/blocklog/events/block/{blockIndex}Get events of a block
CorecontractsApiBlocklogGetEventsOfContractGet /v1/chains/{chainID}/core/blocklog/events/contract/{contractHname}Get events of a contract
CorecontractsApiBlocklogGetEventsOfLatestBlockGet /v1/chains/{chainID}/core/blocklog/events/block/latestGet events of the latest block
CorecontractsApiBlocklogGetEventsOfRequestGet /v1/chains/{chainID}/core/blocklog/events/request/{requestID}Get events of a request
CorecontractsApiBlocklogGetLatestBlockInfoGet /v1/chains/{chainID}/core/blocklog/blocks/latestGet the block info of the latest block
CorecontractsApiBlocklogGetRequestIDsForBlockGet /v1/chains/{chainID}/core/blocklog/blocks/{blockIndex}/requestidsGet the request ids for a certain block index
CorecontractsApiBlocklogGetRequestIDsForLatestBlockGet /v1/chains/{chainID}/core/blocklog/blocks/latest/requestidsGet the request ids for the latest block
CorecontractsApiBlocklogGetRequestIsProcessedGet /v1/chains/{chainID}/core/blocklog/requests/{requestID}/is_processedGet the request processing status
CorecontractsApiBlocklogGetRequestReceiptGet /v1/chains/{chainID}/core/blocklog/requests/{requestID}Get the receipt of a certain request id
CorecontractsApiBlocklogGetRequestReceiptsOfBlockGet /v1/chains/{chainID}/core/blocklog/blocks/{blockIndex}/receiptsGet all receipts of a certain block
CorecontractsApiBlocklogGetRequestReceiptsOfLatestBlockGet /v1/chains/{chainID}/core/blocklog/blocks/latest/receiptsGet all receipts of the latest block
CorecontractsApiErrorsGetErrorMessageFormatGet /v1/chains/{chainID}/core/errors/{contractHname}/message/{errorID}Get the error message format of a specific error id
CorecontractsApiGovernanceGetAllowedStateControllerAddressesGet /v1/chains/{chainID}/core/governance/allowedstatecontrollersGet the allowed state controller addresses
CorecontractsApiGovernanceGetChainInfoGet /v1/chains/{chainID}/core/governance/chaininfoGet the chain info
CorecontractsApiGovernanceGetChainOwnerGet /v1/chains/{chainID}/core/governance/chainownerGet the chain owner
DefaultApiGetHealthGet /healthReturns 200 if the node is healthy.
DefaultApiV1WsGetGet /v1/wsThe websocket connection service
MetricsApiGetChainMessageMetricsGet /v1/metrics/chain/{chainID}/messagesGet chain specific message metrics.
MetricsApiGetChainPipeMetricsGet /v1/metrics/chain/{chainID}/pipeGet chain pipe event metrics.
MetricsApiGetChainWorkflowMetricsGet /v1/metrics/chain/{chainID}/workflowGet chain workflow metrics.
MetricsApiGetNodeMessageMetricsGet /v1/metrics/node/messagesGet accumulated message metrics.
NodeApiDistrustPeerDelete /v1/node/peers/trusted/{peer}Distrust a peering node
NodeApiGenerateDKSPost /v1/node/dksGenerate a new distributed key
NodeApiGetAllPeersGet /v1/node/peersGet basic information about all configured peers
NodeApiGetConfigurationGet /v1/node/configReturn the Wasp configuration
NodeApiGetDKSInfoGet /v1/node/dks/{sharedAddress}Get information about the shared address DKS configuration
NodeApiGetInfoGet /v1/node/infoReturns private information about this node.
NodeApiGetPeeringIdentityGet /v1/node/peers/identityGet basic peer info of the current node
NodeApiGetTrustedPeersGet /v1/node/peers/trustedGet trusted peers
NodeApiGetVersionGet /v1/node/versionReturns the node version.
NodeApiSetNodeOwnerPost /v1/node/owner/certificateSets the node owner
NodeApiShutdownNodePost /v1/node/shutdownShut down the node
NodeApiTrustPeerPost /v1/node/peers/trustedTrust a peering node
RequestsApiCallViewPost /v1/requests/callviewCall a view function on a contract by Hname
RequestsApiGetReceiptGet /v1/chains/{chainID}/receipts/{requestID}Get a receipt from a request ID
RequestsApiOffLedgerPost /v1/requests/offledgerPost an off-ledger request
RequestsApiWaitForRequestGet /v1/chains/{chainID}/requests/{requestID}/waitWait until the given request has been processed by the node
UsersApiAddUserPost /v1/usersAdd a user
UsersApiChangeUserPasswordPut /v1/users/{username}/passwordChange user password
UsersApiChangeUserPermissionsPut /v1/users/{username}/permissionsChange user permissions
UsersApiDeleteUserDelete /v1/users/{username}Deletes a user
UsersApiGetUserGet /v1/users/{username}Get a user
UsersApiGetUsersGet /v1/usersGet a list of all users

Documentation For Models

Documentation For Authorization

Authorization

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Authorization and passed in as the auth context for each request.

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author