internal static Guid?GetSpaceGuid(CloudFoundryClient client, TaskLogger logger, string cforganization, string cfspace) { Guid?spaceGuid = null; PagedResponseCollection <ListAllOrganizationsResponse> orgList = client.Organizations.ListAllOrganizations(new RequestOptions() { Query = "name:" + cforganization }).Result; if (orgList.Count() > 1) { logger.LogError("There are more than one organization with name {0}, organization names need to be unique", cforganization); return(null); } ListAllOrganizationsResponse orgInfo = orgList.FirstOrDefault(); if (orgInfo != null) { PagedResponseCollection <ListAllSpacesForOrganizationResponse> spaceList = client.Organizations.ListAllSpacesForOrganization(orgInfo.EntityMetadata.Guid.ToNullableGuid(), new RequestOptions() { Query = "name:" + cfspace }).Result; if (spaceList.Count() > 1) { logger.LogError("There are more than one space with name {0} in organization {1}", cfspace, cforganization); return(null); } if (spaceList.FirstOrDefault() != null) { spaceGuid = new Guid(spaceList.FirstOrDefault().EntityMetadata.Guid); } else { logger.LogError("Space {0} not found", cfspace); return(null); } } else { logger.LogError("Organization {0} not found", cforganization); return(null); } return(spaceGuid); }
public Organization(ListAllOrganizationsResponse org, CloudFoundryClient client) : base(CloudItemType.Organization) { this.client = client; this.organization = org; }