/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Amazon;
using Amazon.Runtime;
using Amazon.Extensions.NETCore.Setup;
namespace Amazon.Extensions.NETCore.Setup
{
///
/// The options used to construct AWS service clients like the Amazon.S3.AmazonS3Client.
///
public class AWSOptions
{
///
/// The profile used to fetch AWS credentials for from the profile manager.
///
public string Profile { get; set; }
///
/// The location of the registered profiles. Set if using the non standard locations for profile stores.
/// This is mostly used when running the application outside of an EC2 instance where the preferred
/// IAM credentials are used and also not running under a logged on user.
///
public string ProfilesLocation { get; set; }
///
/// The AWS region the service client should use when making service operations.
///
public RegionEndpoint Region { get; set; }
///
/// If set this role will be assumed using the resolved AWS credentials.
///
public string SessionRoleArn { get; set; }
///
/// The session name for the assumed session using the SessionRoleArn.
///
public string SessionName { get; set; } = "DefaultSessionName";
///
/// AWS Credentials used for creating service clients. If this is set it overrides the Profile property.
///
public AWSCredentials Credentials { get; set; }
///
/// The default configuration mode set for created service clients.
///
public DefaultConfigurationMode? DefaultConfigurationMode { get; set; }
private ClientConfig _defaultClientConfig;
///
/// A default ClientConfig object. When service client is created any values set on the default ClientConfig
/// are copied to the service specific client config.
///
public ClientConfig DefaultClientConfig
{
get
{
if (this._defaultClientConfig == null)
this._defaultClientConfig = new DefaultClientConfig();
return this._defaultClientConfig;
}
internal set
{
this._defaultClientConfig = value;
}
}
///
/// Logging settings that should be applied to SDK global configuration. This setting is applied while creating
/// the service client through this package.
///
public LoggingSetting Logging { get; set; }
///
/// Create a service client for the specified service interface using the options set in this instance.
/// For example if T is set to IAmazonS3 then the AmazonS3ServiceClient which implements IAmazonS3 is created
/// and returned.
///
/// The service interface that a service client will be created for.
/// The service client that implements the service interface.
public T CreateServiceClient() where T : IAmazonService
{
return (T)ClientFactory.CreateServiceClient(null, typeof(T), this);
}
///
/// Container for logging settings of the SDK
///
public class LoggingSetting
{
///
/// Logging destination.
///
public LoggingOptions? LogTo { get; set; }
///
/// When to log responses.
///
public ResponseLoggingOption? LogResponses { get; set; }
///
/// Gets or sets the size limit in bytes for logged responses. If logging for response
/// body is enabled, logged response body is limited to this size. The SDK defaults to 1KB if this property is net set.
///
public int? LogResponsesSizeLimit { get; set; }
///
/// Whether or not to log SDK metrics.
///
public bool? LogMetrics { get; set; }
}
}
}