Пример #1
0
 private Amazon.IoTSecureTunneling.Model.OpenTunnelResponse CallAWSServiceOperation(IAmazonIoTSecureTunneling client, Amazon.IoTSecureTunneling.Model.OpenTunnelRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT Secure Tunneling", "OpenTunnel");
     try
     {
         #if DESKTOP
         return(client.OpenTunnel(request));
         #elif CORECLR
         return(client.OpenTunnelAsync(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;
     }
 }
Пример #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoTSecureTunneling.Model.OpenTunnelRequest();

            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }

            // populate DestinationConfig
            var requestDestinationConfigIsNull = true;

            request.DestinationConfig = new Amazon.IoTSecureTunneling.Model.DestinationConfig();
            List <System.String> requestDestinationConfig_destinationConfig_Service = null;

            if (cmdletContext.DestinationConfig_Service != null)
            {
                requestDestinationConfig_destinationConfig_Service = cmdletContext.DestinationConfig_Service;
            }
            if (requestDestinationConfig_destinationConfig_Service != null)
            {
                request.DestinationConfig.Services = requestDestinationConfig_destinationConfig_Service;
                requestDestinationConfigIsNull     = false;
            }
            System.String requestDestinationConfig_destinationConfig_ThingName = null;
            if (cmdletContext.DestinationConfig_ThingName != null)
            {
                requestDestinationConfig_destinationConfig_ThingName = cmdletContext.DestinationConfig_ThingName;
            }
            if (requestDestinationConfig_destinationConfig_ThingName != null)
            {
                request.DestinationConfig.ThingName = requestDestinationConfig_destinationConfig_ThingName;
                requestDestinationConfigIsNull      = false;
            }
            // determine if request.DestinationConfig should be set to null
            if (requestDestinationConfigIsNull)
            {
                request.DestinationConfig = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            // populate TimeoutConfig
            var requestTimeoutConfigIsNull = true;

            request.TimeoutConfig = new Amazon.IoTSecureTunneling.Model.TimeoutConfig();
            System.Int32?requestTimeoutConfig_timeoutConfig_MaxLifetimeTimeoutMinute = null;
            if (cmdletContext.TimeoutConfig_MaxLifetimeTimeoutMinute != null)
            {
                requestTimeoutConfig_timeoutConfig_MaxLifetimeTimeoutMinute = cmdletContext.TimeoutConfig_MaxLifetimeTimeoutMinute.Value;
            }
            if (requestTimeoutConfig_timeoutConfig_MaxLifetimeTimeoutMinute != null)
            {
                request.TimeoutConfig.MaxLifetimeTimeoutMinutes = requestTimeoutConfig_timeoutConfig_MaxLifetimeTimeoutMinute.Value;
                requestTimeoutConfigIsNull = false;
            }
            // determine if request.TimeoutConfig should be set to null
            if (requestTimeoutConfigIsNull)
            {
                request.TimeoutConfig = null;
            }

            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);
        }