public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.CreateSubnetRequest(); if (cmdletContext.AvailabilityZone != null) { request.AvailabilityZone = cmdletContext.AvailabilityZone; } if (cmdletContext.AvailabilityZoneId != null) { request.AvailabilityZoneId = cmdletContext.AvailabilityZoneId; } if (cmdletContext.CidrBlock != null) { request.CidrBlock = cmdletContext.CidrBlock; } if (cmdletContext.Ipv6CidrBlock != null) { request.Ipv6CidrBlock = cmdletContext.Ipv6CidrBlock; } if (cmdletContext.OutpostArn != null) { request.OutpostArn = cmdletContext.OutpostArn; } if (cmdletContext.TagSpecification != null) { request.TagSpecifications = cmdletContext.TagSpecification; } if (cmdletContext.VpcId != null) { request.VpcId = cmdletContext.VpcId; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }
protected override void ProcessRecord() { AmazonEC2 client = base.GetClient(); Amazon.EC2.Model.CreateSubnetRequest request = new Amazon.EC2.Model.CreateSubnetRequest(); request.VpcId = this._VpcId; request.CidrBlock = this._CidrBlock; request.AvailabilityZone = this._AvailabilityZone; Amazon.EC2.Model.CreateSubnetResponse response = client.CreateSubnet(request); base.WriteObject(response.CreateSubnetResult.Subnet, true); }
/// <summary> /// Initiates the asynchronous execution of the CreateSubnet operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateSubnet operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<CreateSubnetResponse> CreateSubnetAsync(CreateSubnetRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateSubnetRequestMarshaller(); var unmarshaller = CreateSubnetResponseUnmarshaller.Instance; return InvokeAsync<CreateSubnetRequest,CreateSubnetResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Creates a subnet in an existing VPC. /// /// /// <para> /// When you create each subnet, you provide the VPC ID and the CIDR block you want for /// the subnet. After you create a subnet, you can't change its CIDR block. The subnet's /// CIDR block can be the same as the VPC's CIDR block (assuming you want only a single /// subnet in the VPC), or a subset of the VPC's CIDR block. If you create more than one /// subnet in a VPC, the subnets' CIDR blocks must not overlap. The smallest subnet (and /// VPC) you can create uses a /28 netmask (16 IP addresses), and the largest uses a /16 /// netmask (65,536 IP addresses). /// </para> /// <important> /// <para> /// AWS reserves both the first four and the last IP address in each subnet's CIDR block. /// They're not available for use. /// </para> /// </important> /// <para> /// If you add more than one subnet to a VPC, they're set up in a star topology with a /// logical router in the middle. /// </para> /// /// <para> /// If you launch an instance in a VPC using an Amazon EBS-backed AMI, the IP address /// doesn't change if you stop and restart the instance (unlike a similar instance launched /// outside a VPC, which gets a new IP address when restarted). It's therefore possible /// to have a subnet with no running instances (they're all stopped), but no remaining /// IP addresses available. /// </para> /// /// <para> /// For more information about subnets, see <a href="http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html">Your /// VPC and Subnets</a> in the <i>Amazon Virtual Private Cloud User Guide</i>. /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateSubnet service method.</param> /// /// <returns>The response from the CreateSubnet service method, as returned by EC2.</returns> public CreateSubnetResponse CreateSubnet(CreateSubnetRequest request) { var marshaller = new CreateSubnetRequestMarshaller(); var unmarshaller = CreateSubnetResponseUnmarshaller.Instance; return Invoke<CreateSubnetRequest,CreateSubnetResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Initiates the asynchronous execution of the CreateSubnet operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateSubnet operation on AmazonEC2Client.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateSubnet /// operation.</returns> public IAsyncResult BeginCreateSubnet(CreateSubnetRequest request, AsyncCallback callback, object state) { var marshaller = new CreateSubnetRequestMarshaller(); var unmarshaller = CreateSubnetResponseUnmarshaller.Instance; return BeginInvoke<CreateSubnetRequest>(request, marshaller, unmarshaller, callback, state); }
IAsyncResult invokeCreateSubnet(CreateSubnetRequest createSubnetRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new CreateSubnetRequestMarshaller().Marshall(createSubnetRequest); var unmarshaller = CreateSubnetResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the CreateSubnet operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.CreateSubnet"/> /// </summary> /// /// <param name="createSubnetRequest">Container for the necessary parameters to execute the CreateSubnet operation on AmazonEC2.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCreateSubnet /// operation.</returns> public IAsyncResult BeginCreateSubnet(CreateSubnetRequest createSubnetRequest, AsyncCallback callback, object state) { return invokeCreateSubnet(createSubnetRequest, callback, state, false); }
/// <summary> /// <para>Creates a subnet in an existing VPC.</para> <para>When you create each subnet, you provide the VPC ID and the CIDR block you want for /// the subnet. After you create a subnet, you can't change its CIDR block. The subnet's CIDR block can be the same as the VPC's CIDR block /// (assuming you want only a single subnet in the VPC), or a subset of the VPC's CIDR block. If you create more than one subnet in a VPC, the /// subnets' CIDR blocks must not overlap. The smallest subnet (and VPC) you can create uses a /28 netmask (16 IP addresses), and the largest /// uses a /16 netmask (65,536 IP addresses).</para> <para><b>IMPORTANT:</b> AWS reserves both the first four and the last IP address in each /// subnet's CIDR block. They're not available for use. </para> <para>If you add more than one subnet to a VPC, they're set up in a star /// topology with a logical router in the middle.</para> <para>For more information about subnets, see <a /// href="http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html" >Your VPC and Subnets</a> in the <i>Amazon Virtual Private /// Cloud User Guide</i> .</para> /// </summary> /// /// <param name="createSubnetRequest">Container for the necessary parameters to execute the CreateSubnet service method on AmazonEC2.</param> /// /// <returns>The response from the CreateSubnet service method, as returned by AmazonEC2.</returns> /// public CreateSubnetResponse CreateSubnet(CreateSubnetRequest createSubnetRequest) { IAsyncResult asyncResult = invokeCreateSubnet(createSubnetRequest, null, null, true); return EndCreateSubnet(asyncResult); }
/// <summary> /// <para>Creates a subnet in an existing VPC.</para> <para>When you create each subnet, you provide the VPC ID and the CIDR block you want for /// the subnet. After you create a subnet, you can't change its CIDR block. The subnet's CIDR block can be the same as the VPC's CIDR block /// (assuming you want only a single subnet in the VPC), or a subset of the VPC's CIDR block. If you create more than one subnet in a VPC, the /// subnets' CIDR blocks must not overlap. The smallest subnet (and VPC) you can create uses a /28 netmask (16 IP addresses), and the largest /// uses a /16 netmask (65,536 IP addresses).</para> <para><b>IMPORTANT:</b> AWS reserves both the first four and the last IP address in each /// subnet's CIDR block. They're not available for use. </para> <para>If you add more than one subnet to a VPC, they're set up in a star /// topology with a logical router in the middle.</para> <para>For more information about subnets, see <a href="http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html">Your VPC and Subnets</a> in the <i>Amazon Virtual Private /// Cloud User Guide</i> .</para> /// </summary> /// /// <param name="createSubnetRequest">Container for the necessary parameters to execute the CreateSubnet service method on AmazonEC2.</param> /// /// <returns>The response from the CreateSubnet service method, as returned by AmazonEC2.</returns> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<CreateSubnetResponse> CreateSubnetAsync(CreateSubnetRequest createSubnetRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateSubnetRequestMarshaller(); var unmarshaller = CreateSubnetResponseUnmarshaller.GetInstance(); return Invoke<IRequest, CreateSubnetRequest, CreateSubnetResponse>(createSubnetRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal CreateSubnetResponse CreateSubnet(CreateSubnetRequest request) { var task = CreateSubnetAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Initiates the asynchronous execution of the CreateSubnet operation. /// <seealso cref="Amazon.EC2.IAmazonEC2.CreateSubnet"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateSubnet operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public async Task<CreateSubnetResponse> CreateSubnetAsync(CreateSubnetRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateSubnetRequestMarshaller(); var unmarshaller = CreateSubnetResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, CreateSubnetRequest, CreateSubnetResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// <para> Creates a subnet in an existing VPC. You can create up to 20 subnets in a VPC. If you add more than one subnet to a VPC, they're set /// up in a star topology with a logical router in the middle. When you create each subnet, you provide the VPC ID and the CIDR block you want /// for the subnet. Once you create a subnet, you can't change its CIDR block. The subnet's CIDR block can be the same as the VPC's CIDR block /// (assuming you want only a single subnet in the VPC), or a subset of the VPC's CIDR block. If you create more than one subnet in a VPC, the /// subnets' CIDR blocks must not overlap. The smallest subnet (and VPC) you can create uses a <c>/28</c> netmask (16 IP addresses), and the /// largest uses a <c>/18</c> netmask (16,384 IP addresses). </para> <para><b>IMPORTANT:</b> AWS reserves both the first four and the last IP /// address in each subnet's CIDR block. They're not available for use. </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateSubnet service method on AmazonEC2.</param> /// /// <returns>The response from the CreateSubnet service method, as returned by AmazonEC2.</returns> public CreateSubnetResponse CreateSubnet(CreateSubnetRequest request) { var task = CreateSubnetAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
private Amazon.EC2.Model.CreateSubnetResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.CreateSubnetRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "CreateSubnet"); try { #if DESKTOP return(client.CreateSubnet(request)); #elif CORECLR return(client.CreateSubnetAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }