api

package
v0.0.0-...-22f70c5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package api 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

Constants

This section is empty.

Variables

View Source
var ErrInvalidItemField = errors.New("invalid field")

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m *http.ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m *http.ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func HashItem

func HashItem(content string, properties map[string]interface{}, metadata map[string]interface{}) (string, error)

HashItem generates a SHA-256 hash for the given Item. It hashes the content, properties, and metadata of the item. The function returns the hexadecimal representation of the hash or an error if any step of the hashing process fails.

func NewItemsCreateRequest

func NewItemsCreateRequest(server string, body ItemsCreateJSONRequestBody) (*http.Request, error)

NewItemsCreateRequest calls the generic ItemsCreate builder with application/json body

func NewItemsCreateRequestWithBody

func NewItemsCreateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewItemsCreateRequestWithBody generates requests for ItemsCreate with any type of body

func NewItemsGetRequest

func NewItemsGetRequest(server string, name ItemKey) (*http.Request, error)

NewItemsGetRequest generates requests for ItemsGet

func NewItemsListRequest

func NewItemsListRequest(server string, params *ItemsListParams) (*http.Request, error)

NewItemsListRequest generates requests for ItemsList

func NewItemsUpdateRequest

func NewItemsUpdateRequest(server string, name ItemKey, body ItemsUpdateJSONRequestBody) (*http.Request, error)

NewItemsUpdateRequest calls the generic ItemsUpdate builder with application/json body

func NewItemsUpdateRequestWithBody

func NewItemsUpdateRequestWithBody(server string, name ItemKey, contentType string, body io.Reader) (*http.Request, error)

NewItemsUpdateRequestWithBody generates requests for ItemsUpdate with any type of body

func NewItemsUpsertRequest

func NewItemsUpsertRequest(server string, body ItemsUpsertJSONRequestBody) (*http.Request, error)

NewItemsUpsertRequest calls the generic ItemsUpsert builder with application/json body

func NewItemsUpsertRequestWithBody

func NewItemsUpsertRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewItemsUpsertRequestWithBody generates requests for ItemsUpsert with any type of body

func ValidateItemFieldMask

func ValidateItemFieldMask(fieldmask []string) error

ValidateItemFieldMask validates a field mask for the Item struct

Types

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) ItemsCreate

