diff --git a/go/plumbing/operations/disable_site_parameters.go b/go/plumbing/operations/disable_site_parameters.go new file mode 100644 index 00000000..387e7ad2 --- /dev/null +++ b/go/plumbing/operations/disable_site_parameters.go @@ -0,0 +1,158 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// NewDisableSiteParams creates a new DisableSiteParams object +// with the default values initialized. +func NewDisableSiteParams() *DisableSiteParams { + var () + return &DisableSiteParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewDisableSiteParamsWithTimeout creates a new DisableSiteParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewDisableSiteParamsWithTimeout(timeout time.Duration) *DisableSiteParams { + var () + return &DisableSiteParams{ + + timeout: timeout, + } +} + +// NewDisableSiteParamsWithContext creates a new DisableSiteParams object +// with the default values initialized, and the ability to set a context for a request +func NewDisableSiteParamsWithContext(ctx context.Context) *DisableSiteParams { + var () + return &DisableSiteParams{ + + Context: ctx, + } +} + +// NewDisableSiteParamsWithHTTPClient creates a new DisableSiteParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewDisableSiteParamsWithHTTPClient(client *http.Client) *DisableSiteParams { + var () + return &DisableSiteParams{ + HTTPClient: client, + } +} + +/* +DisableSiteParams contains all the parameters to send to the API endpoint +for the disable site operation typically these are written to a http.Request +*/ +type DisableSiteParams struct { + + /*Reason + Reason for disabling the site + + */ + Reason string + /*SiteID*/ + SiteID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the disable site params +func (o *DisableSiteParams) WithTimeout(timeout time.Duration) *DisableSiteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the disable site params +func (o *DisableSiteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the disable site params +func (o *DisableSiteParams) WithContext(ctx context.Context) *DisableSiteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the disable site params +func (o *DisableSiteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the disable site params +func (o *DisableSiteParams) WithHTTPClient(client *http.Client) *DisableSiteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the disable site params +func (o *DisableSiteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithReason adds the reason to the disable site params +func (o *DisableSiteParams) WithReason(reason string) *DisableSiteParams { + o.SetReason(reason) + return o +} + +// SetReason adds the reason to the disable site params +func (o *DisableSiteParams) SetReason(reason string) { + o.Reason = reason +} + +// WithSiteID adds the siteID to the disable site params +func (o *DisableSiteParams) WithSiteID(siteID string) *DisableSiteParams { + o.SetSiteID(siteID) + return o +} + +// SetSiteID adds the siteId to the disable site params +func (o *DisableSiteParams) SetSiteID(siteID string) { + o.SiteID = siteID +} + +// WriteToRequest writes these params to a swagger request +func (o *DisableSiteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param reason + qrReason := o.Reason + qReason := qrReason + if qReason != "" { + if err := r.SetQueryParam("reason", qReason); err != nil { + return err + } + } + + // path param site_id + if err := r.SetPathParam("site_id", o.SiteID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/go/plumbing/operations/disable_site_responses.go b/go/plumbing/operations/disable_site_responses.go new file mode 100644 index 00000000..d1f5385f --- /dev/null +++ b/go/plumbing/operations/disable_site_responses.go @@ -0,0 +1,107 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/netlify/open-api/v2/go/models" +) + +// DisableSiteReader is a Reader for the DisableSite structure. +type DisableSiteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DisableSiteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 204: + result := NewDisableSiteNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + default: + result := NewDisableSiteDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewDisableSiteNoContent creates a DisableSiteNoContent with default headers values +func NewDisableSiteNoContent() *DisableSiteNoContent { + return &DisableSiteNoContent{} +} + +/* +DisableSiteNoContent handles this case with default header values. + +No content +*/ +type DisableSiteNoContent struct { +} + +func (o *DisableSiteNoContent) Error() string { + return fmt.Sprintf("[PUT /sites/{site_id}/disable][%d] disableSiteNoContent ", 204) +} + +func (o *DisableSiteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewDisableSiteDefault creates a DisableSiteDefault with default headers values +func NewDisableSiteDefault(code int) *DisableSiteDefault { + return &DisableSiteDefault{ + _statusCode: code, + } +} + +/* +DisableSiteDefault handles this case with default header values. + +error +*/ +type DisableSiteDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the disable site default response +func (o *DisableSiteDefault) Code() int { + return o._statusCode +} + +func (o *DisableSiteDefault) Error() string { + return fmt.Sprintf("[PUT /sites/{site_id}/disable][%d] disableSite default %+v", o._statusCode, o.Payload) +} + +func (o *DisableSiteDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *DisableSiteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/plumbing/operations/enable_site_parameters.go b/go/plumbing/operations/enable_site_parameters.go new file mode 100644 index 00000000..ed78496a --- /dev/null +++ b/go/plumbing/operations/enable_site_parameters.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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" +) + +// NewEnableSiteParams creates a new EnableSiteParams object +// with the default values initialized. +func NewEnableSiteParams() *EnableSiteParams { + var () + return &EnableSiteParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewEnableSiteParamsWithTimeout creates a new EnableSiteParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewEnableSiteParamsWithTimeout(timeout time.Duration) *EnableSiteParams { + var () + return &EnableSiteParams{ + + timeout: timeout, + } +} + +// NewEnableSiteParamsWithContext creates a new EnableSiteParams object +// with the default values initialized, and the ability to set a context for a request +func NewEnableSiteParamsWithContext(ctx context.Context) *EnableSiteParams { + var () + return &EnableSiteParams{ + + Context: ctx, + } +} + +// NewEnableSiteParamsWithHTTPClient creates a new EnableSiteParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewEnableSiteParamsWithHTTPClient(client *http.Client) *EnableSiteParams { + var () + return &EnableSiteParams{ + HTTPClient: client, + } +} + +/* +EnableSiteParams contains all the parameters to send to the API endpoint +for the enable site operation typically these are written to a http.Request +*/ +type EnableSiteParams struct { + + /*SiteID*/ + SiteID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the enable site params +func (o *EnableSiteParams) WithTimeout(timeout time.Duration) *EnableSiteParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the enable site params +func (o *EnableSiteParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the enable site params +func (o *EnableSiteParams) WithContext(ctx context.Context) *EnableSiteParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the enable site params +func (o *EnableSiteParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the enable site params +func (o *EnableSiteParams) WithHTTPClient(client *http.Client) *EnableSiteParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the enable site params +func (o *EnableSiteParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithSiteID adds the siteID to the enable site params +func (o *EnableSiteParams) WithSiteID(siteID string) *EnableSiteParams { + o.SetSiteID(siteID) + return o +} + +// SetSiteID adds the siteId to the enable site params +func (o *EnableSiteParams) SetSiteID(siteID string) { + o.SiteID = siteID +} + +// WriteToRequest writes these params to a swagger request +func (o *EnableSiteParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param site_id + if err := r.SetPathParam("site_id", o.SiteID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/go/plumbing/operations/enable_site_responses.go b/go/plumbing/operations/enable_site_responses.go new file mode 100644 index 00000000..df0d6215 --- /dev/null +++ b/go/plumbing/operations/enable_site_responses.go @@ -0,0 +1,147 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package operations + +// 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/netlify/open-api/v2/go/models" +) + +// EnableSiteReader is a Reader for the EnableSite structure. +type EnableSiteReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *EnableSiteReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 204: + result := NewEnableSiteNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 422: + result := NewEnableSiteUnprocessableEntity() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + default: + result := NewEnableSiteDefault(response.Code()) + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + if response.Code()/100 == 2 { + return result, nil + } + return nil, result + } +} + +// NewEnableSiteNoContent creates a EnableSiteNoContent with default headers values +func NewEnableSiteNoContent() *EnableSiteNoContent { + return &EnableSiteNoContent{} +} + +/* +EnableSiteNoContent handles this case with default header values. + +No content +*/ +type EnableSiteNoContent struct { +} + +func (o *EnableSiteNoContent) Error() string { + return fmt.Sprintf("[PUT /sites/{site_id}/enable][%d] enableSiteNoContent ", 204) +} + +func (o *EnableSiteNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewEnableSiteUnprocessableEntity creates a EnableSiteUnprocessableEntity with default headers values +func NewEnableSiteUnprocessableEntity() *EnableSiteUnprocessableEntity { + return &EnableSiteUnprocessableEntity{} +} + +/* +EnableSiteUnprocessableEntity handles this case with default header values. + +Cannot enable this site +*/ +type EnableSiteUnprocessableEntity struct { + Payload *models.Error +} + +func (o *EnableSiteUnprocessableEntity) Error() string { + return fmt.Sprintf("[PUT /sites/{site_id}/enable][%d] enableSiteUnprocessableEntity %+v", 422, o.Payload) +} + +func (o *EnableSiteUnprocessableEntity) GetPayload() *models.Error { + return o.Payload +} + +func (o *EnableSiteUnprocessableEntity) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewEnableSiteDefault creates a EnableSiteDefault with default headers values +func NewEnableSiteDefault(code int) *EnableSiteDefault { + return &EnableSiteDefault{ + _statusCode: code, + } +} + +/* +EnableSiteDefault handles this case with default header values. + +error +*/ +type EnableSiteDefault struct { + _statusCode int + + Payload *models.Error +} + +// Code gets the status code for the enable site default response +func (o *EnableSiteDefault) Code() int { + return o._statusCode +} + +func (o *EnableSiteDefault) Error() string { + return fmt.Sprintf("[PUT /sites/{site_id}/enable][%d] enableSite default %+v", o._statusCode, o.Payload) +} + +func (o *EnableSiteDefault) GetPayload() *models.Error { + return o.Payload +} + +func (o *EnableSiteDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Error) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/go/plumbing/operations/operations_client.go b/go/plumbing/operations/operations_client.go index e3ca6199..240bdd15 100644 --- a/go/plumbing/operations/operations_client.go +++ b/go/plumbing/operations/operations_client.go @@ -123,10 +123,14 @@ type ClientService interface { DeleteSubmission(params *DeleteSubmissionParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteSubmissionNoContent, error) + DisableSite(params *DisableSiteParams, authInfo runtime.ClientAuthInfoWriter) (*DisableSiteNoContent, error) + DisableSplitTest(params *DisableSplitTestParams, authInfo runtime.ClientAuthInfoWriter) (*DisableSplitTestNoContent, error) EnableHook(params *EnableHookParams, authInfo runtime.ClientAuthInfoWriter) (*EnableHookOK, error) + EnableSite(params *EnableSiteParams, authInfo runtime.ClientAuthInfoWriter) (*EnableSiteNoContent, error) + EnableSplitTest(params *EnableSplitTestParams, authInfo runtime.ClientAuthInfoWriter) (*EnableSplitTestNoContent, error) ExchangeTicket(params *ExchangeTicketParams, authInfo runtime.ClientAuthInfoWriter) (*ExchangeTicketCreated, error) @@ -1971,6 +1975,40 @@ func (a *Client) DeleteSubmission(params *DeleteSubmissionParams, authInfo runti return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +DisableSite Disables a site, preventing it from serving content. The site can be re-enabled later using the enable endpoint. +*/ +func (a *Client) DisableSite(params *DisableSiteParams, authInfo runtime.ClientAuthInfoWriter) (*DisableSiteNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDisableSiteParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "disableSite", + Method: "PUT", + PathPattern: "/sites/{site_id}/disable", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DisableSiteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*DisableSiteNoContent) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*DisableSiteDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* DisableSplitTest disable split test API */ @@ -2039,6 +2077,40 @@ func (a *Client) EnableHook(params *EnableHookParams, authInfo runtime.ClientAut return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) } +/* +EnableSite Re-enables a site that was previously disabled by the user. Sites that were disabled for usage exceeded or marked as spam cannot be re-enabled via this endpoint. +*/ +func (a *Client) EnableSite(params *EnableSiteParams, authInfo runtime.ClientAuthInfoWriter) (*EnableSiteNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewEnableSiteParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "enableSite", + Method: "PUT", + PathPattern: "/sites/{site_id}/enable", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &EnableSiteReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*EnableSiteNoContent) + if ok { + return success, nil + } + // unexpected success response + unexpectedSuccess := result.(*EnableSiteDefault) + return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code()) +} + /* EnableSplitTest enable split test API */ diff --git a/swagger.yml b/swagger.yml index 3e75167f..82e66667 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1336,6 +1336,51 @@ paths: $ref: '#/definitions/site' '404': description: Site not found + /sites/{site_id}/enable: + parameters: + - name: site_id + type: string + in: path + required: true + put: + operationId: enableSite + tags: [site] + description: >- + Re-enables a site that was previously disabled by the user. + Sites that were disabled for usage exceeded or marked as spam + cannot be re-enabled via this endpoint. + responses: + '204': + description: No content + '422': + description: Cannot enable this site + schema: + $ref: '#/definitions/error' + default: + $ref: '#/responses/error' + /sites/{site_id}/disable: + parameters: + - name: site_id + type: string + in: path + required: true + put: + operationId: disableSite + tags: [site] + description: >- + Disables a site, preventing it from serving content. + The site can be re-enabled later using the enable endpoint. + parameters: + - name: reason + type: string + in: query + required: true + description: Reason for disabling the site + responses: + '204': + description: No content + default: + $ref: '#/responses/error' /builds/{build_id}: parameters: - name: build_id