openmeter

package
v0.3.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: Apache-2.0 Imports: 16 Imported by: 2

README

OpenMeter Go SDK

Install

go get github.com/openmeterio/openmeter

Usage

func main() {
    // Initialize OpenMeter client
    om, err := openmeter.NewClient("http://localhost:8888")
    if err != nil {
        panic(err.Error())
    }

    // Use OpenMeter client
    // ...
}

Documentation

Overview

Package openmeter provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func NewCreateMeterRequest

func NewCreateMeterRequest(server string, params *CreateMeterParams, body CreateMeterJSONRequestBody) (*http.Request, error)

NewCreateMeterRequest calls the generic CreateMeter builder with application/json body

func NewCreateMeterRequestWithBody

func NewCreateMeterRequestWithBody(server string, params *CreateMeterParams, contentType string, body io.Reader) (*http.Request, error)

NewCreateMeterRequestWithBody generates requests for CreateMeter with any type of body

func NewCreateNamespaceRequest

func NewCreateNamespaceRequest(server string, body CreateNamespaceJSONRequestBody) (*http.Request, error)

NewCreateNamespaceRequest calls the generic CreateNamespace builder with application/json body

func NewCreateNamespaceRequestWithBody

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

NewCreateNamespaceRequestWithBody generates requests for CreateNamespace with any type of body

func NewDeleteMeterRequest

func NewDeleteMeterRequest(server string, meterIdOrSlug MeterIdOrSlug, params *DeleteMeterParams) (*http.Request, error)

NewDeleteMeterRequest generates requests for DeleteMeter

func NewGetMeterRequest

func NewGetMeterRequest(server string, meterIdOrSlug MeterIdOrSlug, params *GetMeterParams) (*http.Request, error)

NewGetMeterRequest generates requests for GetMeter

func NewGetMeterValuesRequest

func NewGetMeterValuesRequest(server string, meterIdOrSlug MeterIdOrSlug, params *GetMeterValuesParams) (*http.Request, error)

NewGetMeterValuesRequest generates requests for GetMeterValues

func NewIngestEventsRequest

func NewIngestEventsRequest(server string, params *IngestEventsParams, body IngestEventsJSONRequestBody) (*http.Request, error)

NewIngestEventsRequest calls the generic IngestEvents builder with application/cloudevents+json body

func NewIngestEventsRequestWithBody

func NewIngestEventsRequestWithBody(server string, params *IngestEventsParams, contentType string, body io.Reader) (*http.Request, error)

NewIngestEventsRequestWithBody generates requests for IngestEvents with any type of body

func NewListMetersRequest

func NewListMetersRequest(server string, params *ListMetersParams) (*http.Request, error)

NewListMetersRequest generates requests for ListMeters

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

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

