azure_mgmt_compute 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f82e2b6afda908d533fdb3c0abc4136ba229884
4
- data.tar.gz: 0d013bf5e4c31d783133b4aeff6de21cf1107c8e
3
+ metadata.gz: 0d64d0f72bfd888f199229e09322c17600c31c74
4
+ data.tar.gz: 81858c76374aab375ed1427bb32c5b40f741ca1b
5
5
  SHA512:
6
- metadata.gz: 66144c200fbd5691d0f1aedd0b76852e29872ce529cc1d891ae22162f5201a220fc1dcd08e1bdf361f2526dbb327589afab4d23cbe630c364ad6828041ce82cb
7
- data.tar.gz: b876967ee786ab3c79f7f3ea383bb1ddef9d3279a82b28aa09f88729997385bf3f8caf8106d29ce5e104fce3ada5a7a4b5c6eb0918a7042f4cae3706cbee7816
6
+ metadata.gz: 3f4389816913424c96a6eab2965f11a74e5dbdd00bf5e76ffd90ff7cf229a1a95bb82f82428e0b966b36e7efda2e3b2775b47d5035d8bfa1cc14a4d050e44b98
7
+ data.tar.gz: 2bd7a8724f623e98d6e2507205a09f1c55b5e0bd94aa98ba4826fe5075af85ce991bb07fa370060d749a3cf0adbe8d2c2faee166489fbce87f07168f9ac016f5
data/README.md CHANGED
@@ -30,31 +30,57 @@ require 'azure_mgmt_compute'
30
30
 
31
31
  After that you should be ready to start using SDK!
32
32
 
33
- ## Authentication
33
+ ## Creating a Client
34
+ ### Option 1 - Using the Compute Profiles
35
+ You can create a new Virtual Machine using the Compute profile.
34
36
 
35
- ```Ruby
36
- # Create authentication objects
37
- token_provider = MsRestAzure::ApplicationTokenProvider.new(tenant_id, client_id, secret)
38
- credentials = MsRest::TokenCredentials.new(token_provider)
39
- ```
40
-
41
- To get tenant_id, client_id and secret for your Azure application visit Azure portal or copy them from the powershell script from the article mentioned above.
42
-
43
- ## Creating new virtual machine
44
-
45
- ```Ruby
37
+ ```ruby
46
38
  # Include SDK modules to ease access to compute classes.
47
39
  include Azure::Compute::Profiles::Latest::Mgmt
48
40
  include Azure::Compute::Profiles::Latest::Mgmt::Models
49
41
 
50
- # Create a client - a point of access to the API and set the subscription id
42
+ provider = MsRestAzure::ApplicationTokenProvider.new(
43
+ 'YOUR TENANT ID',
44
+ 'YOUR CLIENT ID',
45
+ 'YOUR CLIENT SECRET')
46
+ credentials = MsRest::TokenCredentials.new(provider)
47
+
51
48
  options = {
52
- credentials: credentials,
53
- subscription_id: subscription_id
49
+ tenant_id: 'YOUR TENANT ID',
50
+ client_id: 'YOUR CLIENT ID',
51
+ client_secret: 'YOUR CLIENT SECRET',
52
+ subscription_id: 'YOUR SUBSCRIPTION ID',
53
+ credentials: credentials
54
54
  }
55
55
 
56
56
  client = Client.new(options)
57
+ ```
58
+
59
+ ### Option 2 - Using a specific version of Compute
60
+ You can create a new Virtual Machine using a specific version of Compute, say 2017-03-30.
57
61
 
62
+ ```ruby
63
+ # Include SDK modules to ease access to compute classes.
64
+ include Azure::Compute::Mgmt::V2017_03_30
65
+ include Azure::Compute::Mgmt::V2017_03_30::Models
66
+
67
+ # Note: The tenant_id, client_id, client_secret and subscription_id
68
+ # must be set using the env variables.
69
+
70
+ provider = MsRestAzure::ApplicationTokenProvider.new(
71
+ ENV['AZURE_TENANT_ID'],
72
+ ENV['AZURE_CLIENT_ID'],
73
+ ENV['AZURE_CLIENT_SECRET'])
74
+ credentials = MsRest::TokenCredentials.new(provider)
75
+
76
+ client = ComputeManagementClient.new(credentials)
77
+ client.subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
78
+ ```
79
+
80
+ ## Using the client
81
+ Once the client is initialized, we could create the virtual machine.
82
+
83
+ ```ruby
58
84
  windows_config = WindowsConfiguration.new
59
85
  windows_config.provision_vmagent = true
60
86
  windows_config.enable_automatic_updates = true
@@ -69,6 +95,7 @@ os_profile.secrets = []
69
95
  hardware_profile = HardwareProfile.new
70
96
  hardware_profile.vm_size = 'Standard_A0'
71
97
 
98
+ params = VirtualMachine.new
72
99
  # create_storage_profile is hypothetical helper method which creates storage
73
100
  # profile by means of ARM Storage SDK.
74
101
  params.storage_profile = create_storage_profile
@@ -4,5 +4,5 @@
4
4
  # regenerated.
5
5
 
6
6
  module Azure::Compute::Mgmt::V2015_06_15
7
- VERSION = '0.15.0'
7
+ VERSION = '0.15.1'
8
8
  end
@@ -4,5 +4,5 @@
4
4
  # regenerated.
5
5
 
6
6
  module Azure::Compute::Mgmt::V2016_03_30
7
- VERSION = '0.15.0'
7
+ VERSION = '0.15.1'
8
8
  end
@@ -4,5 +4,5 @@
4
4
  # regenerated.
5
5
 
6
6
  module Azure::Compute::Mgmt::V2016_04_30_preview
7
- VERSION = '0.15.0'
7
+ VERSION = '0.15.1'
8
8
  end
@@ -4,5 +4,5 @@
4
4
  # regenerated.
5
5
 
6
6
  module Azure::Compute::Mgmt::V2017_03_30
7
- VERSION = '0.15.0'
7
+ VERSION = '0.15.1'
8
8
  end
@@ -2,8 +2,8 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
- module Azure::ARM
6
- # The Azure::ARM::Configurable module provides basic configuration for Azure ARM activities.
5
+ module Azure::Common
6
+ # The Azure::Common::Configurable module provides basic configuration for Azure activities.
7
7
  module Configurable
8
8
  # @return [String] Azure tenant id (also known as domain).
9
9
  attr_accessor :tenant_id
@@ -25,11 +25,11 @@ module Azure::ARM
25
25
 
26
26
  class << self
27
27
  #
28
- # List of configurable keys for {Azure::ARM::Client}.
28
+ # List of configurable keys for {Azure::Common::Client}.
29
29
  # @return [Array] of option keys.
30
30
  #
31
31
  def keys
32
- @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings, :credentials]
32
+ @keys ||= [:tenant_id, :client_id, :client_secret, :subscription_id, :active_directory_settings]
33
33
  end
34
34
  end
35
35
 
@@ -45,11 +45,23 @@ module Azure::ARM
45
45
  # This will also creates MsRest::TokenCredentials to be used for subsequent Azure Resource Manager clients.
46
46
  #
47
47
  def reset!(options = {})
48
- Azure::ARM::Configurable.keys.each do |key|
49
- default_value = Azure::ARM::Default.options[key]
48
+ Azure::Common::Configurable.keys.each do |key|
49
+ default_value = Azure::Common::Default.options[key]
50
50
  instance_variable_set(:"@#{key}", options.fetch(key, default_value))
51
51
  end
52
52
 
53
+ fail ArgumentError, 'tenant_id is nil' if self.tenant_id.nil?
54
+ fail ArgumentError, 'client_id is nil' if self.client_id.nil?
55
+ fail ArgumentError, 'client_secret is nil' if self.client_secret.nil?
56
+ fail ArgumentError, 'subscription_id is nil' if self.subscription_id.nil?
57
+ fail ArgumentError, 'active_directory_settings is nil' if self.active_directory_settings.nil?
58
+
59
+ default_value = MsRest::TokenCredentials.new(
60
+ MsRestAzure::ApplicationTokenProvider.new(
61
+ self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings))
62
+
63
+ instance_variable_set(:"@credentials", options.fetch(:credentials, default_value))
64
+
53
65
  self
54
66
  end
55
67
 
@@ -62,11 +74,12 @@ module Azure::ARM
62
74
  #
63
75
  # configures configurable options to default values
64
76
  #
65
- def setup_options
77
+ def setup_default_options
66
78
  opts = {}
