public virtual async Task <Response <VMwareDatastore> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _vMwareDatastoreDatastoresClientDiagnostics.CreateScope("VMwareDatastore.Get"); scope.Start(); try { var response = await _vMwareDatastoreDatastoresRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new VMwareDatastore(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <VMwareDatastore> > GetAsync(string datastoreName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(datastoreName, nameof(datastoreName)); using var scope = _vMwareDatastoreDatastoresClientDiagnostics.CreateScope("VMwareDatastoreCollection.Get"); scope.Start(); try { var response = await _vMwareDatastoreDatastoresRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, datastoreName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _vMwareDatastoreDatastoresClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new VMwareDatastore(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }