Beispiel #1
0
 private Amazon.Lex.Model.PutSessionResponse CallAWSServiceOperation(IAmazonLex client, Amazon.Lex.Model.PutSessionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lex", "PutSession");
     try
     {
         #if DESKTOP
         return(client.PutSession(request));
         #elif CORECLR
         return(client.PutSessionAsync(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;
     }
 }
Beispiel #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Lex.Model.PutSessionRequest();

            if (cmdletContext.Accept != null)
            {
                request.Accept = cmdletContext.Accept;
            }
            if (cmdletContext.ActiveContext != null)
            {
                request.ActiveContexts = cmdletContext.ActiveContext;
            }
            if (cmdletContext.BotAlias != null)
            {
                request.BotAlias = cmdletContext.BotAlias;
            }
            if (cmdletContext.BotName != null)
            {
                request.BotName = cmdletContext.BotName;
            }

            // populate DialogAction
            var requestDialogActionIsNull = true;

            request.DialogAction = new Amazon.Lex.Model.DialogAction();
            Amazon.Lex.FulfillmentState requestDialogAction_dialogAction_FulfillmentState = null;
            if (cmdletContext.DialogAction_FulfillmentState != null)
            {
                requestDialogAction_dialogAction_FulfillmentState = cmdletContext.DialogAction_FulfillmentState;
            }
            if (requestDialogAction_dialogAction_FulfillmentState != null)
            {
                request.DialogAction.FulfillmentState = requestDialogAction_dialogAction_FulfillmentState;
                requestDialogActionIsNull             = false;
            }
            System.String requestDialogAction_dialogAction_IntentName = null;
            if (cmdletContext.DialogAction_IntentName != null)
            {
                requestDialogAction_dialogAction_IntentName = cmdletContext.DialogAction_IntentName;
            }
            if (requestDialogAction_dialogAction_IntentName != null)
            {
                request.DialogAction.IntentName = requestDialogAction_dialogAction_IntentName;
                requestDialogActionIsNull       = false;
            }
            System.String requestDialogAction_dialogAction_Message = null;
            if (cmdletContext.DialogAction_Message != null)
            {
                requestDialogAction_dialogAction_Message = cmdletContext.DialogAction_Message;
            }
            if (requestDialogAction_dialogAction_Message != null)
            {
                request.DialogAction.Message = requestDialogAction_dialogAction_Message;
                requestDialogActionIsNull    = false;
            }
            Amazon.Lex.MessageFormatType requestDialogAction_dialogAction_MessageFormat = null;
            if (cmdletContext.DialogAction_MessageFormat != null)
            {
                requestDialogAction_dialogAction_MessageFormat = cmdletContext.DialogAction_MessageFormat;
            }
            if (requestDialogAction_dialogAction_MessageFormat != null)
            {
                request.DialogAction.MessageFormat = requestDialogAction_dialogAction_MessageFormat;
                requestDialogActionIsNull          = false;
            }
            Dictionary <System.String, System.String> requestDialogAction_dialogAction_Slot = null;

            if (cmdletContext.DialogAction_Slot != null)
            {
                requestDialogAction_dialogAction_Slot = cmdletContext.DialogAction_Slot;
            }
            if (requestDialogAction_dialogAction_Slot != null)
            {
                request.DialogAction.Slots = requestDialogAction_dialogAction_Slot;
                requestDialogActionIsNull  = false;
            }
            System.String requestDialogAction_dialogAction_SlotToElicit = null;
            if (cmdletContext.DialogAction_SlotToElicit != null)
            {
                requestDialogAction_dialogAction_SlotToElicit = cmdletContext.DialogAction_SlotToElicit;
            }
            if (requestDialogAction_dialogAction_SlotToElicit != null)
            {
                request.DialogAction.SlotToElicit = requestDialogAction_dialogAction_SlotToElicit;
                requestDialogActionIsNull         = false;
            }
            Amazon.Lex.DialogActionType requestDialogAction_dialogAction_Type = null;
            if (cmdletContext.DialogAction_Type != null)
            {
                requestDialogAction_dialogAction_Type = cmdletContext.DialogAction_Type;
            }
            if (requestDialogAction_dialogAction_Type != null)
            {
                request.DialogAction.Type = requestDialogAction_dialogAction_Type;
                requestDialogActionIsNull = false;
            }
            // determine if request.DialogAction should be set to null
            if (requestDialogActionIsNull)
            {
                request.DialogAction = null;
            }
            if (cmdletContext.RecentIntentSummaryView != null)
            {
                request.RecentIntentSummaryView = cmdletContext.RecentIntentSummaryView;
            }
            if (cmdletContext.SessionAttribute != null)
            {
                request.SessionAttributes = cmdletContext.SessionAttribute;
            }
            if (cmdletContext.UserId != null)
            {
                request.UserId = cmdletContext.UserId;
            }

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