Skip to content

Commit dab391d

Browse files
authoredMar 6, 2025
Remove obsolete endpoint logic code (#3680)
1 parent db94a97 commit dab391d

File tree

37 files changed

+96
-632
lines changed

37 files changed

+96
-632
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"core": {
3+
"changeLogMessages": [
4+
"Remove obsolete endpoint logic code",
5+
"Remove obsolete global ClockSkew property"
6+
],
7+
"type": "patch",
8+
"updateMinimum": true
9+
}
10+
}

‎generator/ServiceClientGeneratorLib/Generators/Endpoints/EndpointResolver.partial.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private string GetValueSource(Parameter parameter)
1414
{
1515
switch (parameter.builtIn)
1616
{
17-
case "AWS::Region": return "config.RegionEndpoint?.SystemName";
17+
case "AWS::Region": return "requestContext.Request.AlternateEndpoint?.SystemName ?? config.RegionEndpoint?.SystemName;";
1818
case "AWS::UseFIPS": return "config.UseFIPSEndpoint";
1919
case "AWS::UseDualStack": return "config.UseDualstackEndpoint";
2020
case "SDK::Endpoint": return "config.ServiceURL";

‎generator/ServiceClientGeneratorLib/Generators/SourceFiles/ServiceConfig.cs

+40-37
Large diffs are not rendered by default.

‎generator/ServiceClientGeneratorLib/Generators/SourceFiles/ServiceConfig.tt

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ namespace <#=this.Config.Namespace#>
135135
ClientConfig = this,
136136
OriginalRequest = parameters.Request,
137137
Request = new DefaultRequest(parameters.Request, ServiceId)
138+
{
139+
AlternateEndpoint = parameters.AlternateEndpoint
140+
}
138141
};
139142

140143
var executionContext = new Amazon.Runtime.Internal.ExecutionContext(requestContext, null);

‎sdk/src/Core/AWSConfigs.cs

-20
Original file line numberDiff line numberDiff line change
@@ -123,33 +123,13 @@ public static TimeSpan? ManualClockCorrection
123123
/// by determining the correct server time and reissuing the
124124
/// request with the correct time.
125125
/// Default value of this field is True.
126-
/// <seealso cref="ClockOffset"/> will be updated with the calculated
127-
/// offset even if this field is set to false, though requests
128-
/// will not be corrected or retried.
129-
/// Ignored if <seealso cref="ManualClockCorrection"/> is set.
130126
/// </summary>
131127
public static bool CorrectForClockSkew
132128
{
133129
get { return _rootConfig.CorrectForClockSkew; }
134130
set { _rootConfig.CorrectForClockSkew = value; }
135131
}
136132

137-
/// <summary>
138-
/// The calculated clock skew correction, if there is one.
139-
/// This field will be set if a service call resulted in an exception
140-
/// and the SDK has determined that there is a difference between local
141-
/// and server times.
142-
///
143-
/// If <seealso cref="CorrectForClockSkew"/> is set to true, this
144-
/// value will be set to the correction, but it will not be used by the
145-
/// SDK and clock skew errors will not be retried.
146-
/// </summary>
147-
[Obsolete("This value is deprecated in favor of IClientConfig.ClockOffset, use CorrectClockSkew.GetClockCorrectionForEndpoint(string endpoint) instead.")]
148-
public static TimeSpan ClockOffset
149-
{
150-
get;
151-
internal set;
152-
}
153133
#endregion
154134

155135
#region Region

‎sdk/src/Core/Amazon.Runtime/ClientConfig.cs

-25
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121

2222
using Amazon.Util;
23-
using Amazon.Internal;
2423
using Amazon.Runtime.Endpoints;
2524
using Amazon.Runtime.Internal;
2625
using Amazon.Runtime.Internal.Util;
@@ -417,18 +416,6 @@ public bool UseHttp
417416
set { this.useHttp = value; }
418417
}
419418

420-
internal static string GetUrl(IClientConfig config, RegionEndpoint regionEndpoint)
421-
{
422-
#pragma warning disable CS0612,CS0618
423-
var endpoint =
424-
regionEndpoint.GetEndpointForService(
425-
config.RegionEndpointServiceName,
426-
config.ToGetEndpointForServiceOptions());
427-
#pragma warning restore CS0612,CS0618
428-
string url = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}", config.UseHttp ? "http://" : "https://", endpoint.Hostname)).AbsoluteUri;
429-
return url;
430-
}
431-
432419
/// <summary>
433420
/// Gets and sets the AuthenticationRegion property.
434421
/// Used in AWS4 request signing, this is an optional property;
@@ -958,18 +945,6 @@ public virtual void Validate()
958945
#endif
959946
}
960947

