public async virtual Task <Response <CommunicationService> > GetAsync(string communicationServiceName, CancellationToken cancellationToken = default)
        {
            if (communicationServiceName == null)
            {
                throw new ArgumentNullException(nameof(communicationServiceName));
            }

            using var scope = _clientDiagnostics.CreateScope("CommunicationServiceCollection.Get");
            scope.Start();
            try
            {
                var response = await _communicationServiceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, communicationServiceName, cancellationToken).ConfigureAwait(false);

                if (response.Value == null)
                {
                    throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false);
                }
                return(Response.FromValue(new CommunicationService(this, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public virtual async Task <Response <CommunicationServiceResource> > GetAsync(CancellationToken cancellationToken = default)
        {
            using var scope = _communicationServiceClientDiagnostics.CreateScope("CommunicationServiceResource.Get");
            scope.Start();
            try
            {
                var response = await _communicationServiceRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false);

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