public async virtual Task <JitRequestCreateOrUpdateOperation> CreateOrUpdateAsync(string jitRequestName, JitRequestDefinitionData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (jitRequestName == null) { throw new ArgumentNullException(nameof(jitRequestName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("JitRequestDefinitionContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, jitRequestName, parameters, cancellationToken).ConfigureAwait(false); var operation = new JitRequestCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, jitRequestName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <JitRequestCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string jitRequestName, JitRequestData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jitRequestName, nameof(jitRequestName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _jitRequestClientDiagnostics.CreateScope("JitRequestCollection.CreateOrUpdate"); scope.Start(); try { var response = await _jitRequestRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters, cancellationToken).ConfigureAwait(false); var operation = new JitRequestCreateOrUpdateOperation(ArmClient, _jitRequestClientDiagnostics, Pipeline, _jitRequestRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }