mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
1591 lines
43 KiB
Go
1591 lines
43 KiB
Go
// Package e2e provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/deepmap/oapi-codegen version v1.13.4 DO NOT EDIT.
|
|
package e2e
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|
)
|
|
|
|
// Account Information about an account and its balance
|
|
type Account struct {
|
|
// Balance balance in base units for each currency
|
|
Balance []Amount `json:"balance"`
|
|
|
|
// Id account id as registered at the Certificate Authority
|
|
Id string `json:"id"`
|
|
}
|
|
|
|
// Amount The amount to issue, transfer or redeem.
|
|
type Amount struct {
|
|
// Code the code of the token
|
|
Code string `json:"code"`
|
|
|
|
// Value value in base units (usually cents)
|
|
Value int64 `json:"value"`
|
|
}
|
|
|
|
// Counterparty The counterparty in a Transfer or Issuance transaction.
|
|
type Counterparty struct {
|
|
Account string `json:"account"`
|
|
|
|
// Node The node that holds the recipient account
|
|
Node string `json:"node"`
|
|
}
|
|
|
|
// Error defines model for Error.
|
|
type Error struct {
|
|
// Message High level error message
|
|
Message string `json:"message"`
|
|
|
|
// Payload Details about the error
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// RedeemRequest Instructions to redeem tokens from an account
|
|
type RedeemRequest struct {
|
|
// Amount The amount to issue, transfer or redeem.
|
|
Amount Amount `json:"amount"`
|
|
|
|
// Message optional message that will be visible to the auditor
|
|
Message *string `json:"message,omitempty"`
|
|
}
|
|
|
|
// TransactionRecord A transaction
|
|
type TransactionRecord struct {
|
|
// Amount The amount to issue, transfer or redeem.
|
|
Amount Amount `json:"amount"`
|
|
|
|
// Id transaction id
|
|
Id string `json:"id"`
|
|
|
|
// Message user provided message
|
|
Message string `json:"message"`
|
|
|
|
// Recipient the recipient of the transaction
|
|
Recipient string `json:"recipient"`
|
|
|
|
// Sender the sender of the transaction
|
|
Sender string `json:"sender"`
|
|
|
|
// Status Unknown | Pending | Confirmed | Deleted
|
|
Status string `json:"status"`
|
|
|
|
// Timestamp timestamp in the format: "2018-03-20T09:12:28Z"
|
|
Timestamp time.Time `json:"timestamp"`
|
|
}
|
|
|
|
// TransferRequest Instructions to issue or transfer tokens to an account
|
|
type TransferRequest struct {
|
|
// Amount The amount to issue, transfer or redeem.
|
|
Amount Amount `json:"amount"`
|
|
|
|
// Counterparty The counterparty in a Transfer or Issuance transaction.
|
|
Counterparty Counterparty `json:"counterparty"`
|
|
|
|
// Message optional message that will be sent and stored with the transfer transaction
|
|
Message *string `json:"message,omitempty"`
|
|
}
|
|
|
|
// Code The token code to filter on
|
|
type Code = string
|
|
|
|
// Id account id as registered at the Certificate Authority
|
|
type Id = string
|
|
|
|
// AccountSuccess defines model for AccountSuccess.
|
|
type AccountSuccess struct {
|
|
Message string `json:"message"`
|
|
|
|
// Payload Information about an account and its balance
|
|
Payload Account `json:"payload"`
|
|
}
|
|
|
|
// AccountsSuccess defines model for AccountsSuccess.
|
|
type AccountsSuccess struct {
|
|
Message string `json:"message"`
|
|
Payload []Account `json:"payload"`
|
|
}
|
|
|
|
// ErrorResponse defines model for ErrorResponse.
|
|
type ErrorResponse = Error
|
|
|
|
// HealthSuccess defines model for HealthSuccess.
|
|
type HealthSuccess struct {
|
|
// Message ok
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// IssueSuccess defines model for IssueSuccess.
|
|
type IssueSuccess struct {
|
|
Message string `json:"message"`
|
|
|
|
// Payload Transaction id
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// RedeemSuccess defines model for RedeemSuccess.
|
|
type RedeemSuccess struct {
|
|
Message string `json:"message"`
|
|
|
|
// Payload Transaction id
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// TransactionsSuccess defines model for TransactionsSuccess.
|
|
type TransactionsSuccess struct {
|
|
Message string `json:"message"`
|
|
Payload []TransactionRecord `json:"payload"`
|
|
}
|
|
|
|
// TransferSuccess defines model for TransferSuccess.
|
|
type TransferSuccess struct {
|
|
Message string `json:"message"`
|
|
|
|
// Payload Transaction id
|
|
Payload string `json:"payload"`
|
|
}
|
|
|
|
// AuditorAccountParams defines parameters for AuditorAccount.
|
|
type AuditorAccountParams struct {
|
|
Code *Code `form:"code,omitempty" json:"code,omitempty"`
|
|
}
|
|
|
|
// OwnerAccountParams defines parameters for OwnerAccount.
|
|
type OwnerAccountParams struct {
|
|
Code *Code `form:"code,omitempty" json:"code,omitempty"`
|
|
}
|
|
|
|
// IssueJSONRequestBody defines body for Issue for application/json ContentType.
|
|
type IssueJSONRequestBody = TransferRequest
|
|
|
|
// RedeemJSONRequestBody defines body for Redeem for application/json ContentType.
|
|
type RedeemJSONRequestBody = RedeemRequest
|
|
|
|
// TransferJSONRequestBody defines body for Transfer for application/json ContentType.
|
|
type TransferJSONRequestBody = TransferRequest
|
|
|
|
// RequestEditorFn is the function signature for the RequestEditor callback function
|
|
type RequestEditorFn func(ctx context.Context, req *http.Request) error
|
|
|
|
// Doer performs HTTP requests.
|
|
//
|
|
// The standard http.Client implements this interface.
|
|
type HttpRequestDoer interface {
|
|
Do(req *http.Request) (*http.Response, error)
|
|
}
|
|
|
|
// Client which conforms to the OpenAPI3 specification for this service.
|
|
type Client struct {
|
|
// The endpoint of the server conforming to this interface, with scheme,
|
|
// https://api.deepmap.com for example. This can contain a path relative
|
|
// to the server, such as https://api.deepmap.com/dev-test, and all the
|
|
// paths in the swagger spec will be appended to the server.
|
|
Server string
|
|
|
|
// Doer for performing requests, typically a *http.Client with any
|
|
// customized settings, such as certificate chains.
|
|
Client HttpRequestDoer
|
|
|
|
// A list of callbacks for modifying requests which are generated before sending over
|
|
// the network.
|
|
RequestEditors []RequestEditorFn
|
|
}
|
|
|
|
// ClientOption allows setting custom parameters during construction
|
|
type ClientOption func(*Client) error
|
|
|
|
// Creates a new Client, with reasonable defaults
|
|
func NewClient(server string, opts ...ClientOption) (*Client, error) {
|
|
// create a client with sane default values
|
|
client := Client{
|
|
Server: server,
|
|
}
|
|
// mutate client and add all optional params
|
|
for _, o := range opts {
|
|
if err := o(&client); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
// ensure the server URL always has a trailing slash
|
|
if !strings.HasSuffix(client.Server, "/") {
|
|
client.Server += "/"
|
|
}
|
|
// create httpClient, if not already present
|
|
if client.Client == nil {
|
|
client.Client = &http.Client{}
|
|
}
|
|
return &client, nil
|
|
}
|
|
|
|
// WithHTTPClient allows overriding the default Doer, which is
|
|
// automatically created using http.Client. This is useful for tests.
|
|
func WithHTTPClient(doer HttpRequestDoer) ClientOption {
|
|
return func(c *Client) error {
|
|
c.Client = doer
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRequestEditorFn allows setting up a callback function, which will be
|
|
// called right before sending the request. This can be used to mutate the request.
|
|
func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
|
|
return func(c *Client) error {
|
|
c.RequestEditors = append(c.RequestEditors, fn)
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// The interface specification for the client above.
|
|
type ClientInterface interface {
|
|
// AuditorAccount request
|
|
AuditorAccount(ctx context.Context, id Id, params *AuditorAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// AuditorTransactions request
|
|
AuditorTransactions(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// Healthz request
|
|
Healthz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// IssueWithBody request with any body
|
|
IssueWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
Issue(ctx context.Context, body IssueJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// OwnerAccounts request
|
|
OwnerAccounts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// OwnerAccount request
|
|
OwnerAccount(ctx context.Context, id Id, params *OwnerAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// RedeemWithBody request with any body
|
|
RedeemWithBody(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
Redeem(ctx context.Context, id Id, body RedeemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// OwnerTransactions request
|
|
OwnerTransactions(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// TransferWithBody request with any body
|
|
TransferWithBody(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
Transfer(ctx context.Context, id Id, body TransferJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
|
|
// Readyz request
|
|
Readyz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
|
|
}
|
|
|
|
func (c *Client) AuditorAccount(ctx context.Context, id Id, params *AuditorAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewAuditorAccountRequest(c.Server, id, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) AuditorTransactions(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewAuditorTransactionsRequest(c.Server, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) Healthz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewHealthzRequest(c.Server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) IssueWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewIssueRequestWithBody(c.Server, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) Issue(ctx context.Context, body IssueJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewIssueRequest(c.Server, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) OwnerAccounts(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewOwnerAccountsRequest(c.Server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) OwnerAccount(ctx context.Context, id Id, params *OwnerAccountParams, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewOwnerAccountRequest(c.Server, id, params)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) RedeemWithBody(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewRedeemRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) Redeem(ctx context.Context, id Id, body RedeemJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewRedeemRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) OwnerTransactions(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewOwnerTransactionsRequest(c.Server, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) TransferWithBody(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewTransferRequestWithBody(c.Server, id, contentType, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) Transfer(ctx context.Context, id Id, body TransferJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewTransferRequest(c.Server, id, body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
func (c *Client) Readyz(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
|
|
req, err := NewReadyzRequest(c.Server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
req = req.WithContext(ctx)
|
|
if err := c.applyEditors(ctx, req, reqEditors); err != nil {
|
|
return nil, err
|
|
}
|
|
return c.Client.Do(req)
|
|
}
|
|
|
|
// NewAuditorAccountRequest generates requests for AuditorAccount
|
|
func NewAuditorAccountRequest(server string, id Id, params *AuditorAccountParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/auditor/accounts/%s", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
queryValues := queryURL.Query()
|
|
|
|
if params.Code != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithLocation("form", true, "code", runtime.ParamLocationQuery, *params.Code); err != nil {
|
|
return nil, err
|
|
} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for k, v := range parsed {
|
|
for _, v2 := range v {
|
|
queryValues.Add(k, v2)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
queryURL.RawQuery = queryValues.Encode()
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewAuditorTransactionsRequest generates requests for AuditorTransactions
|
|
func NewAuditorTransactionsRequest(server string, id Id) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/auditor/accounts/%s/transactions", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewHealthzRequest generates requests for Healthz
|
|
func NewHealthzRequest(server string) (*http.Request, error) {
|
|
var err error
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/healthz")
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewIssueRequest calls the generic Issue builder with application/json body
|
|
func NewIssueRequest(server string, body IssueJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewIssueRequestWithBody(server, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewIssueRequestWithBody generates requests for Issue with any type of body
|
|
func NewIssueRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/issuer/issue")
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("POST", queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewOwnerAccountsRequest generates requests for OwnerAccounts
|
|
func NewOwnerAccountsRequest(server string) (*http.Request, error) {
|
|
var err error
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/owner/accounts")
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewOwnerAccountRequest generates requests for OwnerAccount
|
|
func NewOwnerAccountRequest(server string, id Id, params *OwnerAccountParams) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/owner/accounts/%s", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if params != nil {
|
|
queryValues := queryURL.Query()
|
|
|
|
if params.Code != nil {
|
|
|
|
if queryFrag, err := runtime.StyleParamWithLocation("form", true, "code", runtime.ParamLocationQuery, *params.Code); err != nil {
|
|
return nil, err
|
|
} else if parsed, err := url.ParseQuery(queryFrag); err != nil {
|
|
return nil, err
|
|
} else {
|
|
for k, v := range parsed {
|
|
for _, v2 := range v {
|
|
queryValues.Add(k, v2)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
queryURL.RawQuery = queryValues.Encode()
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewRedeemRequest calls the generic Redeem builder with application/json body
|
|
func NewRedeemRequest(server string, id Id, body RedeemJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewRedeemRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewRedeemRequestWithBody generates requests for Redeem with any type of body
|
|
func NewRedeemRequestWithBody(server string, id Id, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/owner/accounts/%s/redeem", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("POST", queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewOwnerTransactionsRequest generates requests for OwnerTransactions
|
|
func NewOwnerTransactionsRequest(server string, id Id) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/owner/accounts/%s/transactions", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewTransferRequest calls the generic Transfer builder with application/json body
|
|
func NewTransferRequest(server string, id Id, body TransferJSONRequestBody) (*http.Request, error) {
|
|
var bodyReader io.Reader
|
|
buf, err := json.Marshal(body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
bodyReader = bytes.NewReader(buf)
|
|
return NewTransferRequestWithBody(server, id, "application/json", bodyReader)
|
|
}
|
|
|
|
// NewTransferRequestWithBody generates requests for Transfer with any type of body
|
|
func NewTransferRequestWithBody(server string, id Id, contentType string, body io.Reader) (*http.Request, error) {
|
|
var err error
|
|
|
|
var pathParam0 string
|
|
|
|
pathParam0, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/owner/accounts/%s/transfer", pathParam0)
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("POST", queryURL.String(), body)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req.Header.Add("Content-Type", contentType)
|
|
|
|
return req, nil
|
|
}
|
|
|
|
// NewReadyzRequest generates requests for Readyz
|
|
func NewReadyzRequest(server string) (*http.Request, error) {
|
|
var err error
|
|
|
|
serverURL, err := url.Parse(server)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
operationPath := fmt.Sprintf("/readyz")
|
|
if operationPath[0] == '/' {
|
|
operationPath = "." + operationPath
|
|
}
|
|
|
|
queryURL, err := serverURL.Parse(operationPath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
req, err := http.NewRequest("GET", queryURL.String(), nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return req, nil
|
|
}
|
|
|
|
func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
|
|
for _, r := range c.RequestEditors {
|
|
if err := r(ctx, req); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
for _, r := range additionalEditors {
|
|
if err := r(ctx, req); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClientWithResponses builds on ClientInterface to offer response payloads
|
|
type ClientWithResponses struct {
|
|
ClientInterface
|
|
}
|
|
|
|
// NewClientWithResponses creates a new ClientWithResponses, which wraps
|
|
// Client with return type handling
|
|
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
|
|
client, err := NewClient(server, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &ClientWithResponses{client}, nil
|
|
}
|
|
|
|
// WithBaseURL overrides the baseURL.
|
|
func WithBaseURL(baseURL string) ClientOption {
|
|
return func(c *Client) error {
|
|
newBaseURL, err := url.Parse(baseURL)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
c.Server = newBaseURL.String()
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// ClientWithResponsesInterface is the interface specification for the client with responses above.
|
|
type ClientWithResponsesInterface interface {
|
|
// AuditorAccountWithResponse request
|
|
AuditorAccountWithResponse(ctx context.Context, id Id, params *AuditorAccountParams, reqEditors ...RequestEditorFn) (*AuditorAccountResponse, error)
|
|
|
|
// AuditorTransactionsWithResponse request
|
|
AuditorTransactionsWithResponse(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*AuditorTransactionsResponse, error)
|
|
|
|
// HealthzWithResponse request
|
|
HealthzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthzResponse, error)
|
|
|
|
// IssueWithBodyWithResponse request with any body
|
|
IssueWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IssueResponse, error)
|
|
|
|
IssueWithResponse(ctx context.Context, body IssueJSONRequestBody, reqEditors ...RequestEditorFn) (*IssueResponse, error)
|
|
|
|
// OwnerAccountsWithResponse request
|
|
OwnerAccountsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*OwnerAccountsResponse, error)
|
|
|
|
// OwnerAccountWithResponse request
|
|
OwnerAccountWithResponse(ctx context.Context, id Id, params *OwnerAccountParams, reqEditors ...RequestEditorFn) (*OwnerAccountResponse, error)
|
|
|
|
// RedeemWithBodyWithResponse request with any body
|
|
RedeemWithBodyWithResponse(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RedeemResponse, error)
|
|
|
|
RedeemWithResponse(ctx context.Context, id Id, body RedeemJSONRequestBody, reqEditors ...RequestEditorFn) (*RedeemResponse, error)
|
|
|
|
// OwnerTransactionsWithResponse request
|
|
OwnerTransactionsWithResponse(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*OwnerTransactionsResponse, error)
|
|
|
|
// TransferWithBodyWithResponse request with any body
|
|
TransferWithBodyWithResponse(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TransferResponse, error)
|
|
|
|
TransferWithResponse(ctx context.Context, id Id, body TransferJSONRequestBody, reqEditors ...RequestEditorFn) (*TransferResponse, error)
|
|
|
|
// ReadyzWithResponse request
|
|
ReadyzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReadyzResponse, error)
|
|
}
|
|
|
|
type AuditorAccountResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *AccountSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r AuditorAccountResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r AuditorAccountResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type AuditorTransactionsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *TransactionsSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r AuditorTransactionsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r AuditorTransactionsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type HealthzResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *HealthSuccess
|
|
JSON503 *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r HealthzResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r HealthzResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type IssueResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *IssueSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r IssueResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r IssueResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type OwnerAccountsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *AccountsSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r OwnerAccountsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r OwnerAccountsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type OwnerAccountResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *AccountSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r OwnerAccountResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r OwnerAccountResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type RedeemResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *RedeemSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r RedeemResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r RedeemResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type OwnerTransactionsResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *TransactionsSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r OwnerTransactionsResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r OwnerTransactionsResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type TransferResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *TransferSuccess
|
|
JSONDefault *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r TransferResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r TransferResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
type ReadyzResponse struct {
|
|
Body []byte
|
|
HTTPResponse *http.Response
|
|
JSON200 *HealthSuccess
|
|
JSON503 *ErrorResponse
|
|
}
|
|
|
|
// Status returns HTTPResponse.Status
|
|
func (r ReadyzResponse) Status() string {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.Status
|
|
}
|
|
return http.StatusText(0)
|
|
}
|
|
|
|
// StatusCode returns HTTPResponse.StatusCode
|
|
func (r ReadyzResponse) StatusCode() int {
|
|
if r.HTTPResponse != nil {
|
|
return r.HTTPResponse.StatusCode
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// AuditorAccountWithResponse request returning *AuditorAccountResponse
|
|
func (c *ClientWithResponses) AuditorAccountWithResponse(ctx context.Context, id Id, params *AuditorAccountParams, reqEditors ...RequestEditorFn) (*AuditorAccountResponse, error) {
|
|
rsp, err := c.AuditorAccount(ctx, id, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseAuditorAccountResponse(rsp)
|
|
}
|
|
|
|
// AuditorTransactionsWithResponse request returning *AuditorTransactionsResponse
|
|
func (c *ClientWithResponses) AuditorTransactionsWithResponse(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*AuditorTransactionsResponse, error) {
|
|
rsp, err := c.AuditorTransactions(ctx, id, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseAuditorTransactionsResponse(rsp)
|
|
}
|
|
|
|
// HealthzWithResponse request returning *HealthzResponse
|
|
func (c *ClientWithResponses) HealthzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthzResponse, error) {
|
|
rsp, err := c.Healthz(ctx, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseHealthzResponse(rsp)
|
|
}
|
|
|
|
// IssueWithBodyWithResponse request with arbitrary body returning *IssueResponse
|
|
func (c *ClientWithResponses) IssueWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IssueResponse, error) {
|
|
rsp, err := c.IssueWithBody(ctx, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseIssueResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) IssueWithResponse(ctx context.Context, body IssueJSONRequestBody, reqEditors ...RequestEditorFn) (*IssueResponse, error) {
|
|
rsp, err := c.Issue(ctx, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseIssueResponse(rsp)
|
|
}
|
|
|
|
// OwnerAccountsWithResponse request returning *OwnerAccountsResponse
|
|
func (c *ClientWithResponses) OwnerAccountsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*OwnerAccountsResponse, error) {
|
|
rsp, err := c.OwnerAccounts(ctx, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseOwnerAccountsResponse(rsp)
|
|
}
|
|
|
|
// OwnerAccountWithResponse request returning *OwnerAccountResponse
|
|
func (c *ClientWithResponses) OwnerAccountWithResponse(ctx context.Context, id Id, params *OwnerAccountParams, reqEditors ...RequestEditorFn) (*OwnerAccountResponse, error) {
|
|
rsp, err := c.OwnerAccount(ctx, id, params, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseOwnerAccountResponse(rsp)
|
|
}
|
|
|
|
// RedeemWithBodyWithResponse request with arbitrary body returning *RedeemResponse
|
|
func (c *ClientWithResponses) RedeemWithBodyWithResponse(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RedeemResponse, error) {
|
|
rsp, err := c.RedeemWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseRedeemResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) RedeemWithResponse(ctx context.Context, id Id, body RedeemJSONRequestBody, reqEditors ...RequestEditorFn) (*RedeemResponse, error) {
|
|
rsp, err := c.Redeem(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseRedeemResponse(rsp)
|
|
}
|
|
|
|
// OwnerTransactionsWithResponse request returning *OwnerTransactionsResponse
|
|
func (c *ClientWithResponses) OwnerTransactionsWithResponse(ctx context.Context, id Id, reqEditors ...RequestEditorFn) (*OwnerTransactionsResponse, error) {
|
|
rsp, err := c.OwnerTransactions(ctx, id, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseOwnerTransactionsResponse(rsp)
|
|
}
|
|
|
|
// TransferWithBodyWithResponse request with arbitrary body returning *TransferResponse
|
|
func (c *ClientWithResponses) TransferWithBodyWithResponse(ctx context.Context, id Id, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TransferResponse, error) {
|
|
rsp, err := c.TransferWithBody(ctx, id, contentType, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseTransferResponse(rsp)
|
|
}
|
|
|
|
func (c *ClientWithResponses) TransferWithResponse(ctx context.Context, id Id, body TransferJSONRequestBody, reqEditors ...RequestEditorFn) (*TransferResponse, error) {
|
|
rsp, err := c.Transfer(ctx, id, body, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseTransferResponse(rsp)
|
|
}
|
|
|
|
// ReadyzWithResponse request returning *ReadyzResponse
|
|
func (c *ClientWithResponses) ReadyzWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReadyzResponse, error) {
|
|
rsp, err := c.Readyz(ctx, reqEditors...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseReadyzResponse(rsp)
|
|
}
|
|
|
|
// ParseAuditorAccountResponse parses an HTTP response from a AuditorAccountWithResponse call
|
|
func ParseAuditorAccountResponse(rsp *http.Response) (*AuditorAccountResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &AuditorAccountResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest AccountSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseAuditorTransactionsResponse parses an HTTP response from a AuditorTransactionsWithResponse call
|
|
func ParseAuditorTransactionsResponse(rsp *http.Response) (*AuditorTransactionsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &AuditorTransactionsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest TransactionsSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseHealthzResponse parses an HTTP response from a HealthzWithResponse call
|
|
func ParseHealthzResponse(rsp *http.Response) (*HealthzResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &HealthzResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest HealthSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON503 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseIssueResponse parses an HTTP response from a IssueWithResponse call
|
|
func ParseIssueResponse(rsp *http.Response) (*IssueResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &IssueResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest IssueSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseOwnerAccountsResponse parses an HTTP response from a OwnerAccountsWithResponse call
|
|
func ParseOwnerAccountsResponse(rsp *http.Response) (*OwnerAccountsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &OwnerAccountsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest AccountsSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseOwnerAccountResponse parses an HTTP response from a OwnerAccountWithResponse call
|
|
func ParseOwnerAccountResponse(rsp *http.Response) (*OwnerAccountResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &OwnerAccountResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest AccountSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseRedeemResponse parses an HTTP response from a RedeemWithResponse call
|
|
func ParseRedeemResponse(rsp *http.Response) (*RedeemResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &RedeemResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest RedeemSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseOwnerTransactionsResponse parses an HTTP response from a OwnerTransactionsWithResponse call
|
|
func ParseOwnerTransactionsResponse(rsp *http.Response) (*OwnerTransactionsResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &OwnerTransactionsResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest TransactionsSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseTransferResponse parses an HTTP response from a TransferWithResponse call
|
|
func ParseTransferResponse(rsp *http.Response) (*TransferResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &TransferResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest TransferSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSONDefault = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|
|
|
|
// ParseReadyzResponse parses an HTTP response from a ReadyzWithResponse call
|
|
func ParseReadyzResponse(rsp *http.Response) (*ReadyzResponse, error) {
|
|
bodyBytes, err := io.ReadAll(rsp.Body)
|
|
defer func() { _ = rsp.Body.Close() }()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
response := &ReadyzResponse{
|
|
Body: bodyBytes,
|
|
HTTPResponse: rsp,
|
|
}
|
|
|
|
switch {
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
|
|
var dest HealthSuccess
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON200 = &dest
|
|
|
|
case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 503:
|
|
var dest ErrorResponse
|
|
if err := json.Unmarshal(bodyBytes, &dest); err != nil {
|
|
return nil, err
|
|
}
|
|
response.JSON503 = &dest
|
|
|
|
}
|
|
|
|
return response, nil
|
|
}
|