protected override async Task <IEnumerable <CloudItem> > UpdateChildren() { CloudFoundryClient client = new CloudFoundryClient(this.target.TargetUrl, this.CancellationToken, null, this.target.IgnoreSSLErrors); string password = CloudCredentialsManager.GetPassword(this.target.TargetUrl, this.target.Email); var authenticationContext = await client.Login(new CloudCredentials() { User = this.target.Email, Password = password }); List <Organization> result = new List <Organization>(); PagedResponseCollection <ListAllOrganizationsResponse> orgs = await client.Organizations.ListAllOrganizations(); while (orgs != null && orgs.Properties.TotalResults != 0) { foreach (var org in orgs) { result.Add(new Organization(org, client)); } orgs = await orgs.GetNextPage(); } return(result); }
protected override async Task <IEnumerable <CloudItem> > UpdateChildren() { List <Service> result = new List <Service>(); PagedResponseCollection <ListAllServiceInstancesForSpaceResponse> services = await this.client.Spaces.ListAllServiceInstancesForSpace(this.space.EntityMetadata.Guid); while (services != null && services.Properties.TotalResults != 0) { foreach (var service in services) { List <GetAppSummaryResponse> appsSummary = new List <GetAppSummaryResponse>(); var serviceBindings = await this.client.ServiceInstances.ListAllServiceBindingsForServiceInstance(service.EntityMetadata.Guid); if (serviceBindings.Properties.TotalResults != 0) { foreach (var serviceBinding in serviceBindings) { appsSummary.Add(await this.client.Apps.GetAppSummary(serviceBinding.AppGuid)); } } var servicePlan = await this.client.ServicePlans.RetrieveServicePlan(service.ServicePlanGuid); var systemService = await this.client.Services.RetrieveService(servicePlan.ServiceGuid); result.Add(new Service(service, appsSummary, servicePlan, systemService, this.client)); } services = await services.GetNextPage(); } return(result); }
private async Task RefreshSpaces() { this.RefreshingSpaces = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.Spaces; List <ListAllSpacesForOrganizationResponse> spacesList = new List <ListAllSpacesForOrganizationResponse>(); var org = this.orgs.FirstOrDefault(o => o.Name == this.selectedPublishProfile.Organization); if (org == null) { return; } PagedResponseCollection <ListAllSpacesForOrganizationResponse> spaces = await this.client.Organizations.ListAllSpacesForOrganization(org.EntityMetadata.Guid); while (spaces != null && spaces.Properties.TotalResults != 0) { foreach (var space in spaces) { spacesList.Add(space); } spaces = await spaces.GetNextPage(); } OnUIThread(() => { var oldSelectedSpace = this.selectedPublishProfile.Space; this.spaces.Clear(); foreach (var space in spacesList) { this.spaces.Add(space); } if (this.spaces.Any(o => o.Name == oldSelectedSpace)) { this.selectedPublishProfile.Space = oldSelectedSpace; } if (string.IsNullOrWhiteSpace(this.selectedPublishProfile.Space)) { this.selectedPublishProfile.Space = this.spaces.FirstOrDefault().Name; } }); } finally { this.RefreshingSpaces = false; } }
private async Task RefreshBuildpacks() { this.RefreshingBuildpacks = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.Buildpacks; List <ListAllBuildpacksResponse> buildpacksList = new List <ListAllBuildpacksResponse>(); PagedResponseCollection <ListAllBuildpacksResponse> buildpacksResponse = await this.client.Buildpacks.ListAllBuildpacks(); while (buildpacksResponse != null && buildpacksResponse.Properties.TotalResults != 0) { foreach (var buildpack in buildpacksResponse) { buildpacksList.Add(buildpack); } buildpacksResponse = await buildpacksResponse.GetNextPage(); } OnUIThread(() => { var oldSelectedBuildpack = this.SelectedBuildpack; this.buildpacks.Clear(); foreach (var buildpack in buildpacksList) { this.buildpacks.Add(buildpack); } if (Uri.IsWellFormedUriString(oldSelectedBuildpack, UriKind.Absolute)) { this.SelectedBuildpack = oldSelectedBuildpack; } else { if (this.buildpacks.Any(o => o.Name == oldSelectedBuildpack)) { this.SelectedBuildpack = oldSelectedBuildpack; } else { this.SelectedBuildpack = string.Empty; } } }); } finally { this.RefreshingBuildpacks = false; } }
private async Task RefreshServiceInstances() { this.RefreshingServiceInstances = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.ServiceInstances; List <ServiceInstanceSelection> serviceInstancesList = new List <ServiceInstanceSelection>(); var space = this.spaces.FirstOrDefault(s => s.Name == this.selectedPublishProfile.Space); if (space == null) { return; } PagedResponseCollection <ListAllServiceInstancesForSpaceResponse> serviceInstances = await this.client.Spaces.ListAllServiceInstancesForSpace(space.EntityMetadata.Guid); while (serviceInstances != null && serviceInstances.Properties.TotalResults != 0) { foreach (var serviceInstance in serviceInstances) { var servicePlan = await this.client.ServicePlans.RetrieveServicePlan(serviceInstance.ServicePlanGuid); var systemService = await this.client.Services.RetrieveService(servicePlan.ServiceGuid); ServiceInstanceSelection serviceProfile = new ServiceInstanceSelection(this); serviceProfile.ServiceInstance = serviceInstance; serviceProfile.Service = systemService; serviceProfile.ServicePlan = servicePlan; serviceInstancesList.Add(serviceProfile); } serviceInstances = await serviceInstances.GetNextPage(); } OnUIThread(() => { this.serviceInstances.Clear(); foreach (var serviceProfile in serviceInstancesList) { this.serviceInstances.Add(serviceProfile); } }); } finally { this.RefreshingServiceInstances = false; } }
private async Task RefreshOrganizations() { this.RefreshingOrganizations = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.Organizations; List <ListAllOrganizationsResponse> orgsList = new List <ListAllOrganizationsResponse>(); PagedResponseCollection <ListAllOrganizationsResponse> orgsResponse = await this.client.Organizations.ListAllOrganizations(); while (orgsResponse != null && orgsResponse.Properties.TotalResults != 0) { foreach (var org in orgsResponse) { orgsList.Add(org); } orgsResponse = await orgsResponse.GetNextPage(); } OnUIThread(() => { var oldSelectedOrg = this.selectedPublishProfile.Organization; this.orgs.Clear(); foreach (var org in orgsList) { this.orgs.Add(org); } if (this.orgs.Any(o => o.Name == oldSelectedOrg)) { this.selectedPublishProfile.Organization = oldSelectedOrg; } if (string.IsNullOrWhiteSpace(this.selectedPublishProfile.Organization)) { if (this.Orgs.Count > 0) { this.selectedPublishProfile.Organization = this.Orgs.FirstOrDefault().Name; } } }); } finally { this.RefreshingOrganizations = false; } }
public void Stacks() { CloudFoundryClient client = SetTargetInfoFromFile(); PagedResponseCollection <ListAllStacksResponse> stacks = client.Stacks.ListAllStacks().Result; while (stacks != null && stacks.Properties.TotalResults != 0) { foreach (var stack in stacks) { new ConsoleString(string.Format("{0} - {1}", stack.Name, stack.Description), ConsoleColor.White).WriteLine(); } stacks = stacks.GetNextPage().Result; } }
private async Task RefreshStacks() { this.RefreshingSpaces = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.Stacks; List <ListAllStacksResponse> stacksList = new List <ListAllStacksResponse>(); PagedResponseCollection <ListAllStacksResponse> stacksResponse = await this.client.Stacks.ListAllStacks(); while (stacksResponse != null && stacksResponse.Properties.TotalResults != 0) { foreach (var stack in stacksResponse) { stacksList.Add(stack); } stacksResponse = await stacksResponse.GetNextPage(); } OnUIThread(() => { var oldSelectedStack = this.SelectedStack; this.stacks.Clear(); foreach (var stack in stacksList) { this.stacks.Add(stack); } if (stacks.Any(o => o.Name == oldSelectedStack)) { this.SelectedStack = oldSelectedStack; } if (string.IsNullOrWhiteSpace(this.SelectedStack)) { this.SelectedStack = this.stacks.FirstOrDefault().Name; } }); } finally { this.RefreshingStacks = false; } }
private async Task RefreshPrivateDomains() { this.RefreshingPrivateDomains = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.PrivateDomains; List <PrivateDomainsWithSelection> privateDomainsList = new List <PrivateDomainsWithSelection>(); var org = this.orgs.FirstOrDefault(o => o.Name == this.selectedPublishProfile.Organization); if (org == null) { return; } PagedResponseCollection <ListAllPrivateDomainsForOrganizationResponse> privateDomainsResponse = await this.client.Organizations.ListAllPrivateDomainsForOrganization(org.EntityMetadata.Guid); while (privateDomainsResponse != null && privateDomainsResponse.Properties.TotalResults != 0) { foreach (var privateDomain in privateDomainsResponse) { privateDomainsList.Add(new PrivateDomainsWithSelection(this) { PrivateDomain = privateDomain }); } privateDomainsResponse = await privateDomainsResponse.GetNextPage(); } OnUIThread(() => { this.privateDomains.Clear(); foreach (var privateDomain in privateDomainsList) { this.privateDomains.Add(privateDomain); } }); } finally { this.RefreshingPrivateDomains = false; } }
protected override async Task <IEnumerable <CloudItem> > UpdateChildren() { List <Space> result = new List <Space>(); PagedResponseCollection <ListAllSpacesForOrganizationResponse> spaces = await this.client.Organizations.ListAllSpacesForOrganization(this.organization.EntityMetadata.Guid); while (spaces != null && spaces.Properties.TotalResults != 0) { foreach (var space in spaces) { result.Add(new Space(space, this.client)); } spaces = await spaces.GetNextPage(); } return(result); }
protected override async Task <IEnumerable <CloudItem> > UpdateChildren() { List <App> result = new List <App>(); PagedResponseCollection <ListAllAppsForSpaceResponse> apps = await this.client.Spaces.ListAllAppsForSpace(this.space.EntityMetadata.Guid); while (apps != null && apps.Properties.TotalResults != 0) { foreach (var app in apps) { var appSummary = await this.client.Apps.GetAppSummary(app.EntityMetadata.Guid); result.Add(new App(appSummary, app.Diego, this.client)); } apps = await apps.GetNextPage(); } return(result); }
public void Apps() { CloudFoundryClient client = SetTargetInfoFromFile(); PagedResponseCollection <ListAllAppsResponse> apps = client.Apps.ListAllApps().Result; while (apps != null && apps.Properties.TotalResults != 0) { foreach (var app in apps) { new ConsoleString(string.Format("{0}", app.Name), ConsoleColor.Green).WriteLine(); new ConsoleString(string.Format("Memory: {0}", app.Memory), ConsoleColor.White).WriteLine(); new ConsoleString(string.Format("Buildpack: {0}", app.Buildpack ?? app.DetectedBuildpack ?? "n/a"), ConsoleColor.White).WriteLine(); new ConsoleString(string.Format("Instances: {0}", app.Instances), ConsoleColor.White).WriteLine(); new ConsoleString("------------------", ConsoleColor.Gray).WriteLine(); } apps = apps.GetNextPage().Result; } }
protected override async Task <IEnumerable <CloudItem> > UpdateChildren() { List <Route> result = new List <Route>(); PagedResponseCollection <ListAllRoutesForSpaceResponse> routes = await this.client.Spaces.ListAllRoutesForSpace(this.space.EntityMetadata.Guid); while (routes != null && routes.Properties.TotalResults != 0) { foreach (var route in routes) { var routeApps = await this.client.Routes.ListAllAppsForRoute(route.EntityMetadata.Guid); var domain = await this.client.DomainsDeprecated.RetrieveDomainDeprecated(route.DomainGuid); result.Add(new Route(route, domain, routeApps, this.client)); } routes = await routes.GetNextPage(); } return(result); }
private async Task RefreshSharedDomains() { this.RefreshingSharedDomains = true; try { this.LastRefreshTarget = PublishProfileRefreshTarget.SharedDomains; List <SharedDomainWithSelection> sharedDomainsList = new List <SharedDomainWithSelection>(); PagedResponseCollection <ListAllSharedDomainsResponse> sharedDomainsResponse = await this.client.SharedDomains.ListAllSharedDomains(); while (sharedDomainsResponse != null && sharedDomainsResponse.Properties.TotalResults != 0) { foreach (var sharedDomain in sharedDomainsResponse) { sharedDomainsList.Add(new SharedDomainWithSelection(this) { SharedDomain = sharedDomain }); } sharedDomainsResponse = await sharedDomainsResponse.GetNextPage(); } OnUIThread(() => { this.sharedDomains.Clear(); foreach (var sharedDomain in sharedDomainsList) { this.sharedDomains.Add(sharedDomain); } }); } finally { this.RefreshingSharedDomains = false; } }
public void ListBuildpacks_test() { PagedResponseCollection <ListAllBuildpacksResponse> response = null; try { response = client.Buildpacks.ListAllBuildpacks().Result; } catch (Exception ex) { Assert.Fail("Error while reading buildpacks in" + ex.ToString()); } Assert.IsNotNull(response); while (response != null && response.Properties.TotalResults != 0) { foreach (var bp in response) { Assert.IsNotNull(bp.Name); } response = response.GetNextPage().Result; } }
public void ListOrgs_test() { PagedResponseCollection <ListAllOrganizationsResponse> response = null; try { response = client.Organizations.ListAllOrganizations().Result; } catch (Exception ex) { Assert.Fail("Error while reading organizations in" + ex.ToString()); } Assert.IsNotNull(response); while (response != null && response.Properties.TotalResults != 0) { foreach (var org in response) { Assert.IsNotNull(org.Name); } response = response.GetNextPage().Result; } }