961-
/// <summary>
962-
/// Wrapper around <seealso cref="AWSConfigs.ManualClockCorrection"/>
963-
/// </summary>
964-
[Obsolete("Please use CorrectClockSkew.GetClockCorrectionForEndpoint(string endpoint) instead.", false)]
965-
public TimeSpan ClockOffset
966-
{
967-
get
968-
{
969-
return AWSConfigs.ManualClockCorrection.GetValueOrDefault();
970-
}
971-
}
972-
973948
/// <summary>
974949
/// Gets and sets the DisableHostPrefixInjection flag. If true, host prefix injection will be disabled for this client, the default value of this flag is false.
975950
/// Host prefix injection prefixes the service endpoint with request members from APIs which use this feature.

‎sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs

-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ internal static void SetClockCorrectionForEndpoint(string endpoint, TimeSpan cor
127127
try
128128
{
129129
clockCorrectionDictionary[endpoint] = correction;
130-
#pragma warning disable CS0618 // Type or member is obsolete
131-
AWSConfigs.ClockOffset = correction;
132-
#pragma warning restore CS0618 // Type or member is obsolete
133130
}
134131
finally
135132
{

‎sdk/src/Core/Amazon.Runtime/Credentials/URIBasedRefreshingCredentialHelper.cs

-22
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,6 @@ protected static string GetContents(Uri uri, IWebProxy proxy, Dictionary<string,
5151
}
5252
}
5353

54-
[Obsolete("This method is not compatible with Native AOT builds. The GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
55-
[RequiresUnreferencedCode("GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
56-
protected static T GetObjectFromResponse<T>(Uri uri)
57-
{
58-
return GetObjectFromResponse<T>(uri, null, null);
59-
}
60-
61-
[Obsolete("This method is not compatible with Native AOT builds. The GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
62-
[RequiresUnreferencedCode("GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
63-
protected static T GetObjectFromResponse<T>(Uri uri, IWebProxy proxy)
64-
{
65-
return GetObjectFromResponse<T>(uri, proxy, null);
66-
}
67-
68-
[Obsolete("This method is not compatible with Native AOT builds. The GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
69-
[RequiresUnreferencedCode("GetObjectFromResponse overload using the generic parameter taking in a JsonSerializerContext should be used instead.")]
70-
protected static T GetObjectFromResponse<T>(Uri uri, IWebProxy proxy, Dictionary<string, string> headers)
71-
{
72-
string json = GetContents(uri, proxy, headers);
73-
return JsonSerializer.Deserialize<T>(json);
74-
}
75-
7654
protected static T GetObjectFromResponse<T, TC>(Uri uri, IWebProxy proxy, Dictionary<string, string> headers)
7755
where TC :
7856
#if NET8_0_OR_GREATER

‎sdk/src/Core/Amazon.Runtime/Endpoints/ServiceOperationEndpointParameters.cs

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
using System;
1616
using System.Collections.Generic;
17+
using System.Text.RegularExpressions;
1718

1819
namespace Amazon.Runtime.Endpoints
1920
{
@@ -27,9 +28,20 @@ public ServiceOperationEndpointParameters(AmazonWebServiceRequest request)
2728
Request = request;
2829
}
2930

31+
public ServiceOperationEndpointParameters(AmazonWebServiceRequest request, RegionEndpoint alternateEndpoint)
32+
: this(request)
33+
{
34+
AlternateEndpoint = alternateEndpoint;
35+
}
36+
3037
/// <summary>
3138
/// Request for the desired service operation.
3239
/// </summary>
3340
public AmazonWebServiceRequest Request { get; }
41+
42+
/// <summary>
43+
/// Alternate endpoint that overrides the endpoint configured for service client.
44+
/// </summary>
45+
public RegionEndpoint AlternateEndpoint { get; }
3446
}
3547
}

‎sdk/src/Core/Amazon.Runtime/IClientConfig.cs

-5
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,6 @@ public partial interface IClientConfig
319319
/// <exception cref="Amazon.Runtime.AmazonClientException">The timeout specified is null.</exception>
320320
void Validate();
321321

322-
/// <summary>
323-
/// Returns the calculated clock skew value for this config's service endpoint. If AWSConfigs.CorrectForClockSkew is false,
324-
/// this value won't be used to construct service requests.
325-
/// </summary>
326-
TimeSpan ClockOffset { get; }
327322
/// <summary>
328323
/// Gets the DisableHostPrefixInjection flag. If true, host prefix injection will be disabled for this client, the default value of this flag is false.
329324
/// Host prefix injection prefixes the service endpoint with request members from APIs which use this feature.

‎sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4Signer.cs

-17
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using System.Linq;
1919
using System.Text;
2020
using System.Globalization;
21-
using Amazon.Internal;
2221
using Amazon.Util;
2322
using Amazon.Runtime.Internal.Util;
2423
using Amazon.Runtime.Endpoints;
@@ -639,12 +638,6 @@ public static string DetermineSigningRegion(IClientConfig clientConfig,
639638
// client config properties.
640639
if (alternateEndpoint != null)
641640
{
642-
#pragma warning disable CS0612,CS0618
643-
var serviceEndpoint = alternateEndpoint.GetEndpointForService(serviceName, clientConfig.ToGetEndpointForServiceOptions());
644-
#pragma warning restore CS0612,CS0618
645-
if (serviceEndpoint.AuthRegion != null)
646-
return serviceEndpoint.AuthRegion;
647-
648641
return alternateEndpoint.SystemName;
649642
}
650643

@@ -670,16 +663,6 @@ public static string DetermineSigningRegion(IClientConfig clientConfig,
670663
var endpoint = clientConfig.RegionEndpoint;
671664
if (endpoint != null)
672665
{
673-
#pragma warning disable CS0612,CS0618
674-
var serviceEndpoint = endpoint.GetEndpointForService(serviceName, clientConfig.ToGetEndpointForServiceOptions());
675-
if (!string.IsNullOrEmpty(serviceEndpoint.AuthRegion))
676-
return serviceEndpoint.AuthRegion;
677-
678-
// Check if the region is overridden in the endpoints.json file
679-
var overrideRegion = RegionEndpoint.GetRegionEndpointOverride(endpoint);
680-
if (overrideRegion != null)
681-
return overrideRegion.SystemName;
682-
#pragma warning restore CS0612,CS0618
683666
return endpoint.SystemName;
684667
}
685668

‎sdk/src/Core/Amazon.Runtime/Internal/Auth/AbstractAWSSigner.cs

-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
* permissions and limitations under the License.
1414
*/
1515
using System;
16-
using System.Collections.Generic;
17-
using System.Text;
18-
using System.Net;
19-
#if AWS_ASYNC_API
2016
using System.Threading;
2117
using System.Threading.Tasks;
22-
#endif
23-
using Amazon.Internal;
2418
using Amazon.Util;
2519
using Amazon.Runtime.Internal.Util;
2620
using Amazon.Runtime.Identity;

‎sdk/src/Core/Amazon.Runtime/Pipeline/Handlers/EndpointResolver.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ public virtual Uri DetermineEndpoint(IRequestContext requestContext)
7676

7777
public static Uri DetermineEndpoint(IClientConfig config, IRequest request)
7878
{
79-
Uri endpoint = request.AlternateEndpoint != null
80-
? new Uri(ClientConfig.GetUrl(config, request.AlternateEndpoint))
81-
: new Uri(config.DetermineServiceOperationEndpoint(
82-
new ServiceOperationEndpointParameters(request.OriginalRequest)).URL);
79+
Uri endpoint = new Uri(config.DetermineServiceOperationEndpoint(
80+
new ServiceOperationEndpointParameters(request.OriginalRequest, request.AlternateEndpoint)).URL);
8381

8482
return InjectHostPrefix(config, request, endpoint);
8583
}

‎sdk/src/Core/Amazon.Runtime/Pipeline/RetryHandler/RetryPolicy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ private bool IsClockskew(IExecutionContext executionContext, Exception exception
452452
if (isDefiniteClockSkewErrorCode && serverTimeDetermined)
453453
{
454454
Logger.InfoFormat(clockSkewMessageFormat,
455-
realNow, correctedNow, clientConfig.ClockOffset, serverTime, endpoint);
455+
realNow, correctedNow, CorrectClockSkew.GetCorrectedUtcNowForEndpoint(endpoint), serverTime, endpoint);
456456
var newCorrection = serverTime - realNow;
457457
CorrectClockSkew.SetClockCorrectionForEndpoint(endpoint, newCorrection);
458458
if (shouldRetry)

‎sdk/src/Core/Amazon.Util/AWSSDKUtils.cs

+1-22
Original file line numberDiff line numberDiff line change
@@ -480,28 +480,7 @@ public static IEnumerable<UriComponent> SplitResourcePathIntoSegmentsV2(string r
480480

481481
return uriComponentSegments;
482482
}
483-
484-
/// <summary>
485-
/// Joins all path segments with the / character and encodes each segment before joining.
486-
/// </summary>
487-
/// <param name="pathSegments">The segments of a URL path split at each / character</param>
488-
/// <param name="path">If the path property is specified,
489-
/// the accepted path characters {/+:} are not encoded.</param>
490-
/// <returns>A joined URL with encoded segments</returns>
491-
[Obsolete("This method has been deprecated due to an issue with not encoding special characters. Use JoinResourcePathSegmentsV2 instead.")]
492-
public static string JoinResourcePathSegments(IEnumerable<string> pathSegments, bool path)
493-
{
494-
// Encode for canonicalization
495-
pathSegments = pathSegments.Select(segment => UrlEncode(segment, path));
496-
497-
if (path)
498-
{
499-
pathSegments = pathSegments.Select(segment => segment.Replace(Slash, EncodedSlash));
500-
}
501-
502-
// join the encoded segments with /
503-
return string.Join(Slash, pathSegments.ToArray());
504-
}
483+
505484
/// <summary>
506485
/// Joins all path segments with the / character and encodes each segment before joining
507486
/// </summary>

‎sdk/src/Core/Amazon.Util/Internal/InternalSDKUtils.cs

-33
Original file line numberDiff line numberDiff line change
@@ -144,39 +144,6 @@ public static string BuildUserAgentString(string serviceId, string serviceSdkVer
144144
}
145145

146146
#endregion
147-
[Obsolete("This method is not AOT safe and is no longer used in the SDK. Please use ApplyValuesV2 for AOT compatibility. This method is left here for backwards compatibility purposes")]
148-
public static void ApplyValues(object target, IDictionary<string, object> propertyValues)
149-
{
150-
if (propertyValues == null || propertyValues.Count == 0)
151-
return;
152-
153-
var targetType = target.GetType();
154-
155-
foreach(var kvp in propertyValues)
156-
{
157-
var property = targetType.GetProperty(kvp.Key);
158-
if (property == null)
159-
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unable to find property {0} on type {1}.", kvp.Key, targetType.FullName));
160-
161-
try
162-
{
163-
var propertyTypeInfo = property.PropertyType;
164-
if (propertyTypeInfo.IsEnum)
165-
{
166-
var enumValue = Enum.Parse(propertyTypeInfo, kvp.Value.ToString(), true);
167-
property.SetValue(target, enumValue, null);
168-
}
169-
else
170-
{
171-
property.SetValue(target, kvp.Value, null);
172-
}
173-
}
174-
catch(Exception e)
175-
{
176-
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unable to set property {0} on type {1}: {2}", kvp.Key, targetType.FullName, e.Message));
177-
}
178-
}
179-
}
180147

181148
public static void ApplyValuesV2<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T target, IDictionary<string, object> propertyValues)
182149
{

‎sdk/src/Core/Amazon.Util/Internal/RegionFinder.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717
using System.Collections.Generic;
1818
using System.Linq;
1919
using System.Text.RegularExpressions;
20-
using Amazon.Internal;
2120
using Amazon.Runtime.Internal.Util;
2221

2322
namespace Amazon.Util.Internal
2423
{
2524
/// <summary>
2625
/// Finds region string in the endpoint string using predefined rules
27-
/// If predefined rules fail to match the region, regular expression strings provided in
28-
/// endpoints.json are used to find the region.
26+
/// If predefined rules fail to match the region, regular expression are used to find the region.
2927
/// If regular expressions also fail, then a default region is returned.
3028
/// </summary>
3129
public class RegionFinder
@@ -67,7 +65,7 @@ internal RegionFinder()
6765

6866
/// <summary>
6967
/// Finds the region in the provided endpoint parsing from right to left
70-
/// Try to find exact match of the region in endpoints.json
68+
/// Try to find exact match of the region from the SDK's known regions.
7169
/// If there doesn't exist an exact match, find a fuzzy match
7270
/// Else return default region
7371
/// </summary>
@@ -131,7 +129,7 @@ public static string GetAuthority(string url)
131129
}
132130

133131
/// <summary>
134-
/// Find region in the endpoint using endpoints.json region regexs
132+
/// Find region in the endpoint using regexs
135133
/// If there doesn't exist a match, return null
136134
/// </summary>
137135
/// <param name="endpoint"></param>

0 commit comments

Comments
 (0)
Failed to load comments.