azure_mgmt_notification_hubs 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/LICENSE.txt +21 -0
  4. data/Rakefile +5 -0
  5. data/azure_mgmt_notification_hubs.gemspec +35 -0
  6. data/lib/azure_mgmt_notification_hubs.rb +57 -0
  7. data/lib/azure_mgmt_notification_hubs/models/access_rights.rb +17 -0
  8. data/lib/azure_mgmt_notification_hubs/models/adm_credential.rb +63 -0
  9. data/lib/azure_mgmt_notification_hubs/models/adm_credential_properties.rb +74 -0
  10. data/lib/azure_mgmt_notification_hubs/models/apns_credential.rb +63 -0
  11. data/lib/azure_mgmt_notification_hubs/models/apns_credential_properties.rb +83 -0
  12. data/lib/azure_mgmt_notification_hubs/models/baidu_credential.rb +63 -0
  13. data/lib/azure_mgmt_notification_hubs/models/baidu_credential_properties.rb +74 -0
  14. data/lib/azure_mgmt_notification_hubs/models/check_availability_parameters.rb +86 -0
  15. data/lib/azure_mgmt_notification_hubs/models/check_availability_resource.rb +102 -0
  16. data/lib/azure_mgmt_notification_hubs/models/gcm_credential.rb +63 -0
  17. data/lib/azure_mgmt_notification_hubs/models/gcm_credential_properties.rb +65 -0
  18. data/lib/azure_mgmt_notification_hubs/models/mpns_credential.rb +63 -0
  19. data/lib/azure_mgmt_notification_hubs/models/mpns_credential_properties.rb +74 -0
  20. data/lib/azure_mgmt_notification_hubs/models/namespace_create_or_update_parameters.rb +83 -0
  21. data/lib/azure_mgmt_notification_hubs/models/namespace_list_result.rb +87 -0
  22. data/lib/azure_mgmt_notification_hubs/models/namespace_properties.rb +159 -0
  23. data/lib/azure_mgmt_notification_hubs/models/namespace_resource.rb +108 -0
  24. data/lib/azure_mgmt_notification_hubs/models/namespace_type.rb +16 -0
  25. data/lib/azure_mgmt_notification_hubs/models/notification_hub_create_or_update_parameters.rb +84 -0
  26. data/lib/azure_mgmt_notification_hubs/models/notification_hub_list_result.rb +87 -0
  27. data/lib/azure_mgmt_notification_hubs/models/notification_hub_properties.rb +197 -0
  28. data/lib/azure_mgmt_notification_hubs/models/notification_hub_resource.rb +111 -0
  29. data/lib/azure_mgmt_notification_hubs/models/resource_list_keys.rb +67 -0
  30. data/lib/azure_mgmt_notification_hubs/models/shared_access_authorization_rule_create_or_update_parameters.rb +83 -0
  31. data/lib/azure_mgmt_notification_hubs/models/shared_access_authorization_rule_list_result.rb +87 -0
  32. data/lib/azure_mgmt_notification_hubs/models/shared_access_authorization_rule_properties.rb +145 -0
  33. data/lib/azure_mgmt_notification_hubs/models/shared_access_authorization_rule_resource.rb +113 -0
  34. data/lib/azure_mgmt_notification_hubs/models/wns_credential.rb +63 -0
  35. data/lib/azure_mgmt_notification_hubs/models/wns_credential_properties.rb +74 -0
  36. data/lib/azure_mgmt_notification_hubs/module_definition.rb +8 -0
  37. data/lib/azure_mgmt_notification_hubs/namespaces.rb +1012 -0
  38. data/lib/azure_mgmt_notification_hubs/notification_hubs.rb +896 -0
  39. data/lib/azure_mgmt_notification_hubs/notification_hubs_management_client.rb +72 -0
  40. data/lib/azure_mgmt_notification_hubs/version.rb +8 -0
  41. metadata +167 -0
@@ -0,0 +1,896 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::NotificationHubs
7
+ #
8
+ # .Net client wrapper for the REST API for Azure NotificationHub Service
9
+ #
10
+ class NotificationHubs
11
+ include Azure::ARM::NotificationHubs::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the NotificationHubs class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return reference to the NotificationHubsManagementClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Checks the availability of the given notificationHub in a namespace.
27
+ #
28
+ # @param resource_group_name [String] The name of the resource group.
29
+ # @param namespace_name [String] The namespace name.
30
+ # @param parameters [CheckAvailabilityParameters] The notificationHub name.
31
+ # @param [Hash{String => String}] The hash of custom headers need to be
32
+ # applied to HTTP request.
33
+ #
34
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
35
+ # response.
36
+ #
37
+ def check_availability(resource_group_name, namespace_name, parameters, custom_headers = nil)
38
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
39
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
40
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
41
+ parameters.validate unless parameters.nil?
42
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
43
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
44
+ request_headers = {}
45
+
46
+ # Set Headers
47
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
48
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
49
+
50
+ # Serialize Request
51
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
52
+ unless parameters.nil?
53
+ parameters = CheckAvailabilityParameters.serialize_object(parameters)
54
+ end
55
+ request_content = JSON.generate(parameters, quirks_mode: true)
56
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability'
57
+ options = {
58
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
59
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
60
+ query_params: {'api-version' => @client.api_version},
61
+ body: request_content,
62
+ headers: request_headers.merge(custom_headers || {})
63
+ }
64
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
65
+ promise = request.run_promise do |req|
66
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
67
+ end
68
+
69
+ promise = promise.then do |http_response|
70
+ status_code = http_response.status
71
+ response_content = http_response.body
72
+ unless status_code == 200
73
+ error_model = JSON.load(response_content)
74
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
75
+ end
76
+
77
+ # Create Result
78
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
79
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
80
+ # Deserialize Response
81
+ if status_code == 200
82
+ begin
83
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
84
+ unless parsed_response.nil?
85
+ parsed_response = CheckAvailabilityResource.deserialize_object(parsed_response)
86
+ end
87
+ result.body = parsed_response
88
+ rescue Exception => e
89
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
90
+ end
91
+ end
92
+
93
+ result
94
+ end
95
+
96
+ promise.execute
97
+ end
98
+
99
+ #
100
+ # Creates a new NotificationHub in a namespace.
101
+ #
102
+ # @param resource_group_name [String] The name of the resource group.
103
+ # @param namespace_name [String] The namespace name.
104
+ # @param notification_hub_name [String] The notification hub name.
105
+ # @param parameters [NotificationHubCreateOrUpdateParameters] Parameters
106
+ # supplied to the create a Namespace Resource.
107
+ # @param [Hash{String => String}] The hash of custom headers need to be
108
+ # applied to HTTP request.
109
+ #
110
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
111
+ # response.
112
+ #
113
+ def create(resource_group_name, namespace_name, notification_hub_name, parameters, custom_headers = nil)
114
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
115
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
116
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
117
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
118
+ parameters.validate unless parameters.nil?
119
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
120
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
121
+ request_headers = {}
122
+
123
+ # Set Headers
124
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
125
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
126
+
127
+ # Serialize Request
128
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
129
+ unless parameters.nil?
130
+ parameters = NotificationHubCreateOrUpdateParameters.serialize_object(parameters)
131
+ end
132
+ request_content = JSON.generate(parameters, quirks_mode: true)
133
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}'
134
+ options = {
135
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
136
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'subscriptionId' => @client.subscription_id},
137
+ query_params: {'api-version' => @client.api_version},
138
+ body: request_content,
139
+ headers: request_headers.merge(custom_headers || {})
140
+ }
141
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
142
+ promise = request.run_promise do |req|
143
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
144
+ end
145
+
146
+ promise = promise.then do |http_response|
147
+ status_code = http_response.status
148
+ response_content = http_response.body
149
+ unless status_code == 200 || status_code == 201
150
+ error_model = JSON.load(response_content)
151
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
152
+ end
153
+
154
+ # Create Result
155
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
156
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
157
+ # Deserialize Response
158
+ if status_code == 200
159
+ begin
160
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
161
+ unless parsed_response.nil?
162
+ parsed_response = NotificationHubResource.deserialize_object(parsed_response)
163
+ end
164
+ result.body = parsed_response
165
+ rescue Exception => e
166
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
167
+ end
168
+ end
169
+ # Deserialize Response
170
+ if status_code == 201
171
+ begin
172
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
173
+ unless parsed_response.nil?
174
+ parsed_response = NotificationHubResource.deserialize_object(parsed_response)
175
+ end
176
+ result.body = parsed_response
177
+ rescue Exception => e
178
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
179
+ end
180
+ end
181
+
182
+ result
183
+ end
184
+
185
+ promise.execute
186
+ end
187
+
188
+ #
189
+ # Deletes a notification hub associated with a namespace.
190
+ #
191
+ # @param resource_group_name [String] The name of the resource group.
192
+ # @param namespace_name [String] The namespace name.
193
+ # @param notification_hub_name [String] The notification hub name.
194
+ # @param [Hash{String => String}] The hash of custom headers need to be
195
+ # applied to HTTP request.
196
+ #
197
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
198
+ # response.
199
+ #
200
+ def delete(resource_group_name, namespace_name, notification_hub_name, custom_headers = nil)
201
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
202
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
203
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
204
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
205
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
206
+ request_headers = {}
207
+
208
+ # Set Headers
209
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
210
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
211
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}'
212
+ options = {
213
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
214
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'subscriptionId' => @client.subscription_id},
215
+ query_params: {'api-version' => @client.api_version},
216
+ headers: request_headers.merge(custom_headers || {})
217
+ }
218
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
219
+ promise = request.run_promise do |req|
220
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
221
+ end
222
+
223
+ promise = promise.then do |http_response|
224
+ status_code = http_response.status
225
+ response_content = http_response.body
226
+ unless status_code == 200
227
+ error_model = JSON.load(response_content)
228
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
229
+ end
230
+
231
+ # Create Result
232
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
233
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
234
+
235
+ result
236
+ end
237
+
238
+ promise.execute
239
+ end
240
+
241
+ #
242
+ # Lists the notification hubs associated with a namespace.
243
+ #
244
+ # @param resource_group_name [String] The name of the resource group.
245
+ # @param namespace_name [String] The namespace name.
246
+ # @param notification_hub_name [String] The notification hub name.
247
+ # @param [Hash{String => String}] The hash of custom headers need to be
248
+ # applied to HTTP request.
249
+ #
250
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
251
+ # response.
252
+ #
253
+ def get(resource_group_name, namespace_name, notification_hub_name, custom_headers = nil)
254
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
255
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
256
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
257
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
258
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
259
+ request_headers = {}
260
+
261
+ # Set Headers
262
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
263
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
264
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}'
265
+ options = {
266
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
267
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'subscriptionId' => @client.subscription_id},
268
+ query_params: {'api-version' => @client.api_version},
269
+ headers: request_headers.merge(custom_headers || {})
270
+ }
271
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
272
+ promise = request.run_promise do |req|
273
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
274
+ end
275
+
276
+ promise = promise.then do |http_response|
277
+ status_code = http_response.status
278
+ response_content = http_response.body
279
+ unless status_code == 200
280
+ error_model = JSON.load(response_content)
281
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
282
+ end
283
+
284
+ # Create Result
285
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
286
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
287
+ # Deserialize Response
288
+ if status_code == 200
289
+ begin
290
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
291
+ unless parsed_response.nil?
292
+ parsed_response = NotificationHubResource.deserialize_object(parsed_response)
293
+ end
294
+ result.body = parsed_response
295
+ rescue Exception => e
296
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
297
+ end
298
+ end
299
+
300
+ result
301
+ end
302
+
303
+ promise.execute
304
+ end
305
+
306
+ #
307
+ # The create NotificationHub authorization rule operation creates an
308
+ # authorization rule for a NotificationHub
309
+ #
310
+ # @param resource_group_name [String] The name of the resource group.
311
+ # @param namespace_name [String] The namespace name.
312
+ # @param notification_hub_name [String] The notification hub name.
313
+ # @param authorization_rule_name [String] The namespace authorizationRuleName
314
+ # name.
315
+ # @param parameters [SharedAccessAuthorizationRuleCreateOrUpdateParameters]
316
+ # The shared access authorization rule.
317
+ # @param [Hash{String => String}] The hash of custom headers need to be
318
+ # applied to HTTP request.
319
+ #
320
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
321
+ # response.
322
+ #
323
+ def create_or_update_authorization_rule(resource_group_name, namespace_name, notification_hub_name, authorization_rule_name, parameters, custom_headers = nil)
324
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
325
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
326
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
327
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
328
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
329
+ parameters.validate unless parameters.nil?
330
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
331
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
332
+ request_headers = {}
333
+
334
+ # Set Headers
335
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
336
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
337
+
338
+ # Serialize Request
339
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
340
+ unless parameters.nil?
341
+ parameters = SharedAccessAuthorizationRuleCreateOrUpdateParameters.serialize_object(parameters)
342
+ end
343
+ request_content = JSON.generate(parameters, quirks_mode: true)
344
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}'
345
+ options = {
346
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
347
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
348
+ query_params: {'api-version' => @client.api_version},
349
+ body: request_content,
350
+ headers: request_headers.merge(custom_headers || {})
351
+ }
352
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
353
+ promise = request.run_promise do |req|
354
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
355
+ end
356
+
357
+ promise = promise.then do |http_response|
358
+ status_code = http_response.status
359
+ response_content = http_response.body
360
+ unless status_code == 200
361
+ error_model = JSON.load(response_content)
362
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
363
+ end
364
+
365
+ # Create Result
366
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
367
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
368
+ # Deserialize Response
369
+ if status_code == 200
370
+ begin
371
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
372
+ unless parsed_response.nil?
373
+ parsed_response = SharedAccessAuthorizationRuleResource.deserialize_object(parsed_response)
374
+ end
375
+ result.body = parsed_response
376
+ rescue Exception => e
377
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
378
+ end
379
+ end
380
+
381
+ result
382
+ end
383
+
384
+ promise.execute
385
+ end
386
+
387
+ #
388
+ # The delete a notificationHub authorization rule operation
389
+ #
390
+ # @param resource_group_name [String] The name of the resource group.
391
+ # @param namespace_name [String] The namespace name.
392
+ # @param notification_hub_name [String] The notification hub name.
393
+ # @param authorization_rule_name [String] The namespace authorizationRuleName
394
+ # name.
395
+ # @param [Hash{String => String}] The hash of custom headers need to be
396
+ # applied to HTTP request.
397
+ #
398
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
399
+ # response.
400
+ #
401
+ def delete_authorization_rule(resource_group_name, namespace_name, notification_hub_name, authorization_rule_name, custom_headers = nil)
402
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
403
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
404
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
405
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
406
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
407
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
408
+ request_headers = {}
409
+
410
+ # Set Headers
411
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
412
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
413
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}'
414
+ options = {
415
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
416
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
417
+ query_params: {'api-version' => @client.api_version},
418
+ headers: request_headers.merge(custom_headers || {})
419
+ }
420
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
421
+ promise = request.run_promise do |req|
422
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
423
+ end
424
+
425
+ promise = promise.then do |http_response|
426
+ status_code = http_response.status
427
+ response_content = http_response.body
428
+ unless status_code == 204 || status_code == 200
429
+ error_model = JSON.load(response_content)
430
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
431
+ end
432
+
433
+ # Create Result
434
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
435
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
436
+
437
+ result
438
+ end
439
+
440
+ promise.execute
441
+ end
442
+
443
+ #
444
+ # The get authorization rule operation gets an authorization rule for a
445
+ # NotificationHub by name.
446
+ #
447
+ # @param resource_group_name [String] The name of the resource group.
448
+ # @param namespace_name [String] The namespace to get the authorization rule
449
+ # for.
450
+ # @param notification_hub_name [String] The notification hub name.
451
+ # @param authorization_rule_name [String] The entity name to get the
452
+ # authorization rule for.
453
+ # @param [Hash{String => String}] The hash of custom headers need to be
454
+ # applied to HTTP request.
455
+ #
456
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
457
+ # response.
458
+ #
459
+ def get_authorization_rule(resource_group_name, namespace_name, notification_hub_name, authorization_rule_name, custom_headers = nil)
460
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
461
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
462
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
463
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
464
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
465
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
466
+ request_headers = {}
467
+
468
+ # Set Headers
469
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
470
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
471
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}'
472
+ options = {
473
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
474
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
475
+ query_params: {'api-version' => @client.api_version},
476
+ headers: request_headers.merge(custom_headers || {})
477
+ }
478
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
479
+ promise = request.run_promise do |req|
480
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
481
+ end
482
+
483
+ promise = promise.then do |http_response|
484
+ status_code = http_response.status
485
+ response_content = http_response.body
486
+ unless status_code == 200
487
+ error_model = JSON.load(response_content)
488
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
489
+ end
490
+
491
+ # Create Result
492
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
493
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
494
+ # Deserialize Response
495
+ if status_code == 200
496
+ begin
497
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
498
+ unless parsed_response.nil?
499
+ parsed_response = SharedAccessAuthorizationRuleResource.deserialize_object(parsed_response)
500
+ end
501
+ result.body = parsed_response
502
+ rescue Exception => e
503
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
504
+ end
505
+ end
506
+
507
+ result
508
+ end
509
+
510
+ promise.execute
511
+ end
512
+
513
+ #
514
+ # Lists the notification hubs associated with a namespace.
515
+ #
516
+ # @param resource_group_name [String] The name of the resource group.
517
+ # @param namespace_name [String] The namespace name.
518
+ # @param [Hash{String => String}] The hash of custom headers need to be
519
+ # applied to HTTP request.
520
+ #
521
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
522
+ # response.
523
+ #
524
+ def list(resource_group_name, namespace_name, custom_headers = nil)
525
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
526
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
527
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
528
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
529
+ request_headers = {}
530
+
531
+ # Set Headers
532
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
533
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
534
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs'
535
+ options = {
536
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
537
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
538
+ query_params: {'api-version' => @client.api_version},
539
+ headers: request_headers.merge(custom_headers || {})
540
+ }
541
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
542
+ promise = request.run_promise do |req|
543
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
544
+ end
545
+
546
+ promise = promise.then do |http_response|
547
+ status_code = http_response.status
548
+ response_content = http_response.body
549
+ unless status_code == 200
550
+ error_model = JSON.load(response_content)
551
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
552
+ end
553
+
554
+ # Create Result
555
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
556
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
557
+ # Deserialize Response
558
+ if status_code == 200
559
+ begin
560
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
561
+ unless parsed_response.nil?
562
+ parsed_response = NotificationHubListResult.deserialize_object(parsed_response)
563
+ end
564
+ result.body = parsed_response
565
+ rescue Exception => e
566
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
567
+ end
568
+ end
569
+
570
+ result
571
+ end
572
+
573
+ promise.execute
574
+ end
575
+
576
+ #
577
+ # The get authorization rules operation gets the authorization rules for a
578
+ # NotificationHub.
579
+ #
580
+ # @param resource_group_name [String] The name of the resource group.
581
+ # @param namespace_name [String] The NotificationHub to get the authorization
582
+ # rule for.
583
+ # @param notification_hub_name [String] The notification hub name.
584
+ # @param [Hash{String => String}] The hash of custom headers need to be
585
+ # applied to HTTP request.
586
+ #
587
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
588
+ # response.
589
+ #
590
+ def list_authorization_rules(resource_group_name, namespace_name, notification_hub_name, custom_headers = nil)
591
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
592
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
593
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
594
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
595
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
596
+ request_headers = {}
597
+
598
+ # Set Headers
599
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
600
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
601
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules'
602
+ options = {
603
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
604
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'subscriptionId' => @client.subscription_id},
605
+ query_params: {'api-version' => @client.api_version},
606
+ headers: request_headers.merge(custom_headers || {})
607
+ }
608
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
609
+ promise = request.run_promise do |req|
610
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
611
+ end
612
+
613
+ promise = promise.then do |http_response|
614
+ status_code = http_response.status
615
+ response_content = http_response.body
616
+ unless status_code == 200
617
+ error_model = JSON.load(response_content)
618
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
619
+ end
620
+
621
+ # Create Result
622
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
623
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
624
+ # Deserialize Response
625
+ if status_code == 200
626
+ begin
627
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
628
+ unless parsed_response.nil?
629
+ parsed_response = SharedAccessAuthorizationRuleListResult.deserialize_object(parsed_response)
630
+ end
631
+ result.body = parsed_response
632
+ rescue Exception => e
633
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
634
+ end
635
+ end
636
+
637
+ result
638
+ end
639
+
640
+ promise.execute
641
+ end
642
+
643
+ #
644
+ # Gets the Primary and Secondary ConnectionStrings to the NotificationHub
645
+ #
646
+ # @param resource_group_name [String] The name of the resource group.
647
+ # @param namespace_name [String] The namespace name.
648
+ # @param notification_hub_name [String] The notification hub name.
649
+ # @param authorization_rule_name [String] The connection string of the
650
+ # NotificationHub for the specified authorizationRule.
651
+ # @param [Hash{String => String}] The hash of custom headers need to be
652
+ # applied to HTTP request.
653
+ #
654
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
655
+ # response.
656
+ #
657
+ def list_keys(resource_group_name, namespace_name, notification_hub_name, authorization_rule_name, custom_headers = nil)
658
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
659
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
660
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
661
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
662
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
663
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
664
+ request_headers = {}
665
+
666
+ # Set Headers
667
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
668
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
669
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys'
670
+ options = {
671
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
672
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
673
+ query_params: {'api-version' => @client.api_version},
674
+ headers: request_headers.merge(custom_headers || {})
675
+ }
676
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
677
+ promise = request.run_promise do |req|
678
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
679
+ end
680
+
681
+ promise = promise.then do |http_response|
682
+ status_code = http_response.status
683
+ response_content = http_response.body
684
+ unless status_code == 200
685
+ error_model = JSON.load(response_content)
686
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
687
+ end
688
+
689
+ # Create Result
690
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
691
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
692
+ # Deserialize Response
693
+ if status_code == 200
694
+ begin
695
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
696
+ unless parsed_response.nil?
697
+ parsed_response = ResourceListKeys.deserialize_object(parsed_response)
698
+ end
699
+ result.body = parsed_response
700
+ rescue Exception => e
701
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
702
+ end
703
+ end
704
+
705
+ result
706
+ end
707
+
708
+ promise.execute
709
+ end
710
+
711
+ #
712
+ # Lists the PNS Credentials associated with a notification hub .
713
+ #
714
+ # @param resource_group_name [String] The name of the resource group.
715
+ # @param namespace_name [String] The namespace name.
716
+ # @param notification_hub_name [String] The notification hub name.
717
+ # @param [Hash{String => String}] The hash of custom headers need to be
718
+ # applied to HTTP request.
719
+ #
720
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
721
+ # response.
722
+ #
723
+ def get_pns_credentials(resource_group_name, namespace_name, notification_hub_name, custom_headers = nil)
724
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
725
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
726
+ fail ArgumentError, 'notification_hub_name is nil' if notification_hub_name.nil?
727
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
728
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
729
+ request_headers = {}
730
+
731
+ # Set Headers
732
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
733
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
734
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials'
735
+ options = {
736
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
737
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'notificationHubName' => notification_hub_name,'subscriptionId' => @client.subscription_id},
738
+ query_params: {'api-version' => @client.api_version},
739
+ headers: request_headers.merge(custom_headers || {})
740
+ }
741
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
742
+ promise = request.run_promise do |req|
743
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
744
+ end
745
+
746
+ promise = promise.then do |http_response|
747
+ status_code = http_response.status
748
+ response_content = http_response.body
749
+ unless status_code == 200
750
+ error_model = JSON.load(response_content)
751
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
752
+ end
753
+
754
+ # Create Result
755
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
756
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
757
+ # Deserialize Response
758
+ if status_code == 200
759
+ begin
760
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
761
+ unless parsed_response.nil?
762
+ parsed_response = NotificationHubResource.deserialize_object(parsed_response)
763
+ end
764
+ result.body = parsed_response
765
+ rescue Exception => e
766
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
767
+ end
768
+ end
769
+
770
+ result
771
+ end
772
+
773
+ promise.execute
774
+ end
775
+
776
+ #
777
+ # Lists the notification hubs associated with a namespace.
778
+ #
779
+ # @param next_page_link [String] The NextLink from the previous successful
780
+ # call to List operation.
781
+ # @param [Hash{String => String}] The hash of custom headers need to be
782
+ # applied to HTTP request.
783
+ #
784
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
785
+ # response.
786
+ #
787
+ def list_next(next_page_link, custom_headers = nil)
788
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
789
+ request_headers = {}
790
+
791
+ # Set Headers
792
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
793
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
794
+ path_template = '{nextLink}'
795
+ options = {
796
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
797
+ skip_encoding_path_params: {'nextLink' => next_page_link},
798
+ headers: request_headers.merge(custom_headers || {})
799
+ }
800
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
801
+ promise = request.run_promise do |req|
802
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
803
+ end
804
+
805
+ promise = promise.then do |http_response|
806
+ status_code = http_response.status
807
+ response_content = http_response.body
808
+ unless status_code == 200
809
+ error_model = JSON.load(response_content)
810
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
811
+ end
812
+
813
+ # Create Result
814
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
815
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
816
+ # Deserialize Response
817
+ if status_code == 200
818
+ begin
819
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
820
+ unless parsed_response.nil?
821
+ parsed_response = NotificationHubListResult.deserialize_object(parsed_response)
822
+ end
823
+ result.body = parsed_response
824
+ rescue Exception => e
825
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
826
+ end
827
+ end
828
+
829
+ result
830
+ end
831
+
832
+ promise.execute
833
+ end
834
+
835
+ #
836
+ # The get authorization rules operation gets the authorization rules for a
837
+ # NotificationHub.
838
+ #
839
+ # @param next_page_link [String] The NextLink from the previous successful
840
+ # call to List operation.
841
+ # @param [Hash{String => String}] The hash of custom headers need to be
842
+ # applied to HTTP request.
843
+ #
844
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
845
+ # response.
846
+ #
847
+ def list_authorization_rules_next(next_page_link, custom_headers = nil)
848
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
849
+ request_headers = {}
850
+
851
+ # Set Headers
852
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
853
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
854
+ path_template = '{nextLink}'
855
+ options = {
856
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
857
+ skip_encoding_path_params: {'nextLink' => next_page_link},
858
+ headers: request_headers.merge(custom_headers || {})
859
+ }
860
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
861
+ promise = request.run_promise do |req|
862
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
863
+ end
864
+
865
+ promise = promise.then do |http_response|
866
+ status_code = http_response.status
867
+ response_content = http_response.body
868
+ unless status_code == 200
869
+ error_model = JSON.load(response_content)
870
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
871
+ end
872
+
873
+ # Create Result
874
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
875
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
876
+ # Deserialize Response
877
+ if status_code == 200
878
+ begin
879
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
880
+ unless parsed_response.nil?
881
+ parsed_response = SharedAccessAuthorizationRuleListResult.deserialize_object(parsed_response)
882
+ end
883
+ result.body = parsed_response
884
+ rescue Exception => e
885
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
886
+ end
887
+ end
888
+
889
+ result
890
+ end
891
+
892
+ promise.execute
893
+ end
894
+
895
+ end
896
+ end