public virtual AsyncPageable <ExpandMsixImage> ExpandMsixImagesAsync(MsixImageUri msixImageUri, CancellationToken cancellationToken = default) { Argument.AssertNotNull(msixImageUri, nameof(msixImageUri)); async Task <Page <ExpandMsixImage> > FirstPageFunc(int?pageSizeHint) { using var scope = _msixImagesClientDiagnostics.CreateScope("HostPool.ExpandMsixImages"); scope.Start(); try { var response = await _msixImagesRestClient.ExpandAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, msixImageUri, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <ExpandMsixImage> > NextPageFunc(string nextLink, int?pageSizeHint) { using var scope = _msixImagesClientDiagnostics.CreateScope("HostPool.ExpandMsixImages"); scope.Start(); try { var response = await _msixImagesRestClient.ExpandNextPageAsync(nextLink, Id.SubscriptionId, Id.ResourceGroupName, Id.Name, msixImageUri, cancellationToken : cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }
public async Task <Response <ExpandMsixImageList> > ExpandAsync(string subscriptionId, string resourceGroupName, string hostPoolName, MsixImageUri msixImageUri, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(hostPoolName, nameof(hostPoolName)); Argument.AssertNotNull(msixImageUri, nameof(msixImageUri)); using var message = CreateExpandRequest(subscriptionId, resourceGroupName, hostPoolName, msixImageUri); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ExpandMsixImageList value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ExpandMsixImageList.DeserializeExpandMsixImageList(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal HttpMessage CreateExpandRequest(string subscriptionId, string resourceGroupName, string hostPoolName, MsixImageUri msixImageUri) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Post; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.DesktopVirtualization/hostPools/", false); uri.AppendPath(hostPoolName, true); uri.AppendPath("/expandMsixImage", false); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(msixImageUri); request.Content = content; _userAgent.Apply(message); return(message); }