class Azure::Armrest::Environment

Constants

China
Public

Pre-generated environments

USGovernment
VALID_KEYS

A list of valid keys that can be passed to the constructor

Attributes

active_directory_authority[R]

The authority used to acquire an AD token

active_directory_resource_id[R]

The resource ID used to obtain an AD token

authority_url[R]

The authority used to acquire an AD token

graph_api_version[R]

The api-version for Active Directory

graph_endpoint[R]

The Active Directory resource ID

graph_url[R]

The Active Directory resource ID

key_vault_dns_suffix[R]

The KeyValut service DNS suffix

key_vault_service_resource_id[R]

The KeyVault service resource ID

login_endpoint[R]

The authority used to acquire an AD token

name[R]

The Environment name

publish_settings_file_url[R]

The publish settings file URL

resource_manager_url[R]

The resource management endpoint

resource_url[R]

The resource management endpoint

service_management_url[R]

The service management URL

sql_database_dns_suffix[R]

The DNS suffix for SQL Server instances

storage_suffix[R]

The endpoint suffix for storage accounts

traffic_manager_dns_suffix[R]

The DNS suffix for TrafficManager

Public Class Methods

discover(options) click to toggle source

Automatically discover and create an Environment given a resource manager endpoint. The options hash must include an endpoint :url key. It may also include a :name (recommended), and http proxy options.

# File lib/azure/armrest/environment.rb, line 94
def self.discover(options)
  url  = options.fetch(:url)
  name = options[:name] || 'Custom'

  uri = Addressable::URI.join(url, '/metadata/', 'endpoints')
  uri.query = "api-version=1.0"

  response = ArmrestService.send(
    :rest_get,
    :url         => uri.to_s,
    :proxy       => options[:proxy],
    :ssl_version => options[:ssl_version],
    :ssl_verify  => options[:ssl_verify]
  )

  endpoint = Endpoint.new(response.body)

  new(
    :name                         => name,
    :gallery_url                  => endpoint.gallery_endpoint,
    :graph_url                    => endpoint.graph_endpoint,
    :active_directory_authority   => endpoint.authentication.login_endpoint,
    :active_directory_resource_id => endpoint.authentication.audiences.first,
    :resource_manager_url         => url
  )
end
new(options) click to toggle source

Creates a new Azure::Armrest::Environment object. At a minimum, the options hash must include the :name, :active_directory_authority and :active_directory_resource_id.

Note that there are pre-generated environments already for Public and US Government environments.

# File lib/azure/armrest/environment.rb, line 71
def initialize(options)
  options.symbolize_keys.each do |key, value|
    raise ArgumentError, "Invalid key '#{key}'" unless VALID_KEYS.include?(key)
    instance_variable_set("@#{key}", value)
  end

  %i[name active_directory_authority resource_manager_url].each do |key|
    unless instance_variable_get("@#{key}")
      raise ArgumentError, "Mandatory argument '#{key}' not set"
    end
  end
end