Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting #3185

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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