IpAllocation IOperationSource <IpAllocation> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = IpAllocationData.DeserializeIpAllocationData(document.RootElement); return(new IpAllocation(_client, data)); }
internal IpAllocation(ArmResource options, IpAllocationData resource) : base(options, new ResourceIdentifier(resource.Id)) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _ipAllocationsRestClient = new IpAllocationsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public async Task <Response <IpAllocationData> > GetAsync(string subscriptionId, string resourceGroupName, string ipAllocationName, string expand = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (ipAllocationName == null) { throw new ArgumentNullException(nameof(ipAllocationName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, ipAllocationName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { IpAllocationData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = IpAllocationData.DeserializeIpAllocationData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal IpAllocation(ArmResource options, IpAllocationData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new IpAllocationsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
internal IpAllocation(ArmClient client, IpAllocationData data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
public async virtual Task <ArmOperation <IpAllocation> > CreateOrUpdateAsync(bool waitForCompletion, string ipAllocationName, IpAllocationData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ipAllocationName, nameof(ipAllocationName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _ipAllocationClientDiagnostics.CreateScope("IpAllocationCollection.CreateOrUpdate"); scope.Start(); try { var response = await _ipAllocationRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <IpAllocation>(new IpAllocationOperationSource(Client), _ipAllocationClientDiagnostics, Pipeline, _ipAllocationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual IpAllocationCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string ipAllocationName, IpAllocationData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(ipAllocationName, nameof(ipAllocationName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _ipAllocationClientDiagnostics.CreateScope("IpAllocationCollection.CreateOrUpdate"); scope.Start(); try { var response = _ipAllocationRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken); var operation = new IpAllocationCreateOrUpdateOperation(ArmClient, _ipAllocationClientDiagnostics, Pipeline, _ipAllocationRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <IpAllocationCreateOrUpdateOperation> CreateOrUpdateAsync(string ipAllocationName, IpAllocationData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (ipAllocationName == null) { throw new ArgumentNullException(nameof(ipAllocationName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("IpAllocationCollection.CreateOrUpdate"); scope.Start(); try { var response = await _ipAllocationsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken).ConfigureAwait(false); var operation = new IpAllocationCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _ipAllocationsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipAllocationName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual IpAllocationCreateOrUpdateOperation CreateOrUpdate(string ipAllocationName, IpAllocationData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (ipAllocationName == null) { throw new ArgumentNullException(nameof(ipAllocationName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("IpAllocationContainer.CreateOrUpdate"); scope.Start(); try { var response = _restClient.CreateOrUpdate(Id.ResourceGroupName, ipAllocationName, parameters, cancellationToken); var operation = new IpAllocationCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, ipAllocationName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }