openapi

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func Logger

func Logger(inner http.Handler, name string) http.Handler

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

func ReadFormFileToTempFile

func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)

ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file

func ReadFormFilesToTempFiles

func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)

ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files

Types

type Burnrate

type Burnrate struct {
	Window int64 `json:"window"`

	Current float64 `json:"current"`

	Query string `json:"query"`
}

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

Implementation response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type Indicator

type Indicator struct {
	Ratio IndicatorRatio `json:"ratio,omitempty"`

	Latency IndicatorLatency `json:"latency,omitempty"`
}

type IndicatorLatency

type IndicatorLatency struct {
	Success Query `json:"success"`

	Total Query `json:"total"`

	Grouping []string `json:"grouping,omitempty"`
}

type IndicatorRatio

type IndicatorRatio struct {
	Errors Query `json:"errors"`

	Total Query `json:"total"`

	Grouping []string `json:"grouping,omitempty"`
}

type MultiBurnrateAlert

type MultiBurnrateAlert struct {
	Severity string `json:"severity"`

	For int64 `json:"for"`

	Factor float64 `json:"factor"`

	Short Burnrate `json:"short"`

	Long Burnrate `json:"long"`

	State string `json:"state"`
}

type Objective

type Objective struct {
	Labels map[string]string `json:"labels"`

	Description string `json:"description"`

	Target float64 `json:"target"`

	Window int64 `json:"window"`

	Config string `json:"config"`

	Indicator Indicator `json:"indicator,omitempty"`
}

type ObjectiveStatus

type ObjectiveStatus struct {
	Labels map[string]string `json:"labels,omitempty"`

	Availability ObjectiveStatusAvailability `json:"availability"`

	Budget ObjectiveStatusBudget `json:"budget"`
}

type ObjectiveStatusAvailability

type ObjectiveStatusAvailability struct {
	Percentage float64 `json:"percentage"`

	Total float64 `json:"total"`

	Errors float64 `json:"errors"`
}

type ObjectiveStatusBudget

type ObjectiveStatusBudget struct {
	Total float64 `json:"total"`

	Remaining float64 `json:"remaining"`

	Max float64 `json:"max"`
}

type ObjectivesApiController

type ObjectivesApiController struct {
	// contains filtered or unexported fields
}

A ObjectivesApiController binds http requests to an api service and writes the service results to the http response

func (*ObjectivesApiController) GetMultiBurnrateAlerts

func (c *ObjectivesApiController) GetMultiBurnrateAlerts(w http.ResponseWriter, r *http.Request)

GetMultiBurnrateAlerts - Get the MultiBurnrateAlerts for the Objective

func (*ObjectivesApiController) GetObjectiveErrorBudget

func (c *ObjectivesApiController) GetObjectiveErrorBudget(w http.ResponseWriter, r *http.Request)

GetObjectiveErrorBudget - Get ErrorBudget graph sample pairs

func (*ObjectivesApiController) GetObjectiveStatus

func (c *ObjectivesApiController) GetObjectiveStatus(w http.ResponseWriter, r *http.Request)

GetObjectiveStatus - Get objective status

func (*ObjectivesApiController) GetREDErrors

func (c *ObjectivesApiController) GetREDErrors(w http.ResponseWriter, r *http.Request)

GetREDErrors - Get a matrix of error percentage by label

func (*ObjectivesApiController) GetREDRequests

func (c *ObjectivesApiController) GetREDRequests(w http.ResponseWriter, r *http.Request)

GetREDRequests - Get a matrix of requests by label

func (*ObjectivesApiController) ListObjectives

func (c *ObjectivesApiController) ListObjectives(w http.ResponseWriter, r *http.Request)

ListObjectives - List Objectives

func (*ObjectivesApiController) Routes

func (c *ObjectivesApiController) Routes() Routes

Routes returns all of the api route for the ObjectivesApiController

type ObjectivesApiRouter

type ObjectivesApiRouter interface {
	GetMultiBurnrateAlerts(http.ResponseWriter, *http.Request)
	GetObjectiveErrorBudget(http.ResponseWriter, *http.Request)
	GetObjectiveStatus(http.ResponseWriter, *http.Request)
	GetREDErrors(http.ResponseWriter, *http.Request)
	GetREDRequests(http.ResponseWriter, *http.Request)
	ListObjectives(http.ResponseWriter, *http.Request)
}

ObjectivesApiRouter defines the required methods for binding the api requests to a responses for the ObjectivesApi The ObjectivesApiRouter implementation should parse necessary information from the http request, pass the data to a ObjectivesApiServicer to perform the required actions, then write the service results to the http response.

type ObjectivesApiService

type ObjectivesApiService struct {
}

ObjectivesApiService is a service that implents the logic for the ObjectivesApiServicer This service should implement the business logic for every endpoint for the ObjectivesApi API. Include any external packages or services that will be required by this service.

func (*ObjectivesApiService) GetMultiBurnrateAlerts

func (s *ObjectivesApiService) GetMultiBurnrateAlerts(ctx context.Context, expr string, grouping string) (ImplResponse, error)

GetMultiBurnrateAlerts - Get the MultiBurnrateAlerts for the Objective

func (*ObjectivesApiService) GetObjectiveErrorBudget

func (s *ObjectivesApiService) GetObjectiveErrorBudget(ctx context.Context, expr string, grouping string, start int32, end int32) (ImplResponse, error)

GetObjectiveErrorBudget - Get ErrorBudget graph sample pairs

func (*ObjectivesApiService) GetObjectiveStatus

func (s *ObjectivesApiService) GetObjectiveStatus(ctx context.Context, expr string, grouping string) (ImplResponse, error)

GetObjectiveStatus - Get objective status

func (*ObjectivesApiService) GetREDErrors

func (s *ObjectivesApiService) GetREDErrors(ctx context.Context, expr string, grouping string, start int32, end int32) (ImplResponse, error)

GetREDErrors - Get a matrix of error percentage by label

func (*ObjectivesApiService) GetREDRequests

func (s *ObjectivesApiService) GetREDRequests(ctx context.Context, expr string, grouping string, start int32, end int32) (ImplResponse, error)

GetREDRequests - Get a matrix of requests by label

func (*ObjectivesApiService) ListObjectives

func (s *ObjectivesApiService) ListObjectives(ctx context.Context, expr string) (ImplResponse, error)

ListObjectives - List Objectives

type ObjectivesApiServicer

type ObjectivesApiServicer interface {
	GetMultiBurnrateAlerts(context.Context, string, string) (ImplResponse, error)
	GetObjectiveErrorBudget(context.Context, string, string, int32, int32) (ImplResponse, error)
	GetObjectiveStatus(context.Context, string, string) (ImplResponse, error)
	GetREDErrors(context.Context, string, string, int32, int32) (ImplResponse, error)
	GetREDRequests(context.Context, string, string, int32, int32) (ImplResponse, error)
	ListObjectives(context.Context, string) (ImplResponse, error)
}

ObjectivesApiServicer defines the api actions for the ObjectivesApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can ignored with the .openapi-generator-ignore file and updated with the logic required for the API.

func NewObjectivesApiService

func NewObjectivesApiService() ObjectivesApiServicer

NewObjectivesApiService creates a default api service

type Query

type Query struct {
	Metric string `json:"metric"`

	Name string `json:"name,omitempty"`

	Matchers []QueryMatchers `json:"matchers,omitempty"`
}

type QueryMatchers

type QueryMatchers struct {
	Name string `json:"name,omitempty"`

	Value string `json:"value,omitempty"`

	Type int32 `json:"type,omitempty"`
}

type QueryRange

type QueryRange struct {
	Query string `json:"query"`

	Labels []string `json:"labels"`

	Values [][]float64 `json:"values"`
}

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewObjectivesApiController

func NewObjectivesApiController(s ObjectivesApiServicer) Router

NewObjectivesApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

Jump to

Keyboard shortcuts

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