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