Skip to content

Commit 278552c

Browse files
authored
Merge pull request #15 from netlify/add_deploys_endpoint_2
Add getDeploy endpoint.
2 parents 327baa7 + fdc2af4 commit 278552c

File tree

6 files changed

+248
-5
lines changed

6 files changed

+248
-5
lines changed

go/models/deploy.go

+28
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ swagger:model deploy
1616
*/
1717
type Deploy struct {
1818

19+
/* admin url
20+
*/
21+
AdminURL string `json:"admin_url,omitempty"`
22+
23+
/* branch
24+
*/
25+
Branch string `json:"branch,omitempty"`
26+
27+
/* build id
28+
*/
29+
BuildID string `json:"build_id,omitempty"`
30+
1931
/* commit ref
2032
*/
2133
CommitRef string `json:"commit_ref,omitempty"`
2234

35+
/* commit url
36+
*/
37+
CommitURL string `json:"commit_url,omitempty"`
38+
2339
/* created at
2440
*/
2541
CreatedAt string `json:"created_at,omitempty"`
@@ -36,10 +52,18 @@ type Deploy struct {
3652
*/
3753
Draft bool `json:"draft,omitempty"`
3854

55+
/* error message
56+
*/
57+
ErrorMessage string `json:"error_message,omitempty"`
58+
3959
/* id
4060
*/
4161
ID string `json:"id,omitempty"`
4262

63+
/* name
64+
*/
65+
Name string `json:"name,omitempty"`
66+
4367
/* required
4468
*/
4569
Required []string `json:"required,omitempty"`
@@ -56,6 +80,10 @@ type Deploy struct {
5680
*/
5781
SiteID string `json:"site_id,omitempty"`
5882

83+
/* skipped
84+
*/
85+
Skipped bool `json:"skipped,omitempty"`
86+
5987
/* state
6088
*/
6189
State string `json:"state,omitempty"`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package operations
2+
3+
// This file was generated by the swagger tool.
4+
// Editing this file might prove futile when you re-run the swagger generate command
5+
6+
import (
7+
"github.com/go-openapi/errors"
8+
"github.com/go-openapi/runtime"
9+
10+
strfmt "github.com/go-openapi/strfmt"
11+
)
12+
13+
// NewGetDeployParams creates a new GetDeployParams object
14+
// with the default values initialized.
15+
func NewGetDeployParams() *GetDeployParams {
16+
var ()
17+
return &GetDeployParams{}
18+
}
19+
20+
/*GetDeployParams contains all the parameters to send to the API endpoint
21+
for the get deploy operation typically these are written to a http.Request
22+
*/
23+
type GetDeployParams struct {
24+
25+
/*DeployID*/
26+
DeployID string
27+
}
28+
29+
// WithDeployID adds the deployId to the get deploy params
30+
func (o *GetDeployParams) WithDeployID(DeployID string) *GetDeployParams {
31+
o.DeployID = DeployID
32+
return o
33+
}
34+
35+
// WriteToRequest writes these params to a swagger request
36+
func (o *GetDeployParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
37+
38+
var res []error
39+
40+
// path param deploy_id
41+
if err := r.SetPathParam("deploy_id", o.DeployID); err != nil {
42+
return err
43+
}
44+
45+
if len(res) > 0 {
46+
return errors.CompositeValidationError(res...)
47+
}
48+
return nil
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package operations
2+
3+
// This file was generated by the swagger tool.
4+
// Editing this file might prove futile when you re-run the swagger generate command
5+
6+
import (
7+
"fmt"
8+
"io"
9+
10+
"github.com/go-openapi/runtime"
11+
12+
strfmt "github.com/go-openapi/strfmt"
13+
14+
"github.com/netlify/open-api/go/models"
15+
)
16+
17+
// GetDeployReader is a Reader for the GetDeploy structure.
18+
type GetDeployReader struct {
19+
formats strfmt.Registry
20+
}
21+
22+
// ReadResponse reads a server response into the recieved o.
23+
func (o *GetDeployReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
24+
switch response.Code() {
25+
26+
case 200:
27+
result := NewGetDeployOK()
28+
if err := result.readResponse(response, consumer, o.formats); err != nil {
29+
return nil, err
30+
}
31+
return result, nil
32+
33+
default:
34+
result := NewGetDeployDefault(response.Code())
35+
if err := result.readResponse(response, consumer, o.formats); err != nil {
36+
return nil, err
37+
}
38+
return nil, result
39+
}
40+
}
41+
42+
// NewGetDeployOK creates a GetDeployOK with default headers values
43+
func NewGetDeployOK() *GetDeployOK {
44+
return &GetDeployOK{}
45+
}
46+
47+
/*GetDeployOK handles this case with default header values.
48+
49+
OK
50+
*/
51+
type GetDeployOK struct {
52+
Payload *models.Deploy
53+
}
54+
55+
func (o *GetDeployOK) Error() string {
56+
return fmt.Sprintf("[GET /deploys/{deploy_id}][%d] getDeployOK %+v", 200, o.Payload)
57+
}
58+
59+
func (o *GetDeployOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
60+
61+
o.Payload = new(models.Deploy)
62+
63+
// response payload
64+
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
65+
return err
66+
}
67+
68+
return nil
69+
}
70+
71+
// NewGetDeployDefault creates a GetDeployDefault with default headers values
72+
func NewGetDeployDefault(code int) *GetDeployDefault {
73+
return &GetDeployDefault{
74+
_statusCode: code,
75+
}
76+
}
77+
78+
/*GetDeployDefault handles this case with default header values.
79+
80+
error
81+
*/
82+
type GetDeployDefault struct {
83+
_statusCode int
84+
85+
Payload *models.Error
86+
}
87+
88+
// Code gets the status code for the get deploy default response
89+
func (o *GetDeployDefault) Code() int {
90+
return o._statusCode
91+
}
92+
93+
func (o *GetDeployDefault) Error() string {
94+
return fmt.Sprintf("[GET /deploys/{deploy_id}][%d] getDeploy default %+v", o._statusCode, o.Payload)
95+
}
96+
97+
func (o *GetDeployDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
98+
99+
o.Payload = new(models.Error)
100+
101+
// response payload
102+
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
103+
return err
104+
}
105+
106+
return nil
107+
}

go/plumbing/operations/operations_client.go

+26
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,32 @@ func (a *Client) GetDNSForSite(params *GetDNSForSiteParams, authInfo runtime.Cli
256256
return result.(*GetDNSForSiteOK), nil
257257
}
258258

259+
/*
260+
GetDeploy get deploy API
261+
*/
262+
func (a *Client) GetDeploy(params *GetDeployParams, authInfo runtime.ClientAuthInfoWriter) (*GetDeployOK, error) {
263+
// TODO: Validate the params before sending
264+
if params == nil {
265+
params = NewGetDeployParams()
266+
}
267+
268+
result, err := a.transport.Submit(&runtime.ClientOperation{
269+
ID: "getDeploy",
270+
Method: "GET",
271+
PathPattern: "/deploys/{deploy_id}",
272+
ProducesMediaTypes: []string{"application/json"},
273+
ConsumesMediaTypes: []string{"application/json"},
274+
Schemes: []string{"https"},
275+
Params: params,
276+
Reader: &GetDeployReader{formats: a.formats},
277+
AuthInfo: authInfo,
278+
})
279+
if err != nil {
280+
return nil, err
281+
}
282+
return result.(*GetDeployOK), nil
283+
}
284+
259285
/*
260286
GetSite get site API
261287
*/

swagger.yml

+37-4
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,23 @@ paths:
450450
description: error
451451
schema:
452452
$ref: "#/definitions/error"
453+
/deploys/{deploy_id}:
454+
get:
455+
operationId: getDeploy
456+
parameters:
457+
- name: deploy_id
458+
type: string
459+
in: path
460+
required: true
461+
responses:
462+
'200':
463+
description: OK
464+
schema:
465+
$ref: "#/definitions/deploy"
466+
default:
467+
description: error
468+
schema:
469+
$ref: "#/definitions/error"
453470
/deploys/{deploy_id}/files/{path}:
454471
put:
455472
operationId: uploadDeployFile
@@ -728,18 +745,22 @@ definitions:
728745
type: string
729746
user_id:
730747
type: string
748+
build_id:
749+
type: string
731750
state:
732751
type: string
752+
name:
753+
type: string
754+
url:
755+
type: string
756+
admin_url:
757+
type: string
733758
deploy_url:
734759
type: string
735760
deploy_ssl_url:
736761
type: string
737-
url:
738-
type: string
739762
screenshot_url:
740763
type: string
741-
commit_ref:
742-
type: string
743764
review_id:
744765
type: string
745766
draft:
@@ -748,6 +769,18 @@ definitions:
748769
type: array
749770
items:
750771
type: string
772+
error_message:
773+
type: string
774+
review_id:
775+
type: string
776+
branch:
777+
type: string
778+
commit_ref:
779+
type: string
780+
commit_url:
781+
type: string
782+
skipped:
783+
type: boolean
751784
created_at:
752785
type: string
753786
format: dateTime

0 commit comments

Comments
 (0)