public virtual Response <ManagedHsmResource> Get(CancellationToken cancellationToken = default) { using var scope = _managedHsmClientDiagnostics.CreateScope("ManagedHsmResource.Get"); scope.Start(); try { var response = _managedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ManagedHsmResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <ManagedHsm> Get(string name, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); using var scope = _managedHsmClientDiagnostics.CreateScope("ManagedHsmCollection.Get"); scope.Start(); try { var response = _managedHsmRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, name, cancellationToken); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ManagedHsm(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <ManagedHsm> Get(string name, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("ManagedHsmCollection.Get"); scope.Start(); try { if (name == null) { throw new ArgumentNullException(nameof(name)); } var response = _restClient.Get(Id.ResourceGroupName, name, cancellationToken: cancellationToken); if (response.Value == null) { throw _clientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new ManagedHsm(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }