From d95dfc11ea77a8c7689d3c6eea20043867db6dab Mon Sep 17 00:00:00 2001 From: Aleksandr Matsko <90016901+AleksandrMatsko@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:50:34 +0700 Subject: [PATCH] feat: generate client from actual spec (#10) --- .gitignore | 1 + .../delete_all_notifications_responses.go | 14 +- .../delete_notification_responses.go | 101 ++++++- .../notification/notification_client.go | 42 ++- .../team/get_all_teams_for_user_parameters.go | 128 +++++++++ .../team/get_all_teams_for_user_responses.go | 258 ++++++++++++++++++ pkg/client/team/get_all_teams_parameters.go | 166 ++++++++++- pkg/client/team/get_all_teams_responses.go | 172 +++++++++++- pkg/client/team/team_client.go | 44 ++- pkg/client/trigger/trigger_check_responses.go | 76 ++++++ pkg/models/api_feature_flags.go | 4 + pkg/models/dto_teams_list.go | 133 +++++++++ pkg/models/handler_configuration_response.go | 125 --------- pkg/models/handler_contact_example.go | 67 ----- pkg/models/moira_schedule_data_day.go | 70 +++++ 15 files changed, 1180 insertions(+), 221 deletions(-) create mode 100644 pkg/client/team/get_all_teams_for_user_parameters.go create mode 100644 pkg/client/team/get_all_teams_for_user_responses.go create mode 100644 pkg/models/dto_teams_list.go delete mode 100644 pkg/models/handler_configuration_response.go delete mode 100644 pkg/models/handler_contact_example.go diff --git a/.gitignore b/.gitignore index 722d5e7..aafda3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +.idea diff --git a/pkg/client/notification/delete_all_notifications_responses.go b/pkg/client/notification/delete_all_notifications_responses.go index 9d98229..2039136 100644 --- a/pkg/client/notification/delete_all_notifications_responses.go +++ b/pkg/client/notification/delete_all_notifications_responses.go @@ -43,7 +43,7 @@ func (o *DeleteAllNotificationsReader) ReadResponse(response runtime.ClientRespo } return nil, result default: - return nil, runtime.NewAPIError("[DELETE /notification] delete-all-notifications", response, response.Code()) + return nil, runtime.NewAPIError("[DELETE /notification/all] delete-all-notifications", response, response.Code()) } } @@ -93,12 +93,12 @@ func (o *DeleteAllNotificationsOK) Code() int { func (o *DeleteAllNotificationsOK) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsOK %s", 200, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsOK %s", 200, payload) } func (o *DeleteAllNotificationsOK) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsOK %s", 200, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsOK %s", 200, payload) } func (o *DeleteAllNotificationsOK) GetPayload() *models.DtoNotificationsList { @@ -163,12 +163,12 @@ func (o *DeleteAllNotificationsForbidden) Code() int { func (o *DeleteAllNotificationsForbidden) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsForbidden %s", 403, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsForbidden %s", 403, payload) } func (o *DeleteAllNotificationsForbidden) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsForbidden %s", 403, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsForbidden %s", 403, payload) } func (o *DeleteAllNotificationsForbidden) GetPayload() *models.APIErrorForbiddenExample { @@ -233,12 +233,12 @@ func (o *DeleteAllNotificationsInternalServerError) Code() int { func (o *DeleteAllNotificationsInternalServerError) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsInternalServerError %s", 500, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsInternalServerError %s", 500, payload) } func (o *DeleteAllNotificationsInternalServerError) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[DELETE /notification][%d] deleteAllNotificationsInternalServerError %s", 500, payload) + return fmt.Sprintf("[DELETE /notification/all][%d] deleteAllNotificationsInternalServerError %s", 500, payload) } func (o *DeleteAllNotificationsInternalServerError) GetPayload() *models.APIErrorInternalServerExample { diff --git a/pkg/client/notification/delete_notification_responses.go b/pkg/client/notification/delete_notification_responses.go index f997e98..47d2f71 100644 --- a/pkg/client/notification/delete_notification_responses.go +++ b/pkg/client/notification/delete_notification_responses.go @@ -6,6 +6,7 @@ package notification // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" "fmt" "io" @@ -35,6 +36,12 @@ func (o *DeleteNotificationReader) ReadResponse(response runtime.ClientResponse, return nil, err } return nil, result + case 403: + result := NewDeleteNotificationForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 422: result := NewDeleteNotificationUnprocessableEntity() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -97,11 +104,13 @@ func (o *DeleteNotificationOK) Code() int { } func (o *DeleteNotificationOK) Error() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationOK %s", 200, payload) } func (o *DeleteNotificationOK) String() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationOK %+v", 200, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationOK %s", 200, payload) } func (o *DeleteNotificationOK) GetPayload() *models.DtoNotificationDeleteResponse { @@ -165,11 +174,13 @@ func (o *DeleteNotificationBadRequest) Code() int { } func (o *DeleteNotificationBadRequest) Error() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationBadRequest %s", 400, payload) } func (o *DeleteNotificationBadRequest) String() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationBadRequest %+v", 400, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationBadRequest %s", 400, payload) } func (o *DeleteNotificationBadRequest) GetPayload() *models.APIErrorInvalidRequestExample { @@ -188,6 +199,76 @@ func (o *DeleteNotificationBadRequest) readResponse(response runtime.ClientRespo return nil } +// NewDeleteNotificationForbidden creates a DeleteNotificationForbidden with default headers values +func NewDeleteNotificationForbidden() *DeleteNotificationForbidden { + return &DeleteNotificationForbidden{} +} + +/* +DeleteNotificationForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type DeleteNotificationForbidden struct { + Payload *models.APIErrorForbiddenExample +} + +// IsSuccess returns true when this delete notification forbidden response has a 2xx status code +func (o *DeleteNotificationForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this delete notification forbidden response has a 3xx status code +func (o *DeleteNotificationForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this delete notification forbidden response has a 4xx status code +func (o *DeleteNotificationForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this delete notification forbidden response has a 5xx status code +func (o *DeleteNotificationForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this delete notification forbidden response a status code equal to that given +func (o *DeleteNotificationForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the delete notification forbidden response +func (o *DeleteNotificationForbidden) Code() int { + return 403 +} + +func (o *DeleteNotificationForbidden) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationForbidden %s", 403, payload) +} + +func (o *DeleteNotificationForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationForbidden %s", 403, payload) +} + +func (o *DeleteNotificationForbidden) GetPayload() *models.APIErrorForbiddenExample { + return o.Payload +} + +func (o *DeleteNotificationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorForbiddenExample) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewDeleteNotificationUnprocessableEntity creates a DeleteNotificationUnprocessableEntity with default headers values func NewDeleteNotificationUnprocessableEntity() *DeleteNotificationUnprocessableEntity { return &DeleteNotificationUnprocessableEntity{} @@ -233,11 +314,13 @@ func (o *DeleteNotificationUnprocessableEntity) Code() int { } func (o *DeleteNotificationUnprocessableEntity) Error() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationUnprocessableEntity %s", 422, payload) } func (o *DeleteNotificationUnprocessableEntity) String() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationUnprocessableEntity %+v", 422, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationUnprocessableEntity %s", 422, payload) } func (o *DeleteNotificationUnprocessableEntity) GetPayload() *models.APIErrorRenderExample { @@ -301,11 +384,13 @@ func (o *DeleteNotificationInternalServerError) Code() int { } func (o *DeleteNotificationInternalServerError) Error() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationInternalServerError %+v", 500, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationInternalServerError %s", 500, payload) } func (o *DeleteNotificationInternalServerError) String() string { - return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationInternalServerError %+v", 500, o.Payload) + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[DELETE /notification][%d] deleteNotificationInternalServerError %s", 500, payload) } func (o *DeleteNotificationInternalServerError) GetPayload() *models.APIErrorInternalServerExample { diff --git a/pkg/client/notification/notification_client.go b/pkg/client/notification/notification_client.go index 2ba4c1a..6e89f51 100644 --- a/pkg/client/notification/notification_client.go +++ b/pkg/client/notification/notification_client.go @@ -58,6 +58,8 @@ type ClientOption func(*runtime.ClientOperation) type ClientService interface { DeleteAllNotifications(params *DeleteAllNotificationsParams, opts ...ClientOption) (*DeleteAllNotificationsOK, error) + DeleteNotification(params *DeleteNotificationParams, opts ...ClientOption) (*DeleteNotificationOK, error) + GetNotifications(params *GetNotificationsParams, opts ...ClientOption) (*GetNotificationsOK, error) SetTransport(transport runtime.ClientTransport) @@ -74,7 +76,7 @@ func (a *Client) DeleteAllNotifications(params *DeleteAllNotificationsParams, op op := &runtime.ClientOperation{ ID: "delete-all-notifications", Method: "DELETE", - PathPattern: "/notification", + PathPattern: "/notification/all", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -101,6 +103,44 @@ func (a *Client) DeleteAllNotifications(params *DeleteAllNotificationsParams, op panic(msg) } +/* +DeleteNotification deletes a notification by id +*/ +func (a *Client) DeleteNotification(params *DeleteNotificationParams, opts ...ClientOption) (*DeleteNotificationOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteNotificationParams() + } + op := &runtime.ClientOperation{ + ID: "delete-notification", + Method: "DELETE", + PathPattern: "/notification", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &DeleteNotificationReader{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.(*DeleteNotificationOK) + 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 delete-notification: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* GetNotifications gets a paginated list of notifications all notifications are fetched if end 1 and start 0 */ diff --git a/pkg/client/team/get_all_teams_for_user_parameters.go b/pkg/client/team/get_all_teams_for_user_parameters.go new file mode 100644 index 0000000..12aaa28 --- /dev/null +++ b/pkg/client/team/get_all_teams_for_user_parameters.go @@ -0,0 +1,128 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package team + +// 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" +) + +// NewGetAllTeamsForUserParams creates a new GetAllTeamsForUserParams 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 NewGetAllTeamsForUserParams() *GetAllTeamsForUserParams { + return &GetAllTeamsForUserParams{ + timeout: cr.DefaultTimeout, + } +} + +// NewGetAllTeamsForUserParamsWithTimeout creates a new GetAllTeamsForUserParams object +// with the ability to set a timeout on a request. +func NewGetAllTeamsForUserParamsWithTimeout(timeout time.Duration) *GetAllTeamsForUserParams { + return &GetAllTeamsForUserParams{ + timeout: timeout, + } +} + +// NewGetAllTeamsForUserParamsWithContext creates a new GetAllTeamsForUserParams object +// with the ability to set a context for a request. +func NewGetAllTeamsForUserParamsWithContext(ctx context.Context) *GetAllTeamsForUserParams { + return &GetAllTeamsForUserParams{ + Context: ctx, + } +} + +// NewGetAllTeamsForUserParamsWithHTTPClient creates a new GetAllTeamsForUserParams object +// with the ability to set a custom HTTPClient for a request. +func NewGetAllTeamsForUserParamsWithHTTPClient(client *http.Client) *GetAllTeamsForUserParams { + return &GetAllTeamsForUserParams{ + HTTPClient: client, + } +} + +/* +GetAllTeamsForUserParams contains all the parameters to send to the API endpoint + + for the get all teams for user operation. + + Typically these are written to a http.Request. +*/ +type GetAllTeamsForUserParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithDefaults hydrates default values in the get all teams for user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAllTeamsForUserParams) WithDefaults() *GetAllTeamsForUserParams { + o.SetDefaults() + return o +} + +// SetDefaults hydrates default values in the get all teams for user params (not the query body). +// +// All values with no default are reset to their zero value. +func (o *GetAllTeamsForUserParams) SetDefaults() { + // no default values defined for this parameter +} + +// WithTimeout adds the timeout to the get all teams for user params +func (o *GetAllTeamsForUserParams) WithTimeout(timeout time.Duration) *GetAllTeamsForUserParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get all teams for user params +func (o *GetAllTeamsForUserParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get all teams for user params +func (o *GetAllTeamsForUserParams) WithContext(ctx context.Context) *GetAllTeamsForUserParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get all teams for user params +func (o *GetAllTeamsForUserParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get all teams for user params +func (o *GetAllTeamsForUserParams) WithHTTPClient(client *http.Client) *GetAllTeamsForUserParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get all teams for user params +func (o *GetAllTeamsForUserParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetAllTeamsForUserParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/pkg/client/team/get_all_teams_for_user_responses.go b/pkg/client/team/get_all_teams_for_user_responses.go new file mode 100644 index 0000000..20a359d --- /dev/null +++ b/pkg/client/team/get_all_teams_for_user_responses.go @@ -0,0 +1,258 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package team + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/go-openapi/runtime" + "github.com/go-openapi/strfmt" + + "github.com/moira-alert/client-go/pkg/models" +) + +// GetAllTeamsForUserReader is a Reader for the GetAllTeamsForUser structure. +type GetAllTeamsForUserReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetAllTeamsForUserReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewGetAllTeamsForUserOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 422: + result := NewGetAllTeamsForUserUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 500: + result := NewGetAllTeamsForUserInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + return nil, runtime.NewAPIError("[GET /teams] get-all-teams-for-user", response, response.Code()) + } +} + +// NewGetAllTeamsForUserOK creates a GetAllTeamsForUserOK with default headers values +func NewGetAllTeamsForUserOK() *GetAllTeamsForUserOK { + return &GetAllTeamsForUserOK{} +} + +/* +GetAllTeamsForUserOK describes a response with status code 200, with default header values. + +Teams fetched successfully +*/ +type GetAllTeamsForUserOK struct { + Payload *models.DtoUserTeams +} + +// IsSuccess returns true when this get all teams for user o k response has a 2xx status code +func (o *GetAllTeamsForUserOK) IsSuccess() bool { + return true +} + +// IsRedirect returns true when this get all teams for user o k response has a 3xx status code +func (o *GetAllTeamsForUserOK) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get all teams for user o k response has a 4xx status code +func (o *GetAllTeamsForUserOK) IsClientError() bool { + return false +} + +// IsServerError returns true when this get all teams for user o k response has a 5xx status code +func (o *GetAllTeamsForUserOK) IsServerError() bool { + return false +} + +// IsCode returns true when this get all teams for user o k response a status code equal to that given +func (o *GetAllTeamsForUserOK) IsCode(code int) bool { + return code == 200 +} + +// Code gets the status code for the get all teams for user o k response +func (o *GetAllTeamsForUserOK) Code() int { + return 200 +} + +func (o *GetAllTeamsForUserOK) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserOK %s", 200, payload) +} + +func (o *GetAllTeamsForUserOK) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserOK %s", 200, payload) +} + +func (o *GetAllTeamsForUserOK) GetPayload() *models.DtoUserTeams { + return o.Payload +} + +func (o *GetAllTeamsForUserOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.DtoUserTeams) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetAllTeamsForUserUnprocessableEntity creates a GetAllTeamsForUserUnprocessableEntity with default headers values +func NewGetAllTeamsForUserUnprocessableEntity() *GetAllTeamsForUserUnprocessableEntity { + return &GetAllTeamsForUserUnprocessableEntity{} +} + +/* +GetAllTeamsForUserUnprocessableEntity describes a response with status code 422, with default header values. + +Render error +*/ +type GetAllTeamsForUserUnprocessableEntity struct { + Payload *models.APIErrorRenderExample +} + +// IsSuccess returns true when this get all teams for user unprocessable entity response has a 2xx status code +func (o *GetAllTeamsForUserUnprocessableEntity) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get all teams for user unprocessable entity response has a 3xx status code +func (o *GetAllTeamsForUserUnprocessableEntity) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get all teams for user unprocessable entity response has a 4xx status code +func (o *GetAllTeamsForUserUnprocessableEntity) IsClientError() bool { + return true +} + +// IsServerError returns true when this get all teams for user unprocessable entity response has a 5xx status code +func (o *GetAllTeamsForUserUnprocessableEntity) IsServerError() bool { + return false +} + +// IsCode returns true when this get all teams for user unprocessable entity response a status code equal to that given +func (o *GetAllTeamsForUserUnprocessableEntity) IsCode(code int) bool { + return code == 422 +} + +// Code gets the status code for the get all teams for user unprocessable entity response +func (o *GetAllTeamsForUserUnprocessableEntity) Code() int { + return 422 +} + +func (o *GetAllTeamsForUserUnprocessableEntity) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserUnprocessableEntity %s", 422, payload) +} + +func (o *GetAllTeamsForUserUnprocessableEntity) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserUnprocessableEntity %s", 422, payload) +} + +func (o *GetAllTeamsForUserUnprocessableEntity) GetPayload() *models.APIErrorRenderExample { + return o.Payload +} + +func (o *GetAllTeamsForUserUnprocessableEntity) 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 +} + +// NewGetAllTeamsForUserInternalServerError creates a GetAllTeamsForUserInternalServerError with default headers values +func NewGetAllTeamsForUserInternalServerError() *GetAllTeamsForUserInternalServerError { + return &GetAllTeamsForUserInternalServerError{} +} + +/* +GetAllTeamsForUserInternalServerError describes a response with status code 500, with default header values. + +Internal server error +*/ +type GetAllTeamsForUserInternalServerError struct { + Payload *models.APIErrorInternalServerExample +} + +// IsSuccess returns true when this get all teams for user internal server error response has a 2xx status code +func (o *GetAllTeamsForUserInternalServerError) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get all teams for user internal server error response has a 3xx status code +func (o *GetAllTeamsForUserInternalServerError) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get all teams for user internal server error response has a 4xx status code +func (o *GetAllTeamsForUserInternalServerError) IsClientError() bool { + return false +} + +// IsServerError returns true when this get all teams for user internal server error response has a 5xx status code +func (o *GetAllTeamsForUserInternalServerError) IsServerError() bool { + return true +} + +// IsCode returns true when this get all teams for user internal server error response a status code equal to that given +func (o *GetAllTeamsForUserInternalServerError) IsCode(code int) bool { + return code == 500 +} + +// Code gets the status code for the get all teams for user internal server error response +func (o *GetAllTeamsForUserInternalServerError) Code() int { + return 500 +} + +func (o *GetAllTeamsForUserInternalServerError) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserInternalServerError %s", 500, payload) +} + +func (o *GetAllTeamsForUserInternalServerError) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams][%d] getAllTeamsForUserInternalServerError %s", 500, payload) +} + +func (o *GetAllTeamsForUserInternalServerError) GetPayload() *models.APIErrorInternalServerExample { + return o.Payload +} + +func (o *GetAllTeamsForUserInternalServerError) 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/team/get_all_teams_parameters.go b/pkg/client/team/get_all_teams_parameters.go index 0ddab25..ad753f8 100644 --- a/pkg/client/team/get_all_teams_parameters.go +++ b/pkg/client/team/get_all_teams_parameters.go @@ -14,6 +14,7 @@ import ( "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" ) // NewGetAllTeamsParams creates a new GetAllTeamsParams object, @@ -60,6 +61,37 @@ GetAllTeamsParams contains all the parameters to send to the API endpoint Typically these are written to a http.Request. */ type GetAllTeamsParams struct { + + /* P. + + Defines the number of the displayed page. E.g, p=2 would display the 2nd page + */ + P *int64 + + /* SearchText. + + Regular expression which will be applied to team id or team name than filtering teams + + Default: ".*" + */ + SearchText *string + + /* Size. + + Number of items to be displayed on one page. if size = -1 then all teams returned + + Default: -1 + */ + Size *int64 + + /* Sort. + + String to set sort order (by name). On empty - no order, asc - ascending, desc - descending + + Default: "asc" + */ + Sort *string + timeout time.Duration Context context.Context HTTPClient *http.Client @@ -77,7 +109,27 @@ func (o *GetAllTeamsParams) WithDefaults() *GetAllTeamsParams { // // All values with no default are reset to their zero value. func (o *GetAllTeamsParams) SetDefaults() { - // no default values defined for this parameter + var ( + pDefault = int64(0) + + searchTextDefault = string(".*") + + sizeDefault = int64(-1) + + sortDefault = string("asc") + ) + + val := GetAllTeamsParams{ + P: &pDefault, + SearchText: &searchTextDefault, + Size: &sizeDefault, + Sort: &sortDefault, + } + + val.timeout = o.timeout + val.Context = o.Context + val.HTTPClient = o.HTTPClient + *o = val } // WithTimeout adds the timeout to the get all teams params @@ -113,6 +165,50 @@ func (o *GetAllTeamsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithP adds the p to the get all teams params +func (o *GetAllTeamsParams) WithP(p *int64) *GetAllTeamsParams { + o.SetP(p) + return o +} + +// SetP adds the p to the get all teams params +func (o *GetAllTeamsParams) SetP(p *int64) { + o.P = p +} + +// WithSearchText adds the searchText to the get all teams params +func (o *GetAllTeamsParams) WithSearchText(searchText *string) *GetAllTeamsParams { + o.SetSearchText(searchText) + return o +} + +// SetSearchText adds the searchText to the get all teams params +func (o *GetAllTeamsParams) SetSearchText(searchText *string) { + o.SearchText = searchText +} + +// WithSize adds the size to the get all teams params +func (o *GetAllTeamsParams) WithSize(size *int64) *GetAllTeamsParams { + o.SetSize(size) + return o +} + +// SetSize adds the size to the get all teams params +func (o *GetAllTeamsParams) SetSize(size *int64) { + o.Size = size +} + +// WithSort adds the sort to the get all teams params +func (o *GetAllTeamsParams) WithSort(sort *string) *GetAllTeamsParams { + o.SetSort(sort) + return o +} + +// SetSort adds the sort to the get all teams params +func (o *GetAllTeamsParams) SetSort(sort *string) { + o.Sort = sort +} + // WriteToRequest writes these params to a swagger request func (o *GetAllTeamsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -121,6 +217,74 @@ func (o *GetAllTeamsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.R } var res []error + if o.P != nil { + + // query param p + var qrP int64 + + if o.P != nil { + qrP = *o.P + } + qP := swag.FormatInt64(qrP) + if qP != "" { + + if err := r.SetQueryParam("p", qP); err != nil { + return err + } + } + } + + if o.SearchText != nil { + + // query param searchText + var qrSearchText string + + if o.SearchText != nil { + qrSearchText = *o.SearchText + } + qSearchText := qrSearchText + if qSearchText != "" { + + if err := r.SetQueryParam("searchText", qSearchText); err != nil { + return err + } + } + } + + if o.Size != nil { + + // query param size + var qrSize int64 + + if o.Size != nil { + qrSize = *o.Size + } + qSize := swag.FormatInt64(qrSize) + if qSize != "" { + + if err := r.SetQueryParam("size", qSize); err != nil { + return err + } + } + } + + if o.Sort != nil { + + // query param sort + var qrSort string + + if o.Sort != nil { + qrSort = *o.Sort + } + qSort := qrSort + if qSort != "" { + + if err := r.SetQueryParam("sort", qSort); err != nil { + return err + } + } + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/pkg/client/team/get_all_teams_responses.go b/pkg/client/team/get_all_teams_responses.go index ab4cdf1..744510d 100644 --- a/pkg/client/team/get_all_teams_responses.go +++ b/pkg/client/team/get_all_teams_responses.go @@ -30,6 +30,18 @@ func (o *GetAllTeamsReader) ReadResponse(response runtime.ClientResponse, consum return nil, err } return result, nil + case 400: + result := NewGetAllTeamsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 403: + result := NewGetAllTeamsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result case 422: result := NewGetAllTeamsUnprocessableEntity() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -43,7 +55,7 @@ func (o *GetAllTeamsReader) ReadResponse(response runtime.ClientResponse, consum } return nil, result default: - return nil, runtime.NewAPIError("[GET /teams] get-all-teams", response, response.Code()) + return nil, runtime.NewAPIError("[GET /teams/all] get-all-teams", response, response.Code()) } } @@ -58,7 +70,7 @@ GetAllTeamsOK describes a response with status code 200, with default header val Teams fetched successfully */ type GetAllTeamsOK struct { - Payload *models.DtoUserTeams + Payload *models.DtoTeamsList } // IsSuccess returns true when this get all teams o k response has a 2xx status code @@ -93,21 +105,161 @@ func (o *GetAllTeamsOK) Code() int { func (o *GetAllTeamsOK) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsOK %s", 200, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsOK %s", 200, payload) } func (o *GetAllTeamsOK) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsOK %s", 200, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsOK %s", 200, payload) } -func (o *GetAllTeamsOK) GetPayload() *models.DtoUserTeams { +func (o *GetAllTeamsOK) GetPayload() *models.DtoTeamsList { return o.Payload } func (o *GetAllTeamsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - o.Payload = new(models.DtoUserTeams) + o.Payload = new(models.DtoTeamsList) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetAllTeamsBadRequest creates a GetAllTeamsBadRequest with default headers values +func NewGetAllTeamsBadRequest() *GetAllTeamsBadRequest { + return &GetAllTeamsBadRequest{} +} + +/* +GetAllTeamsBadRequest describes a response with status code 400, with default header values. + +Bad request from client +*/ +type GetAllTeamsBadRequest struct { + Payload *models.APIErrorInvalidRequestExample +} + +// IsSuccess returns true when this get all teams bad request response has a 2xx status code +func (o *GetAllTeamsBadRequest) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get all teams bad request response has a 3xx status code +func (o *GetAllTeamsBadRequest) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get all teams bad request response has a 4xx status code +func (o *GetAllTeamsBadRequest) IsClientError() bool { + return true +} + +// IsServerError returns true when this get all teams bad request response has a 5xx status code +func (o *GetAllTeamsBadRequest) IsServerError() bool { + return false +} + +// IsCode returns true when this get all teams bad request response a status code equal to that given +func (o *GetAllTeamsBadRequest) IsCode(code int) bool { + return code == 400 +} + +// Code gets the status code for the get all teams bad request response +func (o *GetAllTeamsBadRequest) Code() int { + return 400 +} + +func (o *GetAllTeamsBadRequest) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsBadRequest %s", 400, payload) +} + +func (o *GetAllTeamsBadRequest) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsBadRequest %s", 400, payload) +} + +func (o *GetAllTeamsBadRequest) GetPayload() *models.APIErrorInvalidRequestExample { + return o.Payload +} + +func (o *GetAllTeamsBadRequest) 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 +} + +// NewGetAllTeamsForbidden creates a GetAllTeamsForbidden with default headers values +func NewGetAllTeamsForbidden() *GetAllTeamsForbidden { + return &GetAllTeamsForbidden{} +} + +/* +GetAllTeamsForbidden describes a response with status code 403, with default header values. + +Forbidden +*/ +type GetAllTeamsForbidden struct { + Payload *models.APIErrorForbiddenExample +} + +// IsSuccess returns true when this get all teams forbidden response has a 2xx status code +func (o *GetAllTeamsForbidden) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this get all teams forbidden response has a 3xx status code +func (o *GetAllTeamsForbidden) IsRedirect() bool { + return false +} + +// IsClientError returns true when this get all teams forbidden response has a 4xx status code +func (o *GetAllTeamsForbidden) IsClientError() bool { + return true +} + +// IsServerError returns true when this get all teams forbidden response has a 5xx status code +func (o *GetAllTeamsForbidden) IsServerError() bool { + return false +} + +// IsCode returns true when this get all teams forbidden response a status code equal to that given +func (o *GetAllTeamsForbidden) IsCode(code int) bool { + return code == 403 +} + +// Code gets the status code for the get all teams forbidden response +func (o *GetAllTeamsForbidden) Code() int { + return 403 +} + +func (o *GetAllTeamsForbidden) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsForbidden %s", 403, payload) +} + +func (o *GetAllTeamsForbidden) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsForbidden %s", 403, payload) +} + +func (o *GetAllTeamsForbidden) GetPayload() *models.APIErrorForbiddenExample { + return o.Payload +} + +func (o *GetAllTeamsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorForbiddenExample) // response payload if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { @@ -163,12 +315,12 @@ func (o *GetAllTeamsUnprocessableEntity) Code() int { func (o *GetAllTeamsUnprocessableEntity) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsUnprocessableEntity %s", 422, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsUnprocessableEntity %s", 422, payload) } func (o *GetAllTeamsUnprocessableEntity) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsUnprocessableEntity %s", 422, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsUnprocessableEntity %s", 422, payload) } func (o *GetAllTeamsUnprocessableEntity) GetPayload() *models.APIErrorRenderExample { @@ -233,12 +385,12 @@ func (o *GetAllTeamsInternalServerError) Code() int { func (o *GetAllTeamsInternalServerError) Error() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsInternalServerError %s", 500, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsInternalServerError %s", 500, payload) } func (o *GetAllTeamsInternalServerError) String() string { payload, _ := json.Marshal(o.Payload) - return fmt.Sprintf("[GET /teams][%d] getAllTeamsInternalServerError %s", 500, payload) + return fmt.Sprintf("[GET /teams/all][%d] getAllTeamsInternalServerError %s", 500, payload) } func (o *GetAllTeamsInternalServerError) GetPayload() *models.APIErrorInternalServerExample { diff --git a/pkg/client/team/team_client.go b/pkg/client/team/team_client.go index c62dbfb..a09512a 100644 --- a/pkg/client/team/team_client.go +++ b/pkg/client/team/team_client.go @@ -66,6 +66,8 @@ type ClientService interface { GetAllTeams(params *GetAllTeamsParams, opts ...ClientOption) (*GetAllTeamsOK, error) + GetAllTeamsForUser(params *GetAllTeamsForUserParams, opts ...ClientOption) (*GetAllTeamsForUserOK, error) + GetTeam(params *GetTeamParams, opts ...ClientOption) (*GetTeamOK, error) GetTeamSettings(params *GetTeamSettingsParams, opts ...ClientOption) (*GetTeamSettingsOK, error) @@ -232,7 +234,7 @@ func (a *Client) DeleteTeamUser(params *DeleteTeamUserParams, opts ...ClientOpti } /* -GetAllTeams gets all teams +GetAllTeams gets all moira teams */ func (a *Client) GetAllTeams(params *GetAllTeamsParams, opts ...ClientOption) (*GetAllTeamsOK, error) { // TODO: Validate the params before sending @@ -242,7 +244,7 @@ func (a *Client) GetAllTeams(params *GetAllTeamsParams, opts ...ClientOption) (* op := &runtime.ClientOperation{ ID: "get-all-teams", Method: "GET", - PathPattern: "/teams", + PathPattern: "/teams/all", ProducesMediaTypes: []string{"application/json"}, ConsumesMediaTypes: []string{"application/json"}, Schemes: []string{"http"}, @@ -269,6 +271,44 @@ func (a *Client) GetAllTeams(params *GetAllTeamsParams, opts ...ClientOption) (* panic(msg) } +/* +GetAllTeamsForUser gets all teams for user +*/ +func (a *Client) GetAllTeamsForUser(params *GetAllTeamsForUserParams, opts ...ClientOption) (*GetAllTeamsForUserOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetAllTeamsForUserParams() + } + op := &runtime.ClientOperation{ + ID: "get-all-teams-for-user", + Method: "GET", + PathPattern: "/teams", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"http"}, + Params: params, + Reader: &GetAllTeamsForUserReader{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.(*GetAllTeamsForUserOK) + 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 get-all-teams-for-user: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* GetTeam gets a team by ID */ diff --git a/pkg/client/trigger/trigger_check_responses.go b/pkg/client/trigger/trigger_check_responses.go index a00e78e..d9d9c76 100644 --- a/pkg/client/trigger/trigger_check_responses.go +++ b/pkg/client/trigger/trigger_check_responses.go @@ -42,6 +42,12 @@ func (o *TriggerCheckReader) ReadResponse(response runtime.ClientResponse, consu return nil, err } return nil, result + case 503: + result := NewTriggerCheckServiceUnavailable() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("[PUT /trigger/check] trigger-check", response, response.Code()) } @@ -256,3 +262,73 @@ func (o *TriggerCheckInternalServerError) readResponse(response runtime.ClientRe return nil } + +// NewTriggerCheckServiceUnavailable creates a TriggerCheckServiceUnavailable with default headers values +func NewTriggerCheckServiceUnavailable() *TriggerCheckServiceUnavailable { + return &TriggerCheckServiceUnavailable{} +} + +/* +TriggerCheckServiceUnavailable describes a response with status code 503, with default header values. + +Remote server unavailable +*/ +type TriggerCheckServiceUnavailable struct { + Payload *models.APIErrorRemoteServerUnavailableExample +} + +// IsSuccess returns true when this trigger check service unavailable response has a 2xx status code +func (o *TriggerCheckServiceUnavailable) IsSuccess() bool { + return false +} + +// IsRedirect returns true when this trigger check service unavailable response has a 3xx status code +func (o *TriggerCheckServiceUnavailable) IsRedirect() bool { + return false +} + +// IsClientError returns true when this trigger check service unavailable response has a 4xx status code +func (o *TriggerCheckServiceUnavailable) IsClientError() bool { + return false +} + +// IsServerError returns true when this trigger check service unavailable response has a 5xx status code +func (o *TriggerCheckServiceUnavailable) IsServerError() bool { + return true +} + +// IsCode returns true when this trigger check service unavailable response a status code equal to that given +func (o *TriggerCheckServiceUnavailable) IsCode(code int) bool { + return code == 503 +} + +// Code gets the status code for the trigger check service unavailable response +func (o *TriggerCheckServiceUnavailable) Code() int { + return 503 +} + +func (o *TriggerCheckServiceUnavailable) Error() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /trigger/check][%d] triggerCheckServiceUnavailable %s", 503, payload) +} + +func (o *TriggerCheckServiceUnavailable) String() string { + payload, _ := json.Marshal(o.Payload) + return fmt.Sprintf("[PUT /trigger/check][%d] triggerCheckServiceUnavailable %s", 503, payload) +} + +func (o *TriggerCheckServiceUnavailable) GetPayload() *models.APIErrorRemoteServerUnavailableExample { + return o.Payload +} + +func (o *TriggerCheckServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.APIErrorRemoteServerUnavailableExample) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/pkg/models/api_feature_flags.go b/pkg/models/api_feature_flags.go index 53616b3..31fa477 100644 --- a/pkg/models/api_feature_flags.go +++ b/pkg/models/api_feature_flags.go @@ -17,6 +17,10 @@ import ( // swagger:model api.FeatureFlags type APIFeatureFlags struct { + // celebration mode + // Example: new_year + CelebrationMode string `json:"celebrationMode,omitempty"` + // is plotting available // Example: true IsPlottingAvailable bool `json:"isPlottingAvailable,omitempty"` diff --git a/pkg/models/dto_teams_list.go b/pkg/models/dto_teams_list.go new file mode 100644 index 0000000..1a1f274 --- /dev/null +++ b/pkg/models/dto_teams_list.go @@ -0,0 +1,133 @@ +// 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" +) + +// DtoTeamsList dto teams list +// +// swagger:model dto.TeamsList +type DtoTeamsList struct { + + // list + List []*DtoTeamModel `json:"list"` + + // page + // Example: 0 + Page int64 `json:"page,omitempty"` + + // size + // Example: 100 + Size int64 `json:"size,omitempty"` + + // total + // Example: 10 + Total int64 `json:"total,omitempty"` +} + +// Validate validates this dto teams list +func (m *DtoTeamsList) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateList(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DtoTeamsList) validateList(formats strfmt.Registry) error { + if swag.IsZero(m.List) { // not required + return nil + } + + for i := 0; i < len(m.List); i++ { + if swag.IsZero(m.List[i]) { // not required + continue + } + + if m.List[i] != nil { + if err := m.List[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("list" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("list" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this dto teams list based on the context it is used +func (m *DtoTeamsList) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateList(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *DtoTeamsList) contextValidateList(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.List); i++ { + + if m.List[i] != nil { + + if swag.IsZero(m.List[i]) { // not required + return nil + } + + if err := m.List[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("list" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("list" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *DtoTeamsList) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *DtoTeamsList) UnmarshalBinary(b []byte) error { + var res DtoTeamsList + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/pkg/models/handler_configuration_response.go b/pkg/models/handler_configuration_response.go deleted file mode 100644 index d44f462..0000000 --- a/pkg/models/handler_configuration_response.go +++ /dev/null @@ -1,125 +0,0 @@ -// 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" -) - -// HandlerConfigurationResponse handler configuration response -// -// swagger:model handler.ConfigurationResponse -type HandlerConfigurationResponse struct { - - // contacts - Contacts []*HandlerContactExample `json:"contacts"` - - // remote allowed - // Example: false - RemoteAllowed bool `json:"remoteAllowed,omitempty"` -} - -// Validate validates this handler configuration response -func (m *HandlerConfigurationResponse) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateContacts(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *HandlerConfigurationResponse) 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 -} - -// ContextValidate validate this handler configuration response based on the context it is used -func (m *HandlerConfigurationResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateContacts(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *HandlerConfigurationResponse) 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 -} - -// MarshalBinary interface implementation -func (m *HandlerConfigurationResponse) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *HandlerConfigurationResponse) UnmarshalBinary(b []byte) error { - var res HandlerConfigurationResponse - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/handler_contact_example.go b/pkg/models/handler_contact_example.go deleted file mode 100644 index bee1f2b..0000000 --- a/pkg/models/handler_contact_example.go +++ /dev/null @@ -1,67 +0,0 @@ -// 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" -) - -// HandlerContactExample handler contact example -// -// swagger:model handler.ContactExample -type HandlerContactExample struct { - - // help - // Example: ### Domains whitelist:\n - skbkontur.ru\n - testkontur.ru\n - kontur.host - Help string `json:"help,omitempty"` - - // label - // Example: Webhook Kontur - Label string `json:"label,omitempty"` - - // placeholder - // Example: https://service.testkontur.ru/webhooks/moira - Placeholder string `json:"placeholder,omitempty"` - - // type - // Example: webhook kontur - Type string `json:"type,omitempty"` - - // validation - // Example: ^(http|https):\\/\\/.*(testkontur.ru|kontur.host|skbkontur.ru)(:[0-9]{2,5})?\\/ - Validation string `json:"validation,omitempty"` -} - -// Validate validates this handler contact example -func (m *HandlerContactExample) Validate(formats strfmt.Registry) error { - return nil -} - -// ContextValidate validates this handler contact example based on context it is used -func (m *HandlerContactExample) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *HandlerContactExample) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *HandlerContactExample) UnmarshalBinary(b []byte) error { - var res HandlerContactExample - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/models/moira_schedule_data_day.go b/pkg/models/moira_schedule_data_day.go index 8afb411..316a14e 100644 --- a/pkg/models/moira_schedule_data_day.go +++ b/pkg/models/moira_schedule_data_day.go @@ -7,9 +7,12 @@ package models import ( "context" + "encoding/json" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // MoiraScheduleDataDay moira schedule data day @@ -23,11 +26,78 @@ type MoiraScheduleDataDay struct { // name // Example: Mon + // Enum: ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"] Name string `json:"name,omitempty"` } // Validate validates this moira schedule data day func (m *MoiraScheduleDataDay) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateName(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var moiraScheduleDataDayTypeNamePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + moiraScheduleDataDayTypeNamePropEnum = append(moiraScheduleDataDayTypeNamePropEnum, v) + } +} + +const ( + + // MoiraScheduleDataDayNameMon captures enum value "Mon" + MoiraScheduleDataDayNameMon string = "Mon" + + // MoiraScheduleDataDayNameTue captures enum value "Tue" + MoiraScheduleDataDayNameTue string = "Tue" + + // MoiraScheduleDataDayNameWed captures enum value "Wed" + MoiraScheduleDataDayNameWed string = "Wed" + + // MoiraScheduleDataDayNameThu captures enum value "Thu" + MoiraScheduleDataDayNameThu string = "Thu" + + // MoiraScheduleDataDayNameFri captures enum value "Fri" + MoiraScheduleDataDayNameFri string = "Fri" + + // MoiraScheduleDataDayNameSat captures enum value "Sat" + MoiraScheduleDataDayNameSat string = "Sat" + + // MoiraScheduleDataDayNameSun captures enum value "Sun" + MoiraScheduleDataDayNameSun string = "Sun" +) + +// prop value enum +func (m *MoiraScheduleDataDay) validateNameEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, moiraScheduleDataDayTypeNamePropEnum, true); err != nil { + return err + } + return nil +} + +func (m *MoiraScheduleDataDay) validateName(formats strfmt.Registry) error { + if swag.IsZero(m.Name) { // not required + return nil + } + + // value enum + if err := m.validateNameEnum("name", "body", m.Name); err != nil { + return err + } + return nil }