From 2579772c5e7dc6b7075459df69f31d374e0efe1f Mon Sep 17 00:00:00 2001 From: Karin Hendrikse <30577427+khendrikse@users.noreply.github.com> Date: Mon, 8 Dec 2025 15:46:12 +0100 Subject: [PATCH] fix: add more zip info for build and deploy --- go/models/deploy_files.go | 16 ++++++++-- .../create_site_build_parameters.go | 32 +++++++++++++++++++ go/plumbing/operations/operations_client.go | 6 +++- swagger.yml | 29 ++++++++++++++++- 4 files changed, 79 insertions(+), 4 deletions(-) diff --git a/go/models/deploy_files.go b/go/models/deploy_files.go index 065f99de..1aaba0dd 100644 --- a/go/models/deploy_files.go +++ b/go/models/deploy_files.go @@ -6,6 +6,7 @@ package models // Editing this file might prove futile when you re-run the swagger generate command import ( + "io" "strconv" "github.com/go-openapi/errors" @@ -14,7 +15,11 @@ import ( "github.com/go-openapi/validate" ) -// DeployFiles deploy files +// DeployFiles Deploy files can be provided in two ways: +// 1. As a JSON object using 'files' (a hash mapping file paths to SHA1 digests), OR +// 2. As a zip file using one of these methods: +// - Set Content-Type to 'application/zip' and send the zip file as the raw request body +// - Include the zip file content in the 'zip' field of this JSON object with Content-Type 'application/json' // // swagger:model deployFiles type DeployFiles struct { @@ -28,7 +33,7 @@ type DeployFiles struct { // draft Draft bool `json:"draft,omitempty"` - // files + // A hash mapping file paths to SHA1 digests of the file contents. Files interface{} `json:"files,omitempty"` // framework @@ -45,6 +50,13 @@ type DeployFiles struct { // functions config FunctionsConfig map[string]FunctionConfig `json:"functions_config,omitempty"` + + // A zip file containing the site files to deploy. Alternative to 'files'. + // To use this field, set Content-Type to 'application/json' and include the zip content here. + // Alternatively, you can set Content-Type to 'application/zip' and send the zip as the raw request body (not as JSON). + // + // Format: binary + Zip io.ReadCloser `json:"zip,omitempty"` } // Validate validates this deploy files diff --git a/go/plumbing/operations/create_site_build_parameters.go b/go/plumbing/operations/create_site_build_parameters.go index c6f71790..30d48c31 100644 --- a/go/plumbing/operations/create_site_build_parameters.go +++ b/go/plumbing/operations/create_site_build_parameters.go @@ -89,6 +89,14 @@ type CreateSiteBuildParams struct { */ Title *string + /*Zip + A zip file containing the site files to build. + Only used with Content-Type 'multipart/form-data'. + Alternatively, set Content-Type to 'application/zip' and send the zip as the raw request body (no 'zip' parameter needed). + + + */ + Zip runtime.NamedReadCloser timeout time.Duration Context context.Context @@ -194,6 +202,17 @@ func (o *CreateSiteBuildParams) SetTitle(title *string) { o.Title = title } +// WithZip adds the zip to the create site build params +func (o *CreateSiteBuildParams) WithZip(zip runtime.NamedReadCloser) *CreateSiteBuildParams { + o.SetZip(zip) + return o +} + +// SetZip adds the zip to the create site build params +func (o *CreateSiteBuildParams) SetZip(zip runtime.NamedReadCloser) { + o.Zip = zip +} + // WriteToRequest writes these params to a swagger request func (o *CreateSiteBuildParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { @@ -287,6 +306,19 @@ func (o *CreateSiteBuildParams) WriteToRequest(r runtime.ClientRequest, reg strf } + if o.Zip != nil { + + if o.Zip != nil { + + // form file param zip + if err := r.SetFileParam("zip", o.Zip); 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 0f2bc487..e7a4916f 100644 --- a/go/plumbing/operations/operations_client.go +++ b/go/plumbing/operations/operations_client.go @@ -1015,7 +1015,11 @@ func (a *Client) CreateSiteAsset(params *CreateSiteAssetParams, authInfo runtime } /* -CreateSiteBuild Runs a build for a site. The build will be scheduled to run at the first opportunity, but it might not start immediately if insufficient account build capacity is available. Files for build could be also uploaded as a zipped site. + CreateSiteBuild Runs a build for a site. The build will be scheduled to run at the first opportunity, but it might not start immediately if insufficient account build capacity is available. + +Files for build can also be uploaded as a zipped site using one of these methods: +1. Set Content-Type to 'application/zip' and send the zip file as the raw request body +2. Set Content-Type to 'multipart/form-data' and include the zip file in the 'zip' field */ func (a *Client) CreateSiteBuild(params *CreateSiteBuildParams, authInfo runtime.ClientAuthInfoWriter) (*CreateSiteBuildOK, error) { // TODO: Validate the params before sending diff --git a/swagger.yml b/swagger.yml index 1f9f71e2..da379bd7 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1233,7 +1233,12 @@ paths: post: operationId: createSiteBuild tags: [build] - description: 'Runs a build for a site. The build will be scheduled to run at the first opportunity, but it might not start immediately if insufficient account build capacity is available. Files for build could be also uploaded as a zipped site.' + description: | + Runs a build for a site. The build will be scheduled to run at the first opportunity, but it might not start immediately if insufficient account build capacity is available. + + Files for build can also be uploaded as a zipped site using one of these methods: + 1. Set Content-Type to 'application/zip' and send the zip file as the raw request body + 2. Set Content-Type to 'multipart/form-data' and include the zip file in the 'zip' field parameters: - name: branch description: >- @@ -1263,6 +1268,14 @@ paths: required: false in: query type: string + - name: zip + description: | + A zip file containing the site files to build. + Only used with Content-Type 'multipart/form-data'. + Alternatively, set Content-Type to 'application/zip' and send the zip as the raw request body (no 'zip' parameter needed). + required: false + in: formData + type: file responses: '200': description: OK @@ -3783,9 +3796,23 @@ definitions: $ref: '#/definitions/functionSchedule' deployFiles: type: object + description: | + Deploy files can be provided in two ways: + 1. As a JSON object using 'files' (a hash mapping file paths to SHA1 digests), OR + 2. As a zip file using one of these methods: + - Set Content-Type to 'application/zip' and send the zip file as the raw request body + - Include the zip file content in the 'zip' field of this JSON object with Content-Type 'application/json' properties: files: type: object + description: A hash mapping file paths to SHA1 digests of the file contents. + zip: + type: string + format: binary + description: | + A zip file containing the site files to deploy. Alternative to 'files'. + To use this field, set Content-Type to 'application/json' and include the zip content here. + Alternatively, you can set Content-Type to 'application/zip' and send the zip as the raw request body (not as JSON). draft: type: boolean async: