Example #1
0
 internal RouteTable(ArmResource options, RouteTableData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new RouteTablesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Example #2
0
 internal SubnetData(string id, string name, string etag, string type, string addressPrefix, IList <string> addressPrefixes, NetworkSecurityGroupData networkSecurityGroup, RouteTableData routeTable, Models.SubResource natGateway, IList <ServiceEndpointPropertiesFormat> serviceEndpoints, IList <ServiceEndpointPolicyData> serviceEndpointPolicies, IReadOnlyList <PrivateEndpointData> privateEndpoints, IReadOnlyList <IPConfiguration> ipConfigurations, IReadOnlyList <IPConfigurationProfile> ipConfigurationProfiles, IList <Models.SubResource> ipAllocations, IReadOnlyList <ResourceNavigationLink> resourceNavigationLinks, IReadOnlyList <ServiceAssociationLink> serviceAssociationLinks, IList <Delegation> delegations, string purpose, ProvisioningState?provisioningState, VirtualNetworkPrivateEndpointNetworkPolicies?privateEndpointNetworkPolicies, VirtualNetworkPrivateLinkServiceNetworkPolicies?privateLinkServiceNetworkPolicies, IList <ApplicationGatewayIPConfiguration> applicationGatewayIpConfigurations) : base(id)
 {
     Name                               = name;
     Etag                               = etag;
     Type                               = type;
     AddressPrefix                      = addressPrefix;
     AddressPrefixes                    = addressPrefixes;
     NetworkSecurityGroup               = networkSecurityGroup;
     RouteTable                         = routeTable;
     NatGateway                         = natGateway;
     ServiceEndpoints                   = serviceEndpoints;
     ServiceEndpointPolicies            = serviceEndpointPolicies;
     PrivateEndpoints                   = privateEndpoints;
     IpConfigurations                   = ipConfigurations;
     IpConfigurationProfiles            = ipConfigurationProfiles;
     IpAllocations                      = ipAllocations;
     ResourceNavigationLinks            = resourceNavigationLinks;
     ServiceAssociationLinks            = serviceAssociationLinks;
     Delegations                        = delegations;
     Purpose                            = purpose;
     ProvisioningState                  = provisioningState;
     PrivateEndpointNetworkPolicies     = privateEndpointNetworkPolicies;
     PrivateLinkServiceNetworkPolicies  = privateLinkServiceNetworkPolicies;
     ApplicationGatewayIpConfigurations = applicationGatewayIpConfigurations;
 }
Example #3
0
        public async Task <Response <RouteTableData> > GetAsync(string subscriptionId, string resourceGroupName, string routeTableName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (routeTableName == null)
            {
                throw new ArgumentNullException(nameof(routeTableName));
            }

            using var message = CreateGetRequest(subscriptionId, resourceGroupName, routeTableName, expand);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                RouteTableData value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = RouteTableData.DeserializeRouteTableData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal RouteTable(ArmResource options, RouteTableData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData                = true;
     _data                  = resource;
     _clientDiagnostics     = new ClientDiagnostics(ClientOptions);
     _routeTablesRestClient = new RouteTablesRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Example #5
0
        RouteTable IOperationSource <RouteTable> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = RouteTableData.DeserializeRouteTableData(document.RootElement);

            return(new RouteTable(_client, data));
        }
        public virtual RouteTableCreateOrUpdateOperation CreateOrUpdate(string routeTableName, RouteTableData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (routeTableName == null)
            {
                throw new ArgumentNullException(nameof(routeTableName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("RouteTableCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _restClient.CreateOrUpdate(Id.ResourceGroupName, routeTableName, parameters, cancellationToken);
                var operation = new RouteTableCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, routeTableName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #7
0
 internal RouteTable(ArmClient client, RouteTableData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }
Example #8
0
        internal static SubnetData DeserializeSubnetData(JsonElement element)
        {
            Optional <string>                   name                                    = default;
            Optional <string>                   etag                                    = default;
            Optional <string>                   type                                    = default;
            Optional <string>                   id                                      = default;
            Optional <string>                   addressPrefix                           = default;
            Optional <IList <string> >          addressPrefixes                         = default;
            Optional <NetworkSecurityGroupData> networkSecurityGroup                    = default;
            Optional <RouteTableData>           routeTable                              = default;
            Optional <WritableSubResource>      natGateway                              = default;
            Optional <IList <ServiceEndpointPropertiesFormat> > serviceEndpoints        = default;
            Optional <IList <ServiceEndpointPolicyData> >       serviceEndpointPolicies = default;
            Optional <IReadOnlyList <PrivateEndpointData> >     privateEndpoints        = default;
            Optional <IReadOnlyList <IPConfiguration> >         ipConfigurations        = default;
            Optional <IReadOnlyList <IPConfigurationProfile> >  ipConfigurationProfiles = default;
            Optional <IList <WritableSubResource> >             ipAllocations           = default;
            Optional <IReadOnlyList <ResourceNavigationLink> >  resourceNavigationLinks = default;
            Optional <IReadOnlyList <ServiceAssociationLink> >  serviceAssociationLinks = default;
            Optional <IList <Delegation> > delegations                                  = default;
            Optional <string>            purpose           = default;
            Optional <ProvisioningState> provisioningState = default;
            Optional <VirtualNetworkPrivateEndpointNetworkPolicies>    privateEndpointNetworkPolicies     = default;
            Optional <VirtualNetworkPrivateLinkServiceNetworkPolicies> privateLinkServiceNetworkPolicies  = default;
            Optional <IList <ApplicationGatewayIPConfiguration> >      applicationGatewayIpConfigurations = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("addressPrefix"))
                        {
                            addressPrefix = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("addressPrefixes"))
                        {
                            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());
                            }
                            addressPrefixes = array;
                            continue;
                        }
                        if (property0.NameEquals("networkSecurityGroup"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkSecurityGroup = NetworkSecurityGroupData.DeserializeNetworkSecurityGroupData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("routeTable"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            routeTable = RouteTableData.DeserializeRouteTableData(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("natGateway"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            natGateway = JsonSerializer.Deserialize <WritableSubResource>(property0.Value.ToString());
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPropertiesFormat> array = new List <ServiceEndpointPropertiesFormat>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPropertiesFormat.DeserializeServiceEndpointPropertiesFormat(item));
                            }
                            serviceEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceEndpointPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceEndpointPolicyData> array = new List <ServiceEndpointPolicyData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceEndpointPolicyData.DeserializeServiceEndpointPolicyData(item));
                            }
                            serviceEndpointPolicies = array;
                            continue;
                        }
                        if (property0.NameEquals("privateEndpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <PrivateEndpointData> array = new List <PrivateEndpointData>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(PrivateEndpointData.DeserializePrivateEndpointData(item));
                            }
                            privateEndpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfiguration> array = new List <IPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfiguration.DeserializeIPConfiguration(item));
                            }
                            ipConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("ipConfigurationProfiles"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <IPConfigurationProfile> array = new List <IPConfigurationProfile>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(IPConfigurationProfile.DeserializeIPConfigurationProfile(item));
                            }
                            ipConfigurationProfiles = array;
                            continue;
                        }
                        if (property0.NameEquals("ipAllocations"))
                        {
                            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()));
                            }
                            ipAllocations = array;
                            continue;
                        }
                        if (property0.NameEquals("resourceNavigationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResourceNavigationLink> array = new List <ResourceNavigationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResourceNavigationLink.DeserializeResourceNavigationLink(item));
                            }
                            resourceNavigationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("serviceAssociationLinks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ServiceAssociationLink> array = new List <ServiceAssociationLink>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ServiceAssociationLink.DeserializeServiceAssociationLink(item));
                            }
                            serviceAssociationLinks = array;
                            continue;
                        }
                        if (property0.NameEquals("delegations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <Delegation> array = new List <Delegation>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(Delegation.DeserializeDelegation(item));
                            }
                            delegations = array;
                            continue;
                        }
                        if (property0.NameEquals("purpose"))
                        {
                            purpose = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateEndpointNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateEndpointNetworkPolicies = new VirtualNetworkPrivateEndpointNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("privateLinkServiceNetworkPolicies"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            privateLinkServiceNetworkPolicies = new VirtualNetworkPrivateLinkServiceNetworkPolicies(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("applicationGatewayIpConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ApplicationGatewayIPConfiguration> array = new List <ApplicationGatewayIPConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ApplicationGatewayIPConfiguration.DeserializeApplicationGatewayIPConfiguration(item));
                            }
                            applicationGatewayIpConfigurations = array;
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new SubnetData(id.Value, name.Value, etag.Value, type.Value, addressPrefix.Value, Optional.ToList(addressPrefixes), networkSecurityGroup.Value, routeTable.Value, natGateway, Optional.ToList(serviceEndpoints), Optional.ToList(serviceEndpointPolicies), Optional.ToList(privateEndpoints), Optional.ToList(ipConfigurations), Optional.ToList(ipConfigurationProfiles), Optional.ToList(ipAllocations), Optional.ToList(resourceNavigationLinks), Optional.ToList(serviceAssociationLinks), Optional.ToList(delegations), purpose.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(privateEndpointNetworkPolicies), Optional.ToNullable(privateLinkServiceNetworkPolicies), Optional.ToList(applicationGatewayIpConfigurations)));
        }
        public async virtual Task <RouteTableCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string routeTableName, RouteTableData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _routeTableClientDiagnostics.CreateScope("RouteTableCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _routeTableRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, routeTableName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new RouteTableCreateOrUpdateOperation(ArmClient, _routeTableClientDiagnostics, Pipeline, _routeTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, routeTableName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #10
0
        public virtual async Task <ArmOperation <RouteTableResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string routeTableName, RouteTableData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _routeTableClientDiagnostics.CreateScope("RouteTableCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _routeTableRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, routeTableName, data, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <RouteTableResource>(new RouteTableOperationSource(Client), _routeTableClientDiagnostics, Pipeline, _routeTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, 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;
            }
        }
Example #11
0
        public virtual ArmOperation <RouteTable> CreateOrUpdate(bool waitForCompletion, string routeTableName, RouteTableData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(routeTableName, nameof(routeTableName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _routeTableClientDiagnostics.CreateScope("RouteTableCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _routeTableRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, routeTableName, parameters, cancellationToken);
                var operation = new NetworkArmOperation <RouteTable>(new RouteTableOperationSource(Client), _routeTableClientDiagnostics, Pipeline, _routeTableRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, routeTableName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Example #12
0
 internal RouteTableResource(ArmClient client, RouteTableData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }