public async virtual Task <Response <BastionHost> > GetAsync(string bastionHostName, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("BastionHostContainer.Get"); scope.Start(); try { if (bastionHostName == null) { throw new ArgumentNullException(nameof(bastionHostName)); } var response = await _restClient.GetAsync(Id.ResourceGroupName, bastionHostName, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new BastionHost(Parent, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <BastionHost> > GetAsync(CancellationToken cancellationToken = default) { using var scope = _bastionHostClientDiagnostics.CreateScope("BastionHost.Get"); scope.Start(); try { var response = await _bastionHostRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new BastionHost(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <BastionHost> > GetAsync(string bastionHostName, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(bastionHostName, nameof(bastionHostName)); using var scope = _bastionHostClientDiagnostics.CreateScope("BastionHostCollection.Get"); scope.Start(); try { var response = await _bastionHostRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, bastionHostName, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _bastionHostClientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new BastionHost(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }