diff --git a/services/metrics/swagger_gen/models/JWTClaimBody.go b/services/metrics/swagger_gen/models/JWTClaimBody.go new file mode 100644 index 000000000..234b5828e --- /dev/null +++ b/services/metrics/swagger_gen/models/JWTClaimBody.go @@ -0,0 +1,18 @@ +package models + +import ( + "github.com/dgrijalva/jwt-go" +) + +type JWTClaimBody struct { + *jwt.StandardClaims + TokenType string + ResourceAccess map[string]Group `json:"resource_access"` + Scope string `json:"scope"` + PreferredUsername string `json:"preferred_username"` + FacilityCode string `json:"facility_code"` +} + +type Group struct { + Roles []string `json:"roles"` +} diff --git a/services/metrics/swagger_gen/restapi/operations/health/get_health.go b/services/metrics/swagger_gen/restapi/operations/health/get_health.go new file mode 100644 index 000000000..fb1fa0fec --- /dev/null +++ b/services/metrics/swagger_gen/restapi/operations/health/get_health.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// GetHealthHandlerFunc turns a function with the right signature into a get health handler +type GetHealthHandlerFunc func(GetHealthParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn GetHealthHandlerFunc) Handle(params GetHealthParams) middleware.Responder { + return fn(params) +} + +// GetHealthHandler interface for that can handle valid get health params +type GetHealthHandler interface { + Handle(GetHealthParams) middleware.Responder +} + +// NewGetHealth creates a new http.Handler for the get health operation +func NewGetHealth(ctx *middleware.Context, handler GetHealthHandler) *GetHealth { + return &GetHealth{Context: ctx, Handler: handler} +} + +/* + GetHealth swagger:route GET /health health getHealth + +# Get the health status + +API to get the notification health status +*/ +type GetHealth struct { + Context *middleware.Context + Handler GetHealthHandler +} + +func (o *GetHealth) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewGetHealthParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/services/metrics/swagger_gen/restapi/operations/health/get_health_parameters.go b/services/metrics/swagger_gen/restapi/operations/health/get_health_parameters.go new file mode 100644 index 000000000..f975f8866 --- /dev/null +++ b/services/metrics/swagger_gen/restapi/operations/health/get_health_parameters.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" +) + +// NewGetHealthParams creates a new GetHealthParams object +// +// There are no default values defined in the spec. +func NewGetHealthParams() GetHealthParams { + + return GetHealthParams{} +} + +// GetHealthParams contains all the bound params for the get health operation +// typically these are obtained from a http.Request +// +// swagger:parameters GetHealth +type GetHealthParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewGetHealthParams() beforehand. +func (o *GetHealthParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/services/metrics/swagger_gen/restapi/operations/health/get_health_responses.go b/services/metrics/swagger_gen/restapi/operations/health/get_health_responses.go new file mode 100644 index 000000000..23e43a3ed --- /dev/null +++ b/services/metrics/swagger_gen/restapi/operations/health/get_health_responses.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" +) + +// GetHealthOKCode is the HTTP code returned for type GetHealthOK +const GetHealthOKCode int = 200 + +/* +GetHealthOK OK + +swagger:response getHealthOK +*/ +type GetHealthOK struct { + + /* + In: Body + */ + Payload interface{} `json:"body,omitempty"` +} + +// NewGetHealthOK creates GetHealthOK with default headers values +func NewGetHealthOK() *GetHealthOK { + + return &GetHealthOK{} +} + +// WithPayload adds the payload to the get health o k response +func (o *GetHealthOK) WithPayload(payload interface{}) *GetHealthOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the get health o k response +func (o *GetHealthOK) SetPayload(payload interface{}) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *GetHealthOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } +} diff --git a/services/metrics/swagger_gen/restapi/operations/health/get_health_urlbuilder.go b/services/metrics/swagger_gen/restapi/operations/health/get_health_urlbuilder.go new file mode 100644 index 000000000..ba1e168b2 --- /dev/null +++ b/services/metrics/swagger_gen/restapi/operations/health/get_health_urlbuilder.go @@ -0,0 +1,87 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package health + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" +) + +// GetHealthURL generates an URL for the get health operation +type GetHealthURL struct { + _basePath string +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) WithBasePath(bp string) *GetHealthURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *GetHealthURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *GetHealthURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/health" + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/notification-service/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *GetHealthURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *GetHealthURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *GetHealthURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on GetHealthURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on GetHealthURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *GetHealthURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +}