예제 #1
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);
        }
예제 #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 = "";

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