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 <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(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; } }