Skip to content

Commit 3eb4d46

Browse files
committedMar 4, 2025
Additional refactoring to remove unused code
1 parent c732b06 commit 3eb4d46

File tree

3 files changed

+0
-253
lines changed

3 files changed

+0
-253
lines changed
 

‎sdk/src/Services/EC2/Custom/Internal/AmazonEC2PreMarshallHandler.cs

-58
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ namespace Amazon.EC2.Internal
3131
/// </summary>
3232
public class AmazonEC2PreMarshallHandler : PipelineHandler
3333
{
34-
/// <summary>
35-
/// Internal enum IpRangeValue to determine which of IpRange or Ipv4Ranges property will be used
36-
/// to make a request. If both properties are set differently, an exception will be thrown.
37-
/// </summary>
38-
internal enum IpRangeValue
39-
{
40-
Invalid,
41-
Ipv4Ranges
42-
}
43-
4434
private readonly AWSCredentials _credentials;
4535

4636
/// <summary>
@@ -178,54 +168,6 @@ protected void PreInvoke(IExecutionContext executionContext)
178168

179169
copySnapshotRequest.PresignedUrl = url.AbsoluteUri + authorization;
180170
}
181-
182-
var authorizeSecurityGroupEgressRequest = request as AuthorizeSecurityGroupEgressRequest;
183-
if (authorizeSecurityGroupEgressRequest != null)
184-
if (authorizeSecurityGroupEgressRequest.IsSetIpPermissions())
185-
SelectModifiedIpRange(authorizeSecurityGroupEgressRequest.IpPermissions);
186-
187-
var authorizeSecurityGroupIngressRequest = request as AuthorizeSecurityGroupIngressRequest;
188-
if (authorizeSecurityGroupIngressRequest != null)
189-
if (authorizeSecurityGroupIngressRequest.IsSetIpPermissions())
190-
SelectModifiedIpRange(authorizeSecurityGroupIngressRequest.IpPermissions);
191-
192-
var revokeSecurityGroupEgressRequest = request as RevokeSecurityGroupEgressRequest;
193-
if (revokeSecurityGroupEgressRequest != null)
194-
if (revokeSecurityGroupEgressRequest.IsSetIpPermissions())
195-
SelectModifiedIpRange(revokeSecurityGroupEgressRequest.IpPermissions);
196-
197-
var revokeSecurityGroupIngressRequest = request as RevokeSecurityGroupIngressRequest;
198-
if (revokeSecurityGroupIngressRequest != null)
199-
if (revokeSecurityGroupIngressRequest.IsSetIpPermissions())
200-
SelectModifiedIpRange(revokeSecurityGroupIngressRequest.IpPermissions);
201-
202-
var updateSecurityGroupRuleDescriptionsEgressRequest = request as UpdateSecurityGroupRuleDescriptionsEgressRequest;
203-
if (updateSecurityGroupRuleDescriptionsEgressRequest != null)
204-
if (updateSecurityGroupRuleDescriptionsEgressRequest.IsSetIpPermissions())
205-
SelectModifiedIpRange(updateSecurityGroupRuleDescriptionsEgressRequest.IpPermissions);
206-
207-
var updateSecurityGroupRuleDescriptionsIngressRequest = request as UpdateSecurityGroupRuleDescriptionsIngressRequest;
208-
if (updateSecurityGroupRuleDescriptionsIngressRequest != null)
209-
if (updateSecurityGroupRuleDescriptionsIngressRequest.IsSetIpPermissions())
210-
SelectModifiedIpRange(updateSecurityGroupRuleDescriptionsIngressRequest.IpPermissions);
211-
}
212-
213-
/// <summary>
214-
/// Analyse the user provided IpPermissions in the request to determine which of IpRanges/Ipv4ranges property will be used to make the final request.
215-
/// If both IpRanges and Ipv4Ranges are set with the same Cidr values, Ipv4Range property is selected.
216-
/// If no modifications have been made on either of IpRanges Ipv4ranges properties, Ipv4Ranges property is selected.
217-
/// If both IpRanges and Ipv4Ranges are set differently, an ArgumentException is thrown.
218-
/// </summary>
219-
/// <param name="IpPermissions"></param>
220-
private static void SelectModifiedIpRange(List<IpPermission> IpPermissions)
221-
{
222-
if (IpPermissions == null)
223-
return;
224-
225-
foreach (var ipPermission in IpPermissions)
226-
{
227-
ipPermission.SelectIpV4RangeForMarshalling(ipPermission.Ipv4Ranges);
228-
}
229171
}
230172
}
231173
}

‎sdk/src/Services/EC2/Custom/Internal/AmazonEC2ResponseHandler.cs

