forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment.go
78 lines (61 loc) · 2.42 KB
/
deployment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package ccv3
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal"
"code.cloudfoundry.org/cli/resources"
)
func (client *Client) CancelDeployment(deploymentGUID string) (Warnings, error) {
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationDeploymentActionCancelRequest,
URIParams: internal.Params{"deployment_guid": deploymentGUID},
})
return warnings, err
}
func (client *Client) CreateApplicationDeployment(appGUID string, dropletGUID string) (string, Warnings, error) {
dep := resources.Deployment{
DropletGUID: dropletGUID,
Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: appGUID}},
}
var responseBody resources.Deployment
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationDeploymentRequest,
RequestBody: dep,
ResponseBody: &responseBody,
})
return responseBody.GUID, warnings, err
}
func (client *Client) CreateApplicationDeploymentByRevision(appGUID string, revisionGUID string) (string, Warnings, error) {
dep := resources.Deployment{
RevisionGUID: revisionGUID,
Relationships: resources.Relationships{constant.RelationshipTypeApplication: resources.Relationship{GUID: appGUID}},
}
var responseBody resources.Deployment
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.PostApplicationDeploymentRequest,
RequestBody: dep,
ResponseBody: &responseBody,
})
return responseBody.GUID, warnings, err
}
func (client *Client) GetDeployment(deploymentGUID string) (resources.Deployment, Warnings, error) {
var responseBody resources.Deployment
_, warnings, err := client.MakeRequest(RequestParams{
RequestName: internal.GetDeploymentRequest,
URIParams: internal.Params{"deployment_guid": deploymentGUID},
ResponseBody: &responseBody,
})
return responseBody, warnings, err
}
func (client *Client) GetDeployments(query ...Query) ([]resources.Deployment, Warnings, error) {
var deployments []resources.Deployment
_, warnings, err := client.MakeListRequest(RequestParams{
RequestName: internal.GetDeploymentsRequest,
Query: query,
ResponseBody: resources.Deployment{},
AppendToList: func(item interface{}) error {
deployments = append(deployments, item.(resources.Deployment))
return nil
},
})
return deployments, warnings, err
}