public async Task <Response <NatGateway> > GetAsync(string resourceGroupName, string natGatewayName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (natGatewayName == null)
            {
                throw new ArgumentNullException(nameof(natGatewayName));
            }

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

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

                if (document.RootElement.ValueKind == JsonValueKind.Null)
                {
                    value = null;
                }
                else
                {
                    value = NatGateway.DeserializeNatGateway(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }
Example #2
0
        private async Task <VpcData> Define()
        {
            var availabilityZonesResult = await GetAvailabilityZones.InvokeAsync(
                null,
                new InvokeOptions
            {
                Provider = _options?.Provider
            });

            var azA = availabilityZonesResult.Names[0];
            var azB = availabilityZonesResult.Names[1];

            var vpcResourceName = $"{GetResourceName()}";
            var vpc             = new Vpc(
                vpcResourceName,
                new VpcArgs
            {
                CidrBlock = $"10.{_args.CidrBlockSegment}.0.0/16",
                Tags      = new InputMap <string>
                {
                    { "Name", vpcResourceName },
                    { "pulumi:ResourceName", vpcResourceName }
                }
            },
                new CustomResourceOptions
            {
                Provider = _options?.Provider,
                Parent   = this
            });

            var private0 = AddSubnet(vpcResourceName, vpc, "private", azA, 0, _args.CidrBlockSegment, 0);
            var private1 = AddSubnet(vpcResourceName, vpc, "private", azB, 1, _args.CidrBlockSegment, 64);
            var public0  = AddSubnet(vpcResourceName, vpc, "public", azA, 0, _args.CidrBlockSegment, 128);
            var public1  = AddSubnet(vpcResourceName, vpc, "public", azB, 1, _args.CidrBlockSegment, 192);

            var ig = new InternetGateway(
                $"{vpc.GetResourceName()}-ig",
                new InternetGatewayArgs
            {
                VpcId = vpc.Id
            },
                new CustomResourceOptions
            {
                Parent = vpc
            });

            new Route($"{public0.RouteTable.GetResourceName()}-ig", new RouteArgs
            {
                RouteTableId         = public0.RouteTable.Id,
                DestinationCidrBlock = "0.0.0.0/0",
                GatewayId            = ig.Id
            }, new CustomResourceOptions
            {
                Parent = public0.RouteTable
            });

            new Route($"{public1.RouteTable.GetResourceName()}-ig", new RouteArgs
            {
                RouteTableId         = public1.RouteTable.Id,
                DestinationCidrBlock = "0.0.0.0/0",
                GatewayId            = ig.Id
            }, new CustomResourceOptions
            {
                Parent = public1.RouteTable
            });


            var eip0 = new Eip(
                $"{public0.Subnet.GetResourceName()}-eip",
                new EipArgs
            {
                Vpc  = true,
                Tags = new InputMap <string>
                {
                    { "Name", $"{public0.Subnet.GetResourceName()}-eip" }
                }
            },
                new CustomResourceOptions
            {
                Parent = public0.Subnet
            });

            var natGateway0 = new NatGateway(
                $"{public0.Subnet.GetResourceName()}-ng",
                new NatGatewayArgs
            {
                SubnetId     = public0.Subnet.Id,
                AllocationId = eip0.Id,
                Tags         = new InputMap <string>
                {
                    { "Name", $"{public0.Subnet.GetResourceName()}-ng" }
                }
            },
                new CustomResourceOptions
            {
                Parent = public0.Subnet
            });

            new Route($"{private0.Subnet.GetResourceName()}-nat-0", new RouteArgs
            {
                RouteTableId         = private0.RouteTable.Id,
                DestinationCidrBlock = "0.0.0.0/0",
                NatGatewayId         = natGateway0.Id
            }, new CustomResourceOptions
            {
                Parent = private0.Subnet
            });


            var eip1 = new Eip(
                $"{public1.Subnet.GetResourceName()}-eip",
                new EipArgs
            {
                Vpc  = true,
                Tags = new InputMap <string>
                {
                    { "Name", $"{public1.Subnet.GetResourceName()}-eip" }
                }
            },
                new CustomResourceOptions
            {
                Parent = public1.Subnet
            });

            var natGateway1 = new NatGateway(
                $"{public1.Subnet.GetResourceName()}-ng",
                new NatGatewayArgs
            {
                SubnetId     = public1.Subnet.Id,
                AllocationId = eip1.Id,
                Tags         = new InputMap <string>
                {
                    { "Name", $"{public1.Subnet.GetResourceName()}-ng" }
                }
            },
                new CustomResourceOptions
            {
                Parent = public1.Subnet
            });

            new Route($"{private1.Subnet.GetResourceName()}-nat-1", new RouteArgs
            {
                RouteTableId         = private1.RouteTable.Id,
                DestinationCidrBlock = "0.0.0.0/0",
                NatGatewayId         = natGateway1.Id
            }, new CustomResourceOptions
            {
                Parent = private1.Subnet
            });

            return(new VpcData(vpc, private0.Subnet, private1.Subnet, public0.Subnet, public1.Subnet));
        }
 /// <summary>
 /// Creates or updates a nat gateway.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='natGatewayName'>
 /// The name of the nat gateway.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update nat gateway operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <NatGateway> BeginCreateOrUpdateAsync(this INatGatewaysOperations operations, string resourceGroupName, string natGatewayName, NatGateway parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, natGatewayName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #4
0
        public virtual NatGatewaysCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string natGatewayName, NatGateway parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (natGatewayName == null)
            {
                throw new ArgumentNullException(nameof(natGatewayName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("NatGatewaysOperations.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, natGatewayName, parameters, cancellationToken);
                return(new NatGatewaysCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, natGatewayName, parameters).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 /// <summary>
 /// Creates or updates a nat gateway.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group.
 /// </param>
 /// <param name='natGatewayName'>
 /// The name of the nat gateway.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the create or update nat gateway operation.
 /// </param>
 public static NatGateway BeginCreateOrUpdate(this INatGatewaysOperations operations, string resourceGroupName, string natGatewayName, NatGateway parameters)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, natGatewayName, parameters).GetAwaiter().GetResult());
 }