azure_mgmt_key_vault 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,74 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::KeyVault
7
+ module Models
8
+ #
9
+ # Parameters for creating or updating a vault
10
+ #
11
+ class VaultCreateOrUpdateParameters
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] The supported Azure location where the key vault
16
+ # should be created.
17
+ attr_accessor :location
18
+
19
+ # @return [Hash{String => String}] The tags that will be assigned to the
20
+ # key vault.
21
+ attr_accessor :tags
22
+
23
+ # @return [VaultProperties] Properties of the vault
24
+ attr_accessor :properties
25
+
26
+
27
+ #
28
+ # Mapper for VaultCreateOrUpdateParameters class as Ruby Hash.
29
+ # This will be used for serialization/deserialization.
30
+ #
31
+ def self.mapper()
32
+ {
33
+ required: false,
34
+ serialized_name: 'VaultCreateOrUpdateParameters',
35
+ type: {
36
+ name: 'Composite',
37
+ class_name: 'VaultCreateOrUpdateParameters',
38
+ model_properties: {
39
+ location: {
40
+ required: true,
41
+ serialized_name: 'location',
42
+ type: {
43
+ name: 'String'
44
+ }
45
+ },
46
+ tags: {
47
+ required: false,
48
+ serialized_name: 'tags',
49
+ type: {
50
+ name: 'Dictionary',
51
+ value: {
52
+ required: false,
53
+ serialized_name: 'StringElementType',
54
+ type: {
55
+ name: 'String'
56
+ }
57
+ }
58
+ }
59
+ },
60
+ properties: {
61
+ required: true,
62
+ serialized_name: 'properties',
63
+ type: {
64
+ name: 'Composite',
65
+ class_name: 'VaultProperties'
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,93 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::KeyVault
7
+ module Models
8
+ #
9
+ # List of vaults
10
+ #
11
+ class VaultListResult
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [Array<Vault>] Gets or sets the list of vaults.
16
+ attr_accessor :value
17
+
18
+ # @return [String] Gets or sets the URL to get the next set of vaults.
19
+ attr_accessor :next_link
20
+
21
+ # return [Proc] with next page method call.
22
+ attr_accessor :next_method
23
+
24
+ #
25
+ # Gets the rest of the items for the request, enabling auto-pagination.
26
+ #
27
+ # @return [Array<Vault>] operation results.
28
+ #
29
+ def get_all_items
30
+ items = @value
31
+ page = self
32
+ while page.next_link != nil do
33
+ page = page.get_next_page
34
+ items.concat(page.value)
35
+ end
36
+ items
37
+ end
38
+
39
+ #
40
+ # Gets the next page of results.
41
+ #
42
+ # @return [VaultListResult] with next page content.
43
+ #
44
+ def get_next_page
45
+ response = @next_method.call(@next_link).value! unless @next_method.nil?
46
+ unless response.nil?
47
+ @next_link = response.body.next_link
48
+ @value = response.body.value
49
+ self
50
+ end
51
+ end
52
+
53
+ #
54
+ # Mapper for VaultListResult class as Ruby Hash.
55
+ # This will be used for serialization/deserialization.
56
+ #
57
+ def self.mapper()
58
+ {
59
+ required: false,
60
+ serialized_name: 'VaultListResult',
61
+ type: {
62
+ name: 'Composite',
63
+ class_name: 'VaultListResult',
64
+ model_properties: {
65
+ value: {
66
+ required: false,
67
+ serialized_name: 'value',
68
+ type: {
69
+ name: 'Sequence',
70
+ element: {
71
+ required: false,
72
+ serialized_name: 'VaultElementType',
73
+ type: {
74
+ name: 'Composite',
75
+ class_name: 'Vault'
76
+ }
77
+ }
78
+ }
79
+ },
80
+ next_link: {
81
+ required: false,
82
+ serialized_name: 'nextLink',
83
+ type: {
84
+ name: 'String'
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,124 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::KeyVault
7
+ module Models
8
+ #
9
+ # Properties of the vault
10
+ #
11
+ class VaultProperties
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] The URI of the vault for performing operations on
16
+ # keys and secrets.
17
+ attr_accessor :vault_uri
18
+
19
+ # @return The Azure Active Directory tenant ID that should be used for
20
+ # authenticating requests to the key vault.
21
+ attr_accessor :tenant_id
22
+
23
+ # @return [Sku] SKU details
24
+ attr_accessor :sku
25
+
26
+ # @return [Array<AccessPolicyEntry>] An array of 0 to 16 identities that
27
+ # have access to the key vault. All identities in the array must use
28
+ # the same tenant ID as the key vault's tenant ID.
29
+ attr_accessor :access_policies
30
+
31
+ # @return [Boolean] Property to specify whether Azure Virtual Machines
32
+ # are permitted to retrieve certificates stored as secrets from the key
33
+ # vault.
34
+ attr_accessor :enabled_for_deployment
35
+
36
+ # @return [Boolean] Property to specify whether Azure Disk Encryption is
37
+ # permitted to retrieve secrets from the vault and unwrap keys.
38
+ attr_accessor :enabled_for_disk_encryption
39
+
40
+ # @return [Boolean] Property to specify whether Azure Resource Manager
41
+ # is permitted to retrieve secrets from the key vault.
42
+ attr_accessor :enabled_for_template_deployment
43
+
44
+
45
+ #
46
+ # Mapper for VaultProperties class as Ruby Hash.
47
+ # This will be used for serialization/deserialization.
48
+ #
49
+ def self.mapper()
50
+ {
51
+ required: false,
52
+ serialized_name: 'VaultProperties',
53
+ type: {
54
+ name: 'Composite',
55
+ class_name: 'VaultProperties',
56
+ model_properties: {
57
+ vault_uri: {
58
+ required: false,
59
+ serialized_name: 'vaultUri',
60
+ type: {
61
+ name: 'String'
62
+ }
63
+ },
64
+ tenant_id: {
65
+ required: true,
66
+ serialized_name: 'tenantId',
67
+ type: {
68
+ name: 'String'
69
+ }
70
+ },
71
+ sku: {
72
+ required: true,
73
+ serialized_name: 'sku',
74
+ type: {
75
+ name: 'Composite',
76
+ class_name: 'Sku'
77
+ }
78
+ },
79
+ access_policies: {
80
+ required: true,
81
+ serialized_name: 'accessPolicies',
82
+ constraints: {
83
+ MaxItems: 16
84
+ },
85
+ type: {
86
+ name: 'Sequence',
87
+ element: {
88
+ required: false,
89
+ serialized_name: 'AccessPolicyEntryElementType',
90
+ type: {
91
+ name: 'Composite',
92
+ class_name: 'AccessPolicyEntry'
93
+ }
94
+ }
95
+ }
96
+ },
97
+ enabled_for_deployment: {
98
+ required: false,
99
+ serialized_name: 'enabledForDeployment',
100
+ type: {
101
+ name: 'Boolean'
102
+ }
103
+ },
104
+ enabled_for_disk_encryption: {
105
+ required: false,
106
+ serialized_name: 'enabledForDiskEncryption',
107
+ type: {
108
+ name: 'Boolean'
109
+ }
110
+ },
111
+ enabled_for_template_deployment: {
112
+ required: false,
113
+ serialized_name: 'enabledForTemplateDeployment',
114
+ type: {
115
+ name: 'Boolean'
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::ARM end
8
+ module Azure::ARM::KeyVault end
@@ -0,0 +1,757 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::KeyVault
7
+ #
8
+ # The Azure management API provides a RESTful set of web services that
9
+ # interact with Azure Key Vault.
10
+ #
11
+ class Vaults
12
+ include Azure::ARM::KeyVault::Models
13
+ include MsRestAzure
14
+
15
+ #
16
+ # Creates and initializes a new instance of the Vaults class.
17
+ # @param client service class for accessing basic functionality.
18
+ #
19
+ def initialize(client)
20
+ @client = client
21
+ end
22
+
23
+ # @return reference to the KeyVaultManagementClient
24
+ attr_reader :client
25
+
26
+ #
27
+ # Create or update a key vault in the specified subscription.
28
+ #
29
+ # @param resource_group_name [String] The name of the Resource Group to which
30
+ # the server belongs.
31
+ # @param vault_name [String] Name of the vault
32
+ # @param parameters [VaultCreateOrUpdateParameters] Parameters to create or
33
+ # update the vault
34
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
35
+ # will be added to the HTTP request.
36
+ #
37
+ # @return [Vault] operation results.
38
+ #
39
+ def create_or_update(resource_group_name, vault_name, parameters, custom_headers = nil)
40
+ response = create_or_update_async(resource_group_name, vault_name, parameters, custom_headers).value!
41
+ response.body unless response.nil?
42
+ end
43
+
44
+ #
45
+ # Create or update a key vault in the specified subscription.
46
+ #
47
+ # @param resource_group_name [String] The name of the Resource Group to which
48
+ # the server belongs.
49
+ # @param vault_name [String] Name of the vault
50
+ # @param parameters [VaultCreateOrUpdateParameters] Parameters to create or
51
+ # update the vault
52
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
53
+ # will be added to the HTTP request.
54
+ #
55
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
56
+ #
57
+ def create_or_update_with_http_info(resource_group_name, vault_name, parameters, custom_headers = nil)
58
+ create_or_update_async(resource_group_name, vault_name, parameters, custom_headers).value!
59
+ end
60
+
61
+ #
62
+ # Create or update a key vault in the specified subscription.
63
+ #
64
+ # @param resource_group_name [String] The name of the Resource Group to which
65
+ # the server belongs.
66
+ # @param vault_name [String] Name of the vault
67
+ # @param parameters [VaultCreateOrUpdateParameters] Parameters to create or
68
+ # update the vault
69
+ # @param [Hash{String => String}] A hash of custom headers that will be added
70
+ # to the HTTP request.
71
+ #
72
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
73
+ #
74
+ def create_or_update_async(resource_group_name, vault_name, parameters, custom_headers = nil)
75
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
76
+ fail ArgumentError, 'vault_name is nil' if vault_name.nil?
77
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
78
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
79
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
80
+
81
+
82
+ request_headers = {}
83
+
84
+ # Set Headers
85
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
86
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
87
+
88
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
89
+
90
+ # Serialize Request
91
+ request_mapper = VaultCreateOrUpdateParameters.mapper()
92
+ request_content = @client.serialize(request_mapper, parameters, 'parameters')
93
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
94
+
95
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}'
96
+ options = {
97
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
98
+ path_params: {'resourceGroupName' => resource_group_name,'vaultName' => vault_name,'subscriptionId' => @client.subscription_id},
99
+ query_params: {'api-version' => @client.api_version},
100
+ body: request_content,
101
+ headers: request_headers.merge(custom_headers || {})
102
+ }
103
+
104
+ request_url = @base_url || @client.base_url
105
+
106
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :put, options)
107
+ promise = request.run_promise do |req|
108
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
109
+ end
110
+
111
+ promise = promise.then do |http_response|
112
+ status_code = http_response.status
113
+ response_content = http_response.body
114
+ unless status_code == 201 || status_code == 200
115
+ error_model = JSON.load(response_content)
116
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
117
+ end
118
+
119
+ # Create Result
120
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
121
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
122
+ # Deserialize Response
123
+ if status_code == 201
124
+ begin
125
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
126
+ result_mapper = Vault.mapper()
127
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
128
+ rescue Exception => e
129
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
130
+ end
131
+ end
132
+ # Deserialize Response
133
+ if status_code == 200
134
+ begin
135
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
136
+ result_mapper = Vault.mapper()
137
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
138
+ rescue Exception => e
139
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
140
+ end
141
+ end
142
+
143
+ result
144
+ end
145
+
146
+ promise.execute
147
+ end
148
+
149
+ #
150
+ # Deletes the specified Azure key vault.
151
+ #
152
+ # @param resource_group_name [String] The name of the Resource Group to which
153
+ # the vault belongs.
154
+ # @param vault_name [String] The name of the vault to delete
155
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
156
+ # will be added to the HTTP request.
157
+ #
158
+ #
159
+ def delete(resource_group_name, vault_name, custom_headers = nil)
160
+ response = delete_async(resource_group_name, vault_name, custom_headers).value!
161
+ nil
162
+ end
163
+
164
+ #
165
+ # Deletes the specified Azure key vault.
166
+ #
167
+ # @param resource_group_name [String] The name of the Resource Group to which
168
+ # the vault belongs.
169
+ # @param vault_name [String] The name of the vault to delete
170
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
171
+ # will be added to the HTTP request.
172
+ #
173
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
174
+ #
175
+ def delete_with_http_info(resource_group_name, vault_name, custom_headers = nil)
176
+ delete_async(resource_group_name, vault_name, custom_headers).value!
177
+ end
178
+
179
+ #
180
+ # Deletes the specified Azure key vault.
181
+ #
182
+ # @param resource_group_name [String] The name of the Resource Group to which
183
+ # the vault belongs.
184
+ # @param vault_name [String] The name of the vault to delete
185
+ # @param [Hash{String => String}] A hash of custom headers that will be added
186
+ # to the HTTP request.
187
+ #
188
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
189
+ #
190
+ def delete_async(resource_group_name, vault_name, custom_headers = nil)
191
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
192
+ fail ArgumentError, 'vault_name is nil' if vault_name.nil?
193
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
194
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
195
+
196
+
197
+ request_headers = {}
198
+
199
+ # Set Headers
200
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
201
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
202
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}'
203
+ options = {
204
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
205
+ path_params: {'resourceGroupName' => resource_group_name,'vaultName' => vault_name,'subscriptionId' => @client.subscription_id},
206
+ query_params: {'api-version' => @client.api_version},
207
+ headers: request_headers.merge(custom_headers || {})
208
+ }
209
+
210
+ request_url = @base_url || @client.base_url
211
+
212
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :delete, options)
213
+ promise = request.run_promise do |req|
214
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
215
+ end
216
+
217
+ promise = promise.then do |http_response|
218
+ status_code = http_response.status
219
+ response_content = http_response.body
220
+ unless status_code == 200
221
+ error_model = JSON.load(response_content)
222
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
223
+ end
224
+
225
+ # Create Result
226
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
227
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
228
+
229
+ result
230
+ end
231
+
232
+ promise.execute
233
+ end
234
+
235
+ #
236
+ # Gets the specified Azure key vault.
237
+ #
238
+ # @param resource_group_name [String] The name of the Resource Group to which
239
+ # the vault belongs.
240
+ # @param vault_name [String] The name of the vault.
241
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
242
+ # will be added to the HTTP request.
243
+ #
244
+ # @return [Vault] operation results.
245
+ #
246
+ def get(resource_group_name, vault_name, custom_headers = nil)
247
+ response = get_async(resource_group_name, vault_name, custom_headers).value!
248
+ response.body unless response.nil?
249
+ end
250
+
251
+ #
252
+ # Gets the specified Azure key vault.
253
+ #
254
+ # @param resource_group_name [String] The name of the Resource Group to which
255
+ # the vault belongs.
256
+ # @param vault_name [String] The name of the vault.
257
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
258
+ # will be added to the HTTP request.
259
+ #
260
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
261
+ #
262
+ def get_with_http_info(resource_group_name, vault_name, custom_headers = nil)
263
+ get_async(resource_group_name, vault_name, custom_headers).value!
264
+ end
265
+
266
+ #
267
+ # Gets the specified Azure key vault.
268
+ #
269
+ # @param resource_group_name [String] The name of the Resource Group to which
270
+ # the vault belongs.
271
+ # @param vault_name [String] The name of the vault.
272
+ # @param [Hash{String => String}] A hash of custom headers that will be added
273
+ # to the HTTP request.
274
+ #
275
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
276
+ #
277
+ def get_async(resource_group_name, vault_name, custom_headers = nil)
278
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
279
+ fail ArgumentError, 'vault_name is nil' if vault_name.nil?
280
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
281
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
282
+
283
+
284
+ request_headers = {}
285
+
286
+ # Set Headers
287
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
288
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
289
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}'
290
+ options = {
291
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
292
+ path_params: {'resourceGroupName' => resource_group_name,'vaultName' => vault_name,'subscriptionId' => @client.subscription_id},
293
+ query_params: {'api-version' => @client.api_version},
294
+ headers: request_headers.merge(custom_headers || {})
295
+ }
296
+
297
+ request_url = @base_url || @client.base_url
298
+
299
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
300
+ promise = request.run_promise do |req|
301
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
302
+ end
303
+
304
+ promise = promise.then do |http_response|
305
+ status_code = http_response.status
306
+ response_content = http_response.body
307
+ unless status_code == 200
308
+ error_model = JSON.load(response_content)
309
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
310
+ end
311
+
312
+ # Create Result
313
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
314
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
315
+ # Deserialize Response
316
+ if status_code == 200
317
+ begin
318
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
319
+ result_mapper = Vault.mapper()
320
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
321
+ rescue Exception => e
322
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
323
+ end
324
+ end
325
+
326
+ result
327
+ end
328
+
329
+ promise.execute
330
+ end
331
+
332
+ #
333
+ # The List operation gets information about the vaults associated with the
334
+ # subscription and within the specified resource group.
335
+ #
336
+ # @param resource_group_name [String] The name of the Resource Group to which
337
+ # the vault belongs.
338
+ # @param top [Integer] Maximum number of results to return.
339
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
340
+ # will be added to the HTTP request.
341
+ #
342
+ # @return [VaultListResult] which provide lazy access to pages of the response.
343
+ #
344
+ def list_by_resource_group_as_lazy(resource_group_name, top = nil, custom_headers = nil)
345
+ response = list_by_resource_group_async(resource_group_name, top, custom_headers).value!
346
+ unless response.nil?
347
+ page = response.body
348
+ page.next_method = Proc.new do |next_link|
349
+ list_by_resource_group_next_async(next_link, custom_headers)
350
+ end
351
+ page
352
+ end
353
+ end
354
+
355
+ #
356
+ # The List operation gets information about the vaults associated with the
357
+ # subscription and within the specified resource group.
358
+ #
359
+ # @param resource_group_name [String] The name of the Resource Group to which
360
+ # the vault belongs.
361
+ # @param top [Integer] Maximum number of results to return.
362
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
363
+ # will be added to the HTTP request.
364
+ #
365
+ # @return [Array<Vault>] operation results.
366
+ #
367
+ def list_by_resource_group(resource_group_name, top = nil, custom_headers = nil)
368
+ first_page = list_by_resource_group_as_lazy(resource_group_name, top, custom_headers)
369
+ first_page.get_all_items
370
+ end
371
+
372
+ #
373
+ # The List operation gets information about the vaults associated with the
374
+ # subscription and within the specified resource group.
375
+ #
376
+ # @param resource_group_name [String] The name of the Resource Group to which
377
+ # the vault belongs.
378
+ # @param top [Integer] Maximum number of results to return.
379
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
380
+ # will be added to the HTTP request.
381
+ #
382
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
383
+ #
384
+ def list_by_resource_group_with_http_info(resource_group_name, top = nil, custom_headers = nil)
385
+ list_by_resource_group_async(resource_group_name, top, custom_headers).value!
386
+ end
387
+
388
+ #
389
+ # The List operation gets information about the vaults associated with the
390
+ # subscription and within the specified resource group.
391
+ #
392
+ # @param resource_group_name [String] The name of the Resource Group to which
393
+ # the vault belongs.
394
+ # @param top [Integer] Maximum number of results to return.
395
+ # @param [Hash{String => String}] A hash of custom headers that will be added
396
+ # to the HTTP request.
397
+ #
398
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
399
+ #
400
+ def list_by_resource_group_async(resource_group_name, top = nil, custom_headers = nil)
401
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
402
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
403
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
404
+
405
+
406
+ request_headers = {}
407
+
408
+ # Set Headers
409
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
410
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
411
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults'
412
+ options = {
413
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
414
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
415
+ query_params: {'$top' => top,'api-version' => @client.api_version},
416
+ headers: request_headers.merge(custom_headers || {})
417
+ }
418
+
419
+ request_url = @base_url || @client.base_url
420
+
421
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
422
+ promise = request.run_promise do |req|
423
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
424
+ end
425
+
426
+ promise = promise.then do |http_response|
427
+ status_code = http_response.status
428
+ response_content = http_response.body
429
+ unless status_code == 200
430
+ error_model = JSON.load(response_content)
431
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
432
+ end
433
+
434
+ # Create Result
435
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
436
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
437
+ # Deserialize Response
438
+ if status_code == 200
439
+ begin
440
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
441
+ result_mapper = VaultListResult.mapper()
442
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
443
+ rescue Exception => e
444
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
445
+ end
446
+ end
447
+
448
+ result
449
+ end
450
+
451
+ promise.execute
452
+ end
453
+
454
+ #
455
+ # The List operation gets information about the vaults associated with the
456
+ # subscription.
457
+ #
458
+ # @param filter [String] The filter to apply on the operation.
459
+ # @param api_version [String] Azure Resource Manager Api Version.
460
+ # @param top [Integer] Maximum number of results to return.
461
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
462
+ # will be added to the HTTP request.
463
+ #
464
+ # @return [VaultListResult] which provide lazy access to pages of the response.
465
+ #
466
+ def list_as_lazy(top = nil, custom_headers = nil)
467
+ response = list_async(top, custom_headers).value!
468
+ unless response.nil?
469
+ page = response.body
470
+ page.next_method = Proc.new do |next_link|
471
+ list_next_async(next_link, custom_headers)
472
+ end
473
+ page
474
+ end
475
+ end
476
+
477
+ #
478
+ # The List operation gets information about the vaults associated with the
479
+ # subscription.
480
+ #
481
+ # @param top [Integer] Maximum number of results to return.
482
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
483
+ # will be added to the HTTP request.
484
+ #
485
+ # @return [Array<Vault>] operation results.
486
+ #
487
+ def list(top = nil, custom_headers = nil)
488
+ first_page = list_as_lazy(top, custom_headers)
489
+ first_page.get_all_items
490
+ end
491
+
492
+ #
493
+ # The List operation gets information about the vaults associated with the
494
+ # subscription.
495
+ #
496
+ # @param top [Integer] Maximum number of results to return.
497
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
498
+ # will be added to the HTTP request.
499
+ #
500
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
501
+ #
502
+ def list_with_http_info(top = nil, custom_headers = nil)
503
+ list_async(top, custom_headers).value!
504
+ end
505
+
506
+ #
507
+ # The List operation gets information about the vaults associated with the
508
+ # subscription.
509
+ #
510
+ # @param top [Integer] Maximum number of results to return.
511
+ # @param [Hash{String => String}] A hash of custom headers that will be added
512
+ # to the HTTP request.
513
+ #
514
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
515
+ #
516
+ def list_async(top = nil, custom_headers = nil)
517
+ filter = 'resourceType eq \'Microsoft.KeyVault/vaults\''
518
+ api_version = '2015-11-01'
519
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
520
+
521
+
522
+ request_headers = {}
523
+
524
+ # Set Headers
525
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
526
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
527
+ path_template = '/subscriptions/{subscriptionId}/resources'
528
+ options = {
529
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
530
+ path_params: {'subscriptionId' => @client.subscription_id},
531
+ query_params: {'$filter' => filter,'$top' => top,'api-version' => api_version},
532
+ headers: request_headers.merge(custom_headers || {})
533
+ }
534
+
535
+ request_url = @base_url || @client.base_url
536
+
537
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
538
+ promise = request.run_promise do |req|
539
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
540
+ end
541
+
542
+ promise = promise.then do |http_response|
543
+ status_code = http_response.status
544
+ response_content = http_response.body
545
+ unless status_code == 200
546
+ error_model = JSON.load(response_content)
547
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
548
+ end
549
+
550
+ # Create Result
551
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
552
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
553
+ # Deserialize Response
554
+ if status_code == 200
555
+ begin
556
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
557
+ result_mapper = VaultListResult.mapper()
558
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
559
+ rescue Exception => e
560
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
561
+ end
562
+ end
563
+
564
+ result
565
+ end
566
+
567
+ promise.execute
568
+ end
569
+
570
+ #
571
+ # The List operation gets information about the vaults associated with the
572
+ # subscription and within the specified resource group.
573
+ #
574
+ # @param next_page_link [String] The NextLink from the previous successful
575
+ # call to List operation.
576
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
577
+ # will be added to the HTTP request.
578
+ #
579
+ # @return [VaultListResult] operation results.
580
+ #
581
+ def list_by_resource_group_next(next_page_link, custom_headers = nil)
582
+ response = list_by_resource_group_next_async(next_page_link, custom_headers).value!
583
+ response.body unless response.nil?
584
+ end
585
+
586
+ #
587
+ # The List operation gets information about the vaults associated with the
588
+ # subscription and within the specified resource group.
589
+ #
590
+ # @param next_page_link [String] The NextLink from the previous successful
591
+ # call to List operation.
592
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
593
+ # will be added to the HTTP request.
594
+ #
595
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
596
+ #
597
+ def list_by_resource_group_next_with_http_info(next_page_link, custom_headers = nil)
598
+ list_by_resource_group_next_async(next_page_link, custom_headers).value!
599
+ end
600
+
601
+ #
602
+ # The List operation gets information about the vaults associated with the
603
+ # subscription and within the specified resource group.
604
+ #
605
+ # @param next_page_link [String] The NextLink from the previous successful
606
+ # call to List operation.
607
+ # @param [Hash{String => String}] A hash of custom headers that will be added
608
+ # to the HTTP request.
609
+ #
610
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
611
+ #
612
+ def list_by_resource_group_next_async(next_page_link, custom_headers = nil)
613
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
614
+
615
+
616
+ request_headers = {}
617
+
618
+ # Set Headers
619
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
620
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
621
+ path_template = '{nextLink}'
622
+ options = {
623
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
624
+ skip_encoding_path_params: {'nextLink' => next_page_link},
625
+ headers: request_headers.merge(custom_headers || {})
626
+ }
627
+
628
+ request_url = @base_url || @client.base_url
629
+
630
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
631
+ promise = request.run_promise do |req|
632
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
633
+ end
634
+
635
+ promise = promise.then do |http_response|
636
+ status_code = http_response.status
637
+ response_content = http_response.body
638
+ unless status_code == 200
639
+ error_model = JSON.load(response_content)
640
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
641
+ end
642
+
643
+ # Create Result
644
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
645
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
646
+ # Deserialize Response
647
+ if status_code == 200
648
+ begin
649
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
650
+ result_mapper = VaultListResult.mapper()
651
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
652
+ rescue Exception => e
653
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
654
+ end
655
+ end
656
+
657
+ result
658
+ end
659
+
660
+ promise.execute
661
+ end
662
+
663
+ #
664
+ # The List operation gets information about the vaults associated with the
665
+ # subscription.
666
+ #
667
+ # @param next_page_link [String] The NextLink from the previous successful
668
+ # call to List operation.
669
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
670
+ # will be added to the HTTP request.
671
+ #
672
+ # @return [VaultListResult] operation results.
673
+ #
674
+ def list_next(next_page_link, custom_headers = nil)
675
+ response = list_next_async(next_page_link, custom_headers).value!
676
+ response.body unless response.nil?
677
+ end
678
+
679
+ #
680
+ # The List operation gets information about the vaults associated with the
681
+ # subscription.
682
+ #
683
+ # @param next_page_link [String] The NextLink from the previous successful
684
+ # call to List operation.
685
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
686
+ # will be added to the HTTP request.
687
+ #
688
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
689
+ #
690
+ def list_next_with_http_info(next_page_link, custom_headers = nil)
691
+ list_next_async(next_page_link, custom_headers).value!
692
+ end
693
+
694
+ #
695
+ # The List operation gets information about the vaults associated with the
696
+ # subscription.
697
+ #
698
+ # @param next_page_link [String] The NextLink from the previous successful
699
+ # call to List operation.
700
+ # @param [Hash{String => String}] A hash of custom headers that will be added
701
+ # to the HTTP request.
702
+ #
703
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
704
+ #
705
+ def list_next_async(next_page_link, custom_headers = nil)
706
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
707
+
708
+
709
+ request_headers = {}
710
+
711
+ # Set Headers
712
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
713
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
714
+ path_template = '{nextLink}'
715
+ options = {
716
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
717
+ skip_encoding_path_params: {'nextLink' => next_page_link},
718
+ headers: request_headers.merge(custom_headers || {})
719
+ }
720
+
721
+ request_url = @base_url || @client.base_url
722
+
723
+ request = MsRest::HttpOperationRequest.new(request_url, path_template, :get, options)
724
+ promise = request.run_promise do |req|
725
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
726
+ end
727
+
728
+ promise = promise.then do |http_response|
729
+ status_code = http_response.status
730
+ response_content = http_response.body
731
+ unless status_code == 200
732
+ error_model = JSON.load(response_content)
733
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
734
+ end
735
+
736
+ # Create Result
737
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
738
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
739
+ # Deserialize Response
740
+ if status_code == 200
741
+ begin
742
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
743
+ result_mapper = VaultListResult.mapper()
744
+ result.body = @client.deserialize(result_mapper, parsed_response, 'result.body')
745
+ rescue Exception => e
746
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
747
+ end
748
+ end
749
+
750
+ result
751
+ end
752
+
753
+ promise.execute
754
+ end
755
+
756
+ end
757
+ end