public virtual ArmOperation <PolicyAssignmentResource> CreateOrUpdate(WaitUntil waitUntil, string policyAssignmentName, PolicyAssignmentData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignmentCollection.CreateOrUpdate"); scope.Start(); try { var response = _policyAssignmentRestClient.Create(Id, policyAssignmentName, data, cancellationToken); var operation = new ResourcesArmOperation <PolicyAssignmentResource>(Response.FromValue(new PolicyAssignmentResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal PolicyAssignment(ArmClient client, PolicyAssignmentData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual async Task <ArmOperation <PolicyAssignmentResource> > UpdateAsync(WaitUntil waitUntil, PolicyAssignmentData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignmentResource.Update"); scope.Start(); try { var response = await _policyAssignmentRestClient.CreateAsync(Id.Parent, Id.Name, data, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <PolicyAssignmentResource>(Response.FromValue(new PolicyAssignmentResource(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <PolicyAssignmentCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string policyAssignmentName, PolicyAssignmentData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignmentCollection.CreateOrUpdate"); scope.Start(); try { var response = await _policyAssignmentRestClient.CreateAsync(Id, policyAssignmentName, parameters, cancellationToken).ConfigureAwait(false); var operation = new PolicyAssignmentCreateOrUpdateOperation(ArmClient, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <ArmOperation <PolicyAssignment> > CreateOrUpdateAsync(WaitUntil waitUntil, string policyAssignmentName, PolicyAssignmentData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(policyAssignmentName, nameof(policyAssignmentName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _policyAssignmentClientDiagnostics.CreateScope("PolicyAssignmentCollection.CreateOrUpdate"); scope.Start(); try { var response = await _policyAssignmentRestClient.CreateAsync(Id, policyAssignmentName, parameters, cancellationToken).ConfigureAwait(false); var operation = new ResourcesArmOperation <PolicyAssignment>(Response.FromValue(new PolicyAssignment(Client, response), response.GetRawResponse())); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }