internal

package
v0.1.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultUserAgent string

DefaultUserAgent :

Functions

func GetOperationRawRequest added in v0.1.15

func GetOperationRawRequest(op *Operation) *gentleman.Request

GetOperationRawRequest return the underlying raw request

func ReplacePlaceHolder

func ReplacePlaceHolder(s string, params map[string]string) string

ReplacePlaceHolder replaces the placeholder with the given string.

Types

type BkApiClient

type BkApiClient struct {
	// contains filtered or unexported fields
}

BkApiClient is a base client for define.

func NewBkApiClient

func NewBkApiClient(
	name string,
	client *gentleman.Client,
	factory func(name string, client define.BkApiClient, request *gentleman.Request) define.Operation,
	config define.ClientConfig,
) (*BkApiClient, error)

NewBkApiClient creates a new BkApiClient.

func (*BkApiClient) AddOperationOptions

func (cli *BkApiClient) AddOperationOptions(opts ...define.OperationOption) error

AddOperationOptions method adds the common options to each operation.

func (*BkApiClient) Apply

func (cli *BkApiClient) Apply(opts ...define.BkApiClientOption) error

Apply method applies the given options to the client.

func (*BkApiClient) Name

func (cli *BkApiClient) Name() string

Name returns the client name.

func (*BkApiClient) NewOperation

func (cli *BkApiClient) NewOperation(
	provider define.OperationConfigProvider,
	opts ...define.OperationOption,
) define.Operation

NewOperation will create a new operation dynamically and apply the given options.

type BkApiClientOption

type BkApiClientOption struct {
	// contains filtered or unexported fields
}

BkApiClientOption is a wrapper for a client option.

func NewBkApiClientOption

func NewBkApiClientOption(fn func(client *BkApiClient) error) *BkApiClientOption

NewBkApiClientOption creates a new client option.

func (*BkApiClientOption) ApplyToClient

func (o *BkApiClientOption) ApplyToClient(cli define.BkApiClient) error

ApplyToClient will check if the given client is a BkApiClient and apply the option to it.

type BkApiResponseDetail

type BkApiResponseDetail struct {
	// contains filtered or unexported fields
}

BkApiResponseDetail implements the define.BkApiResponseDetail interface.

func NewBkApiResponseDetail

func NewBkApiResponseDetail(requestId string, errorCode string, errorMessage string) *BkApiResponseDetail

NewBkApiResponseDetail creates a new BkApiResponseDetail.

func NewBkApiResponseDetailFromResponse

func NewBkApiResponseDetailFromResponse(response *http.Response) *BkApiResponseDetail

NewBkApiResponseDetailFromResponse creates a new BkApiResponseDetail from the response.

func (*BkApiResponseDetail) Cause

func (detail *BkApiResponseDetail) Cause() error

Cause always return define.ErrBkApiRequest

func (*BkApiResponseDetail) Error

func (detail *BkApiResponseDetail) Error() string

Error renders the error message.

func (*BkApiResponseDetail) ErrorCode

func (detail *BkApiResponseDetail) ErrorCode() string

ErrorCode returns the error code.

func (*BkApiResponseDetail) ErrorMessage

func (detail *BkApiResponseDetail) ErrorMessage() string

ErrorMessage returns the error message.

func (*BkApiResponseDetail) GetError

func (detail *BkApiResponseDetail) GetError() error

GetError returns the error when errorCode is not empty.

func (*BkApiResponseDetail) Map

func (detail *BkApiResponseDetail) Map() map[string]interface{}

Map will return a map[string]interface{} that contains the non-empty details.

func (*BkApiResponseDetail) RequestId

func (detail *BkApiResponseDetail) RequestId() string

RequestId returns the request id.

type Operation

type Operation struct {
	// contains filtered or unexported fields
}

Operation is a wrapper for a request, it allows to set the request options and send the request.

func NewOperation

func NewOperation(name string, client define.BkApiClient, request *gentleman.Request) *Operation

NewOperation creates a new operation.

func (*Operation) Apply

func (op *Operation) Apply(opts ...define.OperationOption) define.Operation

Apply method applies the given options to the operation.

func (*Operation) ClientName added in v0.1.15

func (op *Operation) ClientName() string

ClientName returns the client name.

func (*Operation) FullName added in v0.1.15

func (op *Operation) FullName() string

FullName returns the operation name.

func (*Operation) GetError

func (op *Operation) GetError() error

GetError returns the operation error.

func (*Operation) Name

func (op *Operation) Name() string

Name returns the operation name.

func (*Operation) Request

func (op *Operation) Request() (*http.Response, error)

Request will send the operation request and return the response.

func (*Operation) SetBody

func (op *Operation) SetBody(body interface{}) define.Operation

SetBody used to set the operation body.

func (*Operation) SetBodyProvider

func (op *Operation) SetBodyProvider(bodyProvider define.BodyProvider) define.Operation

SetBodyProvider used to set the operation body provider.

func (*Operation) SetBodyReader

func (op *Operation) SetBodyReader(body io.Reader) define.Operation

SetBodyReader used to set the operation body.

func (*Operation) SetContentLength

func (op *Operation) SetContentLength(length int64) define.Operation

SetContentLength used to set the request content length.

func (*Operation) SetContentType

func (op *Operation) SetContentType(contentType string) define.Operation

SetContentType used to set the request content type.

func (*Operation) SetContext

func (op *Operation) SetContext(ctx context.Context) define.Operation

SetContext used to set the request context.

func (*Operation) SetHeaders

func (op *Operation) SetHeaders(headers map[string]string) define.Operation

SetHeaders used to set the request headers.

func (*Operation) SetPathParams

func (op *Operation) SetPathParams(params map[string]string) define.Operation

SetPathParams used to set the request path parameters.

func (*Operation) SetQueryParams

func (op *Operation) SetQueryParams(params map[string]string) define.Operation

SetQueryParams used to set the request query parameters.

func (*Operation) SetResult

func (op *Operation) SetResult(result interface{}) define.Operation

SetResult used to set the operation result.

func (*Operation) SetResultProvider

func (op *Operation) SetResultProvider(provider define.ResultProvider) define.Operation

SetResultProvider used to set the operation result provider.

func (*Operation) String

func (op *Operation) String() string

String returns the operation name.

type OperationOption

type OperationOption struct {
	// contains filtered or unexported fields
}

OperationOption is a wrapper for a operation option.

func NewOperationOption

func NewOperationOption(fn func(operation *Operation) error) *OperationOption

NewOperationOption creates a new operation option.

func (*OperationOption) ApplyToClient

func (o *OperationOption) ApplyToClient(client define.BkApiClient) error

ApplyToClient will apply the given options to the client.

func (*OperationOption) ApplyToOperation

func (o *OperationOption) ApplyToOperation(op define.Operation) error

ApplyToOperation will check if the operation is valid and apply the option to the operation.

type PluginOption

type PluginOption struct {
	*BkApiClientOption
	*OperationOption
}

PluginOption wraps a plugin for a client or an operation.

func NewPluginOption

func NewPluginOption(plugins ...plugin.Plugin) *PluginOption

NewPluginOption creates a new PluginOption.

func (*PluginOption) ApplyToClient

func (o *PluginOption) ApplyToClient(cli define.BkApiClient) error

ApplyToClient

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL