Documentation
¶
Overview ¶
Package client provides primitives to interact with the openapi HTTP API.
Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.0 DO NOT EDIT.
Index ¶
- func NewDefaultErrorRequest(server string) (*http.Request, error)
- func NewDefaultGreetingRequest(server string, name string) (*http.Request, error)
- func NewDefaultReviewRequest(server string, body DefaultReviewJSONRequestBody) (*http.Request, error)
- func NewDefaultReviewRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- type AwesomeErrorResp
- type AwesomeGreetingResp
- type AwesomeReviewReq
- type AwesomeReviewResp
- type Client
- func (c *Client) DefaultError(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- func (c *Client) DefaultGreeting(ctx context.Context, name string, reqEditors ...RequestEditorFn) (*http.Response, error)
- func (c *Client) DefaultReview(ctx context.Context, body DefaultReviewJSONRequestBody, ...) (*http.Response, error)
- func (c *Client) DefaultReviewWithBody(ctx context.Context, contentType string, body io.Reader, ...) (*http.Response, error)
- type ClientInterface
- type ClientOption
- type ClientWithResponses
- func (c *ClientWithResponses) DefaultErrorWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DefaultErrorResponse, error)
- func (c *ClientWithResponses) DefaultGreetingWithResponse(ctx context.Context, name string, reqEditors ...RequestEditorFn) (*DefaultGreetingResponse, error)
- func (c *ClientWithResponses) DefaultReviewWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, ...) (*DefaultReviewResponse, error)
- func (c *ClientWithResponses) DefaultReviewWithResponse(ctx context.Context, body DefaultReviewJSONRequestBody, ...) (*DefaultReviewResponse, error)
- type ClientWithResponsesInterface
- type DefaultErrorResponse
- type DefaultGreetingResponse
- type DefaultReviewJSONRequestBody
- type DefaultReviewResponse
- type HttpRequestDoer
- type ProtobufAny
- type RequestEditorFn
- type RpcStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultErrorRequest ¶
NewDefaultErrorRequest generates requests for DefaultError
func NewDefaultGreetingRequest ¶
NewDefaultGreetingRequest generates requests for DefaultGreeting
func NewDefaultReviewRequest ¶
func NewDefaultReviewRequest(server string, body DefaultReviewJSONRequestBody) (*http.Request, error)
NewDefaultReviewRequest calls the generic DefaultReview builder with application/json body
Types ¶
type AwesomeErrorResp ¶
type AwesomeErrorResp = map[string]interface{}
AwesomeErrorResp defines model for awesomeErrorResp.
type AwesomeGreetingResp ¶
type AwesomeGreetingResp struct {
// Message Greeting message
Message string `json:"message"`
}
AwesomeGreetingResp defines model for awesomeGreetingResp.
type AwesomeReviewReq ¶
type AwesomeReviewReq struct {
// Author Author of the review
Author string `json:"author"`
// Message Review message
Message *string `json:"message,omitempty"`
// Rating Rating from 1 to 5
Rating int64 `json:"rating"`
}
AwesomeReviewReq defines model for awesomeReviewReq.
type AwesomeReviewResp ¶
type AwesomeReviewResp = map[string]interface{}
AwesomeReviewResp defines model for awesomeReviewResp.
type Client ¶
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
}
Client which conforms to the OpenAPI3 specification for this service.
func NewClient ¶
func NewClient(server string, opts ...ClientOption) (*Client, error)
Creates a new Client, with reasonable defaults
func (*Client) DefaultError ¶
func (*Client) DefaultGreeting ¶
func (*Client) DefaultReview ¶
func (c *Client) DefaultReview(ctx context.Context, body DefaultReviewJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
type ClientInterface ¶
type ClientInterface interface {
// DefaultError request
DefaultError(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
// DefaultGreeting request
DefaultGreeting(ctx context.Context, name string, reqEditors ...RequestEditorFn) (*http.Response, error)
// DefaultReviewWithBody request with any body
DefaultReviewWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
DefaultReview(ctx context.Context, body DefaultReviewJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}
The interface specification for the client above.
type ClientOption ¶
ClientOption allows setting custom parameters during construction
func WithHTTPClient ¶
func WithHTTPClient(doer HttpRequestDoer) ClientOption
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.
func WithRequestEditorFn ¶
func WithRequestEditorFn(fn RequestEditorFn) ClientOption
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
type ClientWithResponses ¶
type ClientWithResponses struct {
ClientInterface
}
ClientWithResponses builds on ClientInterface to offer response payloads
func NewClientWithResponses ¶
func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling
func (*ClientWithResponses) DefaultErrorWithResponse ¶
func (c *ClientWithResponses) DefaultErrorWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DefaultErrorResponse, error)
DefaultErrorWithResponse request returning *DefaultErrorResponse
func (*ClientWithResponses) DefaultGreetingWithResponse ¶
func (c *ClientWithResponses) DefaultGreetingWithResponse(ctx context.Context, name string, reqEditors ...RequestEditorFn) (*DefaultGreetingResponse, error)
DefaultGreetingWithResponse request returning *DefaultGreetingResponse
func (*ClientWithResponses) DefaultReviewWithBodyWithResponse ¶
func (c *ClientWithResponses) DefaultReviewWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DefaultReviewResponse, error)
DefaultReviewWithBodyWithResponse request with arbitrary body returning *DefaultReviewResponse
func (*ClientWithResponses) DefaultReviewWithResponse ¶
func (c *ClientWithResponses) DefaultReviewWithResponse(ctx context.Context, body DefaultReviewJSONRequestBody, reqEditors ...RequestEditorFn) (*DefaultReviewResponse, error)
type ClientWithResponsesInterface ¶
type ClientWithResponsesInterface interface {
// DefaultErrorWithResponse request
DefaultErrorWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DefaultErrorResponse, error)
// DefaultGreetingWithResponse request
DefaultGreetingWithResponse(ctx context.Context, name string, reqEditors ...RequestEditorFn) (*DefaultGreetingResponse, error)
// DefaultReviewWithBodyWithResponse request with any body
DefaultReviewWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DefaultReviewResponse, error)
DefaultReviewWithResponse(ctx context.Context, body DefaultReviewJSONRequestBody, reqEditors ...RequestEditorFn) (*DefaultReviewResponse, error)
}
ClientWithResponsesInterface is the interface specification for the client with responses above.
type DefaultErrorResponse ¶
type DefaultErrorResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *AwesomeErrorResp
JSONDefault *RpcStatus
}
func ParseDefaultErrorResponse ¶
func ParseDefaultErrorResponse(rsp *http.Response) (*DefaultErrorResponse, error)
ParseDefaultErrorResponse parses an HTTP response from a DefaultErrorWithResponse call
func (DefaultErrorResponse) Status ¶
func (r DefaultErrorResponse) Status() string
Status returns HTTPResponse.Status
func (DefaultErrorResponse) StatusCode ¶
func (r DefaultErrorResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type DefaultGreetingResponse ¶
type DefaultGreetingResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *AwesomeGreetingResp
JSONDefault *RpcStatus
}
func ParseDefaultGreetingResponse ¶
func ParseDefaultGreetingResponse(rsp *http.Response) (*DefaultGreetingResponse, error)
ParseDefaultGreetingResponse parses an HTTP response from a DefaultGreetingWithResponse call
func (DefaultGreetingResponse) Status ¶
func (r DefaultGreetingResponse) Status() string
Status returns HTTPResponse.Status
func (DefaultGreetingResponse) StatusCode ¶
func (r DefaultGreetingResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type DefaultReviewJSONRequestBody ¶
type DefaultReviewJSONRequestBody = AwesomeReviewReq
DefaultReviewJSONRequestBody defines body for DefaultReview for application/json ContentType.
type DefaultReviewResponse ¶
type DefaultReviewResponse struct {
Body []byte
HTTPResponse *http.Response
JSON200 *AwesomeReviewResp
JSONDefault *RpcStatus
}
func ParseDefaultReviewResponse ¶
func ParseDefaultReviewResponse(rsp *http.Response) (*DefaultReviewResponse, error)
ParseDefaultReviewResponse parses an HTTP response from a DefaultReviewWithResponse call
func (DefaultReviewResponse) Status ¶
func (r DefaultReviewResponse) Status() string
Status returns HTTPResponse.Status
func (DefaultReviewResponse) StatusCode ¶
func (r DefaultReviewResponse) StatusCode() int
StatusCode returns HTTPResponse.StatusCode
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type ProtobufAny ¶
type ProtobufAny struct {
// Type A URL/resource name that uniquely identifies the type of the serialized
// protocol buffer message. This string must contain at least
// one "/" character. The last segment of the URL's path must represent
// the fully qualified name of the type (as in
// `path/google.protobuf.Duration`). The name should be in a canonical form
// (e.g., leading "." is not accepted).
//
// In practice, teams usually precompile into the binary all types that they
// expect it to use in the context of Any. However, for URLs which use the
// scheme `http`, `https`, or no scheme, one can optionally set up a type
// server that maps type URLs to message definitions as follows:
//
// * If no scheme is provided, `https` is assumed.
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
// value in binary format, or produce an error.
// * Applications are allowed to cache lookup results based on the
// URL, or have them precompiled into a binary to avoid any
// lookup. Therefore, binary compatibility needs to be preserved
// on changes to types. (Use versioned type names to manage
// breaking changes.)
//
// Note: this functionality is not currently available in the official
// protobuf release, and it is not used for type URLs beginning with
// type.googleapis.com. As of May 2023, there are no widely used type server
// implementations and no plans to implement one.
//
// Schemes other than `http`, `https` (or the empty scheme) might be
// used with implementation specific semantics.
Type *string `json:"@type,omitempty"`
AdditionalProperties map[string]interface{} `json:"-"`
}
ProtobufAny `Any` contains an arbitrary serialized protocol buffer message along with a URL that describes the type of the serialized message.
Protobuf library provides support to pack/unpack Any values in the form of utility functions or additional generated methods of the Any type.
Example 1: Pack and unpack a message in C++.
Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}
Example 2: Pack and unpack a message in Java.
Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
foo = any.unpack(Foo.getDefaultInstance());
}
Example 3: Pack and unpack a message in Python.
foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...
Example 4: Pack and unpack a message in Go
foo := &pb.Foo{...}
any, err := anypb.New(foo)
if err != nil {
...
}
...
foo := &pb.Foo{}
if err := any.UnmarshalTo(foo); err != nil {
...
}
The pack methods provided by protobuf library will by default use 'type.googleapis.com/full.type.name' as the type URL and the unpack methods only use the fully qualified type name after the last '/' in the type URL, for example "foo.bar.com/x/y.z" will yield type name "y.z".
JSON ==== The JSON representation of an `Any` value uses the regular representation of the deserialized, embedded message, with an additional field `@type` which contains the type URL. Example:
package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}
{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": <string>,
"lastName": <string>
}
If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field `value` which holds the custom JSON in addition to the `@type` field. Example (for message [google.protobuf.Duration][]):
{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}
func (ProtobufAny) Get ¶
func (a ProtobufAny) Get(fieldName string) (value interface{}, found bool)
Getter for additional properties for ProtobufAny. Returns the specified element and whether it was found
func (ProtobufAny) MarshalJSON ¶
func (a ProtobufAny) MarshalJSON() ([]byte, error)
Override default JSON handling for ProtobufAny to handle AdditionalProperties
func (*ProtobufAny) Set ¶
func (a *ProtobufAny) Set(fieldName string, value interface{})
Setter for additional properties for ProtobufAny
func (*ProtobufAny) UnmarshalJSON ¶
func (a *ProtobufAny) UnmarshalJSON(b []byte) error
Override default JSON handling for ProtobufAny to handle AdditionalProperties
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type RpcStatus ¶
type RpcStatus struct {
Code *int32 `json:"code,omitempty"`
Details *[]ProtobufAny `json:"details,omitempty"`
Message *string `json:"message,omitempty"`
}
RpcStatus defines model for rpcStatus.