Documentation
¶
Overview ¶
Package client is the smallest base client the code pandorest generates builds and passes its tests on: what a generated package needs of its base client, in code. The generator's tests build a generated package against it, so a change to what generated code asks of a base client shows up here first.
It is not the base client of any SDK. Each repository keeps its own beside its generated packages, after go-azure-sdk's sdk/client, because that is where a service's own behaviour belongs: how it takes a credential, what it retries, how it words a failure. This one authenticates with a bearer token and does nothing more than it must.
Index ¶
- Constants
- func CSV[T ~string | ~int | ~int64](values []T) string
- func DeepObject[K ~string](name string, value map[K]string) [][2]string
- func JSONObject[T any](value map[string]T) string
- func StatusCode(err error) int
- type Authorizer
- type Client
- type Headers
- type Options
- type QueryParams
- type Request
- type RequestOptions
- type Response
- type StatusError
- type Token
Constants ¶
const DefaultPageSize = 500
DefaultPageSize is the page a Complete method asks for when the options leave the page size unset.
Variables ¶
This section is empty.
Functions ¶
func DeepObject ¶
DeepObject renders an object query parameter the deepObject way, one parameter per key as name[key]=value, in key order.
func JSONObject ¶
JSONObject renders an object query parameter as one JSON string.
func StatusCode ¶
StatusCode returns the status of a *StatusError in err's chain, or 0.
Types ¶
type Authorizer ¶
Authorizer adds credentials to a request.
type Client ¶
type Client struct {
// BaseURL is the server address without a trailing slash.
BaseURL string
HTTPClient *http.Client
Authorizer Authorizer
}
Client sends requests to one server.
func New ¶
func New(baseURL string, authorizer Authorizer) (*Client, error)
New returns a client for the server at baseURL (scheme and host, optionally a path prefix).
func (*Client) NewRequest ¶
NewRequest builds a request with authentication and the options object applied.
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers are request headers from an options object.
type Options ¶
type Options interface {
ToHeaders() *Headers
ToQuery() *QueryParams
}
Options is what a generated options struct implements: the query and header parameters it holds.
type QueryParams ¶
type QueryParams struct {
// contains filtered or unexported fields
}
QueryParams are query parameters from an options object.
func (*QueryParams) Append ¶
func (q *QueryParams) Append(key, value string)
Append adds a query parameter.
func (*QueryParams) Values ¶
func (q *QueryParams) Values() url.Values
Values returns the parameters.
type Request ¶
type Request struct {
*http.Request
ExpectedStatusCodes []int
StreamResponse bool
// contains filtered or unexported fields
}
Request is a request being built.
func (*Request) Execute ¶
Execute sends the request. The response is returned whenever the server answered, including with a *StatusError, so the caller can read its status and body. Its body is buffered (and readable again) unless the request streams a successful response.
type RequestOptions ¶
type RequestOptions struct {
// ContentType is the media type of the request body, when there is one.
ContentType string
// ExpectedStatusCodes are the statuses the operation documents; any
// other is a *StatusError.
ExpectedStatusCodes []int
HTTPMethod string
// OptionsObject supplies query parameters and headers; nil for none.
OptionsObject Options
// Path is the escaped path below BaseURL.
Path string
// StreamResponse leaves a successful response's body unread for the
// caller, for operations that answer a file.
StreamResponse bool
}
RequestOptions describes one request.
type StatusError ¶
StatusError is an answer with a status the operation does not document.
func (*StatusError) Error ¶
func (e *StatusError) Error() string