public virtual Response <VaultKey> Get(CancellationToken cancellationToken = default) { using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKey.Get"); scope.Start(); try { var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); if (response.Value == null) { throw _vaultKeyKeysClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VaultKey(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <VaultKey> Get(string keyName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(keyName, nameof(keyName)); using var scope = _vaultKeyKeysClientDiagnostics.CreateScope("VaultKeyCollection.Get"); scope.Start(); try { var response = _vaultKeyKeysRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, keyName, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VaultKey(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }