public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.EC2.Model.AllocateIpamPoolCidrRequest(); if (cmdletContext.Cidr != null) { request.Cidr = cmdletContext.Cidr; } if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.Description != null) { request.Description = cmdletContext.Description; } if (cmdletContext.DisallowedCidr != null) { request.DisallowedCidrs = cmdletContext.DisallowedCidr; } if (cmdletContext.IpamPoolId != null) { request.IpamPoolId = cmdletContext.IpamPoolId; } if (cmdletContext.NetmaskLength != null) { request.NetmaskLength = cmdletContext.NetmaskLength.Value; } if (cmdletContext.PreviewNextCidr != null) { request.PreviewNextCidr = cmdletContext.PreviewNextCidr.Value; } 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); }
private Amazon.EC2.Model.AllocateIpamPoolCidrResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.AllocateIpamPoolCidrRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "AllocateIpamPoolCidr"); try { #if DESKTOP return(client.AllocateIpamPoolCidr(request)); #elif CORECLR return(client.AllocateIpamPoolCidrAsync(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; } }