Skip to content

Commit

Permalink
Remove obsolete classes from core. Refactor clockskew unit tests in n…
Browse files Browse the repository at this point in the history
…etframework and netstandard. Update obsolete methods in commontest projects (#3401)
  • Loading branch information
peterrsongg authored Jul 31, 2024
1 parent a17338c commit 7244bd3
Show file tree
Hide file tree
Showing 19 changed files with 108 additions and 305 deletions.
128 changes: 0 additions & 128 deletions sdk/src/Core/AWSConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public static partial class AWSConfigs

// Deprecated configs
internal static string _awsRegion = GetConfig(AWSRegionKey);
internal static LoggingOptions _logging = GetLoggingSetting();
internal static ResponseLoggingOption _responseLogging = GetConfigEnum<ResponseLoggingOption>(ResponseLoggingKey);
internal static bool _logMetrics = GetConfigBool(LogMetricsKey);
internal static string _awsProfileName = GetConfig(AWSProfileNameKey);
internal static string _awsAccountsLocation = GetConfig(AWSProfilesLocationKey);
internal static bool _useSdkCache = GetConfigBool(UseSdkCacheKey, defaultValue: true);
Expand Down Expand Up @@ -121,33 +118,13 @@ public static TimeSpan? ManualClockCorrection
/// by determining the correct server time and reissuing the
/// request with the correct time.
/// Default value of this field is True.
/// <seealso cref="ClockOffset"/> will be updated with the calculated
/// offset even if this field is set to false, though requests
/// will not be corrected or retried.
/// Ignored if <seealso cref="ManualClockCorrection"/> is set.
/// </summary>
public static bool CorrectForClockSkew
{
get { return _rootConfig.CorrectForClockSkew; }
set { _rootConfig.CorrectForClockSkew = value; }
}

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

#region Region
Expand Down Expand Up @@ -213,7 +190,6 @@ public static string AWSProfileName

/// <summary>
/// Key for the AWSProfilesLocation property.
/// <seealso cref="Amazon.AWSConfigs.LogMetrics"/>
/// </summary>
public const string AWSProfilesLocationKey = "AWSProfilesLocation";

Expand Down Expand Up @@ -242,110 +218,6 @@ public static string AWSProfilesLocation

#endregion

#region Logging

/// <summary>
/// Key for the Logging property.
/// <seealso cref="Amazon.AWSConfigs.Logging"/>
/// </summary>
public const string LoggingKey = "AWSLogging";

/// <summary>
/// Configures how the SDK should log events, if at all.
/// Changes to this setting will only take effect in newly-constructed clients.
///
/// The setting can be configured through App.config, for example:
/// <code>
/// &lt;appSettings&gt;
/// &lt;add key="AWSLogging" value="log4net"/&gt;
/// &lt;/appSettings&gt;
/// </code>
/// </summary>
[Obsolete("This property is obsolete. Use LoggingConfig.LogTo instead.")]
public static LoggingOptions Logging
{
get { return _rootConfig.Logging.LogTo; }
set { _rootConfig.Logging.LogTo = value; }
}

private static LoggingOptions GetLoggingSetting()
{
string value = GetConfig(LoggingKey);
if (string.IsNullOrEmpty(value))
return LoggingOptions.None;

string[] settings = value.Split(validSeparators, StringSplitOptions.RemoveEmptyEntries);
if (settings == null || settings.Length == 0)
return LoggingOptions.None;

LoggingOptions totalSetting = LoggingOptions.None;
foreach (string setting in settings)
{
LoggingOptions l = ParseEnum<LoggingOptions>(setting);
totalSetting |= l;
}
return totalSetting;
}

#endregion

#region Response Logging

/// <summary>
/// Key for the ResponseLogging property.
///
/// <seealso cref="Amazon.AWSConfigs.ResponseLogging"/>
/// </summary>
public const string ResponseLoggingKey = "AWSResponseLogging";

/// <summary>
/// Configures when the SDK should log service responses.
/// Changes to this setting will take effect immediately.
///
/// The setting can be configured through App.config, for example:
/// <code>
/// &lt;appSettings&gt;
/// &lt;add key="AWSResponseLogging" value="OnError"/&gt;
/// &lt;/appSettings&gt;
/// </code>
/// </summary>
[Obsolete("This property is obsolete. Use LoggingConfig.LogResponses instead.")]
public static ResponseLoggingOption ResponseLogging
{
get { return _rootConfig.Logging.LogResponses; }
set { _rootConfig.Logging.LogResponses = value; }
}

#endregion

#region Log Metrics

/// <summary>
/// Key for the LogMetrics property.
/// <seealso cref="Amazon.AWSConfigs.LogMetrics"/>
/// </summary>
public const string LogMetricsKey = "AWSLogMetrics";

/// <summary>
/// Configures if the SDK should log performance metrics.
/// This setting configures the default LogMetrics property for all clients/configs.
/// Changes to this setting will only take effect in newly-constructed clients.
///
/// The setting can be configured through App.config, for example:
/// <code>
/// &lt;appSettings&gt;
/// &lt;add key="AWSLogMetrics" value="true"/&gt;
/// &lt;/appSettings&gt;
/// </code>
/// </summary>
[Obsolete("This property is obsolete. Use LoggingConfig.LogMetrics instead.")]
public static bool LogMetrics
{
get { return _rootConfig.Logging.LogMetrics; }
set { _rootConfig.Logging.LogMetrics = value; }
}

#endregion

#region SDK Cache

Expand Down
17 changes: 0 additions & 17 deletions sdk/src/Core/Amazon.Auth/AccessControlPolicy/ConditionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,6 @@ public static Condition NewCondition(string key, bool value)
return new Condition("Bool", key, value.ToString().ToLowerInvariant());
}

/// <summary>
/// This method is deprecated. Invoking this method results in non-UTC DateTimes
/// not being marshalled correctly. Use NewConditionUtc instead.
/// Constructs a new access policy condition that compares the current time
/// (on the AWS servers) to the specified date.
/// </summary>
/// <param name="type">The type of comparison to perform. For example,
/// DateComparisonType.DateLessThan will cause this policy
/// condition to evaluate to true if the current date is less than
/// the date specified in the second argument.</param>
/// <param name="date">The date to compare against.</param>
[Obsolete("Invoking this method results in non-UTC DateTimes not being marshalled correctly. Use NewConditionUtc instead.", false)]
public static Condition NewCondition(DateComparisonType type, DateTime date)
{
return new Condition(type.ToString(), CURRENT_TIME_CONDITION_KEY, date.ToString(AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture));
}

/// <summary>
/// Constructs a new access policy condition that compares the current time
/// (on the AWS servers) to the specified date.
Expand Down
26 changes: 0 additions & 26 deletions sdk/src/Core/Amazon.Runtime/AmazonServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,6 @@ protected virtual void Initialize()

#region Invoke methods

[Obsolete("Invoke taking marshallers is obsolete. Use Invoke taking InvokeOptionsBase instead.")]
protected TResponse Invoke<TRequest, TResponse>(TRequest request,
IMarshaller<IRequest, AmazonWebServiceRequest> marshaller, ResponseUnmarshaller unmarshaller)
where TRequest : AmazonWebServiceRequest
where TResponse : AmazonWebServiceResponse
{
var options = new InvokeOptions();
options.RequestMarshaller = marshaller;
options.ResponseUnmarshaller = unmarshaller;
return Invoke<TResponse>(request, options);
}

protected TResponse Invoke<TResponse>(AmazonWebServiceRequest request, InvokeOptionsBase options)
where TResponse : AmazonWebServiceResponse
Expand All @@ -227,21 +216,6 @@ protected TResponse Invoke<TResponse>(AmazonWebServiceRequest request, InvokeOpt

#if AWS_ASYNC_API

[Obsolete("InvokeAsync taking marshallers is obsolete. Use InvokeAsync taking InvokeOptionsBase instead.")]
protected System.Threading.Tasks.Task<TResponse> InvokeAsync<TRequest, TResponse>(
TRequest request,
IMarshaller<IRequest, AmazonWebServiceRequest> marshaller,
ResponseUnmarshaller unmarshaller,
System.Threading.CancellationToken cancellationToken)
where TRequest: AmazonWebServiceRequest
where TResponse : AmazonWebServiceResponse, new()
{
var options = new InvokeOptions();
options.RequestMarshaller = marshaller;
options.ResponseUnmarshaller = unmarshaller;
return InvokeAsync<TResponse>(request, options, cancellationToken);
}

protected System.Threading.Tasks.Task<TResponse> InvokeAsync<TResponse>(
AmazonWebServiceRequest request,
InvokeOptionsBase options,
Expand Down
12 changes: 1 addition & 11 deletions sdk/src/Core/Amazon.Runtime/CapacityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,7 @@ public bool TryAcquireCapacity(RetryCapacity retryCapacity, CapacityType capacit
}
}

/// <summary>
/// This method calls a method to release capacity back
/// based on whether it was a successful response or a successful retry response. This is invoked by a retry request response.
/// </summary>
/// <param name="isRetryRequest">if this request is a retry, use a different capacity cost</param>
/// <param name="retryCapacity">Contains the RetryCapacity object for the said ServiceURL.</param>
[Obsolete("This method is no longer used in favor of allowing the caller to specify the type of capacity to release.")]
public void TryReleaseCapacity(bool isRetryRequest, RetryCapacity retryCapacity)
{
ReleaseCapacity(isRetryRequest ? CapacityType.Retry : CapacityType.Increment, retryCapacity);
}


/// <summary>
/// This method calls a method to release capacity back
Expand Down
51 changes: 4 additions & 47 deletions sdk/src/Core/Amazon.Runtime/ClientConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public abstract partial class ClientConfig : IClientConfig
private string signatureVersion = "4";
private string clientAppId = null;
private SigningAlgorithm signatureMethod = SigningAlgorithm.HmacSHA256;
private bool readEntireResponse = false;
private bool logResponse = false;
private int bufferSize = AWSSDKUtils.DefaultBufferSize;
private long progressUpdateInterval = AWSSDKUtils.DefaultProgressUpdateInterval;
Expand Down Expand Up @@ -379,15 +378,7 @@ public bool UseHttp
set { this.useHttp = value; }
}

/// <summary>
/// Given this client configuration, return a DNS suffix for service endpoint url.
/// </summary>
[Obsolete("This operation is obsoleted because as of version 3.7.100 endpoint is resolved using a newer system that uses request level parameters to resolve the endpoint, use the service-specific client.DetermineServiceOperationEndPoint method instead.")]
public virtual string DetermineDnsSuffix()
{
var endpoint = regionEndpoint.GetEndpointForService(this);
return endpoint.DnsSuffix;
}


internal static string GetUrl(IClientConfig config, RegionEndpoint regionEndpoint)
{
Expand Down Expand Up @@ -491,19 +482,7 @@ public bool LogResponse
set { this.logResponse = value; }
}

/// <summary>
/// Gets and sets the ReadEntireResponse property.
/// NOTE: This property does not effect response processing and is deprecated.
/// To enable response logging, the ClientConfig.LogResponse and AWSConfigs.LoggingConfig
/// properties can be used.
/// </summary>
[Obsolete("This property does not effect response processing and is deprecated." +
"To enable response logging, the ClientConfig.LogResponse and AWSConfigs.LoggingConfig.LogResponses properties can be used.")]
public bool ReadEntireResponse
{
get { return this.readEntireResponse; }
set { this.readEntireResponse = value; }
}


/// <summary>
/// Gets and Sets the BufferSize property.
Expand Down Expand Up @@ -941,31 +920,9 @@ public virtual void Validate()
#endif
}

/// <summary>
/// Returns the current UTC now after clock correction for AWSConfigs.ManualClockCorrection.
/// </summary>
[Obsolete("Please use CorrectClockSkew.GetCorrectedUtcNowForEndpoint(string endpoint) instead.", false)]
public DateTime CorrectedUtcNow
{
get
{
// Passing null will cause GetCorrectedUtcNowForEndpoint to skip calculating ClockSkew based on
// endpoint and only use ManualClockCorrection if is set.
return CorrectClockSkew.GetCorrectedUtcNowForEndpoint(null);
}
}

/// <summary>
/// Wrapper around <seealso cref="AWSConfigs.ManualClockCorrection"/>
/// </summary>
[Obsolete("Please use CorrectClockSkew.GetClockCorrectionForEndpoint(string endpoint) instead.", false)]
public TimeSpan ClockOffset
{
get
{
return AWSConfigs.ManualClockCorrection.GetValueOrDefault();
}
}



/// <summary>
/// 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.
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/Core/Amazon.Runtime/CorrectClockSkew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ internal static void SetClockCorrectionForEndpoint(string endpoint, TimeSpan cor
try
{
clockCorrectionDictionary[endpoint] = correction;
#pragma warning disable CS0618 // Type or member is obsolete
AWSConfigs.ClockOffset = correction;
#pragma warning restore CS0618 // Type or member is obsolete
}
finally
{
Expand Down
24 changes: 4 additions & 20 deletions sdk/src/Core/Amazon.Runtime/IClientConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,7 @@ public partial interface IClientConfig
/// </summary>
bool LogResponse { get; }

/// <summary>
/// Gets the ReadEntireResponse.
/// If this property is set to true, the service response
/// is read in its entirety before being processed.
/// </summary>
bool ReadEntireResponse { get; }



/// <summary>
Expand Down Expand Up @@ -297,11 +292,7 @@ public partial interface IClientConfig
/// <param name="parameters">A Container class for parameters used for endpoint resolution.</param>
/// <returns>The resolved endpoint for the given request.</returns>
Endpoint DetermineServiceOperationEndpoint(ServiceOperationEndpointParameters parameters);
/// <summary>
/// Given this client configuration, return a DNS suffix for service endpoint url.
/// </summary>
[Obsolete("This operation is obsoleted because as of version 3.7.100 endpoint is resolved using a newer system that uses request level parameters to resolve the endpoint, use the service-specific client.DetermineServiceOperationEndPoint method instead.")]
string DetermineDnsSuffix();


/// <summary>
/// Performs validation on this config object.
Expand All @@ -310,16 +301,9 @@ public partial interface IClientConfig
/// <exception cref="Amazon.Runtime.AmazonClientException">The timeout specified is null.</exception>
void Validate();

/// <summary>
/// Returns the clock skew adjusted utc now. This value is affected by AWSConfigs.ManualClockCorrection
/// </summary>
DateTime CorrectedUtcNow { get; }

/// <summary>
/// Returns the calculated clock skew value for this config's service endpoint. If AWSConfigs.CorrectForClockSkew is false,
/// this value won't be used to construct service requests.
/// </summary>
TimeSpan ClockOffset { get; }



/// <summary>
/// Gets the DisableHostPrefixInjection flag. If true, host prefix injection will be disabled for this client, the default value of this flag is false.
Expand Down
Loading

0 comments on commit 7244bd3

Please sign in to comment.