protected override void ProcessRecord() { base.ProcessRecord(); if (!ConfirmShouldProceed(this.Force.IsPresent, this.TableName, "New-DDBTable (CreateTable)")) { return; } var context = new CmdletContext { TableName = this.TableName, SchemaObject = DDBSchemaCmdletHelper.TableSchemaFromParameter(Schema), ReadCapacityUnits = this.ReadCapacity, WriteCapacityUnits = this.WriteCapacity }; if (ParameterWasBound(nameof(this.Select))) { context.Select = CreateSelectDelegate <Amazon.DynamoDBv2.Model.CreateTableResponse, NewDDBTableCmdlet>(Select) ?? throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select)); } var output = Execute(context) as CmdletOutput; ProcessOutput(output); }
protected override void ProcessRecord() { base.ProcessRecord(); try { var schemaObj = DDBSchemaCmdletHelper.TableSchemaFromParameter(Schema); if (schemaObj == null) { throw new ArgumentException("Expected TableSchema object to update."); } if (this.Global.IsPresent) { if (string.IsNullOrEmpty(RangeKeyName) && string.IsNullOrEmpty(HashKeyName)) { throw new ArgumentNullException("Either RangeKeyName or HashKeyName needs to be specified for a global secondary index."); } if (ReadCapacity.HasValue && WriteCapacity.HasValue) { schemaObj.SetGlobalSecondaryIndex(IndexName, HashKeyName, HashKeyDataType, RangeKeyName, RangeKeyDataType, ReadCapacity.Value, WriteCapacity.Value, ProjectionType, NonKeyAttribute); } else { throw new ArgumentNullException( "Both ReadCapacity and WriteCapacity must be specified for a global secondary index."); } } else { schemaObj.SetLocalSecondaryIndex(IndexName, RangeKeyName, RangeKeyDataType, ProjectionType, NonKeyAttribute); } WriteObject(schemaObj); } catch (Exception e) { ThrowError(e); } }
protected override void ProcessRecord() { base.ProcessRecord(); try { var schemaObj = DDBSchemaCmdletHelper.TableSchemaFromParameter(Schema); if (schemaObj == null) { throw new ArgumentException("Expected TableSchema object to update."); } var keyType = !string.IsNullOrEmpty(KeyType) ? KeyType : Amazon.DynamoDBv2.KeyType.HASH; schemaObj.AddKey(KeyName, keyType, KeyDataType); WriteObject(schemaObj); } catch (Exception e) { ThrowError(e); } }