Module: OCI::Regions
- Defined in:
- lib/oci/regions.rb
Overview
Module defining available regions and helper methods to get value service endpoints
Constant Summary collapse
- REGION_ENUM =
[ REGION_AP_MUMBAI_1 = 'ap-mumbai-1'.freeze, REGION_AP_SEOUL_1 = 'ap-seoul-1'.freeze, REGION_AP_TOKYO_1 = 'ap-tokyo-1'.freeze, REGION_CA_TORONTO_1 = 'ca-toronto-1'.freeze, REGION_US_PHOENIX_1 = 'us-phoenix-1'.freeze, REGION_US_ASHBURN_1 = 'us-ashburn-1'.freeze, REGION_EU_FRANKFURT_1 = 'eu-frankfurt-1'.freeze, REGION_UK_LONDON_1 = 'uk-london-1'.freeze, REGION_US_LANGLEY_1 = 'us-langley-1'.freeze, REGION_US_LUKE_1 = 'us-luke-1'.freeze, REGION_US_GOV_ASHBURN_1 = 'us-gov-ashburn-1'.freeze, REGION_US_GOV_PHOENIX_1 = 'us-gov-phoenix-1'.freeze, REGION_US_GOV_CHICAGO_1 = 'us-gov-chicago-1'.freeze ].freeze
- REGION_SHORT_NAMES_TO_LONG_NAMES =
{ 'bom': REGION_AP_MUMBAI_1, 'icn': REGION_AP_SEOUL_1, 'nrt': REGION_AP_TOKYO_1, 'yyz': REGION_CA_TORONTO_1, 'phx': REGION_US_PHOENIX_1, 'iad': REGION_US_ASHBURN_1, 'fra': REGION_EU_FRANKFURT_1, 'lhr': REGION_UK_LONDON_1 }.freeze
- REGION_REALM_MAPPING =
— Start of region realm mapping —
{ 'ap-mumbai-1': 'oc1'.freeze, 'ap-seoul-1': 'oc1'.freeze, 'ap-tokyo-1': 'oc1'.freeze, 'ca-toronto-1': 'oc1'.freeze, 'us-phoenix-1': 'oc1'.freeze, 'us-ashburn-1': 'oc1'.freeze, 'eu-frankfurt-1': 'oc1'.freeze, 'uk-london-1': 'oc1'.freeze, 'us-langley-1': 'oc2'.freeze, 'us-luke-1': 'oc2'.freeze, 'us-gov-ashburn-1': 'oc3'.freeze, 'us-gov-phoenix-1': 'oc3'.freeze, 'us-gov-chicago-1': 'oc3'.freeze }.freeze
- REALM_DOMAIN_MAPPING =
— Start of realm domain mapping —
{ 'oc1': 'oraclecloud.com'.freeze, 'oc2': 'oraclegovcloud.com'.freeze, 'oc3': 'oraclegovcloud.com'.freeze }.freeze
- SERVICE_ENDPOINT_PREFIX_MAPPING =
— Start of service prefixes —
{ AnnouncementClient: 'announcements', AuditClient: 'audit', Auth: 'auth', AutoScalingClient: 'autoscaling', BlockstorageClient: 'iaas', BudgetClient: 'usage', ComputeClient: 'iaas', ComputeManagementClient: 'iaas', ContainerEngineClient: 'containerengine', DatabaseClient: 'database', DnsClient: 'dns', EmailClient: 'email', FileStorageClient: 'filestorage', HealthChecksClient: 'healthchecks', IdentityClient: 'identity', KmsVaultClient: 'kms', LoadBalancerClient: 'iaas', MonitoringClient: 'telemetry', NotificationControlPlaneClient: 'notification', NotificationDataPlaneClient: 'notification', ObjectStorageClient: 'objectstorage', ResourceManagerClient: 'resourcemanager', ResourceSearchClient: 'query', StreamAdminClient: 'streams', StreamClient: 'streams', VirtualNetworkClient: 'iaas', WaasClient: 'waas' }.freeze
Class Method Summary collapse
- .format_endpoint(prefix, region) ⇒ Object
-
.get_second_level_domain(region) ⇒ String
Returns a second level domain for the given region.
-
.get_service_endpoint(region, service) ⇒ String
Returns an endpoint for the given region and service.
-
.get_service_endpoint_for_template(region, endpoint_template) ⇒ String
Returns an endpoint for the given region and service endpoint template.
- .valid_region?(region) ⇒ Boolean
Class Method Details
.format_endpoint(prefix, region) ⇒ Object
131 132 133 134 |
# File 'lib/oci/regions.rb', line 131 def self.format_endpoint(prefix, region) second_level_domain = get_second_level_domain(region) "https://#{prefix}.#{region}.#{second_level_domain}" end |
.get_second_level_domain(region) ⇒ String
Returns a second level domain for the given region.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/oci/regions.rb', line 142 def self.get_second_level_domain(region) symbolised_region = region.to_sym # get realm from region, default to oc1 realm = if REGION_REALM_MAPPING.key?(symbolised_region) REGION_REALM_MAPPING[symbolised_region] else 'oc1' end # return second level domain if exists symbolised_realm = realm.to_sym return REALM_DOMAIN_MAPPING[symbolised_realm] if REALM_DOMAIN_MAPPING.key?(symbolised_realm) REALM_DOMAIN_MAPPING[:oc1] end |
.get_service_endpoint(region, service) ⇒ String
Returns an endpoint for the given region and service.
100 101 102 103 104 105 |
# File 'lib/oci/regions.rb', line 100 def self.get_service_endpoint(region, service) prefix = SERVICE_ENDPOINT_PREFIX_MAPPING[service] raise "Service '#{service}' is not supported." unless prefix format_endpoint(prefix, region) end |
.get_service_endpoint_for_template(region, endpoint_template) ⇒ String
Returns an endpoint for the given region and service endpoint template.
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/oci/regions.rb', line 114 def self.get_service_endpoint_for_template(region, endpoint_template) endpoint = endpoint_template.clone # replace the token inside service_endpoint_template if exists [ ['{region}', region], ['{secondLevelDomain}', get_second_level_domain(region).to_s] ].each { |k, v| endpoint.sub!(k, v) } endpoint end |
.valid_region?(region) ⇒ Boolean
127 128 129 |
# File 'lib/oci/regions.rb', line 127 def self.valid_region?(region) REGION_ENUM.include? region end |