Exemplo n.º 1
0
 internal VpnSite(ArmResource options, VpnSiteData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData             = true;
     _data               = resource;
     _clientDiagnostics  = new ClientDiagnostics(ClientOptions);
     _vpnSitesRestClient = new VpnSitesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Exemplo n.º 2
0
        public async Task <Response <VpnSiteData> > GetAsync(string subscriptionId, string resourceGroupName, string vpnSiteName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (vpnSiteName == null)
            {
                throw new ArgumentNullException(nameof(vpnSiteName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, vpnSiteName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                VpnSiteData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = VpnSiteData.DeserializeVpnSiteData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        VpnSite IOperationSource <VpnSite> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = VpnSiteData.DeserializeVpnSiteData(document.RootElement);

            return(new VpnSite(_client, data));
        }
Exemplo n.º 4
0
 internal VpnSite(ArmResource options, VpnSiteData resource) : base(options, resource.Id)
 {
     HasData                 = true;
     _data                   = resource;
     _clientDiagnostics      = new ClientDiagnostics(ClientOptions);
     _restClient             = new VpnSitesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
     _vpnSiteLinksRestClient = new VpnSiteLinksRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Exemplo n.º 5
0
        public virtual async Task <ArmOperation <VpnSite> > CreateOrUpdateAsync(WaitUntil waitUntil, string vpnSiteName, VpnSiteData vpnSiteParameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(vpnSiteName, nameof(vpnSiteName));
            Argument.AssertNotNull(vpnSiteParameters, nameof(vpnSiteParameters));

            using var scope = _vpnSiteClientDiagnostics.CreateScope("VpnSiteCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _vpnSiteRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, vpnSiteName, vpnSiteParameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <VpnSite>(new VpnSiteOperationSource(Client), _vpnSiteClientDiagnostics, Pipeline, _vpnSiteRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, vpnSiteName, vpnSiteParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual VpnSiteCreateOrUpdateOperation CreateOrUpdate(string vpnSiteName, VpnSiteData vpnSiteParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (vpnSiteName == null)
            {
                throw new ArgumentNullException(nameof(vpnSiteName));
            }
            if (vpnSiteParameters == null)
            {
                throw new ArgumentNullException(nameof(vpnSiteParameters));
            }

            using var scope = _clientDiagnostics.CreateScope("VpnSiteCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _restClient.CreateOrUpdate(Id.ResourceGroupName, vpnSiteName, vpnSiteParameters, cancellationToken);
                var operation = new VpnSiteCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, vpnSiteName, vpnSiteParameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 7
0
 internal VpnSite(ArmClient client, VpnSiteData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }
Exemplo n.º 8
0
 internal VpnSiteResource(ArmClient client, VpnSiteData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Exemplo n.º 9
0
        public async virtual Task <VpnSiteCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string vpnSiteName, VpnSiteData vpnSiteParameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(vpnSiteName, nameof(vpnSiteName));
            if (vpnSiteParameters == null)
            {
                throw new ArgumentNullException(nameof(vpnSiteParameters));
            }

            using var scope = _vpnSiteClientDiagnostics.CreateScope("VpnSiteCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _vpnSiteRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, vpnSiteName, vpnSiteParameters, cancellationToken).ConfigureAwait(false);

                var operation = new VpnSiteCreateOrUpdateOperation(ArmClient, _vpnSiteClientDiagnostics, Pipeline, _vpnSiteRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, vpnSiteName, vpnSiteParameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }