public async virtual Task <Response <InboundNatRule> > GetAsync(string inboundNatRuleName, string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("InboundNatRuleContainer.Get");
            scope.Start();
            try
            {
                if (inboundNatRuleName == null)
                {
                    throw new ArgumentNullException(nameof(inboundNatRuleName));
                }

                var response = await _restClient.GetAsync(Id.ResourceGroupName, Id.Name, inboundNatRuleName, expand, cancellationToken : cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new InboundNatRule(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #2
0
        public virtual async Task <Response <InboundNatRule> > GetAsync(string inboundNatRuleName, string expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(inboundNatRuleName, nameof(inboundNatRuleName));

            using var scope = _inboundNatRuleClientDiagnostics.CreateScope("InboundNatRuleCollection.Get");
            scope.Start();
            try
            {
                var response = await _inboundNatRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, inboundNatRuleName, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new InboundNatRule(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #3
0
        public async virtual Task <Response <InboundNatRule> > GetAsync(string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _inboundNatRuleClientDiagnostics.CreateScope("InboundNatRule.Get");
            scope.Start();
            try
            {
                var response = await _inboundNatRuleRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, expand, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _inboundNatRuleClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new InboundNatRule(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }