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