func (c *Client) ItemsCreate(ctx context.Context, body ItemsCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsCreateWithBody

func (c *Client) ItemsCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsGet

func (c *Client) ItemsGet(ctx context.Context, name ItemKey, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsList

func (c *Client) ItemsList(ctx context.Context, params *ItemsListParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsUpdate

func (c *Client) ItemsUpdate(ctx context.Context, name ItemKey, body ItemsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsUpdateWithBody

func (c *Client) ItemsUpdateWithBody(ctx context.Context, name ItemKey, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsUpsert

func (c *Client) ItemsUpsert(ctx context.Context, body ItemsUpsertJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ItemsUpsertWithBody

func (c *Client) ItemsUpsertWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// ItemsList request
	ItemsList(ctx context.Context, params *ItemsListParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ItemsUpsertWithBody request with any body
	ItemsUpsertWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ItemsUpsert(ctx context.Context, body ItemsUpsertJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ItemsCreateWithBody request with any body
	ItemsCreateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ItemsCreate(ctx context.Context, body ItemsCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ItemsGet request
	ItemsGet(ctx context.Context, name ItemKey, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ItemsUpdateWithBody request with any body
	ItemsUpdateWithBody(ctx context.Context, name ItemKey, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	ItemsUpdate(ctx context.Context, name ItemKey, body ItemsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

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) ItemsCreateWithBodyWithResponse

func (c *ClientWithResponses) ItemsCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsCreateResponse, error)

ItemsCreateWithBodyWithResponse request with arbitrary body returning *ItemsCreateResponse

func (*ClientWithResponses) ItemsCreateWithResponse

func (c *ClientWithResponses) ItemsCreateWithResponse(ctx context.Context, body ItemsCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsCreateResponse, error)

func (*ClientWithResponses) ItemsGetWithResponse

func (c *ClientWithResponses) ItemsGetWithResponse(ctx context.Context, name ItemKey, reqEditors ...RequestEditorFn) (*ItemsGetResponse, error)

ItemsGetWithResponse request returning *ItemsGetResponse

func (*ClientWithResponses) ItemsListWithResponse

func (c *ClientWithResponses) ItemsListWithResponse(ctx context.Context, params *ItemsListParams, reqEditors ...RequestEditorFn) (*ItemsListResponse, error)

ItemsListWithResponse request returning *ItemsListResponse

func (*ClientWithResponses) ItemsUpdateWithBodyWithResponse

func (c *ClientWithResponses) ItemsUpdateWithBodyWithResponse(ctx context.Context, name ItemKey, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsUpdateResponse, error)

ItemsUpdateWithBodyWithResponse request with arbitrary body returning *ItemsUpdateResponse

func (*ClientWithResponses) ItemsUpdateWithResponse

func (c *ClientWithResponses) ItemsUpdateWithResponse(ctx context.Context, name ItemKey, body ItemsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsUpdateResponse, error)

func (*ClientWithResponses) ItemsUpsertWithBodyWithResponse

func (c *ClientWithResponses) ItemsUpsertWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsUpsertResponse, error)

ItemsUpsertWithBodyWithResponse request with arbitrary body returning *ItemsUpsertResponse

func (*ClientWithResponses) ItemsUpsertWithResponse

func (c *ClientWithResponses) ItemsUpsertWithResponse(ctx context.Context, body ItemsUpsertJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsUpsertResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// ItemsListWithResponse request
	ItemsListWithResponse(ctx context.Context, params *ItemsListParams, reqEditors ...RequestEditorFn) (*ItemsListResponse, error)

	// ItemsUpsertWithBodyWithResponse request with any body
	ItemsUpsertWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsUpsertResponse, error)

	ItemsUpsertWithResponse(ctx context.Context, body ItemsUpsertJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsUpsertResponse, error)

	// ItemsCreateWithBodyWithResponse request with any body
	ItemsCreateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsCreateResponse, error)

	ItemsCreateWithResponse(ctx context.Context, body ItemsCreateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsCreateResponse, error)

	// ItemsGetWithResponse request
	ItemsGetWithResponse(ctx context.Context, name ItemKey, reqEditors ...RequestEditorFn) (*ItemsGetResponse, error)

	// ItemsUpdateWithBodyWithResponse request with any body
	ItemsUpdateWithBodyWithResponse(ctx context.Context, name ItemKey, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ItemsUpdateResponse, error)

	ItemsUpdateWithResponse(ctx context.Context, name ItemKey, body ItemsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ItemsUpdateResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type Error

type Error struct {
	Code    ErrorCode              `json:"code"`
	Details map[string]interface{} `json:"details"`
	Message string                 `json:"message"`
	Type    ErrorType              `json:"type"`
}

Error Error is the response model when an API call is unsuccessful.

type ErrorCode

type ErrorCode string

ErrorCode defines model for ErrorCode.

const (
	ParameterInvalid      ErrorCode = "parameter_invalid"
	ParameterMissing      ErrorCode = "parameter_missing"
	ProcessingError       ErrorCode = "processing_error"
	ResourceAlreadyExists ErrorCode = "resource_already_exists"
	ResourceMissing       ErrorCode = "resource_missing"
)

Defines values for ErrorCode.

type ErrorType

type ErrorType string

ErrorType defines model for ErrorType.

const (
	ApiError            ErrorType = "api_error"
	InvalidRequestError ErrorType = "invalid_request_error"
)

Defines values for ErrorType.

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type Item

type Item struct {
	Content     string     `json:"content"`
	CreateTime  time.Time  `json:"create_time"`
	DeleteTime  *time.Time `json:"delete_time,omitempty"`
	DisplayName string     `json:"display_name"`

	// Hash represents a hash value calculated from the item's content.
	Hash       *string                `json:"hash,omitempty"`
	Metadata   map[string]interface{} `json:"metadata"`
	Name       string                 `json:"name"`
	Properties map[string]interface{} `json:"properties"`
	UpdateTime time.Time              `json:"update_time"`
}

Item Item represents an individual content item.

type ItemCreate

type ItemCreate struct {
	Content     string                 `json:"content"`
	CreateTime  time.Time              `json:"create_time"`
	DeleteTime  *time.Time             `json:"delete_time,omitempty"`
	DisplayName string                 `json:"display_name"`
	Metadata    map[string]interface{} `json:"metadata"`
	Name        string                 `json:"name"`
	Properties  map[string]interface{} `json:"properties"`
	UpdateTime  time.Time              `json:"update_time"`
}

ItemCreate Resource create operation model.

type ItemKey

type ItemKey = string

ItemKey defines model for ItemKey.

type ItemUpdate

type ItemUpdate struct {
	Content     *string                 `json:"content,omitempty"`
	CreateTime  *time.Time              `json:"create_time,omitempty"`
	DeleteTime  *time.Time              `json:"delete_time,omitempty"`
	DisplayName *string                 `json:"display_name,omitempty"`
	Metadata    *map[string]interface{} `json:"metadata,omitempty"`
	Properties  *map[string]interface{} `json:"properties,omitempty"`
	UpdateTime  *time.Time              `json:"update_time,omitempty"`
}

ItemUpdate Resource create or update operation model.

type ItemUpsert

type ItemUpsert struct {
	Content     string                 `json:"content"`
	CreateTime  time.Time              `json:"create_time"`
	DeleteTime  *time.Time             `json:"delete_time,omitempty"`
	DisplayName string                 `json:"display_name"`
	Metadata    map[string]interface{} `json:"metadata"`
	Name        string                 `json:"name"`
	Properties  map[string]interface{} `json:"properties"`
	UpdateTime  time.Time              `json:"update_time"`
}

ItemUpsert Resource create operation model.

type ItemsCreateJSONRequestBody

type ItemsCreateJSONRequestBody = ItemCreate

ItemsCreateJSONRequestBody defines body for ItemsCreate for application/json ContentType.

type ItemsCreateResponse

type ItemsCreateResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Item
	JSON201      *Item
	JSONDefault  *Error
}

func ParseItemsCreateResponse

func ParseItemsCreateResponse(rsp *http.Response) (*ItemsCreateResponse, error)

ParseItemsCreateResponse parses an HTTP response from a ItemsCreateWithResponse call

func (ItemsCreateResponse) Status

func (r ItemsCreateResponse) Status() string

Status returns HTTPResponse.Status

func (ItemsCreateResponse) StatusCode

func (r ItemsCreateResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ItemsGetResponse

type ItemsGetResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Item
	JSONDefault  *Error
}

func ParseItemsGetResponse

func ParseItemsGetResponse(rsp *http.Response) (*ItemsGetResponse, error)

ParseItemsGetResponse parses an HTTP response from a ItemsGetWithResponse call

func (ItemsGetResponse) Status

func (r ItemsGetResponse) Status() string

Status returns HTTPResponse.Status

func (ItemsGetResponse) StatusCode

func (r ItemsGetResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ItemsListParams

type ItemsListParams struct {
	Fields *[]string `form:"fields,omitempty" json:"fields,omitempty"`
}

ItemsListParams defines parameters for ItemsList.

type ItemsListResponse

type ItemsListResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]Item
	JSONDefault  *Error
}

func ParseItemsListResponse

func ParseItemsListResponse(rsp *http.Response) (*ItemsListResponse, error)

ParseItemsListResponse parses an HTTP response from a ItemsListWithResponse call

func (ItemsListResponse) Status

func (r ItemsListResponse) Status() string

Status returns HTTPResponse.Status

func (ItemsListResponse) StatusCode

func (r ItemsListResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ItemsUpdateJSONRequestBody

type ItemsUpdateJSONRequestBody = ItemUpdate

ItemsUpdateJSONRequestBody defines body for ItemsUpdate for application/json ContentType.

type ItemsUpdateResponse

type ItemsUpdateResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Item
	JSONDefault  *Error
}

func ParseItemsUpdateResponse

func ParseItemsUpdateResponse(rsp *http.Response) (*ItemsUpdateResponse, error)

ParseItemsUpdateResponse parses an HTTP response from a ItemsUpdateWithResponse call

func (ItemsUpdateResponse) Status

func (r ItemsUpdateResponse) Status() string

Status returns HTTPResponse.Status

func (ItemsUpdateResponse) StatusCode

func (r ItemsUpdateResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ItemsUpsertJSONBody

type ItemsUpsertJSONBody = []ItemUpsert

ItemsUpsertJSONBody defines parameters for ItemsUpsert.

type ItemsUpsertJSONRequestBody

type ItemsUpsertJSONRequestBody = ItemsUpsertJSONBody

ItemsUpsertJSONRequestBody defines body for ItemsUpsert for application/json ContentType.

type ItemsUpsertResponse

type ItemsUpsertResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]Item
	JSONDefault  *Error
}

func ParseItemsUpsertResponse

func ParseItemsUpsertResponse(rsp *http.Response) (*ItemsUpsertResponse, error)

ParseItemsUpsertResponse parses an HTTP response from a ItemsUpsertWithResponse call

func (ItemsUpsertResponse) Status

func (r ItemsUpsertResponse) Status() string

Status returns HTTPResponse.Status

func (ItemsUpsertResponse) StatusCode

func (r ItemsUpsertResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type ServerInterface

type ServerInterface interface {

	// (GET /items)
	ItemsList(w http.ResponseWriter, r *http.Request, params ItemsListParams)

	// (PATCH /items)
	ItemsUpsert(w http.ResponseWriter, r *http.Request)

	// (POST /items)
	ItemsCreate(w http.ResponseWriter, r *http.Request)

	// (GET /items/{name})
	ItemsGet(w http.ResponseWriter, r *http.Request, name ItemKey)

	// (PATCH /items/{name})
	ItemsUpdate(w http.ResponseWriter, r *http.Request, name ItemKey)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) ItemsCreate

func (siw *ServerInterfaceWrapper) ItemsCreate(w http.ResponseWriter, r *http.Request)

ItemsCreate operation middleware

func (*ServerInterfaceWrapper) ItemsGet

func (siw *ServerInterfaceWrapper) ItemsGet(w http.ResponseWriter, r *http.Request)

ItemsGet operation middleware

func (*ServerInterfaceWrapper) ItemsList

func (siw *ServerInterfaceWrapper) ItemsList(w http.ResponseWriter, r *http.Request)

ItemsList operation middleware

func (*ServerInterfaceWrapper) ItemsUpdate

func (siw *ServerInterfaceWrapper) ItemsUpdate(w http.ResponseWriter, r *http.Request)

ItemsUpdate operation middleware

func (*ServerInterfaceWrapper) ItemsUpsert

func (siw *ServerInterfaceWrapper) ItemsUpsert(w http.ResponseWriter, r *http.Request)

ItemsUpsert operation middleware

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       *http.ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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