HubRouteTableResource IOperationSource <HubRouteTableResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = HubRouteTableData.DeserializeHubRouteTableData(document.RootElement); return(new HubRouteTableResource(_client, data)); }
internal HubRouteTable(ArmResource options, HubRouteTableData resource) : base(options, new ResourceIdentifier(resource.Id)) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _hubRouteTablesRestClient = new HubRouteTablesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public async Task <Response <HubRouteTableData> > GetAsync(string subscriptionId, string resourceGroupName, string virtualHubName, string routeTableName, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (virtualHubName == null) { throw new ArgumentNullException(nameof(virtualHubName)); } if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, virtualHubName, routeTableName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { HubRouteTableData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = HubRouteTableData.DeserializeHubRouteTableData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal HubRouteTable(ArmResource options, HubRouteTableData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new HubRouteTablesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
public async virtual Task <HubRouteTableCreateOrUpdateOperation> CreateOrUpdateAsync(string routeTableName, HubRouteTableData routeTableParameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } if (routeTableParameters == null) { throw new ArgumentNullException(nameof(routeTableParameters)); } using var scope = _clientDiagnostics.CreateScope("HubRouteTableContainer.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters, cancellationToken).ConfigureAwait(false); var operation = new HubRouteTableCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string virtualHubName, string routeTableName, HubRouteTableData routeTableParameters, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (virtualHubName == null) { throw new ArgumentNullException(nameof(virtualHubName)); } if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } if (routeTableParameters == null) { throw new ArgumentNullException(nameof(routeTableParameters)); } using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualHubName, routeTableName, routeTableParameters); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw await ClientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(false); } }
internal HttpMessage CreateCreateOrUpdateRequest(string subscriptionId, string resourceGroupName, string virtualHubName, string routeTableName, HubRouteTableData routeTableParameters) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Put; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Network/virtualHubs/", false); uri.AppendPath(virtualHubName, true); uri.AppendPath("/hubRouteTables/", false); uri.AppendPath(routeTableName, true); uri.AppendQuery("api-version", _apiVersion, true); request.Uri = uri; request.Headers.Add("Accept", "application/json"); request.Headers.Add("Content-Type", "application/json"); var content = new Utf8JsonRequestContent(); content.JsonWriter.WriteObjectValue(routeTableParameters); request.Content = content; message.SetProperty("SDKUserAgent", _userAgent); return(message); }
internal HubRouteTableResource(ArmClient client, HubRouteTableData data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
public virtual ArmOperation <HubRouteTableResource> Update(WaitUntil waitUntil, HubRouteTableData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _hubRouteTableClientDiagnostics.CreateScope("HubRouteTableResource.Update"); scope.Start(); try { var response = _hubRouteTableRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new NetworkArmOperation <HubRouteTableResource>(new HubRouteTableOperationSource(Client), _hubRouteTableClientDiagnostics, Pipeline, _hubRouteTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public Response CreateOrUpdate(string resourceGroupName, string virtualHubName, string routeTableName, HubRouteTableData routeTableParameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (virtualHubName == null) { throw new ArgumentNullException(nameof(virtualHubName)); } if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } if (routeTableParameters == null) { throw new ArgumentNullException(nameof(routeTableParameters)); } using var message = CreateCreateOrUpdateRequest(resourceGroupName, virtualHubName, routeTableName, routeTableParameters); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw _clientDiagnostics.CreateRequestFailedException(message.Response); } }
public virtual HubRouteTableCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string routeTableName, HubRouteTableData routeTableParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); if (routeTableParameters == null) { throw new ArgumentNullException(nameof(routeTableParameters)); } using var scope = _hubRouteTableClientDiagnostics.CreateScope("HubRouteTableCollection.CreateOrUpdate"); scope.Start(); try { var response = _hubRouteTableRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters, cancellationToken); var operation = new HubRouteTableCreateOrUpdateOperation(ArmClient, _hubRouteTableClientDiagnostics, Pipeline, _hubRouteTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task <Response> CreateOrUpdateAsync(string subscriptionId, string resourceGroupName, string virtualHubName, string routeTableName, HubRouteTableData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(virtualHubName, nameof(virtualHubName)); Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); Argument.AssertNotNull(data, nameof(data)); using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualHubName, routeTableName, data); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw new RequestFailedException(message.Response); } }
public async virtual Task <ArmOperation <HubRouteTable> > CreateOrUpdateAsync(bool waitForCompletion, string routeTableName, HubRouteTableData routeTableParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); Argument.AssertNotNull(routeTableParameters, nameof(routeTableParameters)); using var scope = _hubRouteTableClientDiagnostics.CreateScope("HubRouteTableCollection.CreateOrUpdate"); scope.Start(); try { var response = await _hubRouteTableRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <HubRouteTable>(new HubRouteTableOperationSource(Client), _hubRouteTableClientDiagnostics, Pipeline, _hubRouteTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, routeTableParameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public Response CreateOrUpdate(string subscriptionId, string resourceGroupName, string virtualHubName, string routeTableName, HubRouteTableData routeTableParameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(virtualHubName, nameof(virtualHubName)); Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); Argument.AssertNotNull(routeTableParameters, nameof(routeTableParameters)); using var message = CreateCreateOrUpdateRequest(subscriptionId, resourceGroupName, virtualHubName, routeTableName, routeTableParameters); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { case 200: case 201: return(message.Response); default: throw new RequestFailedException(message.Response); } }
internal HubRouteTableResource(ArmClient client, HubRouteTableData data) : this(client, data.Id) { HasData = true; _data = data; }