private Amazon.QLDBSession.Model.SendCommandResponse CallAWSServiceOperation(IAmazonQLDBSession client, Amazon.QLDBSession.Model.SendCommandRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon QLDB Session", "SendCommand");
     try
     {
         #if DESKTOP
         return(client.SendCommand(request));
         #elif CORECLR
         return(client.SendCommandAsync(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;
     }
 }
        public object Execute(ExecutorContext context)
        {
            System.IO.MemoryStream _CommitTransaction_CommitDigestStream = null;

            try
            {
                var cmdletContext = context as CmdletContext;
                // create request
                var request = new Amazon.QLDBSession.Model.SendCommandRequest();

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

                // populate CommitTransaction
                var requestCommitTransactionIsNull = true;
                request.CommitTransaction = new Amazon.QLDBSession.Model.CommitTransactionRequest();
                System.IO.MemoryStream requestCommitTransaction_commitTransaction_CommitDigest = null;
                if (cmdletContext.CommitTransaction_CommitDigest != null)
                {
                    _CommitTransaction_CommitDigestStream = new System.IO.MemoryStream(cmdletContext.CommitTransaction_CommitDigest);
                    requestCommitTransaction_commitTransaction_CommitDigest = _CommitTransaction_CommitDigestStream;
                }
                if (requestCommitTransaction_commitTransaction_CommitDigest != null)
                {
                    request.CommitTransaction.CommitDigest = requestCommitTransaction_commitTransaction_CommitDigest;
                    requestCommitTransactionIsNull         = false;
                }
                System.String requestCommitTransaction_commitTransaction_TransactionId = null;
                if (cmdletContext.CommitTransaction_TransactionId != null)
                {
                    requestCommitTransaction_commitTransaction_TransactionId = cmdletContext.CommitTransaction_TransactionId;
                }
                if (requestCommitTransaction_commitTransaction_TransactionId != null)
                {
                    request.CommitTransaction.TransactionId = requestCommitTransaction_commitTransaction_TransactionId;
                    requestCommitTransactionIsNull          = false;
                }
                // determine if request.CommitTransaction should be set to null
                if (requestCommitTransactionIsNull)
                {
                    request.CommitTransaction = null;
                }
                if (cmdletContext.EndSession != null)
                {
                    request.EndSession = cmdletContext.EndSession;
                }

                // populate ExecuteStatement
                var requestExecuteStatementIsNull = true;
                request.ExecuteStatement = new Amazon.QLDBSession.Model.ExecuteStatementRequest();
                List <Amazon.QLDBSession.Model.ValueHolder> requestExecuteStatement_executeStatement_Parameter = null;
                if (cmdletContext.ExecuteStatement_Parameter != null)
                {
                    requestExecuteStatement_executeStatement_Parameter = cmdletContext.ExecuteStatement_Parameter;
                }
                if (requestExecuteStatement_executeStatement_Parameter != null)
                {
                    request.ExecuteStatement.Parameters = requestExecuteStatement_executeStatement_Parameter;
                    requestExecuteStatementIsNull       = false;
                }
                System.String requestExecuteStatement_executeStatement_Statement = null;
                if (cmdletContext.ExecuteStatement_Statement != null)
                {
                    requestExecuteStatement_executeStatement_Statement = cmdletContext.ExecuteStatement_Statement;
                }
                if (requestExecuteStatement_executeStatement_Statement != null)
                {
                    request.ExecuteStatement.Statement = requestExecuteStatement_executeStatement_Statement;
                    requestExecuteStatementIsNull      = false;
                }
                System.String requestExecuteStatement_executeStatement_TransactionId = null;
                if (cmdletContext.ExecuteStatement_TransactionId != null)
                {
                    requestExecuteStatement_executeStatement_TransactionId = cmdletContext.ExecuteStatement_TransactionId;
                }
                if (requestExecuteStatement_executeStatement_TransactionId != null)
                {
                    request.ExecuteStatement.TransactionId = requestExecuteStatement_executeStatement_TransactionId;
                    requestExecuteStatementIsNull          = false;
                }
                // determine if request.ExecuteStatement should be set to null
                if (requestExecuteStatementIsNull)
                {
                    request.ExecuteStatement = null;
                }

                // populate FetchPage
                var requestFetchPageIsNull = true;
                request.FetchPage = new Amazon.QLDBSession.Model.FetchPageRequest();
                System.String requestFetchPage_fetchPage_NextPageToken = null;
                if (cmdletContext.FetchPage_NextPageToken != null)
                {
                    requestFetchPage_fetchPage_NextPageToken = cmdletContext.FetchPage_NextPageToken;
                }
                if (requestFetchPage_fetchPage_NextPageToken != null)
                {
                    request.FetchPage.NextPageToken = requestFetchPage_fetchPage_NextPageToken;
                    requestFetchPageIsNull          = false;
                }
                System.String requestFetchPage_fetchPage_TransactionId = null;
                if (cmdletContext.FetchPage_TransactionId != null)
                {
                    requestFetchPage_fetchPage_TransactionId = cmdletContext.FetchPage_TransactionId;
                }
                if (requestFetchPage_fetchPage_TransactionId != null)
                {
                    request.FetchPage.TransactionId = requestFetchPage_fetchPage_TransactionId;
                    requestFetchPageIsNull          = false;
                }
                // determine if request.FetchPage should be set to null
                if (requestFetchPageIsNull)
                {
                    request.FetchPage = null;
                }
                if (cmdletContext.QLDBSessionToken != null)
                {
                    request.SessionToken = cmdletContext.QLDBSessionToken;
                }

                // populate StartSession
                var requestStartSessionIsNull = true;
                request.StartSession = new Amazon.QLDBSession.Model.StartSessionRequest();
                System.String requestStartSession_startSession_LedgerName = null;
                if (cmdletContext.StartSession_LedgerName != null)
                {
                    requestStartSession_startSession_LedgerName = cmdletContext.StartSession_LedgerName;
                }
                if (requestStartSession_startSession_LedgerName != null)
                {
                    request.StartSession.LedgerName = requestStartSession_startSession_LedgerName;
                    requestStartSessionIsNull       = false;
                }
                // determine if request.StartSession should be set to null
                if (requestStartSessionIsNull)
                {
                    request.StartSession = null;
                }
                if (cmdletContext.StartTransaction != null)
                {
                    request.StartTransaction = cmdletContext.StartTransaction;
                }

                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);
            }
            finally
            {
                if (_CommitTransaction_CommitDigestStream != null)
                {
                    _CommitTransaction_CommitDigestStream.Dispose();
                }
            }
        }