From 5ba2d184657ad025341e13496010c0cf98c8e941 Mon Sep 17 00:00:00 2001 From: David Berlin Date: Wed, 22 Oct 2025 08:27:53 +0300 Subject: [PATCH 1/3] include task_id --- swagger.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/swagger.yml b/swagger.yml index c5ff2465..6a3d309b 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1312,6 +1312,10 @@ paths: type: string in: query required: false + - name: task_id + type: string + in: query + required: false post: operationId: notifyBuildStart tags: [build] @@ -2998,6 +3002,43 @@ paths: '200': description: OK # end sites/{site_id}/dev_servers/{dev_server_id}/activity + # begin sites/{site_id}/dev_servers/{dev_server_id}/state + /sites/{site_id}/dev_servers/{dev_server_id}/state: + parameters: + - name: site_id + type: string + in: path + required: true + - name: dev_server_id + type: string + in: path + required: true + post: + operationId: updateDevServerState + tags: [devServer] + parameters: + - name: body + in: body + required: true + schema: + type: object + required: + - state + properties: + state: + type: string + task_id: + type: string + error: + type: string + responses: + '200': + description: OK + schema: + $ref: '#/definitions/devServer' + '409': + description: Conflict + # end sites/{site_id}/dev_servers/{dev_server_id}/state /sites/{site_id}/dev_server_hooks: parameters: - name: site_id From 08f68a05049f70fe2386d04d1118c9a1e2483487 Mon Sep 17 00:00:00 2001 From: David Berlin Date: Wed, 22 Oct 2025 08:32:16 +0300 Subject: [PATCH 2/3] go generate --- .../update_dev_server_state_params_body.go | 70 +++++++ .../notify_build_start_parameters.go | 29 +++ go/plumbing/operations/operations_client.go | 37 ++++ .../update_dev_server_state_parameters.go | 172 ++++++++++++++++++ .../update_dev_server_state_responses.go | 98 ++++++++++ 5 files changed, 406 insertions(+) create mode 100644 go/models/update_dev_server_state_params_body.go create mode 100644 go/plumbing/operations/update_dev_server_state_parameters.go create mode 100644 go/plumbing/operations/update_dev_server_state_responses.go diff --git a/go/models/update_dev_server_state_params_body.go b/go/models/update_dev_server_state_params_body.go new file mode 100644 index 00000000..17600a85 --- /dev/null +++ b/go/models/update_dev_server_state_params_body.go @@ -0,0 +1,70 @@ +// 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 ( + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UpdateDevServerStateParamsBody update dev server state params body +// +// swagger:model updateDevServerStateParamsBody +type UpdateDevServerStateParamsBody struct { + + // error + Error string `json:"error,omitempty"` + + // state + // Required: true + State *string `json:"state"` + + // task id + TaskID string `json:"task_id,omitempty"` +} + +// Validate validates this update dev server state params body +func (m *UpdateDevServerStateParamsBody) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateState(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *UpdateDevServerStateParamsBody) validateState(formats strfmt.Registry) error { + + if err := validate.Required("state", "body", m.State); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateDevServerStateParamsBody) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateDevServerStateParamsBody) UnmarshalBinary(b []byte) error { + var res UpdateDevServerStateParamsBody + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/go/plumbing/operations/notify_build_start_parameters.go b/go/plumbing/operations/notify_build_start_parameters.go index c52ecc87..9160d84c 100644 --- a/go/plumbing/operations/notify_build_start_parameters.go +++ b/go/plumbing/operations/notify_build_start_parameters.go @@ -67,6 +67,8 @@ type NotifyBuildStartParams struct { BuildVersion *string /*BuildbotVersion*/ BuildbotVersion *string + /*TaskID*/ + TaskID *string timeout time.Duration Context context.Context @@ -139,6 +141,17 @@ func (o *NotifyBuildStartParams) SetBuildbotVersion(buildbotVersion *string) { o.BuildbotVersion = buildbotVersion } +// WithTaskID adds the taskID to the notify build start params +func (o *NotifyBuildStartParams) WithTaskID(taskID *string) *NotifyBuildStartParams { + o.SetTaskID(taskID) + return o +} + +// SetTaskID adds the taskId to the notify build start params +func (o *NotifyBuildStartParams) SetTaskID(taskID *string) { + o.TaskID = taskID +} + // WriteToRequest writes these params to a swagger request func (o *NotifyBuildStartParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -184,6 +197,22 @@ func (o *NotifyBuildStartParams) WriteToRequest(r runtime.ClientRequest, reg str } + if o.TaskID != nil { + + // query param task_id + var qrTaskID string + if o.TaskID != nil { + qrTaskID = *o.TaskID + } + qTaskID := qrTaskID + if qTaskID != "" { + if err := r.SetQueryParam("task_id", qTaskID); err != nil { + return err + } + } + + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } diff --git a/go/plumbing/operations/operations_client.go b/go/plumbing/operations/operations_client.go index 1e2808cd..a532b867 100644 --- a/go/plumbing/operations/operations_client.go +++ b/go/plumbing/operations/operations_client.go @@ -299,6 +299,8 @@ type ClientService interface { UpdateDeployValidations(params *UpdateDeployValidationsParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateDeployValidationsOK, error) + UpdateDevServerState(params *UpdateDevServerStateParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateDevServerStateOK, error) + UpdateEnvVar(params *UpdateEnvVarParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateEnvVarOK, error) UpdateHook(params *UpdateHookParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateHookOK, error) @@ -4967,6 +4969,41 @@ func (a *Client) UpdateDeployValidations(params *UpdateDeployValidationsParams, panic(msg) } +/* +UpdateDevServerState update dev server state API +*/ +func (a *Client) UpdateDevServerState(params *UpdateDevServerStateParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateDevServerStateOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateDevServerStateParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "updateDevServerState", + Method: "POST", + PathPattern: "/sites/{site_id}/dev_servers/{dev_server_id}/state", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &UpdateDevServerStateReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + success, ok := result.(*UpdateDevServerStateOK) + 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 updateDevServerState: API contract not enforced by server. Client expected to get an error, but got: %T", result) + panic(msg) +} + /* UpdateEnvVar Updates an existing environment variable and all of its values. Existing values will be replaced by values provided. */ diff --git a/go/plumbing/operations/update_dev_server_state_parameters.go b/go/plumbing/operations/update_dev_server_state_parameters.go new file mode 100644 index 00000000..378bf038 --- /dev/null +++ b/go/plumbing/operations/update_dev_server_state_parameters.go @@ -0,0 +1,172 @@ +// 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" + + "github.com/netlify/open-api/v2/go/models" +) + +// NewUpdateDevServerStateParams creates a new UpdateDevServerStateParams object +// with the default values initialized. +func NewUpdateDevServerStateParams() *UpdateDevServerStateParams { + var () + return &UpdateDevServerStateParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateDevServerStateParamsWithTimeout creates a new UpdateDevServerStateParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewUpdateDevServerStateParamsWithTimeout(timeout time.Duration) *UpdateDevServerStateParams { + var () + return &UpdateDevServerStateParams{ + + timeout: timeout, + } +} + +// NewUpdateDevServerStateParamsWithContext creates a new UpdateDevServerStateParams object +// with the default values initialized, and the ability to set a context for a request +func NewUpdateDevServerStateParamsWithContext(ctx context.Context) *UpdateDevServerStateParams { + var () + return &UpdateDevServerStateParams{ + + Context: ctx, + } +} + +// NewUpdateDevServerStateParamsWithHTTPClient creates a new UpdateDevServerStateParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewUpdateDevServerStateParamsWithHTTPClient(client *http.Client) *UpdateDevServerStateParams { + var () + return &UpdateDevServerStateParams{ + HTTPClient: client, + } +} + +/* +UpdateDevServerStateParams contains all the parameters to send to the API endpoint +for the update dev server state operation typically these are written to a http.Request +*/ +type UpdateDevServerStateParams struct { + + /*Body*/ + Body *models.UpdateDevServerStateParamsBody + /*DevServerID*/ + DevServerID string + /*SiteID*/ + SiteID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the update dev server state params +func (o *UpdateDevServerStateParams) WithTimeout(timeout time.Duration) *UpdateDevServerStateParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update dev server state params +func (o *UpdateDevServerStateParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update dev server state params +func (o *UpdateDevServerStateParams) WithContext(ctx context.Context) *UpdateDevServerStateParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update dev server state params +func (o *UpdateDevServerStateParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update dev server state params +func (o *UpdateDevServerStateParams) WithHTTPClient(client *http.Client) *UpdateDevServerStateParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update dev server state params +func (o *UpdateDevServerStateParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithBody adds the body to the update dev server state params +func (o *UpdateDevServerStateParams) WithBody(body *models.UpdateDevServerStateParamsBody) *UpdateDevServerStateParams { + o.SetBody(body) + return o +} + +// SetBody adds the body to the update dev server state params +func (o *UpdateDevServerStateParams) SetBody(body *models.UpdateDevServerStateParamsBody) { + o.Body = body +} + +// WithDevServerID adds the devServerID to the update dev server state params +func (o *UpdateDevServerStateParams) WithDevServerID(devServerID string) *UpdateDevServerStateParams { + o.SetDevServerID(devServerID) + return o +} + +// SetDevServerID adds the devServerId to the update dev server state params +func (o *UpdateDevServerStateParams) SetDevServerID(devServerID string) { + o.DevServerID = devServerID +} + +// WithSiteID adds the siteID to the update dev server state params +func (o *UpdateDevServerStateParams) WithSiteID(siteID string) *UpdateDevServerStateParams { + o.SetSiteID(siteID) + return o +} + +// SetSiteID adds the siteId to the update dev server state params +func (o *UpdateDevServerStateParams) SetSiteID(siteID string) { + o.SiteID = siteID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateDevServerStateParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Body != nil { + if err := r.SetBodyParam(o.Body); err != nil { + return err + } + } + + // path param dev_server_id + if err := r.SetPathParam("dev_server_id", o.DevServerID); 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/update_dev_server_state_responses.go b/go/plumbing/operations/update_dev_server_state_responses.go new file mode 100644 index 00000000..7d4409d3 --- /dev/null +++ b/go/plumbing/operations/update_dev_server_state_responses.go @@ -0,0 +1,98 @@ +// 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" +) + +// UpdateDevServerStateReader is a Reader for the UpdateDevServerState structure. +type UpdateDevServerStateReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateDevServerStateReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + case 200: + result := NewUpdateDevServerStateOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + case 409: + result := NewUpdateDevServerStateConflict() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewUpdateDevServerStateOK creates a UpdateDevServerStateOK with default headers values +func NewUpdateDevServerStateOK() *UpdateDevServerStateOK { + return &UpdateDevServerStateOK{} +} + +/* +UpdateDevServerStateOK handles this case with default header values. + +OK +*/ +type UpdateDevServerStateOK struct { + Payload *models.DevServer +} + +func (o *UpdateDevServerStateOK) Error() string { + return fmt.Sprintf("[POST /sites/{site_id}/dev_servers/{dev_server_id}/state][%d] updateDevServerStateOK %+v", 200, o.Payload) +} + +func (o *UpdateDevServerStateOK) GetPayload() *models.DevServer { + return o.Payload +} + +func (o *UpdateDevServerStateOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.DevServer) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateDevServerStateConflict creates a UpdateDevServerStateConflict with default headers values +func NewUpdateDevServerStateConflict() *UpdateDevServerStateConflict { + return &UpdateDevServerStateConflict{} +} + +/* +UpdateDevServerStateConflict handles this case with default header values. + +Conflict +*/ +type UpdateDevServerStateConflict struct { +} + +func (o *UpdateDevServerStateConflict) Error() string { + return fmt.Sprintf("[POST /sites/{site_id}/dev_servers/{dev_server_id}/state][%d] updateDevServerStateConflict ", 409) +} + +func (o *UpdateDevServerStateConflict) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} From 3563815b8b6f5f73e4ad8789ad9cd92d20656b80 Mon Sep 17 00:00:00 2001 From: David Berlin Date: Wed, 22 Oct 2025 08:53:15 +0300 Subject: [PATCH 3/3] convert state to enum of supported states for this endpoint --- .../update_dev_server_state_params_body.go | 43 +++++++++++++++++++ swagger.yml | 5 +++ 2 files changed, 48 insertions(+) diff --git a/go/models/update_dev_server_state_params_body.go b/go/models/update_dev_server_state_params_body.go index 17600a85..6ba30301 100644 --- a/go/models/update_dev_server_state_params_body.go +++ b/go/models/update_dev_server_state_params_body.go @@ -6,6 +6,8 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "encoding/json" + "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" @@ -22,6 +24,7 @@ type UpdateDevServerStateParamsBody struct { // state // Required: true + // Enum: [starting live error done] State *string `json:"state"` // task id @@ -42,12 +45,52 @@ func (m *UpdateDevServerStateParamsBody) Validate(formats strfmt.Registry) error return nil } +var updateDevServerStateParamsBodyTypeStatePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["starting","live","error","done"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + updateDevServerStateParamsBodyTypeStatePropEnum = append(updateDevServerStateParamsBodyTypeStatePropEnum, v) + } +} + +const ( + + // UpdateDevServerStateParamsBodyStateStarting captures enum value "starting" + UpdateDevServerStateParamsBodyStateStarting string = "starting" + + // UpdateDevServerStateParamsBodyStateLive captures enum value "live" + UpdateDevServerStateParamsBodyStateLive string = "live" + + // UpdateDevServerStateParamsBodyStateError captures enum value "error" + UpdateDevServerStateParamsBodyStateError string = "error" + + // UpdateDevServerStateParamsBodyStateDone captures enum value "done" + UpdateDevServerStateParamsBodyStateDone string = "done" +) + +// prop value enum +func (m *UpdateDevServerStateParamsBody) validateStateEnum(path, location string, value string) error { + if err := validate.EnumCase(path, location, value, updateDevServerStateParamsBodyTypeStatePropEnum, true); err != nil { + return err + } + return nil +} + func (m *UpdateDevServerStateParamsBody) validateState(formats strfmt.Registry) error { if err := validate.Required("state", "body", m.State); err != nil { return err } + // value enum + if err := m.validateStateEnum("state", "body", *m.State); err != nil { + return err + } + return nil } diff --git a/swagger.yml b/swagger.yml index 6a3d309b..b2ae6e0a 100644 --- a/swagger.yml +++ b/swagger.yml @@ -3027,6 +3027,11 @@ paths: properties: state: type: string + enum: + - starting + - live + - error + - done task_id: type: string error: