Documentation ¶
Index ¶
- Variables
- func GetOperationRawRequest(op *Operation) *gentleman.Request
- func ReplacePlaceHolder(s string, params map[string]string) string
- type BkApiClient
- func (cli *BkApiClient) AddOperationOptions(opts ...define.OperationOption) error
- func (cli *BkApiClient) Apply(opts ...define.BkApiClientOption) error
- func (cli *BkApiClient) Name() string
- func (cli *BkApiClient) NewOperation(provider define.OperationConfigProvider, opts ...define.OperationOption) define.Operation
- type BkApiClientOption
- type BkApiResponseDetail
- func (detail *BkApiResponseDetail) Cause() error
- func (detail *BkApiResponseDetail) Error() string
- func (detail *BkApiResponseDetail) ErrorCode() string
- func (detail *BkApiResponseDetail) ErrorMessage() string
- func (detail *BkApiResponseDetail) GetError() error
- func (detail *BkApiResponseDetail) Map() map[string]interface{}
- func (detail *BkApiResponseDetail) RequestId() string
- type Operation
- func (op *Operation) Apply(opts ...define.OperationOption) define.Operation
- func (op *Operation) ClientName() string
- func (op *Operation) FullName() string
- func (op *Operation) GetError() error
- func (op *Operation) Name() string
- func (op *Operation) Request() (*http.Response, error)
- func (op *Operation) SetBody(body interface{}) define.Operation
- func (op *Operation) SetBodyProvider(bodyProvider define.BodyProvider) define.Operation
- func (op *Operation) SetBodyReader(body io.Reader) define.Operation
- func (op *Operation) SetContentLength(length int64) define.Operation
- func (op *Operation) SetContentType(contentType string) define.Operation
- func (op *Operation) SetContext(ctx context.Context) define.Operation
- func (op *Operation) SetHeaders(headers map[string]string) define.Operation
- func (op *Operation) SetPathParams(params map[string]string) define.Operation
- func (op *Operation) SetQueryParams(params map[string]string) define.Operation
- func (op *Operation) SetResult(result interface{}) define.Operation
- func (op *Operation) SetResultProvider(provider define.ResultProvider) define.Operation
- func (op *Operation) String() string
- type OperationOption
- type PluginOption
Constants ¶
This section is empty.
Variables ¶
var DefaultUserAgent string
DefaultUserAgent :
Functions ¶
func GetOperationRawRequest ¶ added in v0.1.15
func GetOperationRawRequest(op *Operation) *gentleman.Request
GetOperationRawRequest return the underlying raw request
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) 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
ClientName returns the client name.
func (*Operation) SetBodyProvider ¶
func (op *Operation) SetBodyProvider(bodyProvider define.BodyProvider) define.Operation
SetBodyProvider used to set the operation body provider.
func (*Operation) SetBodyReader ¶
SetBodyReader used to set the operation body.
func (*Operation) SetContentLength ¶
SetContentLength used to set the request content length.
func (*Operation) SetContentType ¶
SetContentType used to set the request content type.
func (*Operation) SetContext ¶
SetContext used to set the request context.
func (*Operation) SetHeaders ¶
SetHeaders used to set the request headers.
func (*Operation) SetPathParams ¶
SetPathParams used to set the request path parameters.
func (*Operation) SetQueryParams ¶
SetQueryParams used to set the request query parameters.
func (*Operation) SetResultProvider ¶
func (op *Operation) SetResultProvider(provider define.ResultProvider) define.Operation
SetResultProvider used to set the operation result provider.
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