Skip to content

Commit 97a7613

Browse files
Add some of cloudwatch marshallers as an example of Cbor marshallers
1 parent ec1abde commit 97a7613

9 files changed

+499
-303
lines changed

sdk/src/Services/CloudWatch/AWSSDK.CloudWatch.NetFramework.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262

6363
<ItemGroup>
6464
<ProjectReference Include="../../Core/AWSSDK.Core.NetFramework.csproj"/>
65+
<ProjectReference Include="../../../../extensions/src/AWSSDK.Extensions.CborProtocol/AWSSDK.Extensions.CborProtocol.NetFramework.csproj"/>
6566
</ItemGroup>
6667

6768
<ItemGroup Condition="$(RunAnalyzersDuringBuild)">

sdk/src/Services/CloudWatch/AWSSDK.CloudWatch.NetStandard.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
<SignAssembly>true</SignAssembly>
2323
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2424

25+
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
2526
<NoWarn>CA1822</NoWarn>
2627
</PropertyGroup>
2728
<!-- Async Enumerable Compatibility -->
@@ -72,6 +73,7 @@
7273

7374
<ItemGroup>
7475
<ProjectReference Include="../../Core/AWSSDK.Core.NetStandard.csproj"/>
76+
<ProjectReference Include="../../../../extensions/src/AWSSDK.Extensions.CborProtocol/AWSSDK.Extensions.CborProtocol.NetStandard.csproj"/>
7577
</ItemGroup>
7678

7779
<ItemGroup Condition="$(RunAnalyzersDuringBuild)">

sdk/src/Services/CloudWatch/CloudWatch.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Core.NetFramework",
88
EndProject
99
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Core.NetStandard", "../../Core/AWSSDK.Core.NetStandard.csproj", "{A855B58E-ED32-40AE-AE8F-054F448B9F2C}"
1010
EndProject
11+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.CborProtocol.NetFramework", "../../../../extensions/src/AWSSDK.Extensions.CborProtocol/AWSSDK.Extensions.CborProtocol.NetFramework.csproj", "{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9}"
12+
EndProject
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSSDK.Extensions.CborProtocol.NetStandard", "../../../../extensions/src/AWSSDK.Extensions.CborProtocol/AWSSDK.Extensions.CborProtocol.NetStandard.csproj", "{BEABF75C-F704-4477-A6EE-70D79C0D186A}"
14+
EndProject
1115
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{939EC5C2-8345-43E2-8F97-72EEEBEEA0AB}"
1216
EndProject
1317
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CloudWatch", "CloudWatch", "{4A5408C4-6E9B-2089-624F-98402298A58E}"
@@ -60,6 +64,14 @@ Global
6064
{A855B58E-ED32-40AE-AE8F-054F448B9F2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
6165
{A855B58E-ED32-40AE-AE8F-054F448B9F2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
6266
{A855B58E-ED32-40AE-AE8F-054F448B9F2C}.Release|Any CPU.Build.0 = Release|Any CPU
67+
{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68+
{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
69+
{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
70+
{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9}.Release|Any CPU.Build.0 = Release|Any CPU
71+
{BEABF75C-F704-4477-A6EE-70D79C0D186A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
72+
{BEABF75C-F704-4477-A6EE-70D79C0D186A}.Debug|Any CPU.Build.0 = Debug|Any CPU
73+
{BEABF75C-F704-4477-A6EE-70D79C0D186A}.Release|Any CPU.ActiveCfg = Release|Any CPU
74+
{BEABF75C-F704-4477-A6EE-70D79C0D186A}.Release|Any CPU.Build.0 = Release|Any CPU
6375
{434D91D7-9794-460E-AAD6-1564523A3464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6476
{434D91D7-9794-460E-AAD6-1564523A3464}.Debug|Any CPU.Build.0 = Debug|Any CPU
6577
{434D91D7-9794-460E-AAD6-1564523A3464}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -127,6 +139,8 @@ Global
127139
GlobalSection(NestedProjects) = preSolution
128140
{7DE3AFA0-1B2D-41B1-82BD-120B8B210B43} = {9863FCB3-BFA4-4B9C-B8F6-302BA5F660B8}
129141
{A855B58E-ED32-40AE-AE8F-054F448B9F2C} = {9863FCB3-BFA4-4B9C-B8F6-302BA5F660B8}
142+
{C0606F12-33EA-40FC-A1B3-F30FE5E1ECA9} = {9863FCB3-BFA4-4B9C-B8F6-302BA5F660B8}
143+
{BEABF75C-F704-4477-A6EE-70D79C0D186A} = {9863FCB3-BFA4-4B9C-B8F6-302BA5F660B8}
130144
{4A5408C4-6E9B-2089-624F-98402298A58E} = {939EC5C2-8345-43E2-8F97-72EEEBEEA0AB}
131145
{434D91D7-9794-460E-AAD6-1564523A3464} = {4A5408C4-6E9B-2089-624F-98402298A58E}
132146
{3E591FA3-A9CE-49C0-96C3-AD583E523AF2} = {4A5408C4-6E9B-2089-624F-98402298A58E}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the monitoring-2010-08-01.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Text;
24+
using System.Xml.Serialization;
25+
26+
using Amazon.CloudWatch.Model;
27+
using Amazon.Runtime;
28+
using Amazon.Runtime.Internal;
29+
using Amazon.Runtime.Internal.Transform;
30+
using Amazon.Runtime.Internal.Util;
31+
using AWSSDK.Extensions.CborProtocol;
32+
using AWSSDK.Extensions.CborProtocol.Internal;
33+
34+
#pragma warning disable CS0612,CS0618
35+
namespace Amazon.CloudWatch.Model.Internal.MarshallTransformations
36+
{
37+
/// <summary>
38+
/// Dimension Marshaller
39+
/// </summary>
40+
public class DimensionMarshaller : IRequestMarshaller<Dimension, CborMarshallerContext>
41+
{
42+
/// <summary>
43+
/// Unmarshaller the response from the service to the response class.
44+
/// </summary>
45+
/// <param name="requestObject"></param>
46+
/// <param name="context"></param>
47+
/// <returns></returns>
48+
public void Marshall(Dimension requestObject, CborMarshallerContext context)
49+
{
50+
if (requestObject == null)
51+
return;
52+
53+
if (requestObject.IsSetName())
54+
{
55+
context.Writer.WriteTextString("Name");
56+
context.Writer.WriteTextString(requestObject.Name);
57+
}
58+
if (requestObject.IsSetValue())
59+
{
60+
context.Writer.WriteTextString("Value");
61+
context.Writer.WriteTextString(requestObject.Value);
62+
}
63+
}
64+
65+
/// <summary>
66+
/// Singleton Marshaller.
67+
/// </summary>
68+
public readonly static DimensionMarshaller Instance = new DimensionMarshaller();
69+
70+
}
71+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the monitoring-2010-08-01.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Text;
24+
using System.Xml.Serialization;
25+
26+
using Amazon.CloudWatch.Model;
27+
using Amazon.Runtime;
28+
using Amazon.Runtime.Internal;
29+
using Amazon.Runtime.Internal.Transform;
30+
using Amazon.Runtime.Internal.Util;
31+
using AWSSDK.Extensions.CborProtocol;
32+
using AWSSDK.Extensions.CborProtocol.Internal;
33+
34+
#pragma warning disable CS0612,CS0618
35+
namespace Amazon.CloudWatch.Model.Internal.MarshallTransformations
36+
{
37+
/// <summary>
38+
/// EntityMetricData Marshaller
39+
/// </summary>
40+
public class EntityMetricDataMarshaller : IRequestMarshaller<EntityMetricData, CborMarshallerContext>
41+
{
42+
/// <summary>
43+
/// Unmarshaller the response from the service to the response class.
44+
/// </summary>
45+
/// <param name="requestObject"></param>
46+
/// <param name="context"></param>
47+
/// <returns></returns>
48+
public void Marshall(EntityMetricData requestObject, CborMarshallerContext context)
49+
{
50+
if (requestObject == null)
51+
return;
52+
53+
if (requestObject.IsSetEntity())
54+
{
55+
context.Writer.WriteTextString("Entity");
56+
context.Writer.WriteStartMap(null);
57+
58+
var marshaller = EntityMarshaller.Instance;
59+
marshaller.Marshall(requestObject.Entity, context);
60+
61+
context.Writer.WriteEndMap();
62+
}
63+
if (requestObject.IsSetMetricData())
64+
{
65+
context.Writer.WriteTextString("MetricData");
66+
context.Writer.WriteStartArray(requestObject.MetricData.Count);
67+
foreach(var requestObjectMetricDataListValue in requestObject.MetricData)
68+
{
69+
context.Writer.WriteStartMap(null);
70+
71+
var marshaller = MetricDatumMarshaller.Instance;
72+
marshaller.Marshall(requestObjectMetricDataListValue, context);
73+
74+
context.Writer.WriteEndMap();
75+
}
76+
context.Writer.WriteEndArray();
77+
}
78+
}
79+
80+
/// <summary>
81+
/// Singleton Marshaller.
82+
/// </summary>
83+
public readonly static EntityMetricDataMarshaller Instance = new EntityMetricDataMarshaller();
84+
85+
}
86+
}

sdk/src/Services/CloudWatch/Generated/Model/Internal/MarshallTransformations/GetMetricStatisticsRequestMarshaller.cs

Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
using Amazon.Runtime.Internal;
2929
using Amazon.Runtime.Internal.Transform;
3030
using Amazon.Runtime.Internal.Util;
31+
using AWSSDK.Extensions.CborProtocol;
32+
using AWSSDK.Extensions.CborProtocol.Internal;
33+
3134
#pragma warning disable CS0612,CS0618
3235
namespace Amazon.CloudWatch.Model.Internal.MarshallTransformations
3336
{
@@ -45,7 +48,7 @@ public IRequest Marshall(AmazonWebServiceRequest input)
4548
{
4649
return this.Marshall((GetMetricStatisticsRequest)input);
4750
}
48-
51+
4952
/// <summary>
5053
/// Marshaller the request object to the HTTP request.
5154
/// </summary>
@@ -54,88 +57,94 @@ public IRequest Marshall(AmazonWebServiceRequest input)
5457
public IRequest Marshall(GetMetricStatisticsRequest publicRequest)
5558
{
5659
IRequest request = new DefaultRequest(publicRequest, "Amazon.CloudWatch");
57-
request.Parameters.Add("Action", "GetMetricStatistics");
58-
request.Parameters.Add("Version", "2010-08-01");
60+
request.Headers["smithy-protocol"] = "rpc-v2-cbor";
61+
request.ResourcePath = "service/GraniteServiceVersion20100801/operation/GetMetricStatistics";
62+
request.Headers["Content-Type"] = "application/cbor";
63+
request.Headers["Accept"] = "application/cbor";
64+
request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2010-08-01";
65+
request.HttpMethod = "POST";
5966

60-
if(publicRequest != null)
67+
var writer = CborWriterPool.Rent();
68+
try
6169
{
62-
if(publicRequest.IsSetDimensions())
70+
writer.WriteStartMap(null);
71+
var context = new CborMarshallerContext(request, writer);
72+
if (publicRequest.IsSetDimensions())
6373
{
64-
if (publicRequest.Dimensions.Count == 0)
65-
request.Parameters.Add("Dimensions", "");
66-
else
74+
context.Writer.WriteTextString("Dimensions");
75+
context.Writer.WriteStartArray(publicRequest.Dimensions.Count);
76+
foreach(var publicRequestDimensionsListValue in publicRequest.Dimensions)
6777
{
68-
int publicRequestlistValueIndex = 1;
69-
foreach(var publicRequestlistValue in publicRequest.Dimensions)
70-
{
71-
if(publicRequestlistValue.IsSetName())
72-
{
73-
request.Parameters.Add("Dimensions" + "." + "member" + "." + publicRequestlistValueIndex + "." + "Name", StringUtils.FromString(publicRequestlistValue.Name));
74-
}
75-
if(publicRequestlistValue.IsSetValue())
76-
{
77-
request.Parameters.Add("Dimensions" + "." + "member" + "." + publicRequestlistValueIndex + "." + "Value", StringUtils.FromString(publicRequestlistValue.Value));
78-
}
79-
publicRequestlistValueIndex++;
80-
}
78+
context.Writer.WriteStartMap(null);
79+
80+
var marshaller = DimensionMarshaller.Instance;
81+
marshaller.Marshall(publicRequestDimensionsListValue, context);
82+
83+
context.Writer.WriteEndMap();
8184
}
85+
context.Writer.WriteEndArray();
8286
}
83-
if(publicRequest.IsSetEndTime())
87+
if (publicRequest.IsSetEndTime())
8488
{
85-
request.Parameters.Add("EndTime", StringUtils.FromDateTimeToISO8601WithOptionalMs(publicRequest.EndTime));
89+
context.Writer.WriteTextString("EndTime");
90+
context.Writer.WriteDateTime(publicRequest.EndTime.Value);
8691
}
87-
if(publicRequest.IsSetExtendedStatistics())
92+
if (publicRequest.IsSetExtendedStatistics())
8893
{
89-
if (publicRequest.ExtendedStatistics.Count == 0)
90-
request.Parameters.Add("ExtendedStatistics", "");
91-
else
94+
context.Writer.WriteTextString("ExtendedStatistics");
95+
context.Writer.WriteStartArray(publicRequest.ExtendedStatistics.Count);
96+
foreach(var publicRequestExtendedStatisticsListValue in publicRequest.ExtendedStatistics)
9297
{
93-
int publicRequestlistValueIndex = 1;
94-
foreach(var publicRequestlistValue in publicRequest.ExtendedStatistics)
95-
{
96-
request.Parameters.Add("ExtendedStatistics" + "." + "member" + "." + publicRequestlistValueIndex, StringUtils.FromString(publicRequestlistValue));
97-
publicRequestlistValueIndex++;
98-
}
98+
context.Writer.WriteTextString(publicRequestExtendedStatisticsListValue);
9999
}
100+
context.Writer.WriteEndArray();
100101
}
101-
if(publicRequest.IsSetMetricName())
102+
if (publicRequest.IsSetMetricName())
102103
{
103-
request.Parameters.Add("MetricName", StringUtils.FromString(publicRequest.MetricName));
104+
context.Writer.WriteTextString("MetricName");
105+
context.Writer.WriteTextString(publicRequest.MetricName);
104106
}
105-
if(publicRequest.IsSetNamespace())
107+
if (publicRequest.IsSetNamespace())
106108
{
107-
request.Parameters.Add("Namespace", StringUtils.FromString(publicRequest.Namespace));
109+
context.Writer.WriteTextString("Namespace");
110+
context.Writer.WriteTextString(publicRequest.Namespace);
108111
}
109-
if(publicRequest.IsSetPeriod())
112+
if (publicRequest.IsSetPeriod())
110113
{
111-
request.Parameters.Add("Period", StringUtils.FromInt(publicRequest.Period));
114+
context.Writer.WriteTextString("Period");
115+
context.Writer.WriteInt32(publicRequest.Period.Value);
112116
}
113-
if(publicRequest.IsSetStartTime())
117+
if (publicRequest.IsSetStartTime())
114118
{
115-
request.Parameters.Add("StartTime", StringUtils.FromDateTimeToISO8601WithOptionalMs(publicRequest.StartTime));
119+
context.Writer.WriteTextString("StartTime");
120+
context.Writer.WriteDateTime(publicRequest.StartTime.Value);
116121
}
117-
if(publicRequest.IsSetStatistics())
122+
if (publicRequest.IsSetStatistics())
118123
{
119-
if (publicRequest.Statistics.Count == 0)
120-
request.Parameters.Add("Statistics", "");
121-
else
124+
context.Writer.WriteTextString("Statistics");
125+
context.Writer.WriteStartArray(publicRequest.Statistics.Count);
126+
foreach(var publicRequestStatisticsListValue in publicRequest.Statistics)
122127
{
123-
int publicRequestlistValueIndex = 1;
124-
foreach(var publicRequestlistValue in publicRequest.Statistics)
125-
{
126-
request.Parameters.Add("Statistics" + "." + "member" + "." + publicRequestlistValueIndex, StringUtils.FromString(publicRequestlistValue));
127-
publicRequestlistValueIndex++;
128-
}
128+
context.Writer.WriteTextString(publicRequestStatisticsListValue);
129129
}
130+
context.Writer.WriteEndArray();
130131
}
131-
if(publicRequest.IsSetUnit())
132+
if (publicRequest.IsSetUnit())
132133
{
133-
request.Parameters.Add("Unit", StringUtils.FromString(publicRequest.Unit));
134+
context.Writer.WriteTextString("Unit");
135+
context.Writer.WriteTextString(publicRequest.Unit);
134136
}
137+
writer.WriteEndMap();
138+
request.Content = writer.Encode();
139+
}
140+
finally
141+
{
142+
CborWriterPool.Return(writer);
135143
}
144+
136145
return request;
137146
}
138-
private static GetMetricStatisticsRequestMarshaller _instance = new GetMetricStatisticsRequestMarshaller();
147+
private static GetMetricStatisticsRequestMarshaller _instance = new GetMetricStatisticsRequestMarshaller();
139148

140149
internal static GetMetricStatisticsRequestMarshaller GetInstance()
141150
{

0 commit comments

Comments
 (0)