-110
Original file line numberDiff line numberDiff line change
@@ -118,116 +118,6 @@ protected virtual void PostInvoke(IExecutionContext executionContext)
118118
PopulateReservationSecurityGroupNames(rir.Reservation);
119119
return;
120120
}
121-
122-
// In case of DescribeSecurityGroupsResponse type, the Ipv4Ranges values for each of the retured IpPermissions is unmarshalled
123-
// and the extracted Cidr values is set on the IpRanges property of IpPermission. If the customer is using IpRanges, then they will not be broken.
124-
var describeSecurityGroupsResponse = response as DescribeSecurityGroupsResponse;
125-
if(describeSecurityGroupsResponse!=null)
126-
{
127-
if(describeSecurityGroupsResponse.IsSetSecurityGroups())
128-
{
129-
foreach (var securityGroup in describeSecurityGroupsResponse.SecurityGroups)
130-
{
131-
if (securityGroup.IsSetIpPermissions())
132-
{
133-
SetIpRangesProperty(securityGroup.IpPermissions);
134-
}
135-
else if(securityGroup.IsSetIpPermissionsEgress())
136-
{
137-
SetIpRangesProperty(securityGroup.IpPermissionsEgress);
138-
}
139-
}
140-
}
141-
return;
142-
}
143-
144-
var authorizeSecurityGroupEgressRequest = request as AuthorizeSecurityGroupEgressRequest;
145-
if (authorizeSecurityGroupEgressRequest != null)
146-
if (authorizeSecurityGroupEgressRequest.IsSetIpPermissions())
147-
{
148-
RestoreRequestIpPermissions(authorizeSecurityGroupEgressRequest.IpPermissions);
149-
return;
150-
}
151-
152-
var authorizeSecurityGroupIngressRequest = request as AuthorizeSecurityGroupIngressRequest;
153-
if (authorizeSecurityGroupIngressRequest != null)
154-
if (authorizeSecurityGroupIngressRequest.IsSetIpPermissions())
155-
{
156-
RestoreRequestIpPermissions(authorizeSecurityGroupIngressRequest.IpPermissions);
157-
return;
158-
}
159-
160-
161-
var revokeSecurityGroupEgressRequest = request as RevokeSecurityGroupEgressRequest;
162-
if (revokeSecurityGroupEgressRequest != null)
163-
if (revokeSecurityGroupEgressRequest.IsSetIpPermissions())
164-
{
165-
RestoreRequestIpPermissions(revokeSecurityGroupEgressRequest.IpPermissions);
166-
return;
167-
}
168-
169-
170-
var revokeSecurityGroupIngressRequest = request as RevokeSecurityGroupIngressRequest;
171-
if (revokeSecurityGroupIngressRequest != null)
172-
if (revokeSecurityGroupIngressRequest.IsSetIpPermissions())
173-
{
174-
RestoreRequestIpPermissions(revokeSecurityGroupIngressRequest.IpPermissions);
175-
return;
176-
}
177-
178-
179-
var updateSecurityGroupRuleDescriptionsEgressRequest = request as UpdateSecurityGroupRuleDescriptionsEgressRequest;
180-
if (updateSecurityGroupRuleDescriptionsEgressRequest != null)
181-
if (updateSecurityGroupRuleDescriptionsEgressRequest.IsSetIpPermissions())
182-
{
183-
RestoreRequestIpPermissions(updateSecurityGroupRuleDescriptionsEgressRequest.IpPermissions);
184-
return;
185-
}
186-
187-
188-
var updateSecurityGroupRuleDescriptionsIngressRequest = request as UpdateSecurityGroupRuleDescriptionsIngressRequest;
189-
if (updateSecurityGroupRuleDescriptionsIngressRequest != null)
190-
if (updateSecurityGroupRuleDescriptionsIngressRequest.IsSetIpPermissions())
191-
{
192-
RestoreRequestIpPermissions(updateSecurityGroupRuleDescriptionsIngressRequest.IpPermissions);
193-
return;
194-
}
195-
196-
}
197-
198-
/// <summary>
199-
/// Cidr values from Ipv4Ranges is extracted and set on IpRanges.
200-
/// The internal dictionary collection is also set to the Ipv4Range values.
201-
/// </summary>
202-
/// <param name="ipPermissions"></param>
203-
private static void SetIpRangesProperty(List<IpPermission> ipPermissions)
204-
{
205-
foreach (var ipPermission in ipPermissions)
206-
{
207-
if (ipPermission.Ipv4Ranges == null)
208-
{
209-
continue;
210-
}
211-
212-
ipPermission.CopyIpv4RangesToInternalCollection(ipPermission.Ipv4Ranges);
213-
}
214-
}
215-
216-
/// <summary>
217-
/// The original values used by the customer in the Ipv4Ranges property on the request
218-
/// object is restored. This is done when the customer is using the deprecated IpRanges property.
219-
/// </summary>
220-
/// <param name="IpPermissions"></param>
221-
private static void RestoreRequestIpPermissions(List<IpPermission> IpPermissions)
222-
{
223-
foreach (var ipPermission in IpPermissions)
224-
{
225-
if (ipPermission.RestoreOldIpV4Range)
226-
{
227-
ipPermission.Ipv4Ranges = ipPermission.PreIpv4Ranges;
228-
ipPermission.RestoreOldIpV4Range = false;
229-
}
230-
}
231121
}
232122

233123
private static void PopulateLaunchSpecificationSecurityGroupNames(LaunchSpecification launchSpecification)

‎sdk/src/Services/EC2/Custom/Model/IpPermission.cs

-85
This file was deleted.

0 commit comments

Comments
 (0)
Failed to load comments.