67
- Azure::ARM::Configurable.keys.map do |key|
68
- opts[key] = Azure::ARM::Default.options[key]
79
+ Azure::Common::Configurable.keys.map do |key|
80
+ opts[key] = Azure::Common::Default.options[key]
69
81
  end
82
+
70
83
  opts
71
84
  end
72
85
  end
@@ -2,8 +2,7 @@
2
2
  # Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
- module Azure::ARM
6
- # Default configuration options for {Azure::ARM.Client}
5
+ module Azure::Common
7
6
  module Default
8
7
  class << self
9
8
  #
@@ -38,16 +37,6 @@ module Azure::ARM
38
37
  ENV['AZURE_SUBSCRIPTION_ID']
39
38
  end
40
39
 
41
- #
42
- # Default Azure credentials to authorize HTTP requests made by the service client.
43
- # @return [MsRest::ServiceClientCredentials] Azure credentials to authorize HTTP requests made by the service client.
44
- #
45
- def credentials
46
- MsRest::TokenCredentials.new(
47
- MsRestAzure::ApplicationTokenProvider.new(
48
- self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings))
49
- end
50
-
51
40
  #
52
41
  # Default Azure Active Directory Service Settings.
53
42
  # @return [MsRestAzure::ActiveDirectoryServiceSettings] Azure Active Directory Service Settings.
@@ -61,7 +50,7 @@ module Azure::ARM
61
50
  # @return [Hash] Configuration options.
62
51
  #
63
52
  def options
64
- Hash[Azure::ARM::Configurable.keys.map{|key| [key, send(key)]}]
53
+ Hash[Azure::Common::Configurable.keys.map { |key| [key, send(key)]}]
65
54
  end
66
55
  end
67
56
  end
@@ -12,22 +12,12 @@ module Azure::Compute::Profiles::Latest::Mgmt
12
12
  # Client class for the Latest profile SDK.
13
13
  #
14
14
  class Client < ComputeClass
15
- include Azure::ARM::Configurable
15
+ include Azure::Common::Configurable
16
16
 
17
17
 
18
18
  def initialize(options = {})
19
19
  super(options)
20
20
  end
21
21
 
22
- def credentials
23
- if @credentials.nil?
24
- self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings
25
-
26
- @credentials = MsRest::TokenCredentials.new(
27
- MsRestAzure::ApplicationTokenProvider.new(
28
- self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings))
29
- end
30
- @credentials
31
- end
32
22
  end
33
23
  end
@@ -200,7 +200,7 @@ module Azure::Compute::Profiles::Latest::Mgmt
200
200
 
201
201
  def initialize(options = {})
202
202
  if options.is_a?(Hash) && options.length == 0
203
- @options = setup_options
203
+ @options = setup_default_options
204
204
  else
205
205
  @options = options
206
206
  end
@@ -12,22 +12,12 @@ module Azure::Compute::Profiles::V2017_03_09::Mgmt
12
12
  # Client class for the V2017_03_09 profile SDK.
13
13
  #
14
14
  class Client < ComputeClass
15
- include Azure::ARM::Configurable
15
+ include Azure::Common::Configurable
16
16
 
17
17
 
18
18
  def initialize(options = {})
19
19
  super(options)
20
20
  end
21
21
 
22
- def credentials
23
- if @credentials.nil?
24
- self.active_directory_settings ||= Azure::ARM::Default.active_directory_settings
25
-
26
- @credentials = MsRest::TokenCredentials.new(
27
- MsRestAzure::ApplicationTokenProvider.new(
28
- self.tenant_id, self.client_id, self.client_secret, self.active_directory_settings))
29
- end
30
- @credentials
31
- end
32
22
  end
33
23
  end
@@ -124,7 +124,7 @@ module Azure::Compute::Profiles::V2017_03_09::Mgmt
124
124
 
125
125
  def initialize(options = {})
126
126
  if options.is_a?(Hash) && options.length == 0
127
- @options = setup_options
127
+ @options = setup_default_options
128
128
  else
129
129
  @options = options
130
130
  end
data/lib/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Licensed under the MIT License. See License.txt in the project root for license information.
4
4
 
5
5
  module Azure::Compute::Mgmt
6
- VERSION = '0.15.0'
6
+ VERSION = '0.15.1'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure_mgmt_compute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler