openapi

package
v0.0.0-...-268cd68 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: Apache-2.0 Imports: 11 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

Types

type ContainerSpec

type ContainerSpec struct {
	Name string `json:"name"`

	Image string `json:"image"`
}

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 Instance

type Instance struct {
	Name string `json:"name"`

	Endpoint string `json:"endpoint"`

	Provider string `json:"provider"`

	Active bool `json:"active"`

	Container ContainerSpec `json:"container"`

	Status InstanceStatus `json:"status"`
}

type InstanceEvent

type InstanceEvent struct {
	Type string `json:"type"`

	Target string `json:"target"`

	Data []Instance `json:"data"`
}

type InstanceSpec

type InstanceSpec struct {
	Container ContainerSpec `json:"container"`
}

type InstanceStatus

type InstanceStatus struct {
	Agent string `json:"agent"`

	Status string `json:"status"`

	Started time.Time `json:"started"`
}

type InstancesApiController

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

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

func (*InstancesApiController) GetInstances

func (c *InstancesApiController) GetInstances(w http.ResponseWriter, r *http.Request)

GetInstances - Get InstanceDemand for a ScrapeTarget

func (*InstancesApiController) Routes

func (c *InstancesApiController) Routes() Routes

Routes returns all of the api route for the InstancesApiController

func (*InstancesApiController) SaveInstances

func (c *InstancesApiController) SaveInstances(w http.ResponseWriter, r *http.Request)

SaveInstances - Update InstanceDemand for a ScrapeTarget

type InstancesApiRouter

type InstancesApiRouter interface {
	GetInstances(http.ResponseWriter, *http.Request)
	SaveInstances(http.ResponseWriter, *http.Request)
}

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

type InstancesApiService

type InstancesApiService struct {
}

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

func (*InstancesApiService) GetInstances

func (s *InstancesApiService) GetInstances(ctx context.Context, target string) (ImplResponse, error)

GetInstances - Get InstanceDemand for a ScrapeTarget

func (*InstancesApiService) SaveInstances

func (s *InstancesApiService) SaveInstances(ctx context.Context, target string, instance []Instance) (ImplResponse, error)

SaveInstances - Update InstanceDemand for a ScrapeTarget

type InstancesApiServicer

type InstancesApiServicer interface {
	GetInstances(context.Context, string) (ImplResponse, error)
	SaveInstances(context.Context, string, []Instance) (ImplResponse, error)
}

InstancesApiServicer defines the api actions for the InstancesApi 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 NewInstancesApiService

func NewInstancesApiService() InstancesApiServicer

NewInstancesApiService creates a default api service

type ProviderSpec

type ProviderSpec struct {
	Weights map[string]float32 `json:"weights"`
}

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 NewInstancesApiController

func NewInstancesApiController(s InstancesApiServicer) Router

NewInstancesApiController creates a default api controller

func NewTargetsApiController

func NewTargetsApiController(s TargetsApiServicer) Router

NewTargetsApiController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

type ScrapeTarget

type ScrapeTarget struct {
	Name string `json:"name"`

	Path string `json:"path"`

	Description string `json:"description"`

	Query string `json:"query"`

	ProviderSpec ProviderSpec `json:"providerSpec"`

	InstanceSpec InstanceSpec `json:"instanceSpec"`

	StaticSpec StaticSpec `json:"staticSpec"`
}

type StaticSpec

type StaticSpec struct {
	Endpoints []string `json:"endpoints"`
}

type TargetsApiController

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

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

func (*TargetsApiController) ListScrapeTargets

func (c *TargetsApiController) ListScrapeTargets(w http.ResponseWriter, r *http.Request)

ListScrapeTargets - List ScrapeTargets

func (*TargetsApiController) Routes

func (c *TargetsApiController) Routes() Routes

Routes returns all of the api route for the TargetsApiController

type TargetsApiRouter

type TargetsApiRouter interface {
	ListScrapeTargets(http.ResponseWriter, *http.Request)
}

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

type TargetsApiService

type TargetsApiService struct {
}

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

func (*TargetsApiService) ListScrapeTargets

func (s *TargetsApiService) ListScrapeTargets(ctx context.Context) (ImplResponse, error)

ListScrapeTargets - List ScrapeTargets

type TargetsApiServicer

type TargetsApiServicer interface {
	ListScrapeTargets(context.Context) (ImplResponse, error)
}

TargetsApiServicer defines the api actions for the TargetsApi 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 NewTargetsApiService

func NewTargetsApiService() TargetsApiServicer

NewTargetsApiService creates a default api service

Jump to

Keyboard shortcuts

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