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