azure-armrest 0.0.1 → 0.0.2

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.
@@ -1,50 +0,0 @@
1
- # Azure namespace
2
- module Azure
3
- # Armrest namespace
4
- module Armrest
5
- # Base class for managing availability sets.
6
- class AvailabilitySetManager < ArmrestManager
7
-
8
- # Create and return a new AvailabilitySetManager (ASM) instance. Most
9
- # methods for an ASM instance will return one or more AvailabilitySet
10
- # instances.
11
- #
12
- def initialize(options = {})
13
- super
14
-
15
- @base_url += "resourceGroups/#{@resource_group}/"
16
- @base_url += "providers/Microsoft.Compute/availabilitySets"
17
- end
18
-
19
- # Creates a new availability set.
20
- #
21
- # TODO: The current documentation doesn't seem to list all the possible
22
- # options at this time.
23
- #--
24
- def create(set_name, options = {})
25
- url = @uri + "#{set_name}?api-version=#{api_version}"
26
- url
27
- end
28
-
29
- alias update create
30
-
31
- # Deletes the +set_name+ availability set.
32
- def delete(set_name)
33
- url = @uri + "#{set_name}?api-version=#{api_version}"
34
- url
35
- end
36
-
37
- # Retrieves the options of an availability set.
38
- def get(set_name)
39
- url = @uri + "#{set_name}?api-version=#{api_version}"
40
- url
41
- end
42
-
43
- # List availability sets.
44
- def list
45
- url = @uri + "?api-version=#{api_version}"
46
- url
47
- end
48
- end
49
- end
50
- end
@@ -1,165 +0,0 @@
1
- module Azure
2
- module Armrest
3
- # Class for managing storage accounts.
4
- class StorageAccountManager < ArmrestManager
5
-
6
- # Valid account types for the create or update method.
7
- VALID_ACCOUNT_TYPES = %w[
8
- Standard_LRS
9
- Standard_ZRS
10
- Standard_GRS
11
- Standard_RAGRS
12
- ]
13
-
14
- # Creates and returns a new StorageAccountManager (SAM) instance. Most
15
- # methods for a SAM instance will return a StorageAccount object.
16
- def initialize(options = {})
17
- super
18
- end
19
-
20
- # Return information for the given storage account name for the
21
- # provided +group+. If no group is specified, it will use the
22
- # group set in the constructor.
23
- #
24
- # Example:
25
- #
26
- # sam.get('portalvhdstjn1ty0dlc2dg')
27
- # sam.get('portalvhdstjn1ty0dlc2dg', 'Default-Storage-CentralUS')
28
- #
29
- def get(account_name, group = @resource_group)
30
- set_default_subscription
31
-
32
- raise ArgumentError, "must specify resource group" unless group
33
-
34
- @api_version = '2014-06-01'
35
- url = build_url(@subscription_id, group, account_name)
36
-
37
- JSON.parse(rest_get(url))
38
- end
39
-
40
- # Returns a list of available storage accounts for the given subscription
41
- # for the provided +group+, or all resource groups if none is provided.
42
- #
43
- def list(group = @resource_group)
44
- if group
45
- @api_version = '2014-06-01'
46
- url = build_url(@subscription_id, group)
47
- JSON.parse(rest_get(url))['value'].first
48
- else
49
- array = []
50
- threads = []
51
-
52
- resource_groups.each do |group|
53
- @api_version = '2014-06-01' # Must be set after resource_groups call
54
- url = build_url(@subscription_id, group['name'])
55
-
56
- threads << Thread.new do
57
- result = JSON.parse(rest_get(url))['value'].first
58
- array << result if result
59
- end
60
- end
61
-
62
- threads.each(&:join)
63
-
64
- array
65
- end
66
- end
67
-
68
- # Creates a new storage account, or updates an existing account with the
69
- # specified parameters. The possible parameters are:
70
- #
71
- # - :account_name
72
- # Required. The name of the storage account within the specified
73
- # resource stack. Must be 3-24 alphanumeric lowercase characters.
74
- #
75
- # - :validating
76
- # Optional. Set to 'nameAvailability' to indicate that the account
77
- # name must be checked for global availability.
78
- #
79
- # - :location
80
- # Required: One of the Azure geo regions, e.g. 'West US'.
81
- #
82
- # - :tags
83
- # A hash of tags to describe the resource. You may have a maximum of
84
- # 10 tags, and each key has a max size of 128 characters, and each
85
- # value has a max size of 256 characters.
86
- #
87
- # -:properties
88
- # - :account_type
89
- # - :custom_domains
90
- # - :custom_domain
91
- # - :name
92
- # - :use_subdomain_name
93
- #--
94
- # PUT
95
- #
96
- def create(option = {})
97
- #account_name = options.fetch(:account_name)
98
- #location = options.fetch(:location)
99
- validating = options[:validating]
100
- #tags = options[:tags]
101
-
102
- url = @uri + "/#{account_name}"
103
-
104
- if validating
105
- url += "?validating=nameAvailability"
106
- end
107
-
108
- url
109
- end
110
-
111
- alias update create
112
-
113
- # Delete the given storage account name.
114
- def delete(account_name)
115
- url = @uri + "/#{account_name}?api-version=#{api_version}"
116
- url
117
- end
118
-
119
-
120
-
121
- # Returns the primary and secondary access keys for the given
122
- # storage account.
123
- #--
124
- # POST
125
- #
126
- def list_account_keys(account_name)
127
- url = @uri + "/#{account_name}/listKeys?api-version=#{api_version}"
128
- url
129
- end
130
-
131
- # Regenerates the primary and secondary access keys for the given
132
- # storage account.
133
- #--
134
- # POST
135
- def regenerate_storage_account_keys(account_name)
136
- url = @uri + "/#{account_name}/regenerateKey?api-version=#{api_version}"
137
- url
138
- end
139
-
140
- private
141
-
142
- # If no default subscription is set, then use the first one found.
143
- def set_default_subscription
144
- @subscription_id ||= subscriptions.first['subscriptionId']
145
- end
146
-
147
- # Builds a URL based on subscription_id an resource_group and any other
148
- # arguments provided, and appends it with the api-version.
149
- def build_url(subscription_id, resource_group, *args)
150
- url = File.join(
151
- Azure::Armrest::COMMON_URI,
152
- subscription_id,
153
- 'resourceGroups',
154
- resource_group,
155
- 'providers',
156
- 'Microsoft.ClassicStorage',
157
- 'storageAccounts',
158
- )
159
-
160
- url = File.join(url, *args) unless args.empty?
161
- url << "?api-version=#{@api_version}"
162
- end
163
- end
164
- end
165
- end