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

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

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

                if (response.Value == null)
                {
                    throw new RequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new PrivateEndpointResource(Client, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 3
0
        public async virtual Task <Response <PrivateEndpoint> > GetAsync(string privateEndpointName, string expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(privateEndpointName, nameof(privateEndpointName));

            using var scope = _privateEndpointClientDiagnostics.CreateScope("PrivateEndpointCollection.Get");
            scope.Start();
            try
            {
                var response = await _privateEndpointRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, privateEndpointName, expand, cancellationToken).ConfigureAwait(false);

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