public virtual Response <bool> Exists(string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(capacityReservationGroupName, nameof(capacityReservationGroupName)); using var scope = _capacityReservationGroupClientDiagnostics.CreateScope("CapacityReservationGroupCollection.Exists"); scope.Start(); try { var response = _capacityReservationGroupRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, capacityReservationGroupName, expand, cancellationToken: cancellationToken); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <CapacityReservationGroup> Get(CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _capacityReservationGroupClientDiagnostics.CreateScope("CapacityReservationGroup.Get"); scope.Start(); try { var response = _capacityReservationGroupRestClient.Get(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken); if (response.Value == null) { throw _capacityReservationGroupClientDiagnostics.CreateRequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new CapacityReservationGroup(ArmClient, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <CapacityReservationGroup> > GetAsync(CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { using var scope = _clientDiagnostics.CreateScope("CapacityReservationGroup.Get"); scope.Start(); try { var response = await _capacityReservationGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(response.GetRawResponse()).ConfigureAwait(false); } return(Response.FromValue(new CapacityReservationGroup(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual Response <bool> Exists(string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { if (capacityReservationGroupName == null) { throw new ArgumentNullException(nameof(capacityReservationGroupName)); } using var scope = _clientDiagnostics.CreateScope("CapacityReservationGroupCollection.Exists"); scope.Start(); try { var response = GetIfExists(capacityReservationGroupName, expand, cancellationToken: cancellationToken); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <CapacityReservationGroupResource> > GetAsync(string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(capacityReservationGroupName, nameof(capacityReservationGroupName)); using var scope = _capacityReservationGroupClientDiagnostics.CreateScope("CapacityReservationGroupCollection.Get"); scope.Start(); try { var response = await _capacityReservationGroupRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, capacityReservationGroupName, expand, cancellationToken).ConfigureAwait(false); if (response.Value == null) { throw new RequestFailedException(response.GetRawResponse()); } return(Response.FromValue(new CapacityReservationGroupResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <Response <CapacityReservationGroup> > GetIfExistsAsync(string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { if (capacityReservationGroupName == null) { throw new ArgumentNullException(nameof(capacityReservationGroupName)); } using var scope = _clientDiagnostics.CreateScope("CapacityReservationGroupCollection.GetIfExists"); scope.Start(); try { var response = await _capacityReservationGroupsRestClient.GetAsync(Id.SubscriptionId, Id.ResourceGroupName, capacityReservationGroupName, expand, cancellationToken : cancellationToken).ConfigureAwait(false); if (response.Value == null) { return(Response.FromValue <CapacityReservationGroup>(null, response.GetRawResponse())); } return(Response.FromValue(new CapacityReservationGroup(this, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public virtual async Task <Response <bool> > ExistsAsync(string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(capacityReservationGroupName, nameof(capacityReservationGroupName)); using var scope = _capacityReservationGroupClientDiagnostics.CreateScope("CapacityReservationGroupCollection.Exists"); scope.Start(); try { var response = await GetIfExistsAsync(capacityReservationGroupName, expand : expand, cancellationToken : cancellationToken).ConfigureAwait(false); return(Response.FromValue(response.Value != null, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public static Response <CapacityReservationGroup> GetCapacityReservationGroup(this ResourceGroup resourceGroup, string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { return(resourceGroup.GetCapacityReservationGroups().Get(capacityReservationGroupName, expand, cancellationToken)); }
public static async Task <Response <CapacityReservationGroup> > GetCapacityReservationGroupAsync(this ResourceGroup resourceGroup, string capacityReservationGroupName, CapacityReservationGroupInstanceViewTypes?expand = null, CancellationToken cancellationToken = default) { return(await resourceGroup.GetCapacityReservationGroups().GetAsync(capacityReservationGroupName, expand, cancellationToken).ConfigureAwait(false)); }