Beispiel #1
0
        public async virtual Task <Response <DdosProtectionPlan> > GetAsync(string ddosProtectionPlanName, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("DdosProtectionPlanCollection.Get");
            scope.Start();
            try
            {
                if (ddosProtectionPlanName == null)
                {
                    throw new ArgumentNullException(nameof(ddosProtectionPlanName));
                }

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

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new DdosProtectionPlan(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <Response <DdosProtectionPlanResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _ddosProtectionPlanClientDiagnostics.CreateScope("DdosProtectionPlanResource.Get");
            scope.Start();
            try
            {
                var response = await _ddosProtectionPlanRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new DdosProtectionPlanResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }