diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722d5e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vscode diff --git a/README.md b/README.md index 67fd453..83dd61c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ If you're new here, better check out our mainĀ [README](https://github.com/moira This API client was generated by the [go-swagger](https://github.com/go-swagger/go-swagger) tool -Our current documentation is available on [swaggerhub](https://app.swaggerhub.com/apis/Moira/moira-alert/master) and on [our website](https://moira.skbkontur.ru/api/swagger/index.html) +Our current documentation is available on [swaggerhub](https://app.swaggerhub.com/apis/Moira/moira-alert/master). ## Installation diff --git a/pkg/client/config/config_client.go b/pkg/client/config/config_client.go index d9b04f6..bd5ebd2 100644 --- a/pkg/client/config/config_client.go +++ b/pkg/client/config/config_client.go @@ -36,7 +36,7 @@ type ClientService interface { } /* -GetWebConfig gets available configuration +GetWebConfig gets web configuration */ func (a *Client) GetWebConfig(params *GetWebConfigParams, opts ...ClientOption) (*GetWebConfigOK, error) { // TODO: Validate the params before sending diff --git a/pkg/client/config/get_web_config_responses.go b/pkg/client/config/get_web_config_responses.go index ffc5486..96b50ae 100644 --- a/pkg/client/config/get_web_config_responses.go +++ b/pkg/client/config/get_web_config_responses.go @@ -29,6 +29,12 @@ func (o *GetWebConfigReader) ReadResponse(response runtime.ClientResponse, consu return nil, err } return result, nil + case 422: + result := NewGetWebConfigUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("[GET /config] get-web-config", response, response.Code()) } @@ -45,7 +51,7 @@ GetWebConfigOK describes a response with status code 200, with default header va Configuration fetched successfully */ type GetWebConfigOK struct { - Payload *models.HandlerConfigurationResponse + Payload *models.APIWebConfig } // IsSuccess returns true when this get web config o k response has a 2xx status code @@ -86,13 +92,81 @@ func (o *GetWebConfigOK) String() string { return fmt.Sprintf("[GET /config][%d] getWebConfigOK %+v", 200, o.Payload) } -func (o *GetWebConfigOK) GetPayload() *models.HandlerConfigurationResponse { +func (o *GetWebConfigOK) GetPayload() *models.APIWebConfig { return o.Payload } func (o *GetWebConfigOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.HandlerConfigurationResponse) + o.Payload = new(models.APIWebConfig) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetWebConfigUnprocessableEntity creates a GetWebConfigUnprocessableEntity with default headers values +func NewGetWebConfigUnprocessableEntity() *GetWebConfigUnprocessableEntity { + return &GetWebConfigUnprocessableEntity{} +} + +/* +GetWebConfigUnprocessableEntity describes a response with status code 422, with default header values. + +Render error +*/ +type GetWebConfigUnprocessableEntity struct { + Payload *models.APIErrorRenderExample +} + +// IsSuccess returns true when this get web config unprocessable entity response has a 2xx status code +func (o *GetWebConfigUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get web config unprocessable entity response has a 3xx status code +func (o *GetWebConfigUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get web config unprocessable entity response has a 4xx status code +func (o *GetWebConfigUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get web config unprocessable entity response has a 5xx status code +func (o *GetWebConfigUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get web config unprocessable entity response a status code equal to that given +func (o *GetWebConfigUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get web config unprocessable entity response +func (o *GetWebConfigUnprocessableEntity) Code() int { + return 422 +} + +func (o *GetWebConfigUnprocessableEntity) Error() string { + return fmt.Sprintf("[GET /config][%d] getWebConfigUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *GetWebConfigUnprocessableEntity) String() string { + return fmt.Sprintf("[GET /config][%d] getWebConfigUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *GetWebConfigUnprocessableEntity) GetPayload() *models.APIErrorRenderExample { + return o.Payload +} + +func (o *GetWebConfigUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorRenderExample) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { diff --git a/pkg/client/tag/create_tags_parameters.go b/pkg/client/tag/create_tags_parameters.go new file mode 100644 index 0000000..10cd0fe --- /dev/null +++ b/pkg/client/tag/create_tags_parameters.go @@ -0,0 +1,153 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tag + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "net/http" + "time" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime" + cr "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + + "github.com/moira-alert/client-go/pkg/models" +) + +// NewCreateTagsParams creates a new CreateTagsParams object, +// with the default timeout for this client. +// +// Default values are not hydrated, since defaults are normally applied by the API server side. +// +// To enforce default values in parameter, use SetDefaults or WithDefaults. +func NewCreateTagsParams() *CreateTagsParams { + return &CreateTagsParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewCreateTagsParamsWithTimeout creates a new CreateTagsParams object +// with the ability to set a timeout on a request. +func NewCreateTagsParamsWithTimeout(timeout time.Duration) *CreateTagsParams { + return &CreateTagsParams{ + timeout: timeout, + } +} + +// NewCreateTagsParamsWithContext creates a new CreateTagsParams object +// with the ability to set a context for a request. +func NewCreateTagsParamsWithContext(ctx context.Context) *CreateTagsParams { + return &CreateTagsParams{ + Context: ctx, + } +} + +// NewCreateTagsParamsWithHTTPClient creates a new CreateTagsParams object +// with the ability to set a custom HTTPClient for a request. +func NewCreateTagsParamsWithHTTPClient(client *http.Client) *CreateTagsParams { + return &CreateTagsParams{ + HTTPClient: client, + } +} + +/* +CreateTagsParams contains all the parameters to send to the API endpoint + + for the create tags operation. + + Typically these are written to a http.Request. +*/ +type CreateTagsParams struct { + + /* Tags. + + Tags data + */ + Tags *models.DtoTagsData + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the create tags params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateTagsParams) WithDefaults() *CreateTagsParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the create tags params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *CreateTagsParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the create tags params +func (o *CreateTagsParams) WithTimeout(timeout time.Duration) *CreateTagsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create tags params +func (o *CreateTagsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create tags params +func (o *CreateTagsParams) WithContext(ctx context.Context) *CreateTagsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create tags params +func (o *CreateTagsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create tags params +func (o *CreateTagsParams) WithHTTPClient(client *http.Client) *CreateTagsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create tags params +func (o *CreateTagsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithTags adds the tags to the create tags params +func (o *CreateTagsParams) WithTags(tags *models.DtoTagsData) *CreateTagsParams { + o.SetTags(tags) + return o +} + +// SetTags adds the tags to the create tags params +func (o *CreateTagsParams) SetTags(tags *models.DtoTagsData) { + o.Tags = tags +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateTagsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + if o.Tags != nil { + if err := r.SetBodyParam(o.Tags); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/client/tag/create_tags_responses.go b/pkg/client/tag/create_tags_responses.go new file mode 100644 index 0000000..fddcade --- /dev/null +++ b/pkg/client/tag/create_tags_responses.go @@ -0,0 +1,313 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package tag + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/moira-alert/client-go/pkg/models" +) + +// CreateTagsReader is a Reader for the CreateTags structure. +type CreateTagsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateTagsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewCreateTagsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 400: + result := NewCreateTagsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 422: + result := NewCreateTagsUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewCreateTagsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[POST /tag] create-tags", response, response.Code()) + } +} + +// NewCreateTagsOK creates a CreateTagsOK with default headers values +func NewCreateTagsOK() *CreateTagsOK { + return &CreateTagsOK{} +} + +/* +CreateTagsOK describes a response with status code 200, with default header values. + +Create tags successfully +*/ +type CreateTagsOK struct { +} + +// IsSuccess returns true when this create tags o k response has a 2xx status code +func (o *CreateTagsOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this create tags o k response has a 3xx status code +func (o *CreateTagsOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create tags o k response has a 4xx status code +func (o *CreateTagsOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this create tags o k response has a 5xx status code +func (o *CreateTagsOK) IsServerError() bool { + return false +} + +// IsCode returns true when this create tags o k response a status code equal to that given +func (o *CreateTagsOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the create tags o k response +func (o *CreateTagsOK) Code() int { + return 200 +} + +func (o *CreateTagsOK) Error() string { + return fmt.Sprintf("[POST /tag][%d] createTagsOK ", 200) +} + +func (o *CreateTagsOK) String() string { + return fmt.Sprintf("[POST /tag][%d] createTagsOK ", 200) +} + +func (o *CreateTagsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewCreateTagsBadRequest creates a CreateTagsBadRequest with default headers values +func NewCreateTagsBadRequest() *CreateTagsBadRequest { + return &CreateTagsBadRequest{} +} + +/* +CreateTagsBadRequest describes a response with status code 400, with default header values. + +Bad request from client +*/ +type CreateTagsBadRequest struct { + Payload *models.APIErrorInvalidRequestExample +} + +// IsSuccess returns true when this create tags bad request response has a 2xx status code +func (o *CreateTagsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create tags bad request response has a 3xx status code +func (o *CreateTagsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create tags bad request response has a 4xx status code +func (o *CreateTagsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this create tags bad request response has a 5xx status code +func (o *CreateTagsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this create tags bad request response a status code equal to that given +func (o *CreateTagsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the create tags bad request response +func (o *CreateTagsBadRequest) Code() int { + return 400 +} + +func (o *CreateTagsBadRequest) Error() string { + return fmt.Sprintf("[POST /tag][%d] createTagsBadRequest %+v", 400, o.Payload) +} + +func (o *CreateTagsBadRequest) String() string { + return fmt.Sprintf("[POST /tag][%d] createTagsBadRequest %+v", 400, o.Payload) +} + +func (o *CreateTagsBadRequest) GetPayload() *models.APIErrorInvalidRequestExample { + return o.Payload +} + +func (o *CreateTagsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorInvalidRequestExample) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateTagsUnprocessableEntity creates a CreateTagsUnprocessableEntity with default headers values +func NewCreateTagsUnprocessableEntity() *CreateTagsUnprocessableEntity { + return &CreateTagsUnprocessableEntity{} +} + +/* +CreateTagsUnprocessableEntity describes a response with status code 422, with default header values. + +Render error +*/ +type CreateTagsUnprocessableEntity struct { + Payload *models.APIErrorRenderExample +} + +// IsSuccess returns true when this create tags unprocessable entity response has a 2xx status code +func (o *CreateTagsUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create tags unprocessable entity response has a 3xx status code +func (o *CreateTagsUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create tags unprocessable entity response has a 4xx status code +func (o *CreateTagsUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this create tags unprocessable entity response has a 5xx status code +func (o *CreateTagsUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this create tags unprocessable entity response a status code equal to that given +func (o *CreateTagsUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the create tags unprocessable entity response +func (o *CreateTagsUnprocessableEntity) Code() int { + return 422 +} + +func (o *CreateTagsUnprocessableEntity) Error() string { + return fmt.Sprintf("[POST /tag][%d] createTagsUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *CreateTagsUnprocessableEntity) String() string { + return fmt.Sprintf("[POST /tag][%d] createTagsUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *CreateTagsUnprocessableEntity) GetPayload() *models.APIErrorRenderExample { + return o.Payload +} + +func (o *CreateTagsUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorRenderExample) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateTagsInternalServerError creates a CreateTagsInternalServerError with default headers values +func NewCreateTagsInternalServerError() *CreateTagsInternalServerError { + return &CreateTagsInternalServerError{} +} + +/* +CreateTagsInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type CreateTagsInternalServerError struct { + Payload *models.APIErrorInternalServerExample +} + +// IsSuccess returns true when this create tags internal server error response has a 2xx status code +func (o *CreateTagsInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this create tags internal server error response has a 3xx status code +func (o *CreateTagsInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this create tags internal server error response has a 4xx status code +func (o *CreateTagsInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this create tags internal server error response has a 5xx status code +func (o *CreateTagsInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this create tags internal server error response a status code equal to that given +func (o *CreateTagsInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the create tags internal server error response +func (o *CreateTagsInternalServerError) Code() int { + return 500 +} + +func (o *CreateTagsInternalServerError) Error() string { + return fmt.Sprintf("[POST /tag][%d] createTagsInternalServerError %+v", 500, o.Payload) +} + +func (o *CreateTagsInternalServerError) String() string { + return fmt.Sprintf("[POST /tag][%d] createTagsInternalServerError %+v", 500, o.Payload) +} + +func (o *CreateTagsInternalServerError) GetPayload() *models.APIErrorInternalServerExample { + return o.Payload +} + +func (o *CreateTagsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorInternalServerExample) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/client/tag/tag_client.go b/pkg/client/tag/tag_client.go index e1b042c..be195ed 100644 --- a/pkg/client/tag/tag_client.go +++ b/pkg/client/tag/tag_client.go @@ -30,6 +30,8 @@ type ClientOption func(*runtime.ClientOperation) // ClientService is the interface for Client methods type ClientService interface { + CreateTags(params *CreateTagsParams, opts ...ClientOption) (*CreateTagsOK, error) + GetAllTags(params *GetAllTagsParams, opts ...ClientOption) (*GetAllTagsOK, error) GetAllTagsAndSubscriptions(params *GetAllTagsAndSubscriptionsParams, opts ...ClientOption) (*GetAllTagsAndSubscriptionsOK, error) @@ -39,6 +41,44 @@ type ClientService interface { SetTransport(transport runtime.ClientTransport) } +/* +CreateTags creates new tags +*/ +func (a *Client) CreateTags(params *CreateTagsParams, opts ...ClientOption) (*CreateTagsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateTagsParams() + } + op := &runtime.ClientOperation{ + ID: "create-tags", + Method: "POST", + PathPattern: "/tag", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &CreateTagsReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + } + for _, opt := range opts { + opt(op) + } + + result, err := a.transport.Submit(op) + if err != nil { + return nil, err + } + success, ok := result.(*CreateTagsOK) + if ok { + return success, nil + } + // unexpected success response + // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue + msg := fmt.Sprintf("unexpected success response for create-tags: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* GetAllTags gets all tags */ diff --git a/pkg/models/api_feature_flags.go b/pkg/models/api_feature_flags.go new file mode 100644 index 0000000..53616b3 --- /dev/null +++ b/pkg/models/api_feature_flags.go @@ -0,0 +1,63 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIFeatureFlags api feature flags +// +// swagger:model api.FeatureFlags +type APIFeatureFlags struct { + + // is plotting available + // Example: true + IsPlottingAvailable bool `json:"isPlottingAvailable,omitempty"` + + // is plotting default on + // Example: false + IsPlottingDefaultOn bool `json:"isPlottingDefaultOn,omitempty"` + + // is readonly enabled + // Example: false + IsReadonlyEnabled bool `json:"isReadonlyEnabled,omitempty"` + + // is subscription to all tags available + // Example: false + IsSubscriptionToAllTagsAvailable bool `json:"isSubscriptionToAllTagsAvailable,omitempty"` +} + +// Validate validates this api feature flags +func (m *APIFeatureFlags) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api feature flags based on context it is used +func (m *APIFeatureFlags) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APIFeatureFlags) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIFeatureFlags) UnmarshalBinary(b []byte) error { + var res APIFeatureFlags + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/api_metric_source_cluster.go b/pkg/models/api_metric_source_cluster.go new file mode 100644 index 0000000..b6f3ce5 --- /dev/null +++ b/pkg/models/api_metric_source_cluster.go @@ -0,0 +1,59 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIMetricSourceCluster api metric source cluster +// +// swagger:model api.MetricSourceCluster +type APIMetricSourceCluster struct { + + // cluster id + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + + // cluster name + // Example: Graphite Remote Prod + ClusterName string `json:"cluster_name,omitempty"` + + // trigger source + // Example: graphite_remote + TriggerSource string `json:"trigger_source,omitempty"` +} + +// Validate validates this api metric source cluster +func (m *APIMetricSourceCluster) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api metric source cluster based on context it is used +func (m *APIMetricSourceCluster) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APIMetricSourceCluster) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIMetricSourceCluster) UnmarshalBinary(b []byte) error { + var res APIMetricSourceCluster + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/api_sentry.go b/pkg/models/api_sentry.go new file mode 100644 index 0000000..3eb107e --- /dev/null +++ b/pkg/models/api_sentry.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APISentry api sentry +// +// swagger:model api.Sentry +type APISentry struct { + + // dsn + // Example: https://secret@sentry.host + Dsn string `json:"dsn,omitempty"` + + // platform + // Example: dev + Platform string `json:"platform,omitempty"` +} + +// Validate validates this api sentry +func (m *APISentry) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api sentry based on context it is used +func (m *APISentry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APISentry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APISentry) UnmarshalBinary(b []byte) error { + var res APISentry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/api_web_config.go b/pkg/models/api_web_config.go new file mode 100644 index 0000000..b0ef9d3 --- /dev/null +++ b/pkg/models/api_web_config.go @@ -0,0 +1,293 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIWebConfig api web config +// +// swagger:model api.WebConfig +type APIWebConfig struct { + + // contacts + Contacts []*APIWebContact `json:"contacts"` + + // feature flags + FeatureFlags *APIFeatureFlags `json:"featureFlags,omitempty"` + + // metric source clusters + MetricSourceClusters []*APIMetricSourceCluster `json:"metric_source_clusters"` + + // remote allowed + // Example: true + RemoteAllowed bool `json:"remoteAllowed,omitempty"` + + // sentry + Sentry *APISentry `json:"sentry,omitempty"` + + // support email + // Example: opensource@skbkontur.com + SupportEmail string `json:"supportEmail,omitempty"` +} + +// Validate validates this api web config +func (m *APIWebConfig) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateContacts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFeatureFlags(formats); err != nil { + res = append(res, err) + } + + if err := m.validateMetricSourceClusters(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSentry(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIWebConfig) validateContacts(formats strfmt.Registry) error { + if swag.IsZero(m.Contacts) { // not required + return nil + } + + for i := 0; i < len(m.Contacts); i++ { + if swag.IsZero(m.Contacts[i]) { // not required + continue + } + + if m.Contacts[i] != nil { + if err := m.Contacts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("contacts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("contacts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIWebConfig) validateFeatureFlags(formats strfmt.Registry) error { + if swag.IsZero(m.FeatureFlags) { // not required + return nil + } + + if m.FeatureFlags != nil { + if err := m.FeatureFlags.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("featureFlags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("featureFlags") + } + return err + } + } + + return nil +} + +func (m *APIWebConfig) validateMetricSourceClusters(formats strfmt.Registry) error { + if swag.IsZero(m.MetricSourceClusters) { // not required + return nil + } + + for i := 0; i < len(m.MetricSourceClusters); i++ { + if swag.IsZero(m.MetricSourceClusters[i]) { // not required + continue + } + + if m.MetricSourceClusters[i] != nil { + if err := m.MetricSourceClusters[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metric_source_clusters" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("metric_source_clusters" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIWebConfig) validateSentry(formats strfmt.Registry) error { + if swag.IsZero(m.Sentry) { // not required + return nil + } + + if m.Sentry != nil { + if err := m.Sentry.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sentry") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sentry") + } + return err + } + } + + return nil +} + +// ContextValidate validate this api web config based on the context it is used +func (m *APIWebConfig) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateContacts(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateFeatureFlags(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateMetricSourceClusters(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateSentry(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *APIWebConfig) contextValidateContacts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Contacts); i++ { + + if m.Contacts[i] != nil { + + if swag.IsZero(m.Contacts[i]) { // not required + return nil + } + + if err := m.Contacts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("contacts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("contacts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIWebConfig) contextValidateFeatureFlags(ctx context.Context, formats strfmt.Registry) error { + + if m.FeatureFlags != nil { + + if swag.IsZero(m.FeatureFlags) { // not required + return nil + } + + if err := m.FeatureFlags.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("featureFlags") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("featureFlags") + } + return err + } + } + + return nil +} + +func (m *APIWebConfig) contextValidateMetricSourceClusters(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.MetricSourceClusters); i++ { + + if m.MetricSourceClusters[i] != nil { + + if swag.IsZero(m.MetricSourceClusters[i]) { // not required + return nil + } + + if err := m.MetricSourceClusters[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("metric_source_clusters" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("metric_source_clusters" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *APIWebConfig) contextValidateSentry(ctx context.Context, formats strfmt.Registry) error { + + if m.Sentry != nil { + + if swag.IsZero(m.Sentry) { // not required + return nil + } + + if err := m.Sentry.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sentry") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sentry") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *APIWebConfig) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIWebConfig) UnmarshalBinary(b []byte) error { + var res APIWebConfig + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/api_web_contact.go b/pkg/models/api_web_contact.go new file mode 100644 index 0000000..1d57ea1 --- /dev/null +++ b/pkg/models/api_web_contact.go @@ -0,0 +1,67 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// APIWebContact api web contact +// +// swagger:model api.WebContact +type APIWebContact struct { + + // help + // Example: ### Domains whitelist:\n - moira.ru\n + Help string `json:"help,omitempty"` + + // label + // Example: Webhook + Label string `json:"label,omitempty"` + + // placeholder + // Example: https://moira.ru/webhooks + Placeholder string `json:"placeholder,omitempty"` + + // type + // Example: webhook + Type string `json:"type,omitempty"` + + // validation + // Example: ^(http|https):\\/\\/.*(moira.ru)(:[0-9]{2,5})?\\/ + Validation string `json:"validation,omitempty"` +} + +// Validate validates this api web contact +func (m *APIWebContact) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this api web contact based on context it is used +func (m *APIWebContact) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *APIWebContact) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *APIWebContact) UnmarshalBinary(b []byte) error { + var res APIWebContact + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/dto_trigger.go b/pkg/models/dto_trigger.go index af87cad..318aa6f 100644 --- a/pkg/models/dto_trigger.go +++ b/pkg/models/dto_trigger.go @@ -22,6 +22,10 @@ type DtoTrigger struct { // Example: {"t1":true} AloneMetrics map[string]bool `json:"alone_metrics,omitempty"` + // Shows the exact cluster from where the metrics are fetched + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + // Datetime when the trigger was created CreatedAt *string `json:"created_at,omitempty"` @@ -78,7 +82,7 @@ type DtoTrigger struct { // Example: 0 Throttling int64 `json:"throttling,omitempty"` - // Shows the source from where the metrics are fetched + // Shows the type of source from where the metrics are fetched // Example: graphite_local TriggerSource string `json:"trigger_source,omitempty"` diff --git a/pkg/models/dto_trigger_check.go b/pkg/models/dto_trigger_check.go index 24a0372..f7e77c1 100644 --- a/pkg/models/dto_trigger_check.go +++ b/pkg/models/dto_trigger_check.go @@ -23,7 +23,7 @@ type DtoTriggerCheck struct { // Example: 1590741878 EventTimestamp int64 `json:"event_timestamp,omitempty"` - // last successful check timestamp + // LastSuccessfulCheckTimestamp - time of the last check of the trigger, during which there were no errors // Example: 1590741916 LastSuccessfulCheckTimestamp int64 `json:"last_successful_check_timestamp,omitempty"` @@ -61,7 +61,7 @@ type DtoTriggerCheck struct { // suppressed state SuppressedState string `json:"suppressed_state,omitempty"` - // timestamp + // Timestamp - time, which means when the checker last checked this trigger, this value stops updating if the trigger does not receive metrics // Example: 1590741916 Timestamp int64 `json:"timestamp,omitempty"` diff --git a/pkg/models/dto_trigger_model.go b/pkg/models/dto_trigger_model.go index ede2de2..64e8873 100644 --- a/pkg/models/dto_trigger_model.go +++ b/pkg/models/dto_trigger_model.go @@ -22,6 +22,10 @@ type DtoTriggerModel struct { // Example: {"t1":true} AloneMetrics map[string]bool `json:"alone_metrics,omitempty"` + // Shows the exact cluster from where the metrics are fetched + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + // Datetime when the trigger was created CreatedAt *string `json:"created_at,omitempty"` @@ -74,7 +78,7 @@ type DtoTriggerModel struct { // Example: ["devOps.my_server.hdd.freespace_mbytes"] Targets []string `json:"targets"` - // Shows the source from where the metrics are fetched + // Shows the type of source from where the metrics are fetched // Example: graphite_local TriggerSource string `json:"trigger_source,omitempty"` diff --git a/pkg/models/moira_check_data.go b/pkg/models/moira_check_data.go index 1d0327b..ebdc717 100644 --- a/pkg/models/moira_check_data.go +++ b/pkg/models/moira_check_data.go @@ -23,7 +23,7 @@ type MoiraCheckData struct { // Example: 1590741878 EventTimestamp int64 `json:"event_timestamp,omitempty"` - // last successful check timestamp + // LastSuccessfulCheckTimestamp - time of the last check of the trigger, during which there were no errors // Example: 1590741916 LastSuccessfulCheckTimestamp int64 `json:"last_successful_check_timestamp,omitempty"` @@ -61,7 +61,7 @@ type MoiraCheckData struct { // suppressed state SuppressedState string `json:"suppressed_state,omitempty"` - // timestamp + // Timestamp - time, which means when the checker last checked this trigger, this value stops updating if the trigger does not receive metrics // Example: 1590741916 Timestamp int64 `json:"timestamp,omitempty"` } diff --git a/pkg/models/moira_scheduled_notification.go b/pkg/models/moira_scheduled_notification.go index 992580b..d48a3cc 100644 --- a/pkg/models/moira_scheduled_notification.go +++ b/pkg/models/moira_scheduled_notification.go @@ -21,6 +21,10 @@ type MoiraScheduledNotification struct { // contact Contact *MoiraContactData `json:"contact,omitempty"` + // created at + // Example: 1594471900 + CreatedAt int64 `json:"created_at,omitempty"` + // event Event *MoiraNotificationEvent `json:"event,omitempty"` diff --git a/pkg/models/moira_trigger.go b/pkg/models/moira_trigger.go index 5cbdc7b..06797fe 100644 --- a/pkg/models/moira_trigger.go +++ b/pkg/models/moira_trigger.go @@ -22,6 +22,10 @@ type MoiraTrigger struct { // Example: {"t1":true} AloneMetrics map[string]bool `json:"alone_metrics,omitempty"` + // cluster id + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + // created at CreatedAt *int64 `json:"created_at,omitempty"` diff --git a/pkg/models/moira_trigger_check.go b/pkg/models/moira_trigger_check.go index ccffc06..b8e8c79 100644 --- a/pkg/models/moira_trigger_check.go +++ b/pkg/models/moira_trigger_check.go @@ -22,6 +22,10 @@ type MoiraTriggerCheck struct { // Example: {"t1":true} AloneMetrics map[string]bool `json:"alone_metrics,omitempty"` + // cluster id + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + // created at CreatedAt *int64 `json:"created_at,omitempty"` diff --git a/pkg/models/moira_trigger_data.go b/pkg/models/moira_trigger_data.go index 33c56d2..cd9e630 100644 --- a/pkg/models/moira_trigger_data.go +++ b/pkg/models/moira_trigger_data.go @@ -21,6 +21,10 @@ type MoiraTriggerData struct { // Example: ["server","disk"] NotifierTriggerTags []string `json:"__notifier_trigger_tags"` + // cluster id + // Example: default + ClusterID string `json:"cluster_id,omitempty"` + // desc // Example: check the size of /var/log Desc string `json:"desc,omitempty"`