api

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
	ErrInvalidToken = &ErrResponse{HTTPStatusCode: 403, StatusText: "Forbidden."}
)

Functions

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func ErrRender

func ErrRender(err error) render.Renderer

func New

func New(aSettings Settings)

Types

type AnalyticRequest

type AnalyticRequest struct {
	*TerraformRequest

	// OrganizationID is the id of the cloudavenue organization
	OrganizationID string `json:"organizationId"`
	// ResourceName is the name of the resource
	ResourceName string `json:"resourceName"`
	// Action is the action performed on the resource (create, update, delete, read or import)
	Action string `json:"action"`

	// ExecutionTime is the time in ms to execute the action
	ExecutionTime int64 `json:"executionTime"`

	// Data is the interface containing extra data
	Data map[string]interface{} `json:"data,omitempty"`
}

func (*AnalyticRequest) Bind

func (a *AnalyticRequest) Bind(r *http.Request) error

func (AnalyticRequest) MarshalBinary

func (a AnalyticRequest) MarshalBinary() ([]byte, error)

type AnalyticResponse

type AnalyticResponse struct{}

AnalyticResponse is the response payload for the Analytic data model.

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,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.

func (*ErrResponse) Render

func (e *ErrResponse) Render(_ http.ResponseWriter, r *http.Request) error

type Settings

type Settings struct {
	// Address is the address of the api server.
	// Default: localhost
	Address string `yaml:"address"`

	// Port is the port of the api server.
	// Default: 8000
	Port string `yaml:"port"`

	// Token is the token of the api server.
	// Default: ""
	Token string `yaml:"token"`

	*clients.RedisClient
	*clients.InfluxDBClient
}

type TerraformRequest

type TerraformRequest struct {
	// TerraformExecutionID is the uniq id generated at the beginning of the terraform execution
	TerraformExecutionID string `json:"terraformExecutionId"`
	// ClientToken is the key used to identify the client
	ClientToken string `json:"clientToken"`
	// ClientVersion is the version of the provider
	ClientVersion string `json:"version"`
}

TerraformRequest is the request payload for Terraform data model.

func (*TerraformRequest) Bind

func (a *TerraformRequest) Bind(_ *http.Request) error

type TerraformResponse

type TerraformResponse struct{}

TerraformResponse is the response payload for the Terraform data model.

Jump to

Keyboard shortcuts

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