azure_mgmt_storage 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -17
- data/lib/2015-05-01-preview/generated/azure_mgmt_storage/version.rb +1 -1
- data/lib/2015-06-15/generated/azure_mgmt_storage/version.rb +1 -1
- data/lib/2016-01-01/generated/azure_mgmt_storage/version.rb +1 -1
- data/lib/2016-12-01/generated/azure_mgmt_storage/version.rb +1 -1
- data/lib/2017-06-01/generated/azure_mgmt_storage/version.rb +1 -1
- data/lib/profiles/common/configurable.rb +22 -9
- data/lib/profiles/common/default.rb +2 -13
- data/lib/profiles/latest/modules/storage_profile_module.rb +1 -1
- data/lib/profiles/latest/storage_latest_profile_client.rb +1 -11
- data/lib/profiles/v2017_03_09/modules/storage_profile_module.rb +1 -1
- data/lib/profiles/v2017_03_09/storage_v2017_03_09_profile_client.rb +1 -11
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2aef90aac96612767777cec4c876d6899d2d092
|
4
|
+
data.tar.gz: c651df5f230e8e67134f5c3ac854189896855db5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10e04fc71bcfe7eda7f0e557ab23204835258d09f927856513c44fc5707a68b3b1e833e673a068bea089617f658bd9fd68c4b3ba1c4957991984316babba7a93
|
7
|
+
data.tar.gz: 39c91d1c1fd200b4221922efb6be7eb3b34e2f13bb6389e7c24ee50c76486d2e315311be0fe8b5bdfdd2fae0754f0ee65aa39544e349ca5b203726b5554a565d
|
data/README.md
CHANGED
@@ -30,34 +30,63 @@ require 'azure_mgmt_storage'
|
|
30
30
|
|
31
31
|
After that you should be ready to start using SDK!
|
32
32
|
|
33
|
-
##
|
33
|
+
## Creating a Client
|
34
|
+
### Option 1 - Using the Storage Profiles
|
35
|
+
You can create a new storage accounts using the Storage profile.
|
34
36
|
|
35
|
-
```
|
36
|
-
#
|
37
|
-
|
38
|
-
|
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.
|
37
|
+
```ruby
|
38
|
+
# Include SDK modules to ease access to Storage classes.
|
39
|
+
include Azure::Storage::Profiles::Latest::Mgmt
|
40
|
+
include Azure::Storage::Profiles::Latest::Mgmt::Models
|
42
41
|
|
43
|
-
|
42
|
+
provider = MsRestAzure::ApplicationTokenProvider.new(
|
43
|
+
'YOUR TENANT ID',
|
44
|
+
'YOUR CLIENT ID',
|
45
|
+
'YOUR CLIENT SECRET')
|
46
|
+
credentials = MsRest::TokenCredentials.new(provider)
|
44
47
|
|
45
|
-
```Ruby
|
46
|
-
include Azure::Compute::Storage::Latest::Mgmt
|
47
|
-
# Create a client - a point of access to the API and set the subscription id
|
48
48
|
options = {
|
49
|
-
|
50
|
-
|
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
|
51
54
|
}
|
55
|
+
|
52
56
|
client = Client.new(options)
|
57
|
+
```
|
58
|
+
|
59
|
+
### Option 2 - Using a specific version of Storage
|
60
|
+
You can create a new storage account using a specific version of Storage, say 2017-06-01.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
# Include SDK modules to ease access to resources classes.
|
64
|
+
include Azure::Storage::Mgmt::V2017_06_01
|
65
|
+
include Azure::Storage::Mgmt::V2017_06_01::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 = ResourceManagementClient.new(credentials)
|
77
|
+
client.subscription_id = ENV['AZURE_SUBSCRIPTION_ID']
|
78
|
+
```
|
79
|
+
## Using the client
|
80
|
+
Once the client is initialized, we could create the storage account.
|
53
81
|
|
82
|
+
```ruby
|
54
83
|
# Create a model for new storage account.
|
55
|
-
params =
|
84
|
+
params = StorageAccountCreateParameters.new
|
56
85
|
params.location = 'westus'
|
57
|
-
sku =
|
86
|
+
sku = Sku.new
|
58
87
|
sku.name = 'Standard_LRS'
|
59
88
|
params.sku = sku
|
60
|
-
params.kind =
|
89
|
+
params.kind = Kind::Storage
|
61
90
|
|
62
91
|
promise = client.storage_accounts.create_async('some_existing_resource_group', 'newstorageaccount', params)
|
63
92
|
```
|
@@ -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::
|
6
|
-
# The Azure::
|
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::
|
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
|
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::
|
49
|
-
default_value = Azure::
|
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
|
77
|
+
def setup_default_options
|
66
78
|
opts = {}
|
67
|
-
Azure::
|
68
|
-
opts[key] = Azure::
|
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::
|
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::
|
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::Storage::Profiles::Latest::Mgmt
|
|
12
12
|
# Client class for the Latest profile SDK.
|
13
13
|
#
|
14
14
|
class Client < StorageClass
|
15
|
-
include Azure::
|
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
|
@@ -12,22 +12,12 @@ module Azure::Storage::Profiles::V2017_03_09::Mgmt
|
|
12
12
|
# Client class for the V2017_03_09 profile SDK.
|
13
13
|
#
|
14
14
|
class Client < StorageClass
|
15
|
-
include Azure::
|
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
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: azure_mgmt_storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
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-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|