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_US_PHOENIX_1 = 'us-phoenix-1'.freeze,
  REGION_US_ASHBURN_1 = 'us-ashburn-1'.freeze
].freeze
SERVICE_ENDPOINT_PREFIX_MAPPING =
{
  BlockstorageClient: 'iaas',
  ComputeClient: 'iaas',
  VirtualNetworkClient: 'iaas',
  IdentityClient: 'identity',
  LoadBalancerClient: 'iaas',
  ObjectStorageClient: 'objectstorage'
}.freeze

Class Method Summary collapse

Class Method Details

.format_endpoint(prefix, region) ⇒ Object



39
40
41
# File 'lib/oci/regions.rb', line 39

def self.format_endpoint(prefix, region)
  "https://#{prefix}.#{region}.oraclecloud.com"
end

.get_service_endpoint(region, service) ⇒ String

Returns an endpoint for the given region and service.

Parameters:

  • region (String)

    A region used to determine the service endpoint. This will usually correspond to a value in REGION_ENUM, but may be an arbitrary string.

  • service (Symbol)

    A symbol representing a service client class (e.g. :IdentityClient)

Returns:

  • (String)

    A fully qualified endpoint



27
28
29
30
31
# File 'lib/oci/regions.rb', line 27

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

.valid_region?(region) ⇒ Boolean

Returns:

  • (Boolean)

    Returns true if the given string corresponds to a known region, as defined in



35
36
37
# File 'lib/oci/regions.rb', line 35

def self.valid_region?(region)
  REGION_ENUM.include? region
end