From 8ff49603748206bdea4ab8f548d7702557a141b2 Mon Sep 17 00:00:00 2001 From: Gerald Pape Date: Thu, 7 May 2020 12:06:32 +0200 Subject: [PATCH] Update generated client for cluster labelling changes (#56) * generate updated client for cluster labelling changes * (generated) labels is now nullable in cluster labels change request --- .../get_cluster_labels_parameters.go | 82 +++++++++++++++++ .../set_cluster_labels_parameters.go | 88 ++++++++++++++++++- client/clusters/add_cluster_responses.go | 36 ++++++++ client/clusters/add_cluster_v5_responses.go | 36 ++++++++ .../get_v5_clusters_by_label_parameters.go | 6 +- ...o => v5_list_clusters_by_label_request.go} | 18 ++-- models/v5_set_cluster_labels_request.go | 45 ++++++++++ 7 files changed, 296 insertions(+), 15 deletions(-) rename models/{v5_list_clusters_by_label.go => v5_list_clusters_by_label_request.go} (63%) create mode 100644 models/v5_set_cluster_labels_request.go diff --git a/client/cluster_labels/get_cluster_labels_parameters.go b/client/cluster_labels/get_cluster_labels_parameters.go index 2adb4b7..0fa748a 100644 --- a/client/cluster_labels/get_cluster_labels_parameters.go +++ b/client/cluster_labels/get_cluster_labels_parameters.go @@ -61,6 +61,28 @@ for the get cluster labels operation typically these are written to a http.Reque */ type GetClusterLabelsParams struct { + /*XGiantSwarmActivity + Name of an activity to track, like "list-clusters". This allows to + analyze several API requests sent in context and gives an idea on + the purpose. + + + */ + XGiantSwarmActivity *string + /*XGiantSwarmCmdLine + If activity has been issued by a CLI, this header can contain the + command line + + + */ + XGiantSwarmCmdLine *string + /*XRequestID + A randomly generated key that can be used to track a request throughout + services of Giant Swarm. + + + */ + XRequestID *string /*ClusterID Cluster ID @@ -105,6 +127,39 @@ func (o *GetClusterLabelsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXGiantSwarmActivity adds the xGiantSwarmActivity to the get cluster labels params +func (o *GetClusterLabelsParams) WithXGiantSwarmActivity(xGiantSwarmActivity *string) *GetClusterLabelsParams { + o.SetXGiantSwarmActivity(xGiantSwarmActivity) + return o +} + +// SetXGiantSwarmActivity adds the xGiantSwarmActivity to the get cluster labels params +func (o *GetClusterLabelsParams) SetXGiantSwarmActivity(xGiantSwarmActivity *string) { + o.XGiantSwarmActivity = xGiantSwarmActivity +} + +// WithXGiantSwarmCmdLine adds the xGiantSwarmCmdLine to the get cluster labels params +func (o *GetClusterLabelsParams) WithXGiantSwarmCmdLine(xGiantSwarmCmdLine *string) *GetClusterLabelsParams { + o.SetXGiantSwarmCmdLine(xGiantSwarmCmdLine) + return o +} + +// SetXGiantSwarmCmdLine adds the xGiantSwarmCmdLine to the get cluster labels params +func (o *GetClusterLabelsParams) SetXGiantSwarmCmdLine(xGiantSwarmCmdLine *string) { + o.XGiantSwarmCmdLine = xGiantSwarmCmdLine +} + +// WithXRequestID adds the xRequestID to the get cluster labels params +func (o *GetClusterLabelsParams) WithXRequestID(xRequestID *string) *GetClusterLabelsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the get cluster labels params +func (o *GetClusterLabelsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithClusterID adds the clusterID to the get cluster labels params func (o *GetClusterLabelsParams) WithClusterID(clusterID string) *GetClusterLabelsParams { o.SetClusterID(clusterID) @@ -124,6 +179,33 @@ func (o *GetClusterLabelsParams) WriteToRequest(r runtime.ClientRequest, reg str } var res []error + if o.XGiantSwarmActivity != nil { + + // header param X-Giant-Swarm-Activity + if err := r.SetHeaderParam("X-Giant-Swarm-Activity", *o.XGiantSwarmActivity); err != nil { + return err + } + + } + + if o.XGiantSwarmCmdLine != nil { + + // header param X-Giant-Swarm-CmdLine + if err := r.SetHeaderParam("X-Giant-Swarm-CmdLine", *o.XGiantSwarmCmdLine); err != nil { + return err + } + + } + + if o.XRequestID != nil { + + // header param X-Request-ID + if err := r.SetHeaderParam("X-Request-ID", *o.XRequestID); err != nil { + return err + } + + } + // path param cluster_id if err := r.SetPathParam("cluster_id", o.ClusterID); err != nil { return err diff --git a/client/cluster_labels/set_cluster_labels_parameters.go b/client/cluster_labels/set_cluster_labels_parameters.go index f2d61a1..618fb2e 100644 --- a/client/cluster_labels/set_cluster_labels_parameters.go +++ b/client/cluster_labels/set_cluster_labels_parameters.go @@ -63,11 +63,33 @@ for the set cluster labels operation typically these are written to a http.Reque */ type SetClusterLabelsParams struct { + /*XGiantSwarmActivity + Name of an activity to track, like "list-clusters". This allows to + analyze several API requests sent in context and gives an idea on + the purpose. + + + */ + XGiantSwarmActivity *string + /*XGiantSwarmCmdLine + If activity has been issued by a CLI, this header can contain the + command line + + + */ + XGiantSwarmCmdLine *string + /*XRequestID + A randomly generated key that can be used to track a request throughout + services of Giant Swarm. + + + */ + XRequestID *string /*Body Labels to attach to this cluster. */ - Body *models.V5ClusterLabelsResponse + Body *models.V5SetClusterLabelsRequest /*ClusterID Cluster ID @@ -112,14 +134,47 @@ func (o *SetClusterLabelsParams) SetHTTPClient(client *http.Client) { o.HTTPClient = client } +// WithXGiantSwarmActivity adds the xGiantSwarmActivity to the set cluster labels params +func (o *SetClusterLabelsParams) WithXGiantSwarmActivity(xGiantSwarmActivity *string) *SetClusterLabelsParams { + o.SetXGiantSwarmActivity(xGiantSwarmActivity) + return o +} + +// SetXGiantSwarmActivity adds the xGiantSwarmActivity to the set cluster labels params +func (o *SetClusterLabelsParams) SetXGiantSwarmActivity(xGiantSwarmActivity *string) { + o.XGiantSwarmActivity = xGiantSwarmActivity +} + +// WithXGiantSwarmCmdLine adds the xGiantSwarmCmdLine to the set cluster labels params +func (o *SetClusterLabelsParams) WithXGiantSwarmCmdLine(xGiantSwarmCmdLine *string) *SetClusterLabelsParams { + o.SetXGiantSwarmCmdLine(xGiantSwarmCmdLine) + return o +} + +// SetXGiantSwarmCmdLine adds the xGiantSwarmCmdLine to the set cluster labels params +func (o *SetClusterLabelsParams) SetXGiantSwarmCmdLine(xGiantSwarmCmdLine *string) { + o.XGiantSwarmCmdLine = xGiantSwarmCmdLine +} + +// WithXRequestID adds the xRequestID to the set cluster labels params +func (o *SetClusterLabelsParams) WithXRequestID(xRequestID *string) *SetClusterLabelsParams { + o.SetXRequestID(xRequestID) + return o +} + +// SetXRequestID adds the xRequestId to the set cluster labels params +func (o *SetClusterLabelsParams) SetXRequestID(xRequestID *string) { + o.XRequestID = xRequestID +} + // WithBody adds the body to the set cluster labels params -func (o *SetClusterLabelsParams) WithBody(body *models.V5ClusterLabelsResponse) *SetClusterLabelsParams { +func (o *SetClusterLabelsParams) WithBody(body *models.V5SetClusterLabelsRequest) *SetClusterLabelsParams { o.SetBody(body) return o } // SetBody adds the body to the set cluster labels params -func (o *SetClusterLabelsParams) SetBody(body *models.V5ClusterLabelsResponse) { +func (o *SetClusterLabelsParams) SetBody(body *models.V5SetClusterLabelsRequest) { o.Body = body } @@ -142,6 +197,33 @@ func (o *SetClusterLabelsParams) WriteToRequest(r runtime.ClientRequest, reg str } var res []error + if o.XGiantSwarmActivity != nil { + + // header param X-Giant-Swarm-Activity + if err := r.SetHeaderParam("X-Giant-Swarm-Activity", *o.XGiantSwarmActivity); err != nil { + return err + } + + } + + if o.XGiantSwarmCmdLine != nil { + + // header param X-Giant-Swarm-CmdLine + if err := r.SetHeaderParam("X-Giant-Swarm-CmdLine", *o.XGiantSwarmCmdLine); err != nil { + return err + } + + } + + if o.XRequestID != nil { + + // header param X-Request-ID + if err := r.SetHeaderParam("X-Request-ID", *o.XRequestID); err != nil { + return err + } + + } + if o.Body != nil { if err := r.SetBodyParam(o.Body); err != nil { return err diff --git a/client/clusters/add_cluster_responses.go b/client/clusters/add_cluster_responses.go index dd836d8..7166524 100644 --- a/client/clusters/add_cluster_responses.go +++ b/client/clusters/add_cluster_responses.go @@ -32,6 +32,13 @@ func (o *AddClusterReader) ReadResponse(response runtime.ClientResponse, consume } return result, nil + case 400: + result := NewAddClusterBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: result := NewAddClusterUnauthorized() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -87,6 +94,35 @@ func (o *AddClusterCreated) readResponse(response runtime.ClientResponse, consum return nil } +// NewAddClusterBadRequest creates a AddClusterBadRequest with default headers values +func NewAddClusterBadRequest() *AddClusterBadRequest { + return &AddClusterBadRequest{} +} + +/*AddClusterBadRequest handles this case with default header values. + +Invalid request +*/ +type AddClusterBadRequest struct { + Payload *models.V4GenericResponse +} + +func (o *AddClusterBadRequest) Error() string { + return fmt.Sprintf("[POST /v4/clusters/][%d] addClusterBadRequest %+v", 400, o.Payload) +} + +func (o *AddClusterBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.V4GenericResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewAddClusterUnauthorized creates a AddClusterUnauthorized with default headers values func NewAddClusterUnauthorized() *AddClusterUnauthorized { return &AddClusterUnauthorized{} diff --git a/client/clusters/add_cluster_v5_responses.go b/client/clusters/add_cluster_v5_responses.go index b9f4b33..8888e72 100644 --- a/client/clusters/add_cluster_v5_responses.go +++ b/client/clusters/add_cluster_v5_responses.go @@ -32,6 +32,13 @@ func (o *AddClusterV5Reader) ReadResponse(response runtime.ClientResponse, consu } return result, nil + case 400: + result := NewAddClusterV5BadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + case 401: result := NewAddClusterV5Unauthorized() if err := result.readResponse(response, consumer, o.formats); err != nil { @@ -80,6 +87,35 @@ func (o *AddClusterV5Created) readResponse(response runtime.ClientResponse, cons return nil } +// NewAddClusterV5BadRequest creates a AddClusterV5BadRequest with default headers values +func NewAddClusterV5BadRequest() *AddClusterV5BadRequest { + return &AddClusterV5BadRequest{} +} + +/*AddClusterV5BadRequest handles this case with default header values. + +Invalid request +*/ +type AddClusterV5BadRequest struct { + Payload *models.V4GenericResponse +} + +func (o *AddClusterV5BadRequest) Error() string { + return fmt.Sprintf("[POST /v5/clusters/][%d] addClusterV5BadRequest %+v", 400, o.Payload) +} + +func (o *AddClusterV5BadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.V4GenericResponse) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + // NewAddClusterV5Unauthorized creates a AddClusterV5Unauthorized with default headers values func NewAddClusterV5Unauthorized() *AddClusterV5Unauthorized { return &AddClusterV5Unauthorized{} diff --git a/client/clusters/get_v5_clusters_by_label_parameters.go b/client/clusters/get_v5_clusters_by_label_parameters.go index 296ec3d..fcf7191 100644 --- a/client/clusters/get_v5_clusters_by_label_parameters.go +++ b/client/clusters/get_v5_clusters_by_label_parameters.go @@ -89,7 +89,7 @@ type GetV5ClustersByLabelParams struct { Label selector */ - Body *models.V5ListClustersByLabel + Body *models.V5ListClustersByLabelRequest timeout time.Duration Context context.Context @@ -163,13 +163,13 @@ func (o *GetV5ClustersByLabelParams) SetXRequestID(xRequestID *string) { } // WithBody adds the body to the get v5 clusters by label params -func (o *GetV5ClustersByLabelParams) WithBody(body *models.V5ListClustersByLabel) *GetV5ClustersByLabelParams { +func (o *GetV5ClustersByLabelParams) WithBody(body *models.V5ListClustersByLabelRequest) *GetV5ClustersByLabelParams { o.SetBody(body) return o } // SetBody adds the body to the get v5 clusters by label params -func (o *GetV5ClustersByLabelParams) SetBody(body *models.V5ListClustersByLabel) { +func (o *GetV5ClustersByLabelParams) SetBody(body *models.V5ListClustersByLabelRequest) { o.Body = body } diff --git a/models/v5_list_clusters_by_label.go b/models/v5_list_clusters_by_label_request.go similarity index 63% rename from models/v5_list_clusters_by_label.go rename to models/v5_list_clusters_by_label_request.go index 26f0fdd..ce4e334 100644 --- a/models/v5_list_clusters_by_label.go +++ b/models/v5_list_clusters_by_label_request.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/validate" ) -// V5ListClustersByLabel v5 list clusters by label -// swagger:model v5ListClustersByLabel -type V5ListClustersByLabel struct { +// V5ListClustersByLabelRequest v5 list clusters by label request +// swagger:model v5ListClustersByLabelRequest +type V5ListClustersByLabelRequest struct { // Label selector // @@ -24,8 +24,8 @@ type V5ListClustersByLabel struct { Labels *string `json:"labels"` } -// Validate validates this v5 list clusters by label -func (m *V5ListClustersByLabel) Validate(formats strfmt.Registry) error { +// Validate validates this v5 list clusters by label request +func (m *V5ListClustersByLabelRequest) Validate(formats strfmt.Registry) error { var res []error if err := m.validateLabels(formats); err != nil { @@ -38,7 +38,7 @@ func (m *V5ListClustersByLabel) Validate(formats strfmt.Registry) error { return nil } -func (m *V5ListClustersByLabel) validateLabels(formats strfmt.Registry) error { +func (m *V5ListClustersByLabelRequest) validateLabels(formats strfmt.Registry) error { if err := validate.Required("labels", "body", m.Labels); err != nil { return err @@ -48,7 +48,7 @@ func (m *V5ListClustersByLabel) validateLabels(formats strfmt.Registry) error { } // MarshalBinary interface implementation -func (m *V5ListClustersByLabel) MarshalBinary() ([]byte, error) { +func (m *V5ListClustersByLabelRequest) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } @@ -56,8 +56,8 @@ func (m *V5ListClustersByLabel) MarshalBinary() ([]byte, error) { } // UnmarshalBinary interface implementation -func (m *V5ListClustersByLabel) UnmarshalBinary(b []byte) error { - var res V5ListClustersByLabel +func (m *V5ListClustersByLabelRequest) UnmarshalBinary(b []byte) error { + var res V5ListClustersByLabelRequest if err := swag.ReadJSON(b, &res); err != nil { return err } diff --git a/models/v5_set_cluster_labels_request.go b/models/v5_set_cluster_labels_request.go new file mode 100644 index 0000000..d098d17 --- /dev/null +++ b/models/v5_set_cluster_labels_request.go @@ -0,0 +1,45 @@ +// 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 ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// V5SetClusterLabelsRequest Cluster labels +// swagger:model v5SetClusterLabelsRequest +type V5SetClusterLabelsRequest struct { + + // Labels object + // + // Object containing keys with string values representing label changes + Labels map[string]*string `json:"labels,omitempty"` +} + +// Validate validates this v5 set cluster labels request +func (m *V5SetClusterLabelsRequest) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *V5SetClusterLabelsRequest) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *V5SetClusterLabelsRequest) UnmarshalBinary(b []byte) error { + var res V5SetClusterLabelsRequest + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}