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

            using var scope = _clientDiagnostics.CreateScope("VpnSiteLinkCollection.Get");
            scope.Start();
            try
            {
                var response = await _vpnSiteLinksRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vpnSiteLinkName, cancellationToken).ConfigureAwait(false);

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

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