Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) FormTest(ctx context.Context, userID string, params FormTestParams, ...) (err error)
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) JsonTest(ctx context.Context, userID string, params JsonTestParams, ...) (err error)
- func (r *Client) ListFoos(ctx context.Context, query ListFoosParams, opts ...option.RequestOption) (res *pagination.PageNumber[ListFoosResponse], err error)
- func (r *Client) ListFoosAutoPaging(ctx context.Context, query ListFoosParams, opts ...option.RequestOption) *pagination.PageNumberAutoPager[ListFoosResponse]
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) UpdateCount(ctx context.Context, body UpdateCountParams, opts ...option.RequestOption) (err error)
- type Error
- type FormTestParams
- type FormTestParamsFilter
- type FormTestParamsFilterMeta
- type FormTestParamsPreferences
- type JsonTestParams
- type JsonTestParamsFilter
- type JsonTestParamsFilterMeta
- type JsonTestParamsPreferences
- type ListFoosParams
- type ListFoosResponse
- type UpdateCountParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (BRUCE_TEST_API_API_KEY, BRUCE_TEST_API_BASE_URL). This should be used to initialize new clients.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type Client ¶
type Client struct {
Options []option.RequestOption
}
Client creates a struct with services and top level methods that help with interacting with the bruce-test-api API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default option read from the environment (BRUCE_TEST_API_API_KEY, BRUCE_TEST_API_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) FormTest ¶
func (r *Client) FormTest(ctx context.Context, userID string, params FormTestParams, opts ...option.RequestOption) (err error)
Mixed parameter types
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) JsonTest ¶
func (r *Client) JsonTest(ctx context.Context, userID string, params JsonTestParams, opts ...option.RequestOption) (err error)
Mixed parameter types
func (*Client) ListFoos ¶
func (r *Client) ListFoos(ctx context.Context, query ListFoosParams, opts ...option.RequestOption) (res *pagination.PageNumber[ListFoosResponse], err error)
Get foos
func (*Client) ListFoosAutoPaging ¶
func (r *Client) ListFoosAutoPaging(ctx context.Context, query ListFoosParams, opts ...option.RequestOption) *pagination.PageNumberAutoPager[ListFoosResponse]
Get foos
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Put ¶
func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) UpdateCount ¶
func (r *Client) UpdateCount(ctx context.Context, body UpdateCountParams, opts ...option.RequestOption) (err error)
type FormTestParams ¶
type FormTestParams struct {
Version int64 `path:"version,required" json:"-"`
Date time.Time `query:"date,required" format:"date" json:"-"`
Datetime time.Time `query:"datetime,required" format:"date-time" json:"-"`
Time string `query:"time,required" format:"time" json:"-"`
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
Blorp param.Opt[string] `json:"blorp,omitzero"`
XTraceID param.Opt[string] `header:"X-Trace-ID,omitzero" json:"-"`
Filter FormTestParamsFilter `query:"filter,omitzero" json:"-"`
Tags []string `query:"tags,omitzero" json:"-"`
Preferences FormTestParamsPreferences `json:"preferences,omitzero"`
XFlags []string `header:"X-Flags,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (FormTestParams) MarshalMultipart ¶
func (r FormTestParams) MarshalMultipart() (data []byte, contentType string, err error)
func (FormTestParams) URLQuery ¶
func (r FormTestParams) URLQuery() (v url.Values, err error)
URLQuery serializes FormTestParams's query parameters as `url.Values`.
type FormTestParamsFilter ¶
type FormTestParamsFilter struct {
Status param.Opt[string] `query:"status,omitzero" json:"-"`
Meta FormTestParamsFilterMeta `query:"meta,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (FormTestParamsFilter) URLQuery ¶
func (r FormTestParamsFilter) URLQuery() (v url.Values, err error)
URLQuery serializes FormTestParamsFilter's query parameters as `url.Values`.
type FormTestParamsFilterMeta ¶
type FormTestParamsFilterMeta struct {
Level param.Opt[int64] `query:"level,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (FormTestParamsFilterMeta) URLQuery ¶
func (r FormTestParamsFilterMeta) URLQuery() (v url.Values, err error)
URLQuery serializes FormTestParamsFilterMeta's query parameters as `url.Values`.
type FormTestParamsPreferences ¶
type FormTestParamsPreferences struct {
Alerts param.Opt[bool] `json:"alerts,omitzero"`
Theme param.Opt[string] `json:"theme,omitzero"`
// contains filtered or unexported fields
}
func (FormTestParamsPreferences) MarshalJSON ¶
func (r FormTestParamsPreferences) MarshalJSON() (data []byte, err error)
func (*FormTestParamsPreferences) UnmarshalJSON ¶
func (r *FormTestParamsPreferences) UnmarshalJSON(data []byte) error
type JsonTestParams ¶
type JsonTestParams struct {
Version int64 `path:"version,required" json:"-"`
Date time.Time `query:"date,required" format:"date" json:"-"`
Datetime time.Time `query:"datetime,required" format:"date-time" json:"-"`
Time string `query:"time,required" format:"time" json:"-"`
Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
Blorp param.Opt[string] `json:"blorp,omitzero"`
XTraceID param.Opt[string] `header:"X-Trace-ID,omitzero" json:"-"`
Filter JsonTestParamsFilter `query:"filter,omitzero" json:"-"`
Tags []string `query:"tags,omitzero" json:"-"`
Preferences JsonTestParamsPreferences `json:"preferences,omitzero"`
XFlags []string `header:"X-Flags,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (JsonTestParams) MarshalJSON ¶
func (r JsonTestParams) MarshalJSON() (data []byte, err error)
func (JsonTestParams) URLQuery ¶
func (r JsonTestParams) URLQuery() (v url.Values, err error)
URLQuery serializes JsonTestParams's query parameters as `url.Values`.
func (*JsonTestParams) UnmarshalJSON ¶
func (r *JsonTestParams) UnmarshalJSON(data []byte) error
type JsonTestParamsFilter ¶
type JsonTestParamsFilter struct {
Status param.Opt[string] `query:"status,omitzero" json:"-"`
Meta JsonTestParamsFilterMeta `query:"meta,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (JsonTestParamsFilter) URLQuery ¶
func (r JsonTestParamsFilter) URLQuery() (v url.Values, err error)
URLQuery serializes JsonTestParamsFilter's query parameters as `url.Values`.
type JsonTestParamsFilterMeta ¶
type JsonTestParamsFilterMeta struct {
Level param.Opt[int64] `query:"level,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (JsonTestParamsFilterMeta) URLQuery ¶
func (r JsonTestParamsFilterMeta) URLQuery() (v url.Values, err error)
URLQuery serializes JsonTestParamsFilterMeta's query parameters as `url.Values`.
type JsonTestParamsPreferences ¶
type JsonTestParamsPreferences struct {
Alerts param.Opt[bool] `json:"alerts,omitzero"`
Theme param.Opt[string] `json:"theme,omitzero"`
// contains filtered or unexported fields
}
func (JsonTestParamsPreferences) MarshalJSON ¶
func (r JsonTestParamsPreferences) MarshalJSON() (data []byte, err error)
func (*JsonTestParamsPreferences) UnmarshalJSON ¶
func (r *JsonTestParamsPreferences) UnmarshalJSON(data []byte) error
type ListFoosParams ¶
type ListFoosParams struct {
// Page number
Page param.Opt[int64] `query:"page,omitzero" json:"-"`
// Page size
Size param.Opt[int64] `query:"size,omitzero" json:"-"`
Tags []string `query:"tags,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (ListFoosParams) URLQuery ¶
func (r ListFoosParams) URLQuery() (v url.Values, err error)
URLQuery serializes ListFoosParams's query parameters as `url.Values`.
type ListFoosResponse ¶
type ListFoosResponse struct {
// The baz field
Baz int64 `json:"baz,required"`
// The foo field
Foo string `json:"foo,required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Baz respjson.Field
Foo respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (ListFoosResponse) RawJSON ¶
func (r ListFoosResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*ListFoosResponse) UnmarshalJSON ¶
func (r *ListFoosResponse) UnmarshalJSON(data []byte) error
type UpdateCountParams ¶
type UpdateCountParams struct {
Body int64
// contains filtered or unexported fields
}
func (UpdateCountParams) MarshalJSON ¶
func (r UpdateCountParams) MarshalJSON() (data []byte, err error)
func (*UpdateCountParams) UnmarshalJSON ¶
func (r *UpdateCountParams) UnmarshalJSON(data []byte) error
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
shared
|
|