/// <summary> /// Gets the endpoint for a service in a region. /// </summary> /// <param name="serviceName">The services system name.</param> /// <exception cref="System.ArgumentException">Thrown when the request service does not have a valid endpoint in the region.</exception> /// <returns></returns> public Endpoint GetEndpointForService(string serviceName) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } var rule = GetEndpointRule(serviceName); var endpointTemplate = rule["endpoint"].ToString(); var hostName = endpointTemplate.Replace("{region}", this.SystemName).Replace("{service}", serviceName); string signatureVersion = null; if (rule["signature-version"] != null) { signatureVersion = rule["signature-version"].ToString(); } string authRegion; if (rule["auth-region"] != null) { authRegion = rule["auth-region"].ToString(); } else { authRegion = Amazon.Util.AWSSDKUtils.DetermineRegion(hostName); } return(new Endpoint(hostName, !string.Equals(authRegion, this.SystemName) ? authRegion : null, signatureVersion)); }
/// <summary> /// Gets the endpoint for a service in a region. /// </summary> /// <param name="serviceName">The services system name.</param> /// <exception cref="System.ArgumentException">Thrown when the request service does not have a valid endpoint in the region.</exception> /// <returns></returns> public Endpoint GetEndpointForService(string serviceName) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } Endpoint endpoint = null; if (this.endpoints == null || !this.endpoints.TryGetValue(serviceName, out endpoint)) { endpoint = GuessEndpointForService(serviceName); } return(endpoint); }
/// <summary> /// Gets the region based on its system name like "us-west-1" /// </summary> /// <param name="systemName">The system name of the service like "us-west-1"</param> /// <returns></returns> public static RegionEndpoint GetBySystemName(string systemName) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } RegionEndpoint region = null; if (!hashBySystemName.TryGetValue(systemName, out region)) { if (systemName.StartsWith("cn-", StringComparison.Ordinal)) { return(NewEndpoint(systemName, "China (Unknown)")); } return(NewEndpoint(systemName, "Unknown")); } return(region); }
/// <summary> /// Gets the region based on its system name like "us-west-1" /// </summary> /// <param name="systemName">The system name of the service like "us-west-1"</param> /// <returns></returns> public static RegionEndpoint GetBySystemName(string systemName) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } RegionEndpoint region = null; if (!hashBySystemName.TryGetValue(systemName.ToLower(CultureInfo.InvariantCulture), out region)) { if (systemName.StartsWith("cn-", StringComparison.Ordinal)) { return(NewEndpoint(systemName, "China (Unknown)", "amazonaws.com.cn")); } return(NewEndpoint(systemName, "Unknown")); } return(region); }
/// <summary> /// Gets the region based on its system name like "us-west-1" /// </summary> /// <param name="systemName">The system name of the service like "us-west-1"</param> /// <returns></returns> public static RegionEndpoint GetBySystemName(string systemName) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } RegionEndpoint region = null; if (!hashBySystemName.TryGetValue(systemName, out region)) { // explicit namespace to avoid collision with UnityEngine.Logger var logger = Amazon.Runtime.Internal.Util.Logger.GetLogger(typeof(RegionEndpoint)); logger.InfoFormat("Region system name {0} was not found in region data bundled with SDK; assuming new region.", systemName); if (systemName.StartsWith("cn-", StringComparison.Ordinal)) { return(NewEndpoint(systemName, "China (Unknown)")); } return(NewEndpoint(systemName, "Unknown")); } return(region); }
/// <summary> /// Gets the endpoint for a service in a region, optionally selecting a dualstack compatible endpoint. /// </summary> /// <param name="serviceName">The services system name.</param> /// <param name="dualStack"> /// If true a dualstack endpoint is returned. It is the user's responsibility to verify that the given service /// supports a dualstack endpoint for the region. /// </param> /// <exception cref="System.ArgumentException">Thrown when the request service does not have a valid endpoint in the region.</exception> /// <returns></returns> public Endpoint GetEndpointForService(string serviceName, bool dualStack) { if (!RegionEndpoint.loaded) { RegionEndpoint.LoadEndpointDefinitions(); } var rule = GetEndpointRule(serviceName); var endpointTemplate = rule["endpoint"].ToString(); if (dualStack) { // We need special handling for S3's s3.amazonaws.com endpoint, which doesn't // support dualstack (need to transform to s3.dualstack.us-east-1.amazonaws.com). // Other endpoints that begin s3-* need to transform to s3.* for dualstack support. // S3's 'external' endpoints do not support dualstack and should not be transformed. if (serviceName.Equals("s3", StringComparison.OrdinalIgnoreCase)) { if (endpointTemplate.Equals("s3.amazonaws.com", StringComparison.OrdinalIgnoreCase)) { endpointTemplate = "s3.dualstack.us-east-1.amazonaws.com"; } else { var isExternalEndpoint = endpointTemplate.StartsWith("s3-external-", StringComparison.OrdinalIgnoreCase); if (!isExternalEndpoint) { // transform fixed s3-<region> to s3.<region> and then onto s3.dualstack.<region>, // bypassing endpoints that do not start with the expected tags. if (endpointTemplate.StartsWith("s3-", StringComparison.OrdinalIgnoreCase)) { endpointTemplate = "s3." + endpointTemplate.Substring(3); } if (endpointTemplate.StartsWith("s3.", StringComparison.OrdinalIgnoreCase)) { endpointTemplate = endpointTemplate.Replace("s3.", "s3.dualstack."); } } } } else { endpointTemplate = endpointTemplate.Replace("{region}", "dualstack.{region}"); } } var hostName = endpointTemplate.Replace("{region}", this.SystemName).Replace("{service}", serviceName); string signatureVersion = null; if (rule["signature-version"] != null) { signatureVersion = rule["signature-version"].ToString(); } string authRegion; if (rule["auth-region"] != null) { authRegion = rule["auth-region"].ToString(); } else { authRegion = Amazon.Util.AWSSDKUtils.DetermineRegion(hostName); } return(new Endpoint(hostName, !string.Equals(authRegion, this.SystemName) ? authRegion : null, signatureVersion)); }