github.com/cloudfoundry-community/cloudfoundry-cli@v6.44.1-0.20240130060226-cda5ed8e89a5+incompatible/actor/v7action/organization.go (about) 1 package v7action 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/actionerror" 5 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 6 "code.cloudfoundry.org/cli/resources" 7 ) 8 9 // Organization represents a V3 actor organization. 10 type Organization resources.Organization 11 12 // GetOrganizationByName returns the organization with the given name. 13 func (actor Actor) GetOrganizationByName(name string) (Organization, Warnings, error) { 14 orgs, warnings, err := actor.CloudControllerClient.GetOrganizations( 15 ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, 16 ) 17 if err != nil { 18 return Organization{}, Warnings(warnings), err 19 } 20 21 if len(orgs) == 0 { 22 return Organization{}, Warnings(warnings), actionerror.OrganizationNotFoundError{Name: name} 23 } 24 25 return Organization(orgs[0]), Warnings(warnings), nil 26 }