func (c *Client) CreateMeter(ctx context.Context, params *CreateMeterParams, body CreateMeterJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateMeterWithBody

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

func (*Client) CreateNamespace

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

func (*Client) CreateNamespaceWithBody

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

func (*Client) DeleteMeter

func (c *Client) DeleteMeter(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *DeleteMeterParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMeter

func (c *Client) GetMeter(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetMeterValues

func (c *Client) GetMeterValues(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterValuesParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) IngestEvents

func (c *Client) IngestEvents(ctx context.Context, params *IngestEventsParams, body IngestEventsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) IngestEventsWithBody

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

func (*Client) ListMeters

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

type ClientInterface

type ClientInterface interface {
	// IngestEvents request with any body
	IngestEventsWithBody(ctx context.Context, params *IngestEventsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	IngestEvents(ctx context.Context, params *IngestEventsParams, body IngestEventsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ListMeters request
	ListMeters(ctx context.Context, params *ListMetersParams, reqEditors ...RequestEditorFn) (*http.Response, error)

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

	CreateMeter(ctx context.Context, params *CreateMeterParams, body CreateMeterJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeleteMeter request
	DeleteMeter(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *DeleteMeterParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetMeter request
	GetMeter(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetMeterValues request
	GetMeterValues(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterValuesParams, reqEditors ...RequestEditorFn) (*http.Response, error)

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

	CreateNamespace(ctx context.Context, body CreateNamespaceJSONRequestBody, 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) CreateMeterWithBodyWithResponse

func (c *ClientWithResponses) CreateMeterWithBodyWithResponse(ctx context.Context, params *CreateMeterParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateMeterResponse, error)

CreateMeterWithBodyWithResponse request with arbitrary body returning *CreateMeterResponse

func (*ClientWithResponses) CreateMeterWithResponse

func (c *ClientWithResponses) CreateMeterWithResponse(ctx context.Context, params *CreateMeterParams, body CreateMeterJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateMeterResponse, error)

func (*ClientWithResponses) CreateNamespaceWithBodyWithResponse

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

CreateNamespaceWithBodyWithResponse request with arbitrary body returning *CreateNamespaceResponse

func (*ClientWithResponses) CreateNamespaceWithResponse

func (c *ClientWithResponses) CreateNamespaceWithResponse(ctx context.Context, body CreateNamespaceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNamespaceResponse, error)

func (*ClientWithResponses) DeleteMeterWithResponse

func (c *ClientWithResponses) DeleteMeterWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *DeleteMeterParams, reqEditors ...RequestEditorFn) (*DeleteMeterResponse, error)

DeleteMeterWithResponse request returning *DeleteMeterResponse

func (*ClientWithResponses) GetMeterValuesWithResponse

func (c *ClientWithResponses) GetMeterValuesWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterValuesParams, reqEditors ...RequestEditorFn) (*GetMeterValuesResponse, error)

GetMeterValuesWithResponse request returning *GetMeterValuesResponse

func (*ClientWithResponses) GetMeterWithResponse

func (c *ClientWithResponses) GetMeterWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterParams, reqEditors ...RequestEditorFn) (*GetMeterResponse, error)

GetMeterWithResponse request returning *GetMeterResponse

func (*ClientWithResponses) IngestEventsWithBodyWithResponse

func (c *ClientWithResponses) IngestEventsWithBodyWithResponse(ctx context.Context, params *IngestEventsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error)

IngestEventsWithBodyWithResponse request with arbitrary body returning *IngestEventsResponse

func (*ClientWithResponses) IngestEventsWithResponse

func (c *ClientWithResponses) IngestEventsWithResponse(ctx context.Context, params *IngestEventsParams, body IngestEventsJSONRequestBody, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error)

func (*ClientWithResponses) ListMetersWithResponse

func (c *ClientWithResponses) ListMetersWithResponse(ctx context.Context, params *ListMetersParams, reqEditors ...RequestEditorFn) (*ListMetersResponse, error)

ListMetersWithResponse request returning *ListMetersResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// IngestEvents request with any body
	IngestEventsWithBodyWithResponse(ctx context.Context, params *IngestEventsParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error)

	IngestEventsWithResponse(ctx context.Context, params *IngestEventsParams, body IngestEventsJSONRequestBody, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error)

	// ListMeters request
	ListMetersWithResponse(ctx context.Context, params *ListMetersParams, reqEditors ...RequestEditorFn) (*ListMetersResponse, error)

	// CreateMeter request with any body
	CreateMeterWithBodyWithResponse(ctx context.Context, params *CreateMeterParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateMeterResponse, error)

	CreateMeterWithResponse(ctx context.Context, params *CreateMeterParams, body CreateMeterJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateMeterResponse, error)

	// DeleteMeter request
	DeleteMeterWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *DeleteMeterParams, reqEditors ...RequestEditorFn) (*DeleteMeterResponse, error)

	// GetMeter request
	GetMeterWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterParams, reqEditors ...RequestEditorFn) (*GetMeterResponse, error)

	// GetMeterValues request
	GetMeterValuesWithResponse(ctx context.Context, meterIdOrSlug MeterIdOrSlug, params *GetMeterValuesParams, reqEditors ...RequestEditorFn) (*GetMeterValuesResponse, error)

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

	CreateNamespaceWithResponse(ctx context.Context, body CreateNamespaceJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNamespaceResponse, error)
}

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

type CreateMeterJSONRequestBody

type CreateMeterJSONRequestBody = Meter

CreateMeterJSONRequestBody defines body for CreateMeter for application/json ContentType.

type CreateMeterParams

type CreateMeterParams struct {
	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

CreateMeterParams defines parameters for CreateMeter.

type CreateMeterResponse

type CreateMeterResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *Meter
	JSON400      *Problem
	JSON501      *Problem
	JSONDefault  *Problem
}

func ParseCreateMeterResponse

func ParseCreateMeterResponse(rsp *http.Response) (*CreateMeterResponse, error)

ParseCreateMeterResponse parses an HTTP response from a CreateMeterWithResponse call

func (CreateMeterResponse) Status

func (r CreateMeterResponse) Status() string

Status returns HTTPResponse.Status

func (CreateMeterResponse) StatusCode

func (r CreateMeterResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type CreateNamespaceJSONRequestBody

type CreateNamespaceJSONRequestBody = Namespace

CreateNamespaceJSONRequestBody defines body for CreateNamespace for application/json ContentType.

type CreateNamespaceResponse

type CreateNamespaceResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON201      *Namespace
	JSONDefault  *Problem
}

func ParseCreateNamespaceResponse

func ParseCreateNamespaceResponse(rsp *http.Response) (*CreateNamespaceResponse, error)

ParseCreateNamespaceResponse parses an HTTP response from a CreateNamespaceWithResponse call

func (CreateNamespaceResponse) Status

func (r CreateNamespaceResponse) Status() string

Status returns HTTPResponse.Status

func (CreateNamespaceResponse) StatusCode

func (r CreateNamespaceResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DeleteMeterParams

type DeleteMeterParams struct {
	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

DeleteMeterParams defines parameters for DeleteMeter.

type DeleteMeterResponse

type DeleteMeterResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON404      *Problem
	JSON501      *Problem
	JSONDefault  *Problem
}

func ParseDeleteMeterResponse

func ParseDeleteMeterResponse(rsp *http.Response) (*DeleteMeterResponse, error)

ParseDeleteMeterResponse parses an HTTP response from a DeleteMeterWithResponse call

func (DeleteMeterResponse) Status

func (r DeleteMeterResponse) Status() string

Status returns HTTPResponse.Status

func (DeleteMeterResponse) StatusCode

func (r DeleteMeterResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ErrResponse

type ErrResponse struct {
	Err error `json:"-"` // low-level runtime error

	StatusCode int    `json:"statusCode"`        // http response status code
	StatusText string `json:"status"`            // user-level status message
	AppCode    int64  `json:"code,omitempty"`    // application-specific error code
	Message    string `json:"message,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors. In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

type Event

type Event = event.Event

Event CloudEvents Specification JSON Schema

type GetMeterParams

type GetMeterParams struct {
	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

GetMeterParams defines parameters for GetMeter.

type GetMeterResponse

type GetMeterResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Meter
	JSON404      *Problem
	JSONDefault  *Problem
}

func ParseGetMeterResponse

func ParseGetMeterResponse(rsp *http.Response) (*GetMeterResponse, error)

ParseGetMeterResponse parses an HTTP response from a GetMeterWithResponse call

func (GetMeterResponse) Status

func (r GetMeterResponse) Status() string

Status returns HTTPResponse.Status

func (GetMeterResponse) StatusCode

func (r GetMeterResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetMeterValuesParams

type GetMeterValuesParams struct {
	Subject *string `form:"subject,omitempty" json:"subject,omitempty"`

	// From Start date-time in RFC 3339 format.
	// Must be aligned with the window size.
	// Inclusive.
	From *time.Time `form:"from,omitempty" json:"from,omitempty"`

	// To End date-time in RFC 3339 format.
	// Must be aligned with the window size.
	// Inclusive.
	To *time.Time `form:"to,omitempty" json:"to,omitempty"`

	// WindowSize If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group.
	WindowSize *WindowSize `form:"windowSize,omitempty" json:"windowSize,omitempty"`

	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

GetMeterValuesParams defines parameters for GetMeterValues.

type GetMeterValuesResponse

type GetMeterValuesResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *struct {
		Data       []MeterValue `json:"data"`
		WindowSize *WindowSize  `json:"windowSize,omitempty"`
	}
	JSON400     *Problem
	JSONDefault *Problem
}

func ParseGetMeterValuesResponse

func ParseGetMeterValuesResponse(rsp *http.Response) (*GetMeterValuesResponse, error)

ParseGetMeterValuesResponse parses an HTTP response from a GetMeterValuesWithResponse call

func (GetMeterValuesResponse) Status

func (r GetMeterValuesResponse) Status() string

Status returns HTTPResponse.Status

func (GetMeterValuesResponse) StatusCode

func (r GetMeterValuesResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type IdOrSlug

type IdOrSlug = string

IdOrSlug defines model for IdOrSlug.

type IngestEventsJSONRequestBody

type IngestEventsJSONRequestBody = Event

IngestEventsJSONRequestBody defines body for IngestEvents for application/cloudevents+json ContentType.

type IngestEventsParams

type IngestEventsParams struct {
	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

IngestEventsParams defines parameters for IngestEvents.

type IngestEventsResponse

type IngestEventsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON400      *Problem
	JSONDefault  *Problem
}

func ParseIngestEventsResponse

func ParseIngestEventsResponse(rsp *http.Response) (*IngestEventsResponse, error)

ParseIngestEventsResponse parses an HTTP response from a IngestEventsWithResponse call

func (IngestEventsResponse) Status

func (r IngestEventsResponse) Status() string

Status returns HTTPResponse.Status

func (IngestEventsResponse) StatusCode

func (r IngestEventsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ListMetersParams

type ListMetersParams struct {
	// OMNamespace Optional namespace
	NamespaceInput *NamespaceInput `json:"OM-Namespace,omitempty"`
}

ListMetersParams defines parameters for ListMeters.

type ListMetersResponse

type ListMetersResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]Meter
	JSONDefault  *Problem
}

func ParseListMetersResponse

func ParseListMetersResponse(rsp *http.Response) (*ListMetersResponse, error)

ParseListMetersResponse parses an HTTP response from a ListMetersWithResponse call

func (ListMetersResponse) Status

func (r ListMetersResponse) Status() string

Status returns HTTPResponse.Status

func (ListMetersResponse) StatusCode

func (r ListMetersResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Meter

type Meter = models.Meter

Meter defines model for Meter.

type MeterAggregation

type MeterAggregation = models.MeterAggregation

MeterAggregation The aggregation type to use for the meter.

type MeterIdOrSlug

type MeterIdOrSlug = IdOrSlug

MeterIdOrSlug defines model for meterIdOrSlug.

type MeterValue

type MeterValue = models.MeterValue

MeterValue defines model for MeterValue.

type Namespace

type Namespace = models.Namespace

Namespace defines model for Namespace.

type NamespaceInput

type NamespaceInput = string

NamespaceInput defines model for namespaceParam.

type Problem

type Problem = models.Problem

Problem A Problem Details object (RFC 7807)

type RequestEditorFn

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

RequestEditorFn is the function signature for the RequestEditor callback function

type WindowSize

type WindowSize = models.WindowSize

WindowSize defines model for WindowSize.

Jump to

Keyboard shortcuts

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