api

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ERROR_NOTSUPPORTED = errors.New("operation not supported")

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 AggregationResetBody

type AggregationResetBody struct {
	ResetType ResetType `json:"ResetType,omitempty"`

	// A list of system URIs to apply the reset to
	TargetURIs []string `json:"TargetURIs,omitempty"`
}

AggregationResetBody - Aggregation reset request

type ComputerSystem

type ComputerSystem struct {

	// An id is a URI-reference for the object
	Id string `json:"id"`

	// The name is the unique name identifier for the ComputerSystem. This is used to reference the system in the API.
	Name string `json:"name"`

	PowerState PowerState `json:"powerState,omitempty"`
}

ComputerSystem - A single computer system with power state

type ComputerSystemCollection

type ComputerSystemCollection struct {

	// An id is a URI-reference for the object
	Id string `json:"id,omitempty"`

	// Human-readable name for the collection
	Name string `json:"name,omitempty"`

	// Collection of ComputerSystem objects
	Systems []ComputerSystem `json:"systems,omitempty"`
}

ComputerSystemCollection - A collection of computer systems

type DefaultApiController

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

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

func (*DefaultApiController) AggregationServiceActionsAggregationServiceResetPost

func (c *DefaultApiController) AggregationServiceActionsAggregationServiceResetPost(w http.ResponseWriter, r *http.Request)

AggregationServiceActionsAggregationServiceResetPost - Request aggregate system reset

func (*DefaultApiController) ComputerSystemsGet

func (c *DefaultApiController) ComputerSystemsGet(w http.ResponseWriter, r *http.Request)

ComputerSystemsGet - Get computer systems

func (*DefaultApiController) ComputerSystemsNameActionsComputerSystemResetPost

func (c *DefaultApiController) ComputerSystemsNameActionsComputerSystemResetPost(w http.ResponseWriter, r *http.Request)

ComputerSystemsNameActionsComputerSystemResetPost - Request system reset

func (*DefaultApiController) ComputerSystemsNameGet

func (c *DefaultApiController) ComputerSystemsNameGet(w http.ResponseWriter, r *http.Request)

ComputerSystemsNameGet - Get a specific computer system state

func (*DefaultApiController) Routes

func (c *DefaultApiController) Routes() Routes

Routes returns all of the api route for the DefaultApiController

type DefaultApiRouter

type DefaultApiRouter interface {
	AggregationServiceActionsAggregationServiceResetPost(http.ResponseWriter, *http.Request)
	ComputerSystemsGet(http.ResponseWriter, *http.Request)
	ComputerSystemsNameActionsComputerSystemResetPost(http.ResponseWriter, *http.Request)
	ComputerSystemsNameGet(http.ResponseWriter, *http.Request)
}

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

type DefaultApiService

type DefaultApiService struct {
}

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

func (*DefaultApiService) AggregationServiceActionsAggregationServiceResetPost

func (s *DefaultApiService) AggregationServiceActionsAggregationServiceResetPost(ctx context.Context, aggregationResetBody AggregationResetBody) (ImplResponse, error)

AggregationServiceActionsAggregationServiceResetPost - Request aggregate system reset

func (*DefaultApiService) ComputerSystemsGet

func (s *DefaultApiService) ComputerSystemsGet(ctx context.Context) (ImplResponse, error)

ComputerSystemsGet - Get computer systems

func (*DefaultApiService) ComputerSystemsNameActionsComputerSystemResetPost

func (s *DefaultApiService) ComputerSystemsNameActionsComputerSystemResetPost(ctx context.Context, name string, resetRequestBody ResetRequestBody) (ImplResponse, error)

ComputerSystemsNameActionsComputerSystemResetPost - Request system reset

func (*DefaultApiService) ComputerSystemsNameGet

func (s *DefaultApiService) ComputerSystemsNameGet(ctx context.Context, name string) (ImplResponse, error)

ComputerSystemsNameGet - Get a specific computer system state

type DefaultApiServicer

type DefaultApiServicer interface {
	AggregationServiceActionsAggregationServiceResetPost(context.Context, AggregationResetBody) (ImplResponse, error)
	ComputerSystemsGet(context.Context) (ImplResponse, error)
	ComputerSystemsNameActionsComputerSystemResetPost(context.Context, string, ResetRequestBody) (ImplResponse, error)
	ComputerSystemsNameGet(context.Context, string) (ImplResponse, error)
}

DefaultApiServicer defines the api actions for the DefaultApi 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 NewDefaultApiService

func NewDefaultApiService() DefaultApiServicer

NewDefaultApiService creates a default api service

func NewPowermanApiService

func NewPowermanApiService(server string, port int) DefaultApiServicer

NewPowermanApiService creates a default api service

type Error

type Error struct {
	Error ErrorError `json:"error,omitempty"`
}

type ErrorError

type ErrorError struct {

	// Response code
	Code string `json:"code"`

	// A human-readable error message string
	Message string `json:"message"`
}

ErrorError - Properties that describe the error

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 PowerState

type PowerState string

PowerState : Power state for a component

const (
	POWERSTATE_ON  PowerState = "On"
	POWERSTATE_OFF PowerState = "Off"
)

List of PowerState

type PowermanApiService

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

PowermanApiService is a service that implents the logic for the DefaultApiServicer

func (*PowermanApiService) AggregationServiceActionsAggregationServiceResetPost

func (s *PowermanApiService) AggregationServiceActionsAggregationServiceResetPost(ctx context.Context, aggregationResetBody AggregationResetBody) (ImplResponse, error)

AggregationServiceActionsAggregationServiceResetPost - Request aggregate system reset

func (*PowermanApiService) ComputerSystemsGet

func (s *PowermanApiService) ComputerSystemsGet(ctx context.Context) (ImplResponse, error)

ComputerSystemsGet - Get computer systems

func (*PowermanApiService) ComputerSystemsNameActionsComputerSystemResetPost

func (s *PowermanApiService) ComputerSystemsNameActionsComputerSystemResetPost(ctx context.Context, name string, resetRequestBody ResetRequestBody) (ImplResponse, error)

ComputerSystemsNameActionsComputerSystemResetPost - Request system reset

func (*PowermanApiService) ComputerSystemsNameGet

func (s *PowermanApiService) ComputerSystemsNameGet(ctx context.Context, name string) (ImplResponse, error)

ComputerSystemsNameGet - Get a specific computer system state

type ResetRequestBody

type ResetRequestBody struct {
	ResetType ResetType `json:"ResetType"`
}

ResetRequestBody - Reset request

type ResetType

type ResetType string
const (
	RESETTYPE_ON                ResetType = "On"
	RESETTYPE_FORCE_OFF         ResetType = "ForceOff"
	RESETTYPE_GRACEFUL_SHUTDOWN ResetType = "GracefulShutdown"
	RESETTYPE_GRACEFUL_RESTART  ResetType = "GracefulRestart"
	RESETTYPE_FORCE_RESTART     ResetType = "ForceRestart"
	RESETTYPE_NMI               ResetType = "Nmi"
	RESETTYPE_FORCE_ON          ResetType = "ForceOn"
	RESETTYPE_PUSH_POWER_BUTTON ResetType = "PushPowerButton"
	RESETTYPE_POWER_CYCLE       ResetType = "PowerCycle"
)

List of ResetType

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 NewDefaultApiController

func NewDefaultApiController(s DefaultApiServicer) Router

NewDefaultApiController 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