Пример #1
0
 private Amazon.LexRuntimeV2.Model.PutSessionResponse CallAWSServiceOperation(IAmazonLexRuntimeV2 client, Amazon.LexRuntimeV2.Model.PutSessionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lex Runtime V2", "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;
     }
 }
Пример #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.LexRuntimeV2.Model.PutSessionRequest();

            if (cmdletContext.BotAliasId != null)
            {
                request.BotAliasId = cmdletContext.BotAliasId;
            }
            if (cmdletContext.BotId != null)
            {
                request.BotId = cmdletContext.BotId;
            }
            if (cmdletContext.LocaleId != null)
            {
                request.LocaleId = cmdletContext.LocaleId;
            }
            if (cmdletContext.Message != null)
            {
                request.Messages = cmdletContext.Message;
            }
            if (cmdletContext.RequestAttribute != null)
            {
                request.RequestAttributes = cmdletContext.RequestAttribute;
            }
            if (cmdletContext.ResponseContentType != null)
            {
                request.ResponseContentType = cmdletContext.ResponseContentType;
            }
            if (cmdletContext.SessionId != null)
            {
                request.SessionId = cmdletContext.SessionId;
            }

            // populate SessionStateValue
            var requestSessionStateValueIsNull = true;

            request.SessionStateValue = new Amazon.LexRuntimeV2.Model.SessionState();
            List <Amazon.LexRuntimeV2.Model.ActiveContext> requestSessionStateValue_sessionStateValue_ActiveContext = null;

            if (cmdletContext.SessionStateValue_ActiveContext != null)
            {
                requestSessionStateValue_sessionStateValue_ActiveContext = cmdletContext.SessionStateValue_ActiveContext;
            }
            if (requestSessionStateValue_sessionStateValue_ActiveContext != null)
            {
                request.SessionStateValue.ActiveContexts = requestSessionStateValue_sessionStateValue_ActiveContext;
                requestSessionStateValueIsNull           = false;
            }
            System.String requestSessionStateValue_sessionStateValue_OriginatingRequestId = null;
            if (cmdletContext.SessionStateValue_OriginatingRequestId != null)
            {
                requestSessionStateValue_sessionStateValue_OriginatingRequestId = cmdletContext.SessionStateValue_OriginatingRequestId;
            }
            if (requestSessionStateValue_sessionStateValue_OriginatingRequestId != null)
            {
                request.SessionStateValue.OriginatingRequestId = requestSessionStateValue_sessionStateValue_OriginatingRequestId;
                requestSessionStateValueIsNull = false;
            }
            Dictionary <System.String, System.String> requestSessionStateValue_sessionStateValue_SessionAttribute = null;

            if (cmdletContext.SessionStateValue_SessionAttribute != null)
            {
                requestSessionStateValue_sessionStateValue_SessionAttribute = cmdletContext.SessionStateValue_SessionAttribute;
            }
            if (requestSessionStateValue_sessionStateValue_SessionAttribute != null)
            {
                request.SessionStateValue.SessionAttributes = requestSessionStateValue_sessionStateValue_SessionAttribute;
                requestSessionStateValueIsNull = false;
            }
            Amazon.LexRuntimeV2.Model.DialogAction requestSessionStateValue_sessionStateValue_DialogAction = null;

            // populate DialogAction
            var requestSessionStateValue_sessionStateValue_DialogActionIsNull = true;

            requestSessionStateValue_sessionStateValue_DialogAction = new Amazon.LexRuntimeV2.Model.DialogAction();
            Amazon.LexRuntimeV2.StyleType requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotElicitationStyle = null;
            if (cmdletContext.DialogAction_SlotElicitationStyle != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotElicitationStyle = cmdletContext.DialogAction_SlotElicitationStyle;
            }
            if (requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotElicitationStyle != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction.SlotElicitationStyle = requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotElicitationStyle;
                requestSessionStateValue_sessionStateValue_DialogActionIsNull = false;
            }
            System.String requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotToElicit = null;
            if (cmdletContext.DialogAction_SlotToElicit != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotToElicit = cmdletContext.DialogAction_SlotToElicit;
            }
            if (requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotToElicit != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction.SlotToElicit = requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_SlotToElicit;
                requestSessionStateValue_sessionStateValue_DialogActionIsNull        = false;
            }
            Amazon.LexRuntimeV2.DialogActionType requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_Type = null;
            if (cmdletContext.DialogAction_Type != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_Type = cmdletContext.DialogAction_Type;
            }
            if (requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_Type != null)
            {
                requestSessionStateValue_sessionStateValue_DialogAction.Type  = requestSessionStateValue_sessionStateValue_DialogAction_dialogAction_Type;
                requestSessionStateValue_sessionStateValue_DialogActionIsNull = false;
            }
            // determine if requestSessionStateValue_sessionStateValue_DialogAction should be set to null
            if (requestSessionStateValue_sessionStateValue_DialogActionIsNull)
            {
                requestSessionStateValue_sessionStateValue_DialogAction = null;
            }
            if (requestSessionStateValue_sessionStateValue_DialogAction != null)
            {
                request.SessionStateValue.DialogAction = requestSessionStateValue_sessionStateValue_DialogAction;
                requestSessionStateValueIsNull         = false;
            }
            Amazon.LexRuntimeV2.Model.Intent requestSessionStateValue_sessionStateValue_Intent = null;

            // populate Intent
            var requestSessionStateValue_sessionStateValue_IntentIsNull = true;

            requestSessionStateValue_sessionStateValue_Intent = new Amazon.LexRuntimeV2.Model.Intent();
            Amazon.LexRuntimeV2.ConfirmationState requestSessionStateValue_sessionStateValue_Intent_intent_ConfirmationState = null;
            if (cmdletContext.Intent_ConfirmationState != null)
            {
                requestSessionStateValue_sessionStateValue_Intent_intent_ConfirmationState = cmdletContext.Intent_ConfirmationState;
            }
            if (requestSessionStateValue_sessionStateValue_Intent_intent_ConfirmationState != null)
            {
                requestSessionStateValue_sessionStateValue_Intent.ConfirmationState = requestSessionStateValue_sessionStateValue_Intent_intent_ConfirmationState;
                requestSessionStateValue_sessionStateValue_IntentIsNull             = false;
            }
            System.String requestSessionStateValue_sessionStateValue_Intent_intent_Name = null;
            if (cmdletContext.Intent_Name != null)
            {
                requestSessionStateValue_sessionStateValue_Intent_intent_Name = cmdletContext.Intent_Name;
            }
            if (requestSessionStateValue_sessionStateValue_Intent_intent_Name != null)
            {
                requestSessionStateValue_sessionStateValue_Intent.Name  = requestSessionStateValue_sessionStateValue_Intent_intent_Name;
                requestSessionStateValue_sessionStateValue_IntentIsNull = false;
            }
            Dictionary <System.String, Amazon.LexRuntimeV2.Model.Slot> requestSessionStateValue_sessionStateValue_Intent_intent_Slot = null;

            if (cmdletContext.Intent_Slot != null)
            {
                requestSessionStateValue_sessionStateValue_Intent_intent_Slot = cmdletContext.Intent_Slot;
            }
            if (requestSessionStateValue_sessionStateValue_Intent_intent_Slot != null)
            {
                requestSessionStateValue_sessionStateValue_Intent.Slots = requestSessionStateValue_sessionStateValue_Intent_intent_Slot;
                requestSessionStateValue_sessionStateValue_IntentIsNull = false;
            }
            Amazon.LexRuntimeV2.IntentState requestSessionStateValue_sessionStateValue_Intent_intent_State = null;
            if (cmdletContext.Intent_State != null)
            {
                requestSessionStateValue_sessionStateValue_Intent_intent_State = cmdletContext.Intent_State;
            }
            if (requestSessionStateValue_sessionStateValue_Intent_intent_State != null)
            {
                requestSessionStateValue_sessionStateValue_Intent.State = requestSessionStateValue_sessionStateValue_Intent_intent_State;
                requestSessionStateValue_sessionStateValue_IntentIsNull = false;
            }
            // determine if requestSessionStateValue_sessionStateValue_Intent should be set to null
            if (requestSessionStateValue_sessionStateValue_IntentIsNull)
            {
                requestSessionStateValue_sessionStateValue_Intent = null;
            }
            if (requestSessionStateValue_sessionStateValue_Intent != null)
            {
                request.SessionStateValue.Intent = requestSessionStateValue_sessionStateValue_Intent;
                requestSessionStateValueIsNull   = false;
            }
            // determine if request.SessionStateValue should be set to null
            if (requestSessionStateValueIsNull)
            {
                request.SessionStateValue = 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);
        }