Exemple #1
0
 public virtual Response<NetworkInterface> Get(string expand = null, CancellationToken cancellationToken = default)
 {
     using var scope = _networkInterfaceClientDiagnostics.CreateScope("NetworkInterface.Get");
     scope.Start();
     try
     {
         var response = _networkInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken);
         if (response.Value == null)
             throw new RequestFailedException(response.GetRawResponse());
         return Response.FromValue(new NetworkInterface(Client, response.Value), response.GetRawResponse());
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
Exemple #2
0
        public virtual Response <NetworkInterface> Get(string networkInterfaceName, string expand = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(networkInterfaceName, nameof(networkInterfaceName));

            using var scope = _networkInterfaceClientDiagnostics.CreateScope("NetworkInterfaceCollection.Get");
            scope.Start();
            try
            {
                var response = _networkInterfaceRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, networkInterfaceName, expand, cancellationToken);
                if (response.Value == null)
                {
                    throw _networkInterfaceClientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new NetworkInterface(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual Response <NetworkInterface> Get(string networkInterfaceName, string expand = null, CancellationToken cancellationToken = default)
        {
            using var scope = _clientDiagnostics.CreateScope("NetworkInterfaceContainer.Get");
            scope.Start();
            try
            {
                if (networkInterfaceName == null)
                {
                    throw new ArgumentNullException(nameof(networkInterfaceName));
                }

                var response = _restClient.Get(Id.ResourceGroupName, networkInterfaceName, expand, cancellationToken: cancellationToken);
                if (response.Value == null)
                {
                    throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse());
                }
                return(Response.FromValue(new NetworkInterface(Parent, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }