internal VpnGateway(ArmResource options, VpnGatewayData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new VpnGatewaysRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
VpnGatewayResource IOperationSource <VpnGatewayResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = VpnGatewayData.DeserializeVpnGatewayData(document.RootElement); return(new VpnGatewayResource(_client, data)); }
internal VpnGateway(ArmResource options, VpnGatewayData resource) : base(options, new ResourceIdentifier(resource.Id)) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _vpnGatewaysRestClient = new VpnGatewaysRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public async Task <Response <VpnGatewayData> > GetAsync(string resourceGroupName, string gatewayName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } using var message = CreateGetRequest(resourceGroupName, gatewayName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VpnGatewayData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = VpnGatewayData.DeserializeVpnGatewayData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal VpnGateway(ArmClient client, VpnGatewayData data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
public virtual async Task <ArmOperation <VpnGatewayResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string gatewayName, VpnGatewayData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = await _vpnGatewayRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <VpnGatewayResource>(new VpnGatewayOperationSource(Client), _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <VpnGatewayCreateOrUpdateOperation> CreateOrUpdateAsync(string gatewayName, VpnGatewayData vpnGatewayParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (gatewayName == null) { throw new ArgumentNullException(nameof(gatewayName)); } if (vpnGatewayParameters == null) { throw new ArgumentNullException(nameof(vpnGatewayParameters)); } using var scope = _clientDiagnostics.CreateScope("VpnGatewayContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken).ConfigureAwait(false); var operation = new VpnGatewayCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual VpnGatewayCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string gatewayName, VpnGatewayData vpnGatewayParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); if (vpnGatewayParameters == null) { throw new ArgumentNullException(nameof(vpnGatewayParameters)); } using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = _vpnGatewayRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken); var operation = new VpnGatewayCreateOrUpdateOperation(ArmClient, _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal VpnGatewayResource(ArmClient client, VpnGatewayData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <VpnGateway> CreateOrUpdate(bool waitForCompletion, string gatewayName, VpnGatewayData vpnGatewayParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(gatewayName, nameof(gatewayName)); Argument.AssertNotNull(vpnGatewayParameters, nameof(vpnGatewayParameters)); using var scope = _vpnGatewayClientDiagnostics.CreateScope("VpnGatewayCollection.CreateOrUpdate"); scope.Start(); try { var response = _vpnGatewayRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters, cancellationToken); var operation = new NetworkArmOperation <VpnGateway>(new VpnGatewayOperationSource(Client), _vpnGatewayClientDiagnostics, Pipeline, _vpnGatewayRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, gatewayName, vpnGatewayParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }