Documentation ¶
Overview ¶
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t BasicAuthCredentials -m validator
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t BearerAuthCredentials -m validator
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by goscinny extractor -t CreateDataPointRequest DO NOT EDIT
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t CreateDataPointRequest -m validator
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by goscinny extractor -t CreateMetricsRequest DO NOT EDIT
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t CreateMetricsRequest -m validator
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t Request -m validator
DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING Autogenerated by rest_tool -t SingleResponse -m validator
Index ¶
- Variables
- func ContentDecoder(contentType string) func(r io.Reader) Decoder
- func ParseToBool(data string) (bool, error)
- func ParseToFloat(data string) (float64, error)
- func ParseToInt(data string) (int64, error)
- func ParseToUint(data string) (uint64, error)
- type BaseResponse
- type BasicAuthCredentials
- type BearerAuthCredentials
- type CreateDataPointRequest
- type CreateDataPointResponse
- type CreateMetricsRequest
- type CreateMetricsResponse
- type Decoder
- type Error
- type Extractor
- type Metadata
- type Request
- type Response
- type SingleDataPointResponse
- type SingleMetricsResponse
- type SingleResponse
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errorFunc(http.StatusNotFound, 1000, "") ErrBadRequestParametersMissing = errorFunc(http.StatusBadRequest, 1001, "Mandatory Parameter missing") ErrBadRequestInvalidParameter = errorFunc(http.StatusBadRequest, 1002, "Invalid parameter") ErrBadRequestInvalidBody = errorFunc(http.StatusBadRequest, 1007, "Invalid request body,failed parsing ") ErrForbidden = errorFunc(http.StatusForbidden, 1003, "Authentication failed") ErrInternalServerError = errorFunc(http.StatusInternalServerError, 1004, "") ErrTooManyRequests = errorFunc(http.StatusTooManyRequests, 1006, "") ErrMethodNotDefined = errorFunc(http.StatusMethodNotAllowed, 1005, "Method not implemented") ErrResourceConflict = errorFunc(http.StatusConflict, 1008, "Duplicate resource") ErrUnAuthorized = errorFunc(http.StatusUnauthorized, 1010, "Authentication failed") ErrMetricNotFound = errorFunc(http.StatusNotFound, 1011, "Metric name not found. Please create first before you send datapoints") )
All the error constants would be here
Functions ¶
func ContentDecoder ¶
ContentDecoder returns decoder given content type if the content type given does not align to the expectations it will return json decoder
func ParseToBool ¶
ParseToBool parses a given string and returns bool value of the string
func ParseToFloat ¶
ParseToFloat parses a given string and returns float64 value of the string
func ParseToInt ¶
ParseToInt parses a given string and returns int64 value of the string
func ParseToUint ¶
ParseToUint parses a given string and returns uint64 value of the string
Types ¶
type BaseResponse ¶
type BaseResponse struct { RequestID string `json:"request_id"` Method string `json:"method"` HTTPCode int `json:"http_code"` Metadata *Metadata `json:"metadata,omitempty"` }
BaseResponse defines the common structure of standard response This contains all but one field of final response All the request response will embed this structure and should have "response" key
func (*BaseResponse) SetHTTPCode ¶
func (res *BaseResponse) SetHTTPCode(code int) Response
SetHTTPCode stets the http code
func (*BaseResponse) SetMetadata ¶
func (res *BaseResponse) SetMetadata(metadata *Metadata) Response
SetMetadata setter for Metadata in Response class
func (*BaseResponse) SetMethod ¶
func (res *BaseResponse) SetMethod(method string) Response
SetMethod sets http method
func (*BaseResponse) SetRequestID ¶
func (res *BaseResponse) SetRequestID(requestID string) Response
SetRequestID sets requst id for response
type BasicAuthCredentials ¶
type BasicAuthCredentials struct { UserName *string `required:"true"` Password *string `required:"true"` }
BasicAuthCredentials defines credentials required for basic auth
func (*BasicAuthCredentials) ExtractFromHTTP ¶
func (ba *BasicAuthCredentials) ExtractFromHTTP(c echo.Context) *Error
ExtractFromHTTP defines how to extract the data form request
func (*BasicAuthCredentials) Validate ¶
func (_receiver_ *BasicAuthCredentials) Validate() *Error
Validate checks if a contract is valid or not and return with appropriate message
type BearerAuthCredentials ¶
BearerAuthCredentials defines credentials required for basic auth
func (*BearerAuthCredentials) ExtractFromHTTP ¶
func (ba *BearerAuthCredentials) ExtractFromHTTP(c echo.Context) *Error
ExtractFromHTTP defines how to extract the data form request
func (*BearerAuthCredentials) Validate ¶
func (_receiver_ *BearerAuthCredentials) Validate() *Error
Validate checks if a contract is valid or not and return with appropriate message
type CreateDataPointRequest ¶
type CreateDataPointRequest struct { *Request `json:"-"` Name *string `json:"-" path:"metricName" required:"true"` Time *time.Time `json:"time" required:"true"` Value *float64 `json:"value" required:"true"` }
CreateDataPointRequest defines the structure to store request data Throttle : Basic,1000,1*M Route : /metrics/:metricName/datapoint
func (*CreateDataPointRequest) ExtractFromHTTP ¶
func (_receiver *CreateDataPointRequest) ExtractFromHTTP(c echo.Context) *Error
ExtractFromHTTP reads http request body and fills the object
func (*CreateDataPointRequest) Validate ¶
func (_receiver_ *CreateDataPointRequest) Validate() *Error
Validate checks if a contract is valid or not and return with appropriate message
type CreateDataPointResponse ¶
type CreateDataPointResponse struct { BaseResponse ResponseData []*SingleDataPointResponse `json:"response"` }
CreateDataPointResponse defines the structure to store response data for Create DP
type CreateMetricsRequest ¶
CreateMetricsRequest defines the structure to store request data Throttle : Basic,1000,1*M Route : /metrics/:metricName
func (*CreateMetricsRequest) ExtractFromHTTP ¶
func (_receiver *CreateMetricsRequest) ExtractFromHTTP(c echo.Context) *Error
ExtractFromHTTP reads http request body and fills the object
func (*CreateMetricsRequest) Validate ¶
func (_receiver_ *CreateMetricsRequest) Validate() *Error
Validate checks if a contract is valid or not and return with appropriate message
type CreateMetricsResponse ¶
type CreateMetricsResponse struct { BaseResponse ResponseData []*SingleMetricsResponse `json:"response"` }
CreateMetricsResponse defines the structure to store response data for CreateItem
type Decoder ¶
type Decoder interface {
Decode(interface{}) error
}
Decoder defines interface for a function
type Error ¶
type Error struct { HTTPCode int `json:"-"` Code uint64 `json:"code"` Description string `json:"description"` InternalMessage []interface{} `json:"-"` Message string `json:"message"` }
Error defines the error contract
type Extractor ¶
Extractor defines the interface to be implemented by all contracts it defines how to read values from a http request to its fields
type Metadata ¶
type Metadata struct { Failed *uint64 `json:"failed,omitempty"` PageSize *uint64 `json:"page_size,omitempty"` Page *uint64 `json:"page,omitempty"` Total *uint64 `json:"total,omitempty"` Success *uint64 `json:"success,omitempty"` Custom interface{} `json:"custom,omitempty"` }
Metadata defines the structure for metadata
type Request ¶
type Request struct { Method *string `json:"-" required:"true"` RequestID *string `json:"-" required:"true"` }
Request defines the base request
type Response ¶
type Response interface { SetHTTPCode(int) Response SetMethod(string) Response SetRequestID(string) Response SetMetadata(*Metadata) Response }
Response defines interface for a valid response
type SingleDataPointResponse ¶
type SingleMetricsResponse ¶
type SingleMetricsResponse struct { SingleResponse ResourceData *model.Anomaly `json:"data" required:"true"` }
SingleMetricsResponse defines the structure of response for single item this is to include in the response item
type SingleResponse ¶
type SingleResponse struct { Code *int `json:"code"` ErrorData *Error `json:"error_data"` Msg *string `json:"msg,omitempty"` Status *string `json:"status" enum:"failure|success"` }
SingleResponse struct defines response for one resource in the request
func (*SingleResponse) SetErrorData ¶
func (res *SingleResponse) SetErrorData(err *Error) *SingleResponse
SetErrorData setter for ErrorData in Response class
func (*SingleResponse) Validate ¶
func (_receiver_ *SingleResponse) Validate() *Error
Validate checks if a contract is valid or not and return with appropriate message
Source Files ¶
- basicauth.go
- basicauthcredentials_validator.go
- bearerauth.go
- bearerauthcredentials_validator.go
- createdatapointrequest_extractor.go
- createdatapointrequest_validator.go
- createmetricsrequest_extractor.go
- createmetricsrequest_validator.go
- datapoint.go
- decoder.go
- error.go
- extractor.go
- metrics_create.go
- request.go
- request_validator.go
- response.go
- singleresponse_validator.go
- validator.go