Skip to content

Commit

Permalink
Merge pull request #3185 from Azure/drwill/formatting
Browse files Browse the repository at this point in the history
Formatting
  • Loading branch information
David R. Williamson authored Mar 22, 2023
2 parents c54658a + 7ea2df6 commit f59bd2a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public async Task ProvisioningServiceClient_DeviceRegistrationState_Query_Ok()
// Create an enrollment group so that the query is guaranteed to return at least one entry
string enrollmentGroupId = Guid.NewGuid().ToString();
var enrollmentGroup = new EnrollmentGroup(enrollmentGroupId, new SymmetricKeyAttestation());
await provisioningServiceClient.EnrollmentGroups
.CreateOrUpdateAsync(enrollmentGroup).ConfigureAwait(false);
await provisioningServiceClient.EnrollmentGroups.CreateOrUpdateAsync(enrollmentGroup).ConfigureAwait(false);

try
{
Expand All @@ -51,8 +50,7 @@ await provisioningServiceClient.EnrollmentGroups
{
try
{
await provisioningServiceClient.EnrollmentGroups
.DeleteAsync(enrollmentGroupId).ConfigureAwait(false);
await provisioningServiceClient.EnrollmentGroups.DeleteAsync(enrollmentGroupId).ConfigureAwait(false);
}
catch (Exception e)
{
Expand Down
22 changes: 17 additions & 5 deletions provisioning/service/src/DeviceRegistrationsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,31 @@ public AsyncPageable<DeviceRegistrationState> CreateEnrollmentGroupQuery(string

try
{
async Task<Page<DeviceRegistrationState>> nextPageFunc(string continuationToken, int? pageSizeHint)
async Task<Page<DeviceRegistrationState>> NextPageFunc(string continuationToken, int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<DeviceRegistrationState>(_contractApiHttp, _internalRetryHandler, query, GetDeviceRegistrationQueryUri(enrollmentGroupId), continuationToken, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<DeviceRegistrationState>(
_contractApiHttp,
_internalRetryHandler,
query,
GetDeviceRegistrationQueryUri(enrollmentGroupId), continuationToken, pageSizeHint, cancellationToken)
.ConfigureAwait(false);
}

async Task<Page<DeviceRegistrationState>> firstPageFunc(int? pageSizeHint)
async Task<Page<DeviceRegistrationState>> FirstPageFunc(int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<DeviceRegistrationState>(_contractApiHttp, _internalRetryHandler, query, GetDeviceRegistrationQueryUri(enrollmentGroupId), null, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<DeviceRegistrationState>(
_contractApiHttp,
_internalRetryHandler,
query,
GetDeviceRegistrationQueryUri(enrollmentGroupId), null, pageSizeHint, cancellationToken)
.ConfigureAwait(false);
}

return PageableHelpers.CreateAsyncEnumerable(firstPageFunc, nextPageFunc, null);
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc, null);
}
catch (Exception ex) when (Logging.IsEnabled)
{
Expand Down
28 changes: 23 additions & 5 deletions provisioning/service/src/EnrollmentGroupsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,37 @@ public AsyncPageable<EnrollmentGroup> CreateQuery(string query, CancellationToke

try
{
async Task<Page<EnrollmentGroup>> nextPageFunc(string continuationToken, int? pageSizeHint)
async Task<Page<EnrollmentGroup>> NextPageFunc(string continuationToken, int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<EnrollmentGroup>(_contractApiHttp, _internalRetryHandler, query, GetEnrollmentGroupQueryUri(), continuationToken, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<EnrollmentGroup>(
_contractApiHttp,
_internalRetryHandler,
query,
GetEnrollmentGroupQueryUri(),
continuationToken,
pageSizeHint,
cancellationToken)
.ConfigureAwait(false);
}

async Task<Page<EnrollmentGroup>> firstPageFunc(int? pageSizeHint)
async Task<Page<EnrollmentGroup>> FirstPageFunc(int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<EnrollmentGroup>(_contractApiHttp, _internalRetryHandler, query, GetEnrollmentGroupQueryUri(), null, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<EnrollmentGroup>(
_contractApiHttp,
_internalRetryHandler,
query,
GetEnrollmentGroupQueryUri(),
null,
pageSizeHint,
cancellationToken)
.ConfigureAwait(false);
}

return PageableHelpers.CreateAsyncEnumerable(firstPageFunc, nextPageFunc, null);
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc, null);
}
catch (Exception ex) when (Logging.IsEnabled)
{
Expand Down
28 changes: 23 additions & 5 deletions provisioning/service/src/IndividualEnrollmentsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,37 @@ public AsyncPageable<IndividualEnrollment> CreateQuery(string query, Cancellatio

try
{
async Task<Page<IndividualEnrollment>> nextPageFunc(string continuationToken, int? pageSizeHint)
async Task<Page<IndividualEnrollment>> NextPageFunc(string continuationToken, int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<IndividualEnrollment>(_contractApiHttp, _internalRetryHandler, query, GetEnrollmentQueryUri(), continuationToken, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<IndividualEnrollment>(
_contractApiHttp,
_internalRetryHandler,
query,
GetEnrollmentQueryUri(),
continuationToken,
pageSizeHint,
cancellationToken)
.ConfigureAwait(false);
}

async Task<Page<IndividualEnrollment>> firstPageFunc(int? pageSizeHint)
async Task<Page<IndividualEnrollment>> FirstPageFunc(int? pageSizeHint)
{
cancellationToken.ThrowIfCancellationRequested();
return await QueryBuilder.BuildAndSendRequestAsync<IndividualEnrollment>(_contractApiHttp, _internalRetryHandler, query, GetEnrollmentQueryUri(), null, pageSizeHint, cancellationToken).ConfigureAwait(false);
return await QueryBuilder
.BuildAndSendRequestAsync<IndividualEnrollment>(
_contractApiHttp,
_internalRetryHandler,
query,
GetEnrollmentQueryUri(),
null,
pageSizeHint,
cancellationToken)
.ConfigureAwait(false);
}

return PageableHelpers.CreateAsyncEnumerable(firstPageFunc, nextPageFunc, null);
return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc, null);
}
catch (Exception ex) when (Logging.IsEnabled)
{
Expand Down
9 changes: 8 additions & 1 deletion provisioning/service/src/Utilities/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ internal class QueryBuilder
private const string PageSizeHeaderKey = "x-ms-max-item-count";
private const string QueryUriFormat = "{0}/query";

internal static async Task<Page<T>> BuildAndSendRequestAsync<T>(ContractApiHttp contractApiHttp, RetryHandler retryHandler, string query, Uri path, string continuationToken, int? pageSizeHint, CancellationToken cancellationToken)
internal static async Task<Page<T>> BuildAndSendRequestAsync<T>(
ContractApiHttp contractApiHttp,
RetryHandler retryHandler,
string query,
Uri path,
string continuationToken,
int? pageSizeHint,
CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();

Expand Down

0 comments on commit f59bd2a

Please sign in to comment.