Class: Azure::Profile::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/profile/subscription.rb

Overview

A class that represents an invididual subscription with an Azure profile.

Constant Summary collapse

DEFAULT_MANAGEMENT_ENDPOINT =
"https://management.core.windows.net"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Subscription

Creates and returns a new Subscription object. If a block is given then the object is yielded to the block.

Example:

# These values are for demonstration purposes only
Subscription.new do |s|
  s.subscription_id = 'abc-123-xyz'
  s.subscription_name = 'My Subscription'
  s.source = 'me'
  s.default = false
  s.management_certificate = generate_my_cert(Etc.getlogin)
  s.environment_name = 'MyEnvironment'
end

If no :management_endpoint is provided, then it will default to using Subscription::DEFAULT_MANAGEMENT_ENDPOINT. If no :source is provided, then it will default to ‘ruby’. If no :default is provided, it will default to false. If no :environment_name is provided, it will default to ‘AzureCloud’.

There is no default for the :registered providers or :management_certificate accessors. You must provide those. The certificate should be a combination of the cert and key so that you can pass its value directly to another interface, such as the azure gem.

Note that you will not normally create Subscription objects directly. The Azure::Profile class will generate them and pass them back to you.

Yields:

  • (_self)

Yield Parameters:



60
61
62
63
64
65
66
67
# File 'lib/azure/profile/subscription.rb', line 60

def initialize
  yield self if block_given?

  @management_endpoint ||= DEFAULT_MANAGEMENT_ENDPOINT
  @source ||= 'ruby'
  @default ||= false
  @environment_name ||= 'AzureCloud'
end

Instance Attribute Details

#defaultObject

Returns whether or not this is a default subscription



15
16
17
# File 'lib/azure/profile/subscription.rb', line 15

def default
  @default
end

#environment_nameObject

Azure environment name, e.g. “AzureCloud”



21
22
23
# File 'lib/azure/profile/subscription.rb', line 21

def environment_name
  @environment_name
end

#management_certificateObject

Azure certificate, a combination of the cert + key



12
13
14
# File 'lib/azure/profile/subscription.rb', line 12

def management_certificate
  @management_certificate
end

#management_endpointObject

Azure endpoint. The default is management.core.windows.net



24
25
26
# File 'lib/azure/profile/subscription.rb', line 24

def management_endpoint
  @management_endpoint
end

#registered_providersObject

An array of registered providers



18
19
20
# File 'lib/azure/profile/subscription.rb', line 18

def registered_providers
  @registered_providers
end

#sourceObject

The source of the subscription, e.g. “~/.azure/azureProfile.json”



27
28
29
# File 'lib/azure/profile/subscription.rb', line 27

def source
  @source
end

#subscription_idObject

Azure subscription ID.



6
7
8
# File 'lib/azure/profile/subscription.rb', line 6

def subscription_id
  @subscription_id
end

#subscription_nameObject

Azure subscription name, e.g. “Free Trial”



9
10
11
# File 'lib/azure/profile/subscription.rb', line 9

def subscription_name
  @subscription_name
end