예제 #1
0
        public IRequest Marshall(UpdateTableRequest updateTableRequest)
        {
            IRequest request = new DefaultRequest(updateTableRequest, "AmazonDynamoDB");
            string   target  = "DynamoDB_20111205.UpdateTable";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (updateTableRequest != null && updateTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(updateTableRequest.TableName);
                }

                if (updateTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = updateTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
                return(request);
            }
        }
예제 #2
0
        public IRequest Marshall(UpdateTableRequest updateTableRequest)
        {
            IRequest request = new DefaultRequest(updateTableRequest, "AmazonDynamoDBv2");
            string   target  = "DynamoDB_20120810.UpdateTable";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.0";


            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                int    queryPosition = uriResourcePath.IndexOf("?", StringComparison.OrdinalIgnoreCase);
                string queryString   = uriResourcePath.Substring(queryPosition + 1);
                uriResourcePath = uriResourcePath.Substring(0, queryPosition);

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (updateTableRequest != null && updateTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(updateTableRequest.TableName);
                }

                if (updateTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = updateTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                if (updateTableRequest != null && updateTableRequest.GlobalSecondaryIndexUpdates != null && updateTableRequest.GlobalSecondaryIndexUpdates.Count > 0)
                {
                    List <GlobalSecondaryIndexUpdate> globalSecondaryIndexUpdatesList = updateTableRequest.GlobalSecondaryIndexUpdates;
                    writer.WritePropertyName("GlobalSecondaryIndexUpdates");
                    writer.WriteArrayStart();

                    foreach (GlobalSecondaryIndexUpdate globalSecondaryIndexUpdatesListValue in globalSecondaryIndexUpdatesList)
                    {
                        writer.WriteObjectStart();

                        if (globalSecondaryIndexUpdatesListValue != null)
                        {
                            UpdateGlobalSecondaryIndexAction update = globalSecondaryIndexUpdatesListValue.Update;
                            if (update != null)
                            {
                                writer.WritePropertyName("Update");
                                writer.WriteObjectStart();
                                if (update != null && update.IsSetIndexName())
                                {
                                    writer.WritePropertyName("IndexName");
                                    writer.Write(update.IndexName);
                                }

                                if (update != null)
                                {
                                    ProvisionedThroughput provisionedThroughput = update.ProvisionedThroughput;
                                    if (provisionedThroughput != null)
                                    {
                                        writer.WritePropertyName("ProvisionedThroughput");
                                        writer.WriteObjectStart();
                                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                                        {
                                            writer.WritePropertyName("ReadCapacityUnits");
                                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                                        }
                                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                                        {
                                            writer.WritePropertyName("WriteCapacityUnits");
                                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                                        }
                                        writer.WriteObjectEnd();
                                    }
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
예제 #3
0
        public IRequest Marshall(CreateTableRequest createTableRequest)
        {
            IRequest request = new DefaultRequest(createTableRequest, "AmazonDynamoDB");
            string   target  = "DynamoDB_20111205.CreateTable";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (createTableRequest != null && createTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(createTableRequest.TableName);
                }

                if (createTableRequest != null)
                {
                    KeySchema keySchema = createTableRequest.KeySchema;
                    if (keySchema != null)
                    {
                        writer.WritePropertyName("KeySchema");
                        writer.WriteObjectStart();

                        if (keySchema != null)
                        {
                            KeySchemaElement hashKeyElement = keySchema.HashKeyElement;
                            if (hashKeyElement != null)
                            {
                                writer.WritePropertyName("HashKeyElement");
                                writer.WriteObjectStart();
                                if (hashKeyElement != null && hashKeyElement.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(hashKeyElement.AttributeName);
                                }
                                if (hashKeyElement != null && hashKeyElement.IsSetAttributeType())
                                {
                                    writer.WritePropertyName("AttributeType");
                                    writer.Write(hashKeyElement.AttributeType);
                                }
                                writer.WriteObjectEnd();
                            }
                        }

                        if (keySchema != null)
                        {
                            KeySchemaElement rangeKeyElement = keySchema.RangeKeyElement;
                            if (rangeKeyElement != null)
                            {
                                writer.WritePropertyName("RangeKeyElement");
                                writer.WriteObjectStart();
                                if (rangeKeyElement != null && rangeKeyElement.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(rangeKeyElement.AttributeName);
                                }
                                if (rangeKeyElement != null && rangeKeyElement.IsSetAttributeType())
                                {
                                    writer.WritePropertyName("AttributeType");
                                    writer.Write(rangeKeyElement.AttributeType);
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                }

                if (createTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = createTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
                return(request);
            }
        }
        public IRequest Marshall(CreateTableRequest createTableRequest)
        {
            IRequest request = new DefaultRequest(createTableRequest, "AmazonDynamoDBv2");
            string   target  = "DynamoDB_20120810.CreateTable";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";



            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                string queryString = uriResourcePath.Substring(uriResourcePath.IndexOf("?") + 1);
                uriResourcePath = uriResourcePath.Substring(0, uriResourcePath.IndexOf("?"));

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();


                if (createTableRequest != null && createTableRequest.AttributeDefinitions != null && createTableRequest.AttributeDefinitions.Count > 0)
                {
                    List <AttributeDefinition> attributeDefinitionsList = createTableRequest.AttributeDefinitions;
                    writer.WritePropertyName("AttributeDefinitions");
                    writer.WriteArrayStart();

                    foreach (AttributeDefinition attributeDefinitionsListValue in attributeDefinitionsList)
                    {
                        writer.WriteObjectStart();
                        if (attributeDefinitionsListValue != null && attributeDefinitionsListValue.IsSetAttributeName())
                        {
                            writer.WritePropertyName("AttributeName");
                            writer.Write(attributeDefinitionsListValue.AttributeName);
                        }
                        if (attributeDefinitionsListValue != null && attributeDefinitionsListValue.IsSetAttributeType())
                        {
                            writer.WritePropertyName("AttributeType");
                            writer.Write(attributeDefinitionsListValue.AttributeType);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }
                if (createTableRequest != null && createTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(createTableRequest.TableName);
                }

                if (createTableRequest != null && createTableRequest.KeySchema != null && createTableRequest.KeySchema.Count > 0)
                {
                    List <KeySchemaElement> keySchemaList = createTableRequest.KeySchema;
                    writer.WritePropertyName("KeySchema");
                    writer.WriteArrayStart();

                    foreach (KeySchemaElement keySchemaListValue in keySchemaList)
                    {
                        writer.WriteObjectStart();
                        if (keySchemaListValue != null && keySchemaListValue.IsSetAttributeName())
                        {
                            writer.WritePropertyName("AttributeName");
                            writer.Write(keySchemaListValue.AttributeName);
                        }
                        if (keySchemaListValue != null && keySchemaListValue.IsSetKeyType())
                        {
                            writer.WritePropertyName("KeyType");
                            writer.Write(keySchemaListValue.KeyType);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (createTableRequest != null && createTableRequest.LocalSecondaryIndexes != null && createTableRequest.LocalSecondaryIndexes.Count > 0)
                {
                    List <LocalSecondaryIndex> localSecondaryIndexesList = createTableRequest.LocalSecondaryIndexes;
                    writer.WritePropertyName("LocalSecondaryIndexes");
                    writer.WriteArrayStart();

                    foreach (LocalSecondaryIndex localSecondaryIndexesListValue in localSecondaryIndexesList)
                    {
                        writer.WriteObjectStart();
                        if (localSecondaryIndexesListValue != null && localSecondaryIndexesListValue.IsSetIndexName())
                        {
                            writer.WritePropertyName("IndexName");
                            writer.Write(localSecondaryIndexesListValue.IndexName);
                        }

                        if (localSecondaryIndexesListValue != null && localSecondaryIndexesListValue.KeySchema != null && localSecondaryIndexesListValue.KeySchema.Count > 0)
                        {
                            List <KeySchemaElement> keySchemaList = localSecondaryIndexesListValue.KeySchema;
                            writer.WritePropertyName("KeySchema");
                            writer.WriteArrayStart();

                            foreach (KeySchemaElement keySchemaListValue in keySchemaList)
                            {
                                writer.WriteObjectStart();
                                if (keySchemaListValue != null && keySchemaListValue.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(keySchemaListValue.AttributeName);
                                }
                                if (keySchemaListValue != null && keySchemaListValue.IsSetKeyType())
                                {
                                    writer.WritePropertyName("KeyType");
                                    writer.Write(keySchemaListValue.KeyType);
                                }
                                writer.WriteObjectEnd();
                            }
                            writer.WriteArrayEnd();
                        }

                        if (localSecondaryIndexesListValue != null)
                        {
                            Projection projection = localSecondaryIndexesListValue.Projection;
                            if (projection != null)
                            {
                                writer.WritePropertyName("Projection");
                                writer.WriteObjectStart();
                                if (projection != null && projection.IsSetProjectionType())
                                {
                                    writer.WritePropertyName("ProjectionType");
                                    writer.Write(projection.ProjectionType);
                                }

                                if (projection != null && projection.NonKeyAttributes != null && projection.NonKeyAttributes.Count > 0)
                                {
                                    List <string> nonKeyAttributesList = projection.NonKeyAttributes;
                                    writer.WritePropertyName("NonKeyAttributes");
                                    writer.WriteArrayStart();

                                    foreach (string nonKeyAttributesListValue in nonKeyAttributesList)
                                    {
                                        writer.Write(StringUtils.FromString(nonKeyAttributesListValue));
                                    }

                                    writer.WriteArrayEnd();
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (createTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = createTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
예제 #5
0
        public IRequest Marshall(UpdateTableRequest updateTableRequest)
        {
            IRequest request = new DefaultRequest(updateTableRequest, "AmazonDynamoDBv2");
            string   target  = "DynamoDB_20120810.UpdateTable";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            string uriResourcePath = "";

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (updateTableRequest != null && updateTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(updateTableRequest.TableName);
                }

                if (updateTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = updateTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                if (updateTableRequest != null && updateTableRequest.GlobalSecondaryIndexUpdates != null && updateTableRequest.GlobalSecondaryIndexUpdates.Count > 0)
                {
                    List <GlobalSecondaryIndexUpdate> globalSecondaryIndexUpdatesList = updateTableRequest.GlobalSecondaryIndexUpdates;
                    writer.WritePropertyName("GlobalSecondaryIndexUpdates");
                    writer.WriteArrayStart();

                    foreach (GlobalSecondaryIndexUpdate globalSecondaryIndexUpdatesListValue in globalSecondaryIndexUpdatesList)
                    {
                        writer.WriteObjectStart();

                        if (globalSecondaryIndexUpdatesListValue != null)
                        {
                            UpdateGlobalSecondaryIndexAction update = globalSecondaryIndexUpdatesListValue.Update;
                            if (update != null)
                            {
                                writer.WritePropertyName("Update");
                                writer.WriteObjectStart();
                                if (update != null && update.IsSetIndexName())
                                {
                                    writer.WritePropertyName("IndexName");
                                    writer.Write(update.IndexName);
                                }

                                if (update != null)
                                {
                                    ProvisionedThroughput provisionedThroughput = update.ProvisionedThroughput;
                                    if (provisionedThroughput != null)
                                    {
                                        writer.WritePropertyName("ProvisionedThroughput");
                                        writer.WriteObjectStart();
                                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                                        {
                                            writer.WritePropertyName("ReadCapacityUnits");
                                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                                        }
                                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                                        {
                                            writer.WritePropertyName("WriteCapacityUnits");
                                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                                        }
                                        writer.WriteObjectEnd();
                                    }
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
        public IRequest Marshall(CreateTableRequest createTableRequest)
        {
            IRequest request = new DefaultRequest(createTableRequest, "AmazonDynamoDBv2");
            string   target  = "DynamoDB_20120810.CreateTable";

            request.Headers["X-Amz-Target"] = target;

            request.Headers["Content-Type"] = "application/x-amz-json-1.0";

            string uriResourcePath = "";

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();


                if (createTableRequest != null && createTableRequest.AttributeDefinitions != null && createTableRequest.AttributeDefinitions.Count > 0)
                {
                    List <AttributeDefinition> attributeDefinitionsList = createTableRequest.AttributeDefinitions;
                    writer.WritePropertyName("AttributeDefinitions");
                    writer.WriteArrayStart();

                    foreach (AttributeDefinition attributeDefinitionsListValue in attributeDefinitionsList)
                    {
                        writer.WriteObjectStart();
                        if (attributeDefinitionsListValue != null && attributeDefinitionsListValue.IsSetAttributeName())
                        {
                            writer.WritePropertyName("AttributeName");
                            writer.Write(attributeDefinitionsListValue.AttributeName);
                        }
                        if (attributeDefinitionsListValue != null && attributeDefinitionsListValue.IsSetAttributeType())
                        {
                            writer.WritePropertyName("AttributeType");
                            writer.Write(attributeDefinitionsListValue.AttributeType);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }
                if (createTableRequest != null && createTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(createTableRequest.TableName);
                }

                if (createTableRequest != null && createTableRequest.KeySchema != null && createTableRequest.KeySchema.Count > 0)
                {
                    List <KeySchemaElement> keySchemaList = createTableRequest.KeySchema;
                    writer.WritePropertyName("KeySchema");
                    writer.WriteArrayStart();

                    foreach (KeySchemaElement keySchemaListValue in keySchemaList)
                    {
                        writer.WriteObjectStart();
                        if (keySchemaListValue != null && keySchemaListValue.IsSetAttributeName())
                        {
                            writer.WritePropertyName("AttributeName");
                            writer.Write(keySchemaListValue.AttributeName);
                        }
                        if (keySchemaListValue != null && keySchemaListValue.IsSetKeyType())
                        {
                            writer.WritePropertyName("KeyType");
                            writer.Write(keySchemaListValue.KeyType);
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (createTableRequest != null && createTableRequest.LocalSecondaryIndexes != null && createTableRequest.LocalSecondaryIndexes.Count > 0)
                {
                    List <LocalSecondaryIndex> localSecondaryIndexesList = createTableRequest.LocalSecondaryIndexes;
                    writer.WritePropertyName("LocalSecondaryIndexes");
                    writer.WriteArrayStart();

                    foreach (LocalSecondaryIndex localSecondaryIndexesListValue in localSecondaryIndexesList)
                    {
                        writer.WriteObjectStart();
                        if (localSecondaryIndexesListValue != null && localSecondaryIndexesListValue.IsSetIndexName())
                        {
                            writer.WritePropertyName("IndexName");
                            writer.Write(localSecondaryIndexesListValue.IndexName);
                        }

                        if (localSecondaryIndexesListValue != null && localSecondaryIndexesListValue.KeySchema != null && localSecondaryIndexesListValue.KeySchema.Count > 0)
                        {
                            List <KeySchemaElement> keySchemaList = localSecondaryIndexesListValue.KeySchema;
                            writer.WritePropertyName("KeySchema");
                            writer.WriteArrayStart();

                            foreach (KeySchemaElement keySchemaListValue in keySchemaList)
                            {
                                writer.WriteObjectStart();
                                if (keySchemaListValue != null && keySchemaListValue.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(keySchemaListValue.AttributeName);
                                }
                                if (keySchemaListValue != null && keySchemaListValue.IsSetKeyType())
                                {
                                    writer.WritePropertyName("KeyType");
                                    writer.Write(keySchemaListValue.KeyType);
                                }
                                writer.WriteObjectEnd();
                            }
                            writer.WriteArrayEnd();
                        }

                        if (localSecondaryIndexesListValue != null)
                        {
                            Projection projection = localSecondaryIndexesListValue.Projection;
                            if (projection != null)
                            {
                                writer.WritePropertyName("Projection");
                                writer.WriteObjectStart();
                                if (projection != null && projection.IsSetProjectionType())
                                {
                                    writer.WritePropertyName("ProjectionType");
                                    writer.Write(projection.ProjectionType);
                                }

                                if (projection != null && projection.NonKeyAttributes != null && projection.NonKeyAttributes.Count > 0)
                                {
                                    List <string> nonKeyAttributesList = projection.NonKeyAttributes;
                                    writer.WritePropertyName("NonKeyAttributes");
                                    writer.WriteArrayStart();

                                    foreach (string nonKeyAttributesListValue in nonKeyAttributesList)
                                    {
                                        writer.Write(StringUtils.FromString(nonKeyAttributesListValue));
                                    }

                                    writer.WriteArrayEnd();
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (createTableRequest != null && createTableRequest.GlobalSecondaryIndexes != null && createTableRequest.GlobalSecondaryIndexes.Count > 0)
                {
                    List <GlobalSecondaryIndex> globalSecondaryIndexesList = createTableRequest.GlobalSecondaryIndexes;
                    writer.WritePropertyName("GlobalSecondaryIndexes");
                    writer.WriteArrayStart();

                    foreach (GlobalSecondaryIndex globalSecondaryIndexesListValue in globalSecondaryIndexesList)
                    {
                        writer.WriteObjectStart();
                        if (globalSecondaryIndexesListValue != null && globalSecondaryIndexesListValue.IsSetIndexName())
                        {
                            writer.WritePropertyName("IndexName");
                            writer.Write(globalSecondaryIndexesListValue.IndexName);
                        }

                        if (globalSecondaryIndexesListValue != null && globalSecondaryIndexesListValue.KeySchema != null && globalSecondaryIndexesListValue.KeySchema.Count > 0)
                        {
                            List <KeySchemaElement> keySchemaList = globalSecondaryIndexesListValue.KeySchema;
                            writer.WritePropertyName("KeySchema");
                            writer.WriteArrayStart();

                            foreach (KeySchemaElement keySchemaListValue in keySchemaList)
                            {
                                writer.WriteObjectStart();
                                if (keySchemaListValue != null && keySchemaListValue.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(keySchemaListValue.AttributeName);
                                }
                                if (keySchemaListValue != null && keySchemaListValue.IsSetKeyType())
                                {
                                    writer.WritePropertyName("KeyType");
                                    writer.Write(keySchemaListValue.KeyType);
                                }
                                writer.WriteObjectEnd();
                            }
                            writer.WriteArrayEnd();
                        }

                        if (globalSecondaryIndexesListValue != null)
                        {
                            Projection projection = globalSecondaryIndexesListValue.Projection;
                            if (projection != null)
                            {
                                writer.WritePropertyName("Projection");
                                writer.WriteObjectStart();
                                if (projection != null && projection.IsSetProjectionType())
                                {
                                    writer.WritePropertyName("ProjectionType");
                                    writer.Write(projection.ProjectionType);
                                }

                                if (projection != null && projection.NonKeyAttributes != null && projection.NonKeyAttributes.Count > 0)
                                {
                                    List <string> nonKeyAttributesList = projection.NonKeyAttributes;
                                    writer.WritePropertyName("NonKeyAttributes");
                                    writer.WriteArrayStart();

                                    foreach (string nonKeyAttributesListValue in nonKeyAttributesList)
                                    {
                                        writer.Write(StringUtils.FromString(nonKeyAttributesListValue));
                                    }

                                    writer.WriteArrayEnd();
                                }
                                writer.WriteObjectEnd();
                            }
                        }

                        if (globalSecondaryIndexesListValue != null)
                        {
                            ProvisionedThroughput provisionedThroughput = globalSecondaryIndexesListValue.ProvisionedThroughput;
                            if (provisionedThroughput != null)
                            {
                                writer.WritePropertyName("ProvisionedThroughput");
                                writer.WriteObjectStart();
                                if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                                {
                                    writer.WritePropertyName("ReadCapacityUnits");
                                    writer.Write(provisionedThroughput.ReadCapacityUnits);
                                }
                                if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                                {
                                    writer.WritePropertyName("WriteCapacityUnits");
                                    writer.Write(provisionedThroughput.WriteCapacityUnits);
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                    writer.WriteArrayEnd();
                }

                if (createTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = createTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }
        public IRequest Marshall(CreateTableRequest createTableRequest)
        {
            IRequest request = new DefaultRequest(createTableRequest, "AmazonDynamoDB");
            string   target  = "DynamoDB_20111205.CreateTable";

            request.Headers["X-Amz-Target"] = target;
            request.Headers["Content-Type"] = "application/x-amz-json-1.0";



            string uriResourcePath = "";

            if (uriResourcePath.Contains("?"))
            {
                string queryString = uriResourcePath.Substring(uriResourcePath.IndexOf("?") + 1);
                uriResourcePath = uriResourcePath.Substring(0, uriResourcePath.IndexOf("?"));

                foreach (string s in queryString.Split('&', ';'))
                {
                    string[] nameValuePair = s.Split('=');
                    if (nameValuePair.Length == 2 && nameValuePair[1].Length > 0)
                    {
                        request.Parameters.Add(nameValuePair[0], nameValuePair[1]);
                    }
                    else
                    {
                        request.Parameters.Add(nameValuePair[0], null);
                    }
                }
            }

            request.ResourcePath = uriResourcePath;


            using (StringWriter stringWriter = new StringWriter())
            {
                JsonWriter writer = new JsonWriter(stringWriter);
                writer.WriteObjectStart();

                if (createTableRequest != null && createTableRequest.IsSetTableName())
                {
                    writer.WritePropertyName("TableName");
                    writer.Write(createTableRequest.TableName);
                }

                if (createTableRequest != null)
                {
                    KeySchema keySchema = createTableRequest.KeySchema;
                    if (keySchema != null)
                    {
                        writer.WritePropertyName("KeySchema");
                        writer.WriteObjectStart();

                        if (keySchema != null)
                        {
                            KeySchemaElement hashKeyElement = keySchema.HashKeyElement;
                            if (hashKeyElement != null)
                            {
                                writer.WritePropertyName("HashKeyElement");
                                writer.WriteObjectStart();
                                if (hashKeyElement != null && hashKeyElement.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(hashKeyElement.AttributeName);
                                }
                                if (hashKeyElement != null && hashKeyElement.IsSetAttributeType())
                                {
                                    writer.WritePropertyName("AttributeType");
                                    writer.Write(hashKeyElement.AttributeType);
                                }
                                writer.WriteObjectEnd();
                            }
                        }

                        if (keySchema != null)
                        {
                            KeySchemaElement rangeKeyElement = keySchema.RangeKeyElement;
                            if (rangeKeyElement != null)
                            {
                                writer.WritePropertyName("RangeKeyElement");
                                writer.WriteObjectStart();
                                if (rangeKeyElement != null && rangeKeyElement.IsSetAttributeName())
                                {
                                    writer.WritePropertyName("AttributeName");
                                    writer.Write(rangeKeyElement.AttributeName);
                                }
                                if (rangeKeyElement != null && rangeKeyElement.IsSetAttributeType())
                                {
                                    writer.WritePropertyName("AttributeType");
                                    writer.Write(rangeKeyElement.AttributeType);
                                }
                                writer.WriteObjectEnd();
                            }
                        }
                        writer.WriteObjectEnd();
                    }
                }

                if (createTableRequest != null)
                {
                    ProvisionedThroughput provisionedThroughput = createTableRequest.ProvisionedThroughput;
                    if (provisionedThroughput != null)
                    {
                        writer.WritePropertyName("ProvisionedThroughput");
                        writer.WriteObjectStart();
                        if (provisionedThroughput != null && provisionedThroughput.IsSetReadCapacityUnits())
                        {
                            writer.WritePropertyName("ReadCapacityUnits");
                            writer.Write(provisionedThroughput.ReadCapacityUnits);
                        }
                        if (provisionedThroughput != null && provisionedThroughput.IsSetWriteCapacityUnits())
                        {
                            writer.WritePropertyName("WriteCapacityUnits");
                            writer.Write(provisionedThroughput.WriteCapacityUnits);
                        }
                        writer.WriteObjectEnd();
                    }
                }

                writer.WriteObjectEnd();

                string snippet = stringWriter.ToString();
                request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
            }


            return(request);
        }