Skip to content

Commit dab391d

Browse files
authored
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
Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 40 additions & 37 deletions
Large diffs are not rendered by default.

generator/ServiceClientGeneratorLib/Generators/SourceFiles/ServiceConfig.tt

Lines changed: 3 additions & 0 deletions
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

Lines changed: 0 additions & 20 deletions
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

Lines changed: 0 additions & 25 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 0 additions & 22 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 0 additions & 5 deletions
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.

0 commit comments

Comments
 (0)