public async Task <Response <AzureFirewallData> > GetAsync(string subscriptionId, string resourceGroupName, string azureFirewallName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (azureFirewallName == null)
            {
                throw new ArgumentNullException(nameof(azureFirewallName));
            }

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

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

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

            return(new AzureFirewallResource(_client, data));
        }
 internal AzureFirewall(ArmResource options, AzureFirewallData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new AzureFirewallsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Exemple #4
0
 internal AzureFirewall(ArmResource options, AzureFirewallData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData                   = true;
     _data                     = resource;
     _clientDiagnostics        = new ClientDiagnostics(ClientOptions);
     _azureFirewallsRestClient = new AzureFirewallsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Exemple #5
0
        public virtual async Task <ArmOperation <AzureFirewall> > CreateOrUpdateAsync(WaitUntil waitUntil, string azureFirewallName, AzureFirewallData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(azureFirewallName, nameof(azureFirewallName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _azureFirewallClientDiagnostics.CreateScope("AzureFirewallCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _azureFirewallRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, azureFirewallName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <AzureFirewall>(new AzureFirewallOperationSource(Client), _azureFirewallClientDiagnostics, Pipeline, _azureFirewallRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, azureFirewallName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #6
0
        public async virtual Task <AzureFirewallCreateOrUpdateOperation> CreateOrUpdateAsync(string azureFirewallName, AzureFirewallData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (azureFirewallName == null)
            {
                throw new ArgumentNullException(nameof(azureFirewallName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("AzureFirewallContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, azureFirewallName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new AzureFirewallCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, azureFirewallName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual AzureFirewallCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string azureFirewallName, AzureFirewallData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(azureFirewallName, nameof(azureFirewallName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _azureFirewallClientDiagnostics.CreateScope("AzureFirewallCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _azureFirewallRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, azureFirewallName, parameters, cancellationToken);
                var operation = new AzureFirewallCreateOrUpdateOperation(ArmClient, _azureFirewallClientDiagnostics, Pipeline, _azureFirewallRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, azureFirewallName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #8
0
 internal AzureFirewallResource(ArmClient client, AzureFirewallData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Exemple #9
0
 internal AzureFirewallResource(ArmClient client, AzureFirewallData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }