public async Task <Response <HostPoolData> > GetAsync(string subscriptionId, string resourceGroupName, string hostPoolName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (hostPoolName == null) { throw new ArgumentNullException(nameof(hostPoolName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, hostPoolName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { HostPoolData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = HostPoolData.DeserializeHostPoolData(document.RootElement); return(Response.FromValue(value, message.Response)); }
public virtual async Task <ArmOperation <HostPoolResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string hostPoolName, HostPoolData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(hostPoolName, nameof(hostPoolName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _hostPoolClientDiagnostics.CreateScope("HostPoolCollection.CreateOrUpdate"); scope.Start(); try { var response = await _hostPoolRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, hostPoolName, data, cancellationToken).ConfigureAwait(false); var operation = new DesktopVirtualizationArmOperation <HostPoolResource>(Response.FromValue(new HostPoolResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal HostPool(ArmClient client, HostPoolData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <HostPool> CreateOrUpdate(bool waitForCompletion, string hostPoolName, HostPoolData hostPool, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(hostPoolName, nameof(hostPoolName)); Argument.AssertNotNull(hostPool, nameof(hostPool)); using var scope = _hostPoolClientDiagnostics.CreateScope("HostPoolCollection.CreateOrUpdate"); scope.Start(); try { var response = _hostPoolRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, hostPoolName, hostPool, cancellationToken); var operation = new DesktopVirtualizationArmOperation <HostPool>(Response.FromValue(new HostPool(Client, response), response.GetRawResponse())); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }