public IRequest Marshall(SetLoadBasedAutoScalingRequest setLoadBasedAutoScalingRequest) { IRequest request = new DefaultRequest(setLoadBasedAutoScalingRequest, "AmazonOpsWorks"); string target = "OpsWorks_20130218.SetLoadBasedAutoScaling"; request.Headers["X-Amz-Target"] = target; request.Headers["Content-Type"] = "application/x-amz-json-1.1"; 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 (setLoadBasedAutoScalingRequest != null && setLoadBasedAutoScalingRequest.IsSetLayerId()) { writer.WritePropertyName("LayerId"); writer.Write(setLoadBasedAutoScalingRequest.LayerId); } if (setLoadBasedAutoScalingRequest != null && setLoadBasedAutoScalingRequest.IsSetEnable()) { writer.WritePropertyName("Enable"); writer.Write(setLoadBasedAutoScalingRequest.Enable); } if (setLoadBasedAutoScalingRequest != null) { AutoScalingThresholds upScaling = setLoadBasedAutoScalingRequest.UpScaling; if (upScaling != null) { writer.WritePropertyName("UpScaling"); writer.WriteObjectStart(); if (upScaling != null && upScaling.IsSetInstanceCount()) { writer.WritePropertyName("InstanceCount"); writer.Write(upScaling.InstanceCount); } if (upScaling != null && upScaling.IsSetThresholdsWaitTime()) { writer.WritePropertyName("ThresholdsWaitTime"); writer.Write(upScaling.ThresholdsWaitTime); } if (upScaling != null && upScaling.IsSetIgnoreMetricsTime()) { writer.WritePropertyName("IgnoreMetricsTime"); writer.Write(upScaling.IgnoreMetricsTime); } if (upScaling != null && upScaling.IsSetCpuThreshold()) { writer.WritePropertyName("CpuThreshold"); writer.Write(upScaling.CpuThreshold); } if (upScaling != null && upScaling.IsSetMemoryThreshold()) { writer.WritePropertyName("MemoryThreshold"); writer.Write(upScaling.MemoryThreshold); } if (upScaling != null && upScaling.IsSetLoadThreshold()) { writer.WritePropertyName("LoadThreshold"); writer.Write(upScaling.LoadThreshold); } writer.WriteObjectEnd(); } } if (setLoadBasedAutoScalingRequest != null) { AutoScalingThresholds downScaling = setLoadBasedAutoScalingRequest.DownScaling; if (downScaling != null) { writer.WritePropertyName("DownScaling"); writer.WriteObjectStart(); if (downScaling != null && downScaling.IsSetInstanceCount()) { writer.WritePropertyName("InstanceCount"); writer.Write(downScaling.InstanceCount); } if (downScaling != null && downScaling.IsSetThresholdsWaitTime()) { writer.WritePropertyName("ThresholdsWaitTime"); writer.Write(downScaling.ThresholdsWaitTime); } if (downScaling != null && downScaling.IsSetIgnoreMetricsTime()) { writer.WritePropertyName("IgnoreMetricsTime"); writer.Write(downScaling.IgnoreMetricsTime); } if (downScaling != null && downScaling.IsSetCpuThreshold()) { writer.WritePropertyName("CpuThreshold"); writer.Write(downScaling.CpuThreshold); } if (downScaling != null && downScaling.IsSetMemoryThreshold()) { writer.WritePropertyName("MemoryThreshold"); writer.Write(downScaling.MemoryThreshold); } if (downScaling != null && downScaling.IsSetLoadThreshold()) { writer.WritePropertyName("LoadThreshold"); writer.Write(downScaling.LoadThreshold); } writer.WriteObjectEnd(); } } writer.WriteObjectEnd(); string snippet = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(snippet); } return(request); }
public IRequest Marshall(SetLoadBasedAutoScalingRequest setLoadBasedAutoScalingRequest) { IRequest request = new DefaultRequest(setLoadBasedAutoScalingRequest, "AmazonOpsWorks"); string target = "OpsWorks_20130218.SetLoadBasedAutoScaling"; request.Headers["X-Amz-Target"] = target; request.Headers["Content-Type"] = "application/x-amz-json-1.1"; string uriResourcePath = ""; request.ResourcePath = uriResourcePath; using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { JsonWriter writer = new JsonWriter(stringWriter); writer.WriteObjectStart(); if (setLoadBasedAutoScalingRequest != null && setLoadBasedAutoScalingRequest.IsSetLayerId()) { writer.WritePropertyName("LayerId"); writer.Write(setLoadBasedAutoScalingRequest.LayerId); } if (setLoadBasedAutoScalingRequest != null && setLoadBasedAutoScalingRequest.IsSetEnable()) { writer.WritePropertyName("Enable"); writer.Write(setLoadBasedAutoScalingRequest.Enable); } if (setLoadBasedAutoScalingRequest != null) { AutoScalingThresholds upScaling = setLoadBasedAutoScalingRequest.UpScaling; if (upScaling != null) { writer.WritePropertyName("UpScaling"); writer.WriteObjectStart(); if (upScaling != null && upScaling.IsSetInstanceCount()) { writer.WritePropertyName("InstanceCount"); writer.Write(upScaling.InstanceCount); } if (upScaling != null && upScaling.IsSetThresholdsWaitTime()) { writer.WritePropertyName("ThresholdsWaitTime"); writer.Write(upScaling.ThresholdsWaitTime); } if (upScaling != null && upScaling.IsSetIgnoreMetricsTime()) { writer.WritePropertyName("IgnoreMetricsTime"); writer.Write(upScaling.IgnoreMetricsTime); } if (upScaling != null && upScaling.IsSetCpuThreshold()) { writer.WritePropertyName("CpuThreshold"); writer.Write(upScaling.CpuThreshold); } if (upScaling != null && upScaling.IsSetMemoryThreshold()) { writer.WritePropertyName("MemoryThreshold"); writer.Write(upScaling.MemoryThreshold); } if (upScaling != null && upScaling.IsSetLoadThreshold()) { writer.WritePropertyName("LoadThreshold"); writer.Write(upScaling.LoadThreshold); } writer.WriteObjectEnd(); } } if (setLoadBasedAutoScalingRequest != null) { AutoScalingThresholds downScaling = setLoadBasedAutoScalingRequest.DownScaling; if (downScaling != null) { writer.WritePropertyName("DownScaling"); writer.WriteObjectStart(); if (downScaling != null && downScaling.IsSetInstanceCount()) { writer.WritePropertyName("InstanceCount"); writer.Write(downScaling.InstanceCount); } if (downScaling != null && downScaling.IsSetThresholdsWaitTime()) { writer.WritePropertyName("ThresholdsWaitTime"); writer.Write(downScaling.ThresholdsWaitTime); } if (downScaling != null && downScaling.IsSetIgnoreMetricsTime()) { writer.WritePropertyName("IgnoreMetricsTime"); writer.Write(downScaling.IgnoreMetricsTime); } if (downScaling != null && downScaling.IsSetCpuThreshold()) { writer.WritePropertyName("CpuThreshold"); writer.Write(downScaling.CpuThreshold); } if (downScaling != null && downScaling.IsSetMemoryThreshold()) { writer.WritePropertyName("MemoryThreshold"); writer.Write(downScaling.MemoryThreshold); } if (downScaling != null && downScaling.IsSetLoadThreshold()) { writer.WritePropertyName("LoadThreshold"); writer.Write(downScaling.LoadThreshold); } writer.WriteObjectEnd(); } } writer.WriteObjectEnd(); string snippet = stringWriter.ToString(); request.Content = System.Text.Encoding.UTF8.GetBytes(snippet); } return(request); }