internal VirtualHubRouteTableV2(ArmResource options, VirtualHubRouteTableV2Data resource) : base(options, new ResourceIdentifier(resource.Id)) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _virtualHubRouteTableV2sRestClient = new VirtualHubRouteTableV2SRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
public async Task <Response <VirtualHubRouteTableV2Data> > GetAsync(string resourceGroupName, string virtualHubName, string routeTableName, 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)); } using var message = CreateGetRequest(resourceGroupName, virtualHubName, routeTableName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { VirtualHubRouteTableV2Data value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = VirtualHubRouteTableV2Data.DeserializeVirtualHubRouteTableV2Data(document.RootElement); return(Response.FromValue(value, message.Response)); }
VirtualHubRouteTableV2Resource IOperationSource <VirtualHubRouteTableV2Resource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = VirtualHubRouteTableV2Data.DeserializeVirtualHubRouteTableV2Data(document.RootElement); return(new VirtualHubRouteTableV2Resource(_client, data)); }
internal VirtualHubRouteTableV2(ArmResource options, VirtualHubRouteTableV2Data resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _restClient = new VirtualHubRouteTableV2SRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri); }
internal static VirtualHubData DeserializeVirtualHubData(JsonElement element) { Optional <string> etag = default; Optional <string> id = default; Optional <string> name = default; Optional <string> type = default; Optional <string> location = default; Optional <IDictionary <string, string> > tags = default; Optional <WritableSubResource> virtualWan = default; Optional <WritableSubResource> vpnGateway = default; Optional <WritableSubResource> p2SVpnGateway = default; Optional <WritableSubResource> expressRouteGateway = default; Optional <WritableSubResource> azureFirewall = default; Optional <WritableSubResource> securityPartnerProvider = default; Optional <string> addressPrefix = default; Optional <VirtualHubRouteTable> routeTable = default; Optional <ProvisioningState> provisioningState = default; Optional <string> securityProviderName = default; Optional <IList <VirtualHubRouteTableV2Data> > virtualHubRouteTableV2s = default; Optional <string> sku = default; Optional <RoutingState> routingState = default; Optional <IReadOnlyList <WritableSubResource> > bgpConnections = default; Optional <IReadOnlyList <WritableSubResource> > ipConfigurations = default; Optional <long> virtualRouterAsn = default; Optional <IList <string> > virtualRouterIps = default; Optional <bool> allowBranchToBranchTraffic = default; Optional <PreferredRoutingGateway> preferredRoutingGateway = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { id = property.Value.GetString(); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("location")) { location = property.Value.GetString(); continue; } if (property.NameEquals("tags")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } Dictionary <string, string> dictionary = new Dictionary <string, string>(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } tags = dictionary; continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("virtualWan")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualWan = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("vpnGateway")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } vpnGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("p2SVpnGateway")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } p2SVpnGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("expressRouteGateway")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } expressRouteGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("azureFirewall")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } azureFirewall = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("securityPartnerProvider")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } securityPartnerProvider = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString()); continue; } if (property0.NameEquals("addressPrefix")) { addressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("routeTable")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } routeTable = VirtualHubRouteTable.DeserializeVirtualHubRouteTable(property0.Value); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } if (property0.NameEquals("securityProviderName")) { securityProviderName = property0.Value.GetString(); continue; } if (property0.NameEquals("virtualHubRouteTableV2s")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <VirtualHubRouteTableV2Data> array = new List <VirtualHubRouteTableV2Data>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(VirtualHubRouteTableV2Data.DeserializeVirtualHubRouteTableV2Data(item)); } virtualHubRouteTableV2s = array; continue; } if (property0.NameEquals("sku")) { sku = property0.Value.GetString(); continue; } if (property0.NameEquals("routingState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } routingState = new RoutingState(property0.Value.GetString()); continue; } if (property0.NameEquals("bgpConnections")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WritableSubResource> array = new List <WritableSubResource>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString())); } bgpConnections = array; continue; } if (property0.NameEquals("ipConfigurations")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <WritableSubResource> array = new List <WritableSubResource>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(JsonSerializer.Deserialize <WritableSubResource>(item.ToString())); } ipConfigurations = array; continue; } if (property0.NameEquals("virtualRouterAsn")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } virtualRouterAsn = property0.Value.GetInt64(); continue; } if (property0.NameEquals("virtualRouterIps")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } virtualRouterIps = array; continue; } if (property0.NameEquals("allowBranchToBranchTraffic")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } allowBranchToBranchTraffic = property0.Value.GetBoolean(); continue; } if (property0.NameEquals("preferredRoutingGateway")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } preferredRoutingGateway = new PreferredRoutingGateway(property0.Value.GetString()); continue; } } continue; } } return(new VirtualHubData(id.Value, name.Value, type.Value, location.Value, Optional.ToDictionary(tags), etag.Value, virtualWan, vpnGateway, p2SVpnGateway, expressRouteGateway, azureFirewall, securityPartnerProvider, addressPrefix.Value, routeTable.Value, Optional.ToNullable(provisioningState), securityProviderName.Value, Optional.ToList(virtualHubRouteTableV2s), sku.Value, Optional.ToNullable(routingState), Optional.ToList(bgpConnections), Optional.ToList(ipConfigurations), Optional.ToNullable(virtualRouterAsn), Optional.ToList(virtualRouterIps), Optional.ToNullable(allowBranchToBranchTraffic), Optional.ToNullable(preferredRoutingGateway))); }
public virtual async Task <ArmOperation <VirtualHubRouteTableV2Resource> > CreateOrUpdateAsync(WaitUntil waitUntil, string routeTableName, VirtualHubRouteTableV2Data data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _virtualHubRouteTableV2ClientDiagnostics.CreateScope("VirtualHubRouteTableV2Collection.CreateOrUpdate"); scope.Start(); try { var response = await _virtualHubRouteTableV2RestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, data, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <VirtualHubRouteTableV2Resource>(new VirtualHubRouteTableV2OperationSource(Client), _virtualHubRouteTableV2ClientDiagnostics, Pipeline, _virtualHubRouteTableV2RestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <VirtualHubRouteTableV2CreateOrUpdateOperation> CreateOrUpdateAsync(string routeTableName, VirtualHubRouteTableV2Data virtualHubRouteTableV2Parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } if (virtualHubRouteTableV2Parameters == null) { throw new ArgumentNullException(nameof(virtualHubRouteTableV2Parameters)); } using var scope = _clientDiagnostics.CreateScope("VirtualHubRouteTableV2Container.CreateOrUpdate"); scope.Start(); try { var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters, cancellationToken).ConfigureAwait(false); var operation = new VirtualHubRouteTableV2CreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal VirtualHubRouteTableV2Resource(ArmClient client, VirtualHubRouteTableV2Data data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual VirtualHubRouteTableV2CreateOrUpdateOperation CreateOrUpdate(string routeTableName, VirtualHubRouteTableV2Data virtualHubRouteTableV2Parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (routeTableName == null) { throw new ArgumentNullException(nameof(routeTableName)); } if (virtualHubRouteTableV2Parameters == null) { throw new ArgumentNullException(nameof(virtualHubRouteTableV2Parameters)); } using var scope = _clientDiagnostics.CreateScope("VirtualHubRouteTableV2Collection.CreateOrUpdate"); scope.Start(); try { var response = _virtualHubRouteTableV2sRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters, cancellationToken); var operation = new VirtualHubRouteTableV2CreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _virtualHubRouteTableV2sRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal VirtualHubRouteTableV2(ArmClient client, VirtualHubRouteTableV2Data data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
public virtual ArmOperation <VirtualHubRouteTableV2> CreateOrUpdate(bool waitForCompletion, string routeTableName, VirtualHubRouteTableV2Data virtualHubRouteTableV2Parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName)); Argument.AssertNotNull(virtualHubRouteTableV2Parameters, nameof(virtualHubRouteTableV2Parameters)); using var scope = _virtualHubRouteTableV2ClientDiagnostics.CreateScope("VirtualHubRouteTableV2Collection.CreateOrUpdate"); scope.Start(); try { var response = _virtualHubRouteTableV2RestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters, cancellationToken); var operation = new NetworkArmOperation <VirtualHubRouteTableV2>(new VirtualHubRouteTableV2OperationSource(Client), _virtualHubRouteTableV2ClientDiagnostics, Pipeline, _virtualHubRouteTableV2RestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, routeTableName, virtualHubRouteTableV2Parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }