Exemplo n.º 1
0
 private Amazon.LexModelsV2.Model.CreateBotResponse CallAWSServiceOperation(IAmazonLexModelsV2 client, Amazon.LexModelsV2.Model.CreateBotRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lex Model Building V2", "CreateBot");
     try
     {
         #if DESKTOP
         return(client.CreateBot(request));
         #elif CORECLR
         return(client.CreateBotAsync(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;
     }
 }
Exemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.LexModelsV2.Model.CreateBotRequest();

            if (cmdletContext.BotName != null)
            {
                request.BotName = cmdletContext.BotName;
            }
            if (cmdletContext.BotTag != null)
            {
                request.BotTags = cmdletContext.BotTag;
            }

            // populate DataPrivacy
            var requestDataPrivacyIsNull = true;

            request.DataPrivacy = new Amazon.LexModelsV2.Model.DataPrivacy();
            System.Boolean?requestDataPrivacy_dataPrivacy_ChildDirected = null;
            if (cmdletContext.DataPrivacy_ChildDirected != null)
            {
                requestDataPrivacy_dataPrivacy_ChildDirected = cmdletContext.DataPrivacy_ChildDirected.Value;
            }
            if (requestDataPrivacy_dataPrivacy_ChildDirected != null)
            {
                request.DataPrivacy.ChildDirected = requestDataPrivacy_dataPrivacy_ChildDirected.Value;
                requestDataPrivacyIsNull          = false;
            }
            // determine if request.DataPrivacy should be set to null
            if (requestDataPrivacyIsNull)
            {
                request.DataPrivacy = null;
            }
            if (cmdletContext.Description != null)
            {
                request.Description = cmdletContext.Description;
            }
            if (cmdletContext.IdleSessionTTLInSecond != null)
            {
                request.IdleSessionTTLInSeconds = cmdletContext.IdleSessionTTLInSecond.Value;
            }
            if (cmdletContext.RoleArn != null)
            {
                request.RoleArn = cmdletContext.RoleArn;
            }
            if (cmdletContext.TestBotAliasTag != null)
            {
                request.TestBotAliasTags = cmdletContext.TestBotAliasTag;
            }

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