Skip to content

Commit 4e4c1a0

Browse files
chore(clients): strictly parse booleans (#2514)
* chore: add helper method for parsing booleans This adds a helper for parsing booleans from strings. Previously a simple `=== "true"` check was being performed, but this implies that anything that isn't that particular string is false. * chore: update generated code * chore: strictly parse xml booleans * chore: update generated code * chore: move parseBoolean to parse-utils * chore: prefer arrow functions Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> * chore: update type signature of parseBoolean to accept all strings Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Co-authored-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
1 parent 9144509 commit 4e4c1a0

File tree

30 files changed

+702
-601
lines changed

30 files changed

+702
-601
lines changed

clients/client-auto-scaling/protocols/Aws_query.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ import {
347347
extendedEncodeURIComponent as __extendedEncodeURIComponent,
348348
getArrayIfSingleItem as __getArrayIfSingleItem,
349349
getValueFromTextNode as __getValueFromTextNode,
350+
parseBoolean as __parseBoolean,
350351
} from "@aws-sdk/smithy-client";
351352
import {
352353
Endpoint as __Endpoint,
@@ -7590,7 +7591,7 @@ const deserializeAws_queryAutoScalingGroup = (output: any, context: __SerdeConte
75907591
);
75917592
}
75927593
if (output["NewInstancesProtectedFromScaleIn"] !== undefined) {
7593-
contents.NewInstancesProtectedFromScaleIn = output["NewInstancesProtectedFromScaleIn"] == "true";
7594+
contents.NewInstancesProtectedFromScaleIn = __parseBoolean(output["NewInstancesProtectedFromScaleIn"]);
75947595
}
75957596
if (output["ServiceLinkedRoleARN"] !== undefined) {
75967597
contents.ServiceLinkedRoleARN = output["ServiceLinkedRoleARN"];
@@ -7599,7 +7600,7 @@ const deserializeAws_queryAutoScalingGroup = (output: any, context: __SerdeConte
75997600
contents.MaxInstanceLifetime = parseInt(output["MaxInstanceLifetime"]);
76007601
}
76017602
if (output["CapacityRebalance"] !== undefined) {
7602-
contents.CapacityRebalance = output["CapacityRebalance"] == "true";
7603+
contents.CapacityRebalance = __parseBoolean(output["CapacityRebalance"]);
76037604
}
76047605
if (output["WarmPoolConfiguration"] !== undefined) {
76057606
contents.WarmPoolConfiguration = deserializeAws_queryWarmPoolConfiguration(
@@ -7685,7 +7686,7 @@ const deserializeAws_queryAutoScalingInstanceDetails = (
76857686
contents.LaunchTemplate = deserializeAws_queryLaunchTemplateSpecification(output["LaunchTemplate"], context);
76867687
}
76877688
if (output["ProtectedFromScaleIn"] !== undefined) {
7688-
contents.ProtectedFromScaleIn = output["ProtectedFromScaleIn"] == "true";
7689+
contents.ProtectedFromScaleIn = __parseBoolean(output["ProtectedFromScaleIn"]);
76897690
}
76907691
if (output["WeightedCapacity"] !== undefined) {
76917692
contents.WeightedCapacity = output["WeightedCapacity"];
@@ -7810,7 +7811,7 @@ const deserializeAws_queryBlockDeviceMapping = (output: any, context: __SerdeCon
78107811
contents.Ebs = deserializeAws_queryEbs(output["Ebs"], context);
78117812
}
78127813
if (output["NoDevice"] !== undefined) {
7813-
contents.NoDevice = output["NoDevice"] == "true";
7814+
contents.NoDevice = __parseBoolean(output["NoDevice"]);
78147815
}
78157816
return contents;
78167817
};
@@ -8255,13 +8256,13 @@ const deserializeAws_queryEbs = (output: any, context: __SerdeContext): Ebs => {
82558256
contents.VolumeType = output["VolumeType"];
82568257
}
82578258
if (output["DeleteOnTermination"] !== undefined) {
8258-
contents.DeleteOnTermination = output["DeleteOnTermination"] == "true";
8259+
contents.DeleteOnTermination = __parseBoolean(output["DeleteOnTermination"]);
82598260
}
82608261
if (output["Iops"] !== undefined) {
82618262
contents.Iops = parseInt(output["Iops"]);
82628263
}
82638264
if (output["Encrypted"] !== undefined) {
8264-
contents.Encrypted = output["Encrypted"] == "true";
8265+
contents.Encrypted = __parseBoolean(output["Encrypted"]);
82658266
}
82668267
if (output["Throughput"] !== undefined) {
82678268
contents.Throughput = parseInt(output["Throughput"]);
@@ -8422,7 +8423,7 @@ const deserializeAws_queryInstance = (output: any, context: __SerdeContext): Ins
84228423
contents.LaunchTemplate = deserializeAws_queryLaunchTemplateSpecification(output["LaunchTemplate"], context);
84238424
}
84248425
if (output["ProtectedFromScaleIn"] !== undefined) {
8425-
contents.ProtectedFromScaleIn = output["ProtectedFromScaleIn"] == "true";
8426+
contents.ProtectedFromScaleIn = __parseBoolean(output["ProtectedFromScaleIn"]);
84268427
}
84278428
if (output["WeightedCapacity"] !== undefined) {
84288429
contents.WeightedCapacity = output["WeightedCapacity"];
@@ -8453,7 +8454,7 @@ const deserializeAws_queryInstanceMonitoring = (output: any, context: __SerdeCon
84538454
Enabled: undefined,
84548455
};
84558456
if (output["Enabled"] !== undefined) {
8456-
contents.Enabled = output["Enabled"] == "true";
8457+
contents.Enabled = __parseBoolean(output["Enabled"]);
84578458
}
84588459
return contents;
84598460
};
@@ -8725,10 +8726,10 @@ const deserializeAws_queryLaunchConfiguration = (output: any, context: __SerdeCo
87258726
contents.CreatedTime = new Date(output["CreatedTime"]);
87268727
}
87278728
if (output["EbsOptimized"] !== undefined) {
8728-
contents.EbsOptimized = output["EbsOptimized"] == "true";
8729+
contents.EbsOptimized = __parseBoolean(output["EbsOptimized"]);
87298730
}
87308731
if (output["AssociatePublicIpAddress"] !== undefined) {
8731-
contents.AssociatePublicIpAddress = output["AssociatePublicIpAddress"] == "true";
8732+
contents.AssociatePublicIpAddress = __parseBoolean(output["AssociatePublicIpAddress"]);
87328733
}
87338734
if (output["PlacementTenancy"] !== undefined) {
87348735
contents.PlacementTenancy = output["PlacementTenancy"];
@@ -9519,7 +9520,7 @@ const deserializeAws_queryScalingPolicy = (output: any, context: __SerdeContext)
95199520
);
95209521
}
95219522
if (output["Enabled"] !== undefined) {
9522-
contents.Enabled = output["Enabled"] == "true";
9523+
contents.Enabled = __parseBoolean(output["Enabled"]);
95239524
}
95249525
if (output["PredictiveScalingConfiguration"] !== undefined) {
95259526
contents.PredictiveScalingConfiguration = deserializeAws_queryPredictiveScalingConfiguration(
@@ -9740,7 +9741,7 @@ const deserializeAws_queryTagDescription = (output: any, context: __SerdeContext
97409741
contents.Value = output["Value"];
97419742
}
97429743
if (output["PropagateAtLaunch"] !== undefined) {
9743-
contents.PropagateAtLaunch = output["PropagateAtLaunch"] == "true";
9744+
contents.PropagateAtLaunch = __parseBoolean(output["PropagateAtLaunch"]);
97449745
}
97459746
return contents;
97469747
};
@@ -9810,7 +9811,7 @@ const deserializeAws_queryTargetTrackingConfiguration = (
98109811
contents.TargetValue = parseFloat(output["TargetValue"]);
98119812
}
98129813
if (output["DisableScaleIn"] !== undefined) {
9813-
contents.DisableScaleIn = output["DisableScaleIn"] == "true";
9814+
contents.DisableScaleIn = __parseBoolean(output["DisableScaleIn"]);
98149815
}
98159816
return contents;
98169817
};

clients/client-cloudformation/protocols/Aws_query.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ import {
309309
extendedEncodeURIComponent as __extendedEncodeURIComponent,
310310
getArrayIfSingleItem as __getArrayIfSingleItem,
311311
getValueFromTextNode as __getValueFromTextNode,
312+
parseBoolean as __parseBoolean,
312313
} from "@aws-sdk/smithy-client";
313314
import {
314315
Endpoint as __Endpoint,
@@ -6449,10 +6450,10 @@ const deserializeAws_queryAutoDeployment = (output: any, context: __SerdeContext
64496450
RetainStacksOnAccountRemoval: undefined,
64506451
};
64516452
if (output["Enabled"] !== undefined) {
6452-
contents.Enabled = output["Enabled"] == "true";
6453+
contents.Enabled = __parseBoolean(output["Enabled"]);
64536454
}
64546455
if (output["RetainStacksOnAccountRemoval"] !== undefined) {
6455-
contents.RetainStacksOnAccountRemoval = output["RetainStacksOnAccountRemoval"] == "true";
6456+
contents.RetainStacksOnAccountRemoval = __parseBoolean(output["RetainStacksOnAccountRemoval"]);
64566457
}
64576458
return contents;
64586459
};
@@ -6570,7 +6571,7 @@ const deserializeAws_queryChangeSetSummary = (output: any, context: __SerdeConte
65706571
contents.Description = output["Description"];
65716572
}
65726573
if (output["IncludeNestedStacks"] !== undefined) {
6573-
contents.IncludeNestedStacks = output["IncludeNestedStacks"] == "true";
6574+
contents.IncludeNestedStacks = __parseBoolean(output["IncludeNestedStacks"]);
65746575
}
65756576
if (output["ParentChangeSetId"] !== undefined) {
65766577
contents.ParentChangeSetId = output["ParentChangeSetId"];
@@ -6825,7 +6826,7 @@ const deserializeAws_queryDescribeChangeSetOutput = (output: any, context: __Ser
68256826
contents.NextToken = output["NextToken"];
68266827
}
68276828
if (output["IncludeNestedStacks"] !== undefined) {
6828-
contents.IncludeNestedStacks = output["IncludeNestedStacks"] == "true";
6829+
contents.IncludeNestedStacks = __parseBoolean(output["IncludeNestedStacks"]);
68296830
}
68306831
if (output["ParentChangeSetId"] !== undefined) {
68316832
contents.ParentChangeSetId = output["ParentChangeSetId"];
@@ -7036,7 +7037,7 @@ const deserializeAws_queryDescribeTypeOutput = (output: any, context: __SerdeCon
70367037
contents.DefaultVersionId = output["DefaultVersionId"];
70377038
}
70387039
if (output["IsDefaultVersion"] !== undefined) {
7039-
contents.IsDefaultVersion = output["IsDefaultVersion"] == "true";
7040+
contents.IsDefaultVersion = __parseBoolean(output["IsDefaultVersion"]);
70407041
}
70417042
if (output["Description"] !== undefined) {
70427043
contents.Description = output["Description"];
@@ -7785,7 +7786,7 @@ const deserializeAws_queryParameter = (output: any, context: __SerdeContext): Pa
77857786
contents.ParameterValue = output["ParameterValue"];
77867787
}
77877788
if (output["UsePreviousValue"] !== undefined) {
7788-
contents.UsePreviousValue = output["UsePreviousValue"] == "true";
7789+
contents.UsePreviousValue = __parseBoolean(output["UsePreviousValue"]);
77897790
}
77907791
if (output["ResolvedValue"] !== undefined) {
77917792
contents.ResolvedValue = output["ResolvedValue"];
@@ -7828,7 +7829,7 @@ const deserializeAws_queryParameterDeclaration = (output: any, context: __SerdeC
78287829
contents.ParameterType = output["ParameterType"];
78297830
}
78307831
if (output["NoEcho"] !== undefined) {
7831-
contents.NoEcho = output["NoEcho"] == "true";
7832+
contents.NoEcho = __parseBoolean(output["NoEcho"]);
78327833
}
78337834
if (output["Description"] !== undefined) {
78347835
contents.Description = output["Description"];
@@ -8271,7 +8272,7 @@ const deserializeAws_queryStack = (output: any, context: __SerdeContext): Stack
82718272
contents.StackStatusReason = output["StackStatusReason"];
82728273
}
82738274
if (output["DisableRollback"] !== undefined) {
8274-
contents.DisableRollback = output["DisableRollback"] == "true";
8275+
contents.DisableRollback = __parseBoolean(output["DisableRollback"]);
82758276
}
82768277
if (output.NotificationARNs === "") {
82778278
contents.NotificationARNs = [];
@@ -8310,7 +8311,7 @@ const deserializeAws_queryStack = (output: any, context: __SerdeContext): Stack
83108311
contents.Tags = deserializeAws_queryTags(__getArrayIfSingleItem(output["Tags"]["member"]), context);
83118312
}
83128313
if (output["EnableTerminationProtection"] !== undefined) {
8313-
contents.EnableTerminationProtection = output["EnableTerminationProtection"] == "true";
8314+
contents.EnableTerminationProtection = __parseBoolean(output["EnableTerminationProtection"]);
83148315
}
83158316
if (output["ParentId"] !== undefined) {
83168317
contents.ParentId = output["ParentId"];
@@ -9040,7 +9041,7 @@ const deserializeAws_queryStackSetOperation = (output: any, context: __SerdeCont
90409041
);
90419042
}
90429043
if (output["RetainStacks"] !== undefined) {
9043-
contents.RetainStacks = output["RetainStacks"] == "true";
9044+
contents.RetainStacks = __parseBoolean(output["RetainStacks"]);
90449045
}
90459046
if (output["AdministrationRoleARN"] !== undefined) {
90469047
contents.AdministrationRoleARN = output["AdministrationRoleARN"];
@@ -9373,7 +9374,7 @@ const deserializeAws_queryTemplateParameter = (output: any, context: __SerdeCont
93739374
contents.DefaultValue = output["DefaultValue"];
93749375
}
93759376
if (output["NoEcho"] !== undefined) {
9376-
contents.NoEcho = output["NoEcho"] == "true";
9377+
contents.NoEcho = __parseBoolean(output["NoEcho"]);
93779378
}
93789379
if (output["Description"] !== undefined) {
93799380
contents.Description = output["Description"];
@@ -9498,7 +9499,7 @@ const deserializeAws_queryTypeVersionSummary = (output: any, context: __SerdeCon
94989499
contents.VersionId = output["VersionId"];
94999500
}
95009501
if (output["IsDefaultVersion"] !== undefined) {
9501-
contents.IsDefaultVersion = output["IsDefaultVersion"] == "true";
9502+
contents.IsDefaultVersion = __parseBoolean(output["IsDefaultVersion"]);
95029503
}
95039504
if (output["Arn"] !== undefined) {
95049505
contents.Arn = output["Arn"];

0 commit comments

Comments
 (0)