Esempio n. 1
0
 private Amazon.IoTEvents.Model.CreateDetectorModelResponse CallAWSServiceOperation(IAmazonIoTEvents client, Amazon.IoTEvents.Model.CreateDetectorModelRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT Events", "CreateDetectorModel");
     try
     {
         #if DESKTOP
         return(client.CreateDetectorModel(request));
         #elif CORECLR
         return(client.CreateDetectorModelAsync(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;
     }
 }
Esempio n. 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.IoTEvents.Model.CreateDetectorModelRequest();


            // populate DetectorModelDefinition
            var requestDetectorModelDefinitionIsNull = true;

            request.DetectorModelDefinition = new Amazon.IoTEvents.Model.DetectorModelDefinition();
            System.String requestDetectorModelDefinition_detectorModelDefinition_InitialStateName = null;
            if (cmdletContext.DetectorModelDefinition_InitialStateName != null)
            {
                requestDetectorModelDefinition_detectorModelDefinition_InitialStateName = cmdletContext.DetectorModelDefinition_InitialStateName;
            }
            if (requestDetectorModelDefinition_detectorModelDefinition_InitialStateName != null)
            {
                request.DetectorModelDefinition.InitialStateName = requestDetectorModelDefinition_detectorModelDefinition_InitialStateName;
                requestDetectorModelDefinitionIsNull             = false;
            }
            List <Amazon.IoTEvents.Model.State> requestDetectorModelDefinition_detectorModelDefinition_State = null;

            if (cmdletContext.DetectorModelDefinition_State != null)
            {
                requestDetectorModelDefinition_detectorModelDefinition_State = cmdletContext.DetectorModelDefinition_State;
            }
            if (requestDetectorModelDefinition_detectorModelDefinition_State != null)
            {
                request.DetectorModelDefinition.States = requestDetectorModelDefinition_detectorModelDefinition_State;
                requestDetectorModelDefinitionIsNull   = false;
            }
            // determine if request.DetectorModelDefinition should be set to null
            if (requestDetectorModelDefinitionIsNull)
            {
                request.DetectorModelDefinition = null;
            }
            if (cmdletContext.DetectorModelDescription != null)
            {
                request.DetectorModelDescription = cmdletContext.DetectorModelDescription;
            }
            if (cmdletContext.DetectorModelName != null)
            {
                request.DetectorModelName = cmdletContext.DetectorModelName;
            }
            if (cmdletContext.EvaluationMethod != null)
            {
                request.EvaluationMethod = cmdletContext.EvaluationMethod;
            }
            if (cmdletContext.Key != null)
            {
                request.Key = cmdletContext.Key;
            }
            if (cmdletContext.RoleArn != null)
            {
                request.RoleArn = cmdletContext.RoleArn;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

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