github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/api/cloudcontroller/ccv3/job_url.go (about) 1 package ccv3 2 3 import ( 4 "bytes" 5 6 "code.cloudfoundry.org/cli/api/cloudcontroller" 7 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" 8 ) 9 10 // JobURL is the URL to a given Job. 11 type JobURL string 12 13 // DeleteApplication deletes the app with the given app GUID. Returns back a 14 // resulting job URL to poll. 15 func (client *Client) DeleteApplication(appGUID string) (JobURL, Warnings, error) { 16 request, err := client.newHTTPRequest(requestOptions{ 17 RequestName: internal.DeleteApplicationRequest, 18 URIParams: internal.Params{"app_guid": appGUID}, 19 }) 20 if err != nil { 21 return "", nil, err 22 } 23 24 response := cloudcontroller.Response{} 25 err = client.connection.Make(request, &response) 26 27 return JobURL(response.ResourceLocationURL), response.Warnings, err 28 } 29 30 // UpdateApplicationApplyManifest applies the manifest to the given 31 // application. Returns back a resulting job URL to poll. 32 func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) { 33 request, err := client.newHTTPRequest(requestOptions{ 34 RequestName: internal.PostApplicationActionApplyManifest, 35 URIParams: map[string]string{"app_guid": appGUID}, 36 Body: bytes.NewReader(rawManifest), 37 }) 38 39 if err != nil { 40 return "", nil, err 41 } 42 43 request.Header.Set("Content-Type", "application/x-yaml") 44 45 response := cloudcontroller.Response{} 46 err = client.connection.Make(request, &response) 47 48 return JobURL(response.ResourceLocationURL), response.Warnings, err 49 } 50 51 // UpdateSpaceApplyManifest - Is there a better name for this, since ... 52 // -- The Space resource is not actually updated. 53 // -- Instead what this ApplyManifest may do is to Create or Update Applications instead. 54 55 // Applies the manifest to the given space. Returns back a resulting job URL to poll. 56 57 // For each app specified in the manifest, the server-side handles: 58 // (1) Finding or creating this app. 59 // (2) Applying manifest properties to this app. 60 61 func (client *Client) UpdateSpaceApplyManifest(spaceGUID string, rawManifest []byte, query ...Query) (JobURL, Warnings, error) { 62 request, requestExecuteErr := client.newHTTPRequest(requestOptions{ 63 RequestName: internal.PostSpaceActionApplyManifestRequest, 64 Query: query, 65 URIParams: map[string]string{"space_guid": spaceGUID}, 66 Body: bytes.NewReader(rawManifest), 67 }) 68 69 if requestExecuteErr != nil { 70 return JobURL(""), nil, requestExecuteErr 71 } 72 73 request.Header.Set("Content-Type", "application/x-yaml") 74 75 response := cloudcontroller.Response{} 76 err := client.connection.Make(request, &response) 77 78 return JobURL(response.ResourceLocationURL), response.Warnings, err 79 }