internal JitRequestDefinition(ArmResource options, JitRequestDefinitionData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new JitRequestsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
public async Task <Response <JitRequestDefinitionData> > GetAsync(string subscriptionId, string resourceGroupName, string jitRequestName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (jitRequestName == null) { throw new ArgumentNullException(nameof(jitRequestName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, jitRequestName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { JitRequestDefinitionData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = JitRequestDefinitionData.DeserializeJitRequestDefinitionData(document.RootElement); return(Response.FromValue(value, message.Response)); }
public async virtual Task <JitRequestDefinitionCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string jitRequestName, JitRequestDefinitionData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(jitRequestName, nameof(jitRequestName)); if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _jitRequestDefinitionJitRequestsClientDiagnostics.CreateScope("JitRequestDefinitionCollection.CreateOrUpdate"); scope.Start(); try { var response = await _jitRequestDefinitionJitRequestsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters, cancellationToken).ConfigureAwait(false); var operation = new JitRequestDefinitionCreateOrUpdateOperation(ArmClient, _jitRequestDefinitionJitRequestsClientDiagnostics, Pipeline, _jitRequestDefinitionJitRequestsRestClient.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; } }
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 virtual JitRequestCreateOrUpdateOperation CreateOrUpdate(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("JitRequestDefinitionCollection.CreateOrUpdate"); scope.Start(); try { var response = _jitRequestsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters, cancellationToken); var operation = new JitRequestCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _jitRequestsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, jitRequestName, parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal JitRequestDefinition(ArmClient armClient, JitRequestDefinitionData data) : this(armClient, data.Id) { HasData = true; _data = data; }