github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/api/cloudcontroller/ccv3/application.go (about) 1 package ccv3 2 3 import ( 4 "net/url" 5 6 "code.cloudfoundry.org/cli/api/cloudcontroller" 7 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/internal" 8 ) 9 10 // Application represents a Cloud Controller V3 Application. 11 type Application struct { 12 Name string `json:"name"` 13 GUID string `json:"guid"` 14 } 15 16 // GetApplications lists applications with optional filters. 17 func (client *Client) GetApplications(query url.Values) ([]Application, Warnings, error) { 18 request, err := client.newHTTPRequest(requestOptions{ 19 RequestName: internal.GetAppsRequest, 20 Query: query, 21 }) 22 if err != nil { 23 return nil, nil, err 24 } 25 26 var fullAppsList []Application 27 warnings, err := client.paginate(request, Application{}, func(item interface{}) error { 28 if app, ok := item.(Application); ok { 29 fullAppsList = append(fullAppsList, app) 30 } else { 31 return cloudcontroller.UnknownObjectInListError{ 32 Expected: Application{}, 33 Unexpected: item, 34 } 35 } 36 return nil 37 }) 38 39 return fullAppsList, warnings, err 40 }