Ejemplo n.º 1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.DynamoDBv2.Model.UpdateTableRequest();

            if (cmdletContext.AttributeDefinition != null)
            {
                request.AttributeDefinitions = cmdletContext.AttributeDefinition;
            }
            if (cmdletContext.BillingMode != null)
            {
                request.BillingMode = cmdletContext.BillingMode;
            }
            if (cmdletContext.GlobalSecondaryIndexUpdate != null)
            {
                request.GlobalSecondaryIndexUpdates = cmdletContext.GlobalSecondaryIndexUpdate;
            }

            // populate ProvisionedThroughput
            var requestProvisionedThroughputIsNull = true;

            request.ProvisionedThroughput = new Amazon.DynamoDBv2.Model.ProvisionedThroughput();
            System.Int64?requestProvisionedThroughput_readCapacity = null;
            if (cmdletContext.ReadCapacity != null)
            {
                requestProvisionedThroughput_readCapacity = cmdletContext.ReadCapacity.Value;
            }
            if (requestProvisionedThroughput_readCapacity != null)
            {
                request.ProvisionedThroughput.ReadCapacityUnits = requestProvisionedThroughput_readCapacity.Value;
                requestProvisionedThroughputIsNull = false;
            }
            System.Int64?requestProvisionedThroughput_writeCapacity = null;
            if (cmdletContext.WriteCapacity != null)
            {
                requestProvisionedThroughput_writeCapacity = cmdletContext.WriteCapacity.Value;
            }
            if (requestProvisionedThroughput_writeCapacity != null)
            {
                request.ProvisionedThroughput.WriteCapacityUnits = requestProvisionedThroughput_writeCapacity.Value;
                requestProvisionedThroughputIsNull = false;
            }
            // determine if request.ProvisionedThroughput should be set to null
            if (requestProvisionedThroughputIsNull)
            {
                request.ProvisionedThroughput = null;
            }
            if (cmdletContext.ReplicaUpdate != null)
            {
                request.ReplicaUpdates = cmdletContext.ReplicaUpdate;
            }

            // populate SSESpecification
            var requestSSESpecificationIsNull = true;

            request.SSESpecification = new Amazon.DynamoDBv2.Model.SSESpecification();
            System.Boolean?requestSSESpecification_sSESpecification_Enabled = null;
            if (cmdletContext.SSESpecification_Enabled != null)
            {
                requestSSESpecification_sSESpecification_Enabled = cmdletContext.SSESpecification_Enabled.Value;
            }
            if (requestSSESpecification_sSESpecification_Enabled != null)
            {
                request.SSESpecification.Enabled = requestSSESpecification_sSESpecification_Enabled.Value;
                requestSSESpecificationIsNull    = false;
            }
            System.String requestSSESpecification_sSESpecification_KMSMasterKeyId = null;
            if (cmdletContext.SSESpecification_KMSMasterKeyId != null)
            {
                requestSSESpecification_sSESpecification_KMSMasterKeyId = cmdletContext.SSESpecification_KMSMasterKeyId;
            }
            if (requestSSESpecification_sSESpecification_KMSMasterKeyId != null)
            {
                request.SSESpecification.KMSMasterKeyId = requestSSESpecification_sSESpecification_KMSMasterKeyId;
                requestSSESpecificationIsNull           = false;
            }
            Amazon.DynamoDBv2.SSEType requestSSESpecification_sSESpecification_SSEType = null;
            if (cmdletContext.SSESpecification_SSEType != null)
            {
                requestSSESpecification_sSESpecification_SSEType = cmdletContext.SSESpecification_SSEType;
            }
            if (requestSSESpecification_sSESpecification_SSEType != null)
            {
                request.SSESpecification.SSEType = requestSSESpecification_sSESpecification_SSEType;
                requestSSESpecificationIsNull    = false;
            }
            // determine if request.SSESpecification should be set to null
            if (requestSSESpecificationIsNull)
            {
                request.SSESpecification = null;
            }

            // populate StreamSpecification
            var requestStreamSpecificationIsNull = true;

            request.StreamSpecification = new Amazon.DynamoDBv2.Model.StreamSpecification();
            System.Boolean?requestStreamSpecification_streamSpecification_StreamEnabled = null;
            if (cmdletContext.StreamSpecification_StreamEnabled != null)
            {
                requestStreamSpecification_streamSpecification_StreamEnabled = cmdletContext.StreamSpecification_StreamEnabled.Value;
            }
            if (requestStreamSpecification_streamSpecification_StreamEnabled != null)
            {
                request.StreamSpecification.StreamEnabled = requestStreamSpecification_streamSpecification_StreamEnabled.Value;
                requestStreamSpecificationIsNull          = false;
            }
            Amazon.DynamoDBv2.StreamViewType requestStreamSpecification_streamSpecification_StreamViewType = null;
            if (cmdletContext.StreamSpecification_StreamViewType != null)
            {
                requestStreamSpecification_streamSpecification_StreamViewType = cmdletContext.StreamSpecification_StreamViewType;
            }
            if (requestStreamSpecification_streamSpecification_StreamViewType != null)
            {
                request.StreamSpecification.StreamViewType = requestStreamSpecification_streamSpecification_StreamViewType;
                requestStreamSpecificationIsNull           = false;
            }
            // determine if request.StreamSpecification should be set to null
            if (requestStreamSpecificationIsNull)
            {
                request.StreamSpecification = null;
            }
            if (cmdletContext.TableClass != null)
            {
                request.TableClass = cmdletContext.TableClass;
            }
            if (cmdletContext.TableName != null)
            {
                request.TableName = cmdletContext.TableName;
            }

            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);
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.DynamoDBv2.Model.RestoreTableToPointInTimeRequest();

            if (cmdletContext.BillingModeOverride != null)
            {
                request.BillingModeOverride = cmdletContext.BillingModeOverride;
            }
            if (cmdletContext.GlobalSecondaryIndexOverride != null)
            {
                request.GlobalSecondaryIndexOverride = cmdletContext.GlobalSecondaryIndexOverride;
            }
            if (cmdletContext.LocalSecondaryIndexOverride != null)
            {
                request.LocalSecondaryIndexOverride = cmdletContext.LocalSecondaryIndexOverride;
            }

            // populate ProvisionedThroughputOverride
            var requestProvisionedThroughputOverrideIsNull = true;

            request.ProvisionedThroughputOverride = new Amazon.DynamoDBv2.Model.ProvisionedThroughput();
            System.Int64?requestProvisionedThroughputOverride_provisionedThroughputOverride_ReadCapacityUnit = null;
            if (cmdletContext.ProvisionedThroughputOverride_ReadCapacityUnit != null)
            {
                requestProvisionedThroughputOverride_provisionedThroughputOverride_ReadCapacityUnit = cmdletContext.ProvisionedThroughputOverride_ReadCapacityUnit.Value;
            }
            if (requestProvisionedThroughputOverride_provisionedThroughputOverride_ReadCapacityUnit != null)
            {
                request.ProvisionedThroughputOverride.ReadCapacityUnits = requestProvisionedThroughputOverride_provisionedThroughputOverride_ReadCapacityUnit.Value;
                requestProvisionedThroughputOverrideIsNull = false;
            }
            System.Int64?requestProvisionedThroughputOverride_provisionedThroughputOverride_WriteCapacityUnit = null;
            if (cmdletContext.ProvisionedThroughputOverride_WriteCapacityUnit != null)
            {
                requestProvisionedThroughputOverride_provisionedThroughputOverride_WriteCapacityUnit = cmdletContext.ProvisionedThroughputOverride_WriteCapacityUnit.Value;
            }
            if (requestProvisionedThroughputOverride_provisionedThroughputOverride_WriteCapacityUnit != null)
            {
                request.ProvisionedThroughputOverride.WriteCapacityUnits = requestProvisionedThroughputOverride_provisionedThroughputOverride_WriteCapacityUnit.Value;
                requestProvisionedThroughputOverrideIsNull = false;
            }
            // determine if request.ProvisionedThroughputOverride should be set to null
            if (requestProvisionedThroughputOverrideIsNull)
            {
                request.ProvisionedThroughputOverride = null;
            }
            if (cmdletContext.RestoreDateTime != null)
            {
                request.RestoreDateTime = cmdletContext.RestoreDateTime.Value;
            }
            if (cmdletContext.SourceTableArn != null)
            {
                request.SourceTableArn = cmdletContext.SourceTableArn;
            }
            if (cmdletContext.SourceTableName != null)
            {
                request.SourceTableName = cmdletContext.SourceTableName;
            }

            // populate SSESpecificationOverride
            var requestSSESpecificationOverrideIsNull = true;

            request.SSESpecificationOverride = new Amazon.DynamoDBv2.Model.SSESpecification();
            System.Boolean?requestSSESpecificationOverride_sSESpecificationOverride_Enabled = null;
            if (cmdletContext.SSESpecificationOverride_Enabled != null)
            {
                requestSSESpecificationOverride_sSESpecificationOverride_Enabled = cmdletContext.SSESpecificationOverride_Enabled.Value;
            }
            if (requestSSESpecificationOverride_sSESpecificationOverride_Enabled != null)
            {
                request.SSESpecificationOverride.Enabled = requestSSESpecificationOverride_sSESpecificationOverride_Enabled.Value;
                requestSSESpecificationOverrideIsNull    = false;
            }
            System.String requestSSESpecificationOverride_sSESpecificationOverride_KMSMasterKeyId = null;
            if (cmdletContext.SSESpecificationOverride_KMSMasterKeyId != null)
            {
                requestSSESpecificationOverride_sSESpecificationOverride_KMSMasterKeyId = cmdletContext.SSESpecificationOverride_KMSMasterKeyId;
            }
            if (requestSSESpecificationOverride_sSESpecificationOverride_KMSMasterKeyId != null)
            {
                request.SSESpecificationOverride.KMSMasterKeyId = requestSSESpecificationOverride_sSESpecificationOverride_KMSMasterKeyId;
                requestSSESpecificationOverrideIsNull           = false;
            }
            Amazon.DynamoDBv2.SSEType requestSSESpecificationOverride_sSESpecificationOverride_SSEType = null;
            if (cmdletContext.SSESpecificationOverride_SSEType != null)
            {
                requestSSESpecificationOverride_sSESpecificationOverride_SSEType = cmdletContext.SSESpecificationOverride_SSEType;
            }
            if (requestSSESpecificationOverride_sSESpecificationOverride_SSEType != null)
            {
                request.SSESpecificationOverride.SSEType = requestSSESpecificationOverride_sSESpecificationOverride_SSEType;
                requestSSESpecificationOverrideIsNull    = false;
            }
            // determine if request.SSESpecificationOverride should be set to null
            if (requestSSESpecificationOverrideIsNull)
            {
                request.SSESpecificationOverride = null;
            }
            if (cmdletContext.TargetTableName != null)
            {
                request.TargetTableName = cmdletContext.TargetTableName;
            }
            if (cmdletContext.UseLatestRestorableTime != null)
            {
                request.UseLatestRestorableTime = cmdletContext.UseLatestRestorableTime.Value;
            }

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