Skip to content

Commit

Permalink
chore: adjust get queries to filter for name (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil91 committed Jul 2, 2024
1 parent accfee8 commit f625814
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/clients/Dim.Clients/Api/Cf/CfClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task<Guid> CreateCloudFoundrySpace(string tenantName, CancellationT

private static async Task<Guid> GetEnvironmentId(string tenantName, CancellationToken cancellationToken, HttpClient client)
{
var environmentsResponse = await client.GetAsync("/v3/organizations", cancellationToken)
var environmentsResponse = await client.GetAsync($"/v3/organizations?names={tenantName}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-organizations", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE);
var environments = await environmentsResponse.Content
.ReadFromJsonAsync<GetEnvironmentsResponse>(JsonSerializerExtensions.Options, cancellationToken)
Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task<Guid> GetSpace(string tenantName, CancellationToken cancellati
{
var spaceName = $"{tenantName}-space";
var client = await _basicAuthTokenService.GetBasicAuthorizedLegacyClient<CfClient>(_settings, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync("/v3/spaces", cancellationToken)
var result = await client.GetAsync($"/v3/spaces?names={spaceName}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-space", HttpAsyncResponseMessageExtension.RecoverOptions.ALLWAYS).ConfigureAwait(false);
try
{
Expand Down Expand Up @@ -181,8 +181,9 @@ await client.PostAsJsonAsync("/v3/service_instances", data, JsonSerializerExtens

private async Task<Guid> GetServiceInstances(string tenantName, Guid? spaceId, CancellationToken cancellationToken)
{
var name = $"{tenantName}-dim-instance";
var client = await _basicAuthTokenService.GetBasicAuthorizedLegacyClient<CfClient>(_settings, cancellationToken).ConfigureAwait(false);
var result = await client.GetAsync("/v3/service_instances", cancellationToken)
var result = await client.GetAsync($"/v3/service_instances?names={name}", cancellationToken)
.CatchingIntoServiceExceptionFor("get-si", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false);
try
{
Expand All @@ -194,7 +195,6 @@ private async Task<Guid> GetServiceInstances(string tenantName, Guid? spaceId, C
throw new ServiceException("Response must not be null");
}

var name = $"{tenantName}-dim-instance";
var resources = response.Resources.Where(x => x.Name == name && x.Type == "managed" && (spaceId == null || x.Relationships.Space.Data.Id == spaceId.Value) && x.LastOperation.State == "succeeded");
if (resources.Count() != 1)
{
Expand Down

0 comments on commit f625814

Please sign in to comment.