public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.Connect.Model.CreateInstanceRequest(); if (cmdletContext.ClientToken != null) { request.ClientToken = cmdletContext.ClientToken; } if (cmdletContext.DirectoryId != null) { request.DirectoryId = cmdletContext.DirectoryId; } if (cmdletContext.IdentityManagementType != null) { request.IdentityManagementType = cmdletContext.IdentityManagementType; } if (cmdletContext.InboundCallsEnabled != null) { request.InboundCallsEnabled = cmdletContext.InboundCallsEnabled.Value; } if (cmdletContext.InstanceAlias != null) { request.InstanceAlias = cmdletContext.InstanceAlias; } if (cmdletContext.OutboundCallsEnabled != null) { request.OutboundCallsEnabled = cmdletContext.OutboundCallsEnabled.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.Connect.Model.CreateInstanceResponse CallAWSServiceOperation(IAmazonConnect client, Amazon.Connect.Model.CreateInstanceRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Connect Service", "CreateInstance"); try { #if DESKTOP return(client.CreateInstance(request)); #elif CORECLR return(client.CreateInstanceAsync(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; } }