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