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,113 @@
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
+ module Models
8
+ #
9
+ # Description of a Namespace AuthorizationRules.
10
+ #
11
+ class SharedAccessAuthorizationRuleResource
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] Gets or sets the id of the created Namespace
16
+ # AuthorizationRules.
17
+ attr_accessor :id
18
+
19
+ # @return [String] Gets or sets datacenter location of the Namespace
20
+ # AuthorizationRules.
21
+ attr_accessor :location
22
+
23
+ # @return [String] Gets or sets name of the Namespace AuthorizationRules.
24
+ attr_accessor :name
25
+
26
+ # @return [String] Gets or sets resource type of the Namespace
27
+ # AuthorizationRules.
28
+ attr_accessor :type
29
+
30
+ # @return [Hash{String => String}] Gets or sets tags of the Namespace
31
+ # AuthorizationRules.
32
+ attr_accessor :tags
33
+
34
+ # @return [SharedAccessAuthorizationRuleProperties] Gets or sets
35
+ # properties of the Namespace.
36
+ attr_accessor :properties
37
+
38
+ #
39
+ # Validate the object. Throws ValidationError if validation fails.
40
+ #
41
+ def validate
42
+ @tags.each{ |e| e.validate if e.respond_to?(:validate) } unless @tags.nil?
43
+ @properties.validate unless @properties.nil?
44
+ end
45
+
46
+ #
47
+ # Serializes given Model object into Ruby Hash.
48
+ # @param object Model object to serialize.
49
+ # @return [Hash] Serialized object in form of Ruby Hash.
50
+ #
51
+ def self.serialize_object(object)
52
+ object.validate
53
+ output_object = {}
54
+
55
+ serialized_property = object.id
56
+ output_object['id'] = serialized_property unless serialized_property.nil?
57
+
58
+ serialized_property = object.location
59
+ output_object['location'] = serialized_property unless serialized_property.nil?
60
+
61
+ serialized_property = object.name
62
+ output_object['name'] = serialized_property unless serialized_property.nil?
63
+
64
+ serialized_property = object.type
65
+ output_object['type'] = serialized_property unless serialized_property.nil?
66
+
67
+ serialized_property = object.tags
68
+ output_object['tags'] = serialized_property unless serialized_property.nil?
69
+
70
+ serialized_property = object.properties
71
+ unless serialized_property.nil?
72
+ serialized_property = SharedAccessAuthorizationRuleProperties.serialize_object(serialized_property)
73
+ end
74
+ output_object['properties'] = serialized_property unless serialized_property.nil?
75
+
76
+ output_object
77
+ end
78
+
79
+ #
80
+ # Deserializes given Ruby Hash into Model object.
81
+ # @param object [Hash] Ruby Hash object to deserialize.
82
+ # @return [SharedAccessAuthorizationRuleResource] Deserialized object.
83
+ #
84
+ def self.deserialize_object(object)
85
+ return if object.nil?
86
+ output_object = SharedAccessAuthorizationRuleResource.new
87
+
88
+ deserialized_property = object['id']
89
+ output_object.id = deserialized_property
90
+
91
+ deserialized_property = object['location']
92
+ output_object.location = deserialized_property
93
+
94
+ deserialized_property = object['name']
95
+ output_object.name = deserialized_property
96
+
97
+ deserialized_property = object['type']
98
+ output_object.type = deserialized_property
99
+
100
+ deserialized_property = object['tags']
101
+ output_object.tags = deserialized_property
102
+
103
+ deserialized_property = object['properties']
104
+ unless deserialized_property.nil?
105
+ deserialized_property = SharedAccessAuthorizationRuleProperties.deserialize_object(deserialized_property)
106
+ end
107
+ output_object.properties = deserialized_property
108
+
109
+ output_object
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,63 @@
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
+ module Models
8
+ #
9
+ # Description of a NotificationHub WnsCredential.
10
+ #
11
+ class WnsCredential
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [WnsCredentialProperties] Gets or sets properties of
16
+ # NotificationHub WnsCredential.
17
+ attr_accessor :properties
18
+
19
+ #
20
+ # Validate the object. Throws ValidationError if validation fails.
21
+ #
22
+ def validate
23
+ @properties.validate unless @properties.nil?
24
+ end
25
+
26
+ #
27
+ # Serializes given Model object into Ruby Hash.
28
+ # @param object Model object to serialize.
29
+ # @return [Hash] Serialized object in form of Ruby Hash.
30
+ #
31
+ def self.serialize_object(object)
32
+ object.validate
33
+ output_object = {}
34
+
35
+ serialized_property = object.properties
36
+ unless serialized_property.nil?
37
+ serialized_property = WnsCredentialProperties.serialize_object(serialized_property)
38
+ end
39
+ output_object['properties'] = serialized_property unless serialized_property.nil?
40
+
41
+ output_object
42
+ end
43
+
44
+ #
45
+ # Deserializes given Ruby Hash into Model object.
46
+ # @param object [Hash] Ruby Hash object to deserialize.
47
+ # @return [WnsCredential] Deserialized object.
48
+ #
49
+ def self.deserialize_object(object)
50
+ return if object.nil?
51
+ output_object = WnsCredential.new
52
+
53
+ deserialized_property = object['properties']
54
+ unless deserialized_property.nil?
55
+ deserialized_property = WnsCredentialProperties.deserialize_object(deserialized_property)
56
+ end
57
+ output_object.properties = deserialized_property
58
+
59
+ output_object
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,74 @@
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
+ module Models
8
+ #
9
+ # Description of a NotificationHub WnsCredential.
10
+ #
11
+ class WnsCredentialProperties
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [String] Gets or sets the package ID for this credential.
16
+ attr_accessor :package_sid
17
+
18
+ # @return [String] Gets or sets the secret key.
19
+ attr_accessor :secret_key
20
+
21
+ # @return [String] Gets or sets the Windows Live endpoint.
22
+ attr_accessor :windows_live_endpoint
23
+
24
+ #
25
+ # Validate the object. Throws ValidationError if validation fails.
26
+ #
27
+ def validate
28
+ # Nothing to validate
29
+ end
30
+
31
+ #
32
+ # Serializes given Model object into Ruby Hash.
33
+ # @param object Model object to serialize.
34
+ # @return [Hash] Serialized object in form of Ruby Hash.
35
+ #
36
+ def self.serialize_object(object)
37
+ object.validate
38
+ output_object = {}
39
+
40
+ serialized_property = object.package_sid
41
+ output_object['packageSid'] = serialized_property unless serialized_property.nil?
42
+
43
+ serialized_property = object.secret_key
44
+ output_object['secretKey'] = serialized_property unless serialized_property.nil?
45
+
46
+ serialized_property = object.windows_live_endpoint
47
+ output_object['windowsLiveEndpoint'] = serialized_property unless serialized_property.nil?
48
+
49
+ output_object
50
+ end
51
+
52
+ #
53
+ # Deserializes given Ruby Hash into Model object.
54
+ # @param object [Hash] Ruby Hash object to deserialize.
55
+ # @return [WnsCredentialProperties] Deserialized object.
56
+ #
57
+ def self.deserialize_object(object)
58
+ return if object.nil?
59
+ output_object = WnsCredentialProperties.new
60
+
61
+ deserialized_property = object['packageSid']
62
+ output_object.package_sid = deserialized_property
63
+
64
+ deserialized_property = object['secretKey']
65
+ output_object.secret_key = deserialized_property
66
+
67
+ deserialized_property = object['windowsLiveEndpoint']
68
+ output_object.windows_live_endpoint = deserialized_property
69
+
70
+ output_object
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,8 @@
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 end
7
+ module Azure::ARM end
8
+ module Azure::ARM::NotificationHubs end
@@ -0,0 +1,1012 @@
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 Namespaces
11
+ include Azure::ARM::NotificationHubs::Models
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Namespaces 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 service namespace across all Windows
27
+ # Azure subscriptions. This is useful because the domain name is created
28
+ # based on the service namespace name.
29
+ #
30
+ # @param parameters [CheckAvailabilityParameters] The namespace 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(parameters, custom_headers = nil)
38
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
39
+ parameters.validate unless parameters.nil?
40
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
41
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
42
+ request_headers = {}
43
+
44
+ # Set Headers
45
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
46
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
47
+
48
+ # Serialize Request
49
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
50
+ unless parameters.nil?
51
+ parameters = CheckAvailabilityParameters.serialize_object(parameters)
52
+ end
53
+ request_content = JSON.generate(parameters, quirks_mode: true)
54
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability'
55
+ options = {
56
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
57
+ path_params: {'subscriptionId' => @client.subscription_id},
58
+ query_params: {'api-version' => @client.api_version},
59
+ body: request_content,
60
+ headers: request_headers.merge(custom_headers || {})
61
+ }
62
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
63
+ promise = request.run_promise do |req|
64
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
65
+ end
66
+
67
+ promise = promise.then do |http_response|
68
+ status_code = http_response.status
69
+ response_content = http_response.body
70
+ unless status_code == 200
71
+ error_model = JSON.load(response_content)
72
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
73
+ end
74
+
75
+ # Create Result
76
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
77
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
78
+ # Deserialize Response
79
+ if status_code == 200
80
+ begin
81
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
82
+ unless parsed_response.nil?
83
+ parsed_response = CheckAvailabilityResource.deserialize_object(parsed_response)
84
+ end
85
+ result.body = parsed_response
86
+ rescue Exception => e
87
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
88
+ end
89
+ end
90
+
91
+ result
92
+ end
93
+
94
+ promise.execute
95
+ end
96
+
97
+ #
98
+ # Creates/Updates a service namespace. Once created, this namespace's resource
99
+ # manifest is immutable. This operation is idempotent.
100
+ #
101
+ # @param resource_group_name [String] The name of the resource group.
102
+ # @param namespace_name [String] The namespace name.
103
+ # @param parameters [NamespaceCreateOrUpdateParameters] Parameters supplied to
104
+ # the create a Namespace Resource.
105
+ # @param [Hash{String => String}] The hash of custom headers need to be
106
+ # applied to HTTP request.
107
+ #
108
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
109
+ # response.
110
+ #
111
+ def create_or_update(resource_group_name, namespace_name, parameters, custom_headers = nil)
112
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
113
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
114
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
115
+ parameters.validate unless parameters.nil?
116
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
117
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
118
+ request_headers = {}
119
+
120
+ # Set Headers
121
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
122
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
123
+
124
+ # Serialize Request
125
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
126
+ unless parameters.nil?
127
+ parameters = NamespaceCreateOrUpdateParameters.serialize_object(parameters)
128
+ end
129
+ request_content = JSON.generate(parameters, quirks_mode: true)
130
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}'
131
+ options = {
132
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
133
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
134
+ query_params: {'api-version' => @client.api_version},
135
+ body: request_content,
136
+ headers: request_headers.merge(custom_headers || {})
137
+ }
138
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
139
+ promise = request.run_promise do |req|
140
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
141
+ end
142
+
143
+ promise = promise.then do |http_response|
144
+ status_code = http_response.status
145
+ response_content = http_response.body
146
+ unless status_code == 201 || status_code == 200
147
+ error_model = JSON.load(response_content)
148
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
149
+ end
150
+
151
+ # Create Result
152
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
153
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
154
+ # Deserialize Response
155
+ if status_code == 201
156
+ begin
157
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
158
+ unless parsed_response.nil?
159
+ parsed_response = NamespaceResource.deserialize_object(parsed_response)
160
+ end
161
+ result.body = parsed_response
162
+ rescue Exception => e
163
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
164
+ end
165
+ end
166
+ # Deserialize Response
167
+ if status_code == 200
168
+ begin
169
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
170
+ unless parsed_response.nil?
171
+ parsed_response = NamespaceResource.deserialize_object(parsed_response)
172
+ end
173
+ result.body = parsed_response
174
+ rescue Exception => e
175
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
176
+ end
177
+ end
178
+
179
+ result
180
+ end
181
+
182
+ promise.execute
183
+ end
184
+
185
+ #
186
+ # Deletes an existing namespace. This operation also removes all associated
187
+ # notificationHubs under the namespace.
188
+ #
189
+ # @param resource_group_name [String] The name of the resource group.
190
+ # @param namespace_name [String] The namespace name.
191
+ # @return [Concurrent::Promise] promise which provides async access to http
192
+ # response.
193
+ #
194
+ def delete(resource_group_name, namespace_name, custom_headers = nil)
195
+ # Send request
196
+ promise = begin_delete(resource_group_name, namespace_name, custom_headers)
197
+
198
+ promise = promise.then do |response|
199
+ # Defining deserialization method.
200
+ deserialize_method = lambda do |parsed_response|
201
+ end
202
+
203
+ # Waiting for response.
204
+ @client.get_post_or_delete_operation_result(response, deserialize_method)
205
+ end
206
+
207
+ promise
208
+ end
209
+
210
+ #
211
+ # Deletes an existing namespace. This operation also removes all associated
212
+ # notificationHubs under the namespace.
213
+ #
214
+ # @param resource_group_name [String] The name of the resource group.
215
+ # @param namespace_name [String] The namespace name.
216
+ # @param [Hash{String => String}] The hash of custom headers need to be
217
+ # applied to HTTP request.
218
+ #
219
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
220
+ # response.
221
+ #
222
+ def begin_delete(resource_group_name, namespace_name, custom_headers = nil)
223
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
224
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
225
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
226
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
227
+ request_headers = {}
228
+
229
+ # Set Headers
230
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
231
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
232
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}'
233
+ options = {
234
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
235
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
236
+ query_params: {'api-version' => @client.api_version},
237
+ headers: request_headers.merge(custom_headers || {})
238
+ }
239
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
240
+ promise = request.run_promise do |req|
241
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
242
+ end
243
+
244
+ promise = promise.then do |http_response|
245
+ status_code = http_response.status
246
+ response_content = http_response.body
247
+ unless status_code == 204 || status_code == 200 || status_code == 202
248
+ error_model = JSON.load(response_content)
249
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
250
+ end
251
+
252
+ # Create Result
253
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
254
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
255
+
256
+ result
257
+ end
258
+
259
+ promise.execute
260
+ end
261
+
262
+ #
263
+ # Returns the description for the specified namespace.
264
+ #
265
+ # @param resource_group_name [String] The name of the resource group.
266
+ # @param namespace_name [String] The namespace name.
267
+ # @param [Hash{String => String}] The hash of custom headers need to be
268
+ # applied to HTTP request.
269
+ #
270
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
271
+ # response.
272
+ #
273
+ def get(resource_group_name, namespace_name, custom_headers = nil)
274
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
275
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
276
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
277
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
278
+ request_headers = {}
279
+
280
+ # Set Headers
281
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
282
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
283
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}'
284
+ options = {
285
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
286
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
287
+ query_params: {'api-version' => @client.api_version},
288
+ headers: request_headers.merge(custom_headers || {})
289
+ }
290
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
291
+ promise = request.run_promise do |req|
292
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
293
+ end
294
+
295
+ promise = promise.then do |http_response|
296
+ status_code = http_response.status
297
+ response_content = http_response.body
298
+ unless status_code == 200
299
+ error_model = JSON.load(response_content)
300
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
301
+ end
302
+
303
+ # Create Result
304
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
305
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
306
+ # Deserialize Response
307
+ if status_code == 200
308
+ begin
309
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
310
+ unless parsed_response.nil?
311
+ parsed_response = NamespaceResource.deserialize_object(parsed_response)
312
+ end
313
+ result.body = parsed_response
314
+ rescue Exception => e
315
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
316
+ end
317
+ end
318
+
319
+ result
320
+ end
321
+
322
+ promise.execute
323
+ end
324
+
325
+ #
326
+ # The create namespace authorization rule operation creates an authorization
327
+ # rule for a namespace
328
+ #
329
+ # @param resource_group_name [String] The name of the resource group.
330
+ # @param namespace_name [String] The namespace name.
331
+ # @param authorization_rule_name [String] The namespace authorizationRuleName
332
+ # name.
333
+ # @param parameters [SharedAccessAuthorizationRuleCreateOrUpdateParameters]
334
+ # The shared access authorization rule.
335
+ # @param [Hash{String => String}] The hash of custom headers need to be
336
+ # applied to HTTP request.
337
+ #
338
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
339
+ # response.
340
+ #
341
+ def create_or_update_authorization_rule(resource_group_name, namespace_name, authorization_rule_name, parameters, custom_headers = nil)
342
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
343
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
344
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
345
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
346
+ parameters.validate unless parameters.nil?
347
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
348
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
349
+ request_headers = {}
350
+
351
+ # Set Headers
352
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
353
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
354
+
355
+ # Serialize Request
356
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
357
+ unless parameters.nil?
358
+ parameters = SharedAccessAuthorizationRuleCreateOrUpdateParameters.serialize_object(parameters)
359
+ end
360
+ request_content = JSON.generate(parameters, quirks_mode: true)
361
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'
362
+ options = {
363
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
364
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
365
+ query_params: {'api-version' => @client.api_version},
366
+ body: request_content,
367
+ headers: request_headers.merge(custom_headers || {})
368
+ }
369
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
370
+ promise = request.run_promise do |req|
371
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
372
+ end
373
+
374
+ promise = promise.then do |http_response|
375
+ status_code = http_response.status
376
+ response_content = http_response.body
377
+ unless status_code == 200
378
+ error_model = JSON.load(response_content)
379
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
380
+ end
381
+
382
+ # Create Result
383
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
384
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
385
+ # Deserialize Response
386
+ if status_code == 200
387
+ begin
388
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
389
+ unless parsed_response.nil?
390
+ parsed_response = SharedAccessAuthorizationRuleResource.deserialize_object(parsed_response)
391
+ end
392
+ result.body = parsed_response
393
+ rescue Exception => e
394
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
395
+ end
396
+ end
397
+
398
+ result
399
+ end
400
+
401
+ promise.execute
402
+ end
403
+
404
+ #
405
+ # The delete a namespace authorization rule operation
406
+ #
407
+ # @param resource_group_name [String] The name of the resource group.
408
+ # @param namespace_name [String] The namespace name.
409
+ # @param authorization_rule_name [String] The namespace authorizationRuleName
410
+ # name.
411
+ # @param [Hash{String => String}] The hash of custom headers need to be
412
+ # applied to HTTP request.
413
+ #
414
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
415
+ # response.
416
+ #
417
+ def delete_authorization_rule(resource_group_name, namespace_name, authorization_rule_name, custom_headers = nil)
418
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
419
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
420
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
421
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
422
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
423
+ request_headers = {}
424
+
425
+ # Set Headers
426
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
427
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
428
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'
429
+ options = {
430
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
431
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
432
+ query_params: {'api-version' => @client.api_version},
433
+ headers: request_headers.merge(custom_headers || {})
434
+ }
435
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
436
+ promise = request.run_promise do |req|
437
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
438
+ end
439
+
440
+ promise = promise.then do |http_response|
441
+ status_code = http_response.status
442
+ response_content = http_response.body
443
+ unless status_code == 204 || status_code == 200
444
+ error_model = JSON.load(response_content)
445
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
446
+ end
447
+
448
+ # Create Result
449
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
450
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
451
+
452
+ result
453
+ end
454
+
455
+ promise.execute
456
+ end
457
+
458
+ #
459
+ # The get authorization rule operation gets an authorization rule for a
460
+ # namespace by name.
461
+ #
462
+ # @param resource_group_name [String] The name of the resource group.
463
+ # @param namespace_name [String] The namespace to get the authorization rule
464
+ # for.
465
+ # @param authorization_rule_name [String] The entity name to get the
466
+ # authorization rule for.
467
+ # @param [Hash{String => String}] The hash of custom headers need to be
468
+ # applied to HTTP request.
469
+ #
470
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
471
+ # response.
472
+ #
473
+ def get_authorization_rule(resource_group_name, namespace_name, authorization_rule_name, custom_headers = nil)
474
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
475
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
476
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
477
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
478
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
479
+ request_headers = {}
480
+
481
+ # Set Headers
482
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
483
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
484
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}'
485
+ options = {
486
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
487
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
488
+ query_params: {'api-version' => @client.api_version},
489
+ headers: request_headers.merge(custom_headers || {})
490
+ }
491
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
492
+ promise = request.run_promise do |req|
493
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
494
+ end
495
+
496
+ promise = promise.then do |http_response|
497
+ status_code = http_response.status
498
+ response_content = http_response.body
499
+ unless status_code == 200
500
+ error_model = JSON.load(response_content)
501
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
502
+ end
503
+
504
+ # Create Result
505
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
506
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
507
+ # Deserialize Response
508
+ if status_code == 200
509
+ begin
510
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
511
+ unless parsed_response.nil?
512
+ parsed_response = SharedAccessAuthorizationRuleResource.deserialize_object(parsed_response)
513
+ end
514
+ result.body = parsed_response
515
+ rescue Exception => e
516
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
517
+ end
518
+ end
519
+
520
+ result
521
+ end
522
+
523
+ promise.execute
524
+ end
525
+
526
+ #
527
+ # The Get Operation Status operation returns the status of the specified
528
+ # operation. After calling an asynchronous operation, you can call Get
529
+ # Operation Status to determine whether the operation has succeeded, failed,
530
+ # or is still in progress.
531
+ #
532
+ # @param operation_status_link [String] Location value returned by the Begin
533
+ # operation.
534
+ # @param [Hash{String => String}] The hash of custom headers need to be
535
+ # applied to HTTP request.
536
+ #
537
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
538
+ # response.
539
+ #
540
+ def get_long_running_operation_status(operation_status_link, custom_headers = nil)
541
+ fail ArgumentError, 'operation_status_link is nil' if operation_status_link.nil?
542
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
543
+ request_headers = {}
544
+
545
+ # Set Headers
546
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
547
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
548
+ path_template = '/{operationStatusLink}'
549
+ options = {
550
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
551
+ path_params: {'subscriptionId' => @client.subscription_id},
552
+ skip_encoding_path_params: {'operationStatusLink' => operation_status_link},
553
+ headers: request_headers.merge(custom_headers || {})
554
+ }
555
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
556
+ promise = request.run_promise do |req|
557
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
558
+ end
559
+
560
+ promise = promise.then do |http_response|
561
+ status_code = http_response.status
562
+ response_content = http_response.body
563
+ unless status_code == 404 || status_code == 202 || status_code == 200
564
+ error_model = JSON.load(response_content)
565
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
566
+ end
567
+
568
+ # Create Result
569
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
570
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
571
+
572
+ result
573
+ end
574
+
575
+ promise.execute
576
+ end
577
+
578
+ #
579
+ # Lists the available namespaces within a resourceGroup.
580
+ #
581
+ # @param resource_group_name [String] The name of the resource group. If
582
+ # resourceGroupName value is null the method lists all the namespaces within
583
+ # subscription
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(resource_group_name, custom_headers = nil)
591
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
592
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
593
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
594
+ request_headers = {}
595
+
596
+ # Set Headers
597
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
598
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
599
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces'
600
+ options = {
601
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
602
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
603
+ query_params: {'api-version' => @client.api_version},
604
+ headers: request_headers.merge(custom_headers || {})
605
+ }
606
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
607
+ promise = request.run_promise do |req|
608
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
609
+ end
610
+
611
+ promise = promise.then do |http_response|
612
+ status_code = http_response.status
613
+ response_content = http_response.body
614
+ unless status_code == 200
615
+ error_model = JSON.load(response_content)
616
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
617
+ end
618
+
619
+ # Create Result
620
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
621
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
622
+ # Deserialize Response
623
+ if status_code == 200
624
+ begin
625
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
626
+ unless parsed_response.nil?
627
+ parsed_response = NamespaceListResult.deserialize_object(parsed_response)
628
+ end
629
+ result.body = parsed_response
630
+ rescue Exception => e
631
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
632
+ end
633
+ end
634
+
635
+ result
636
+ end
637
+
638
+ promise.execute
639
+ end
640
+
641
+ #
642
+ # Lists all the available namespaces within the subscription irrespective of
643
+ # the resourceGroups.
644
+ #
645
+ # @param [Hash{String => String}] The hash of custom headers need to be
646
+ # applied to HTTP request.
647
+ #
648
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
649
+ # response.
650
+ #
651
+ def list_all(custom_headers = nil)
652
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
653
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
654
+ request_headers = {}
655
+
656
+ # Set Headers
657
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
658
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
659
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces'
660
+ options = {
661
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
662
+ path_params: {'subscriptionId' => @client.subscription_id},
663
+ query_params: {'api-version' => @client.api_version},
664
+ headers: request_headers.merge(custom_headers || {})
665
+ }
666
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
667
+ promise = request.run_promise do |req|
668
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
669
+ end
670
+
671
+ promise = promise.then do |http_response|
672
+ status_code = http_response.status
673
+ response_content = http_response.body
674
+ unless status_code == 200
675
+ error_model = JSON.load(response_content)
676
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
677
+ end
678
+
679
+ # Create Result
680
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
681
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
682
+ # Deserialize Response
683
+ if status_code == 200
684
+ begin
685
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
686
+ unless parsed_response.nil?
687
+ parsed_response = NamespaceListResult.deserialize_object(parsed_response)
688
+ end
689
+ result.body = parsed_response
690
+ rescue Exception => e
691
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
692
+ end
693
+ end
694
+
695
+ result
696
+ end
697
+
698
+ promise.execute
699
+ end
700
+
701
+ #
702
+ # The get authorization rules operation gets the authorization rules for a
703
+ # namespace.
704
+ #
705
+ # @param resource_group_name [String] The name of the resource group.
706
+ # @param namespace_name [String] The namespace to get the authorization rule
707
+ # for.
708
+ # @param [Hash{String => String}] The hash of custom headers need to be
709
+ # applied to HTTP request.
710
+ #
711
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
712
+ # response.
713
+ #
714
+ def list_authorization_rules(resource_group_name, namespace_name, custom_headers = nil)
715
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
716
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
717
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
718
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
719
+ request_headers = {}
720
+
721
+ # Set Headers
722
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
723
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
724
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules'
725
+ options = {
726
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
727
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'subscriptionId' => @client.subscription_id},
728
+ query_params: {'api-version' => @client.api_version},
729
+ headers: request_headers.merge(custom_headers || {})
730
+ }
731
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
732
+ promise = request.run_promise do |req|
733
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
734
+ end
735
+
736
+ promise = promise.then do |http_response|
737
+ status_code = http_response.status
738
+ response_content = http_response.body
739
+ unless status_code == 200
740
+ error_model = JSON.load(response_content)
741
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
742
+ end
743
+
744
+ # Create Result
745
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
746
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
747
+ # Deserialize Response
748
+ if status_code == 200
749
+ begin
750
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
751
+ unless parsed_response.nil?
752
+ parsed_response = SharedAccessAuthorizationRuleListResult.deserialize_object(parsed_response)
753
+ end
754
+ result.body = parsed_response
755
+ rescue Exception => e
756
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
757
+ end
758
+ end
759
+
760
+ result
761
+ end
762
+
763
+ promise.execute
764
+ end
765
+
766
+ #
767
+ # Gets the Primary and Secondary ConnectionStrings to the namespace
768
+ #
769
+ # @param resource_group_name [String] The name of the resource group.
770
+ # @param namespace_name [String] The namespace name.
771
+ # @param authorization_rule_name [String] The connection string of the
772
+ # namespace for the specified authorizationRule.
773
+ # @param [Hash{String => String}] The hash of custom headers need to be
774
+ # applied to HTTP request.
775
+ #
776
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
777
+ # response.
778
+ #
779
+ def list_keys(resource_group_name, namespace_name, authorization_rule_name, custom_headers = nil)
780
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
781
+ fail ArgumentError, 'namespace_name is nil' if namespace_name.nil?
782
+ fail ArgumentError, 'authorization_rule_name is nil' if authorization_rule_name.nil?
783
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
784
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
785
+ request_headers = {}
786
+
787
+ # Set Headers
788
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
789
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
790
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys'
791
+ options = {
792
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
793
+ path_params: {'resourceGroupName' => resource_group_name,'namespaceName' => namespace_name,'authorizationRuleName' => authorization_rule_name,'subscriptionId' => @client.subscription_id},
794
+ query_params: {'api-version' => @client.api_version},
795
+ headers: request_headers.merge(custom_headers || {})
796
+ }
797
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
798
+ promise = request.run_promise do |req|
799
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
800
+ end
801
+
802
+ promise = promise.then do |http_response|
803
+ status_code = http_response.status
804
+ response_content = http_response.body
805
+ unless status_code == 200
806
+ error_model = JSON.load(response_content)
807
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
808
+ end
809
+
810
+ # Create Result
811
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
812
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
813
+ # Deserialize Response
814
+ if status_code == 200
815
+ begin
816
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
817
+ unless parsed_response.nil?
818
+ parsed_response = ResourceListKeys.deserialize_object(parsed_response)
819
+ end
820
+ result.body = parsed_response
821
+ rescue Exception => e
822
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
823
+ end
824
+ end
825
+
826
+ result
827
+ end
828
+
829
+ promise.execute
830
+ end
831
+
832
+ #
833
+ # Lists the available namespaces within a resourceGroup.
834
+ #
835
+ # @param next_page_link [String] The NextLink from the previous successful
836
+ # call to List operation.
837
+ # @param [Hash{String => String}] The hash of custom headers need to be
838
+ # applied to HTTP request.
839
+ #
840
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
841
+ # response.
842
+ #
843
+ def list_next(next_page_link, custom_headers = nil)
844
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
845
+ request_headers = {}
846
+
847
+ # Set Headers
848
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
849
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
850
+ path_template = '{nextLink}'
851
+ options = {
852
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
853
+ skip_encoding_path_params: {'nextLink' => next_page_link},
854
+ headers: request_headers.merge(custom_headers || {})
855
+ }
856
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
857
+ promise = request.run_promise do |req|
858
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
859
+ end
860
+
861
+ promise = promise.then do |http_response|
862
+ status_code = http_response.status
863
+ response_content = http_response.body
864
+ unless status_code == 200
865
+ error_model = JSON.load(response_content)
866
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
867
+ end
868
+
869
+ # Create Result
870
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
871
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
872
+ # Deserialize Response
873
+ if status_code == 200
874
+ begin
875
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
876
+ unless parsed_response.nil?
877
+ parsed_response = NamespaceListResult.deserialize_object(parsed_response)
878
+ end
879
+ result.body = parsed_response
880
+ rescue Exception => e
881
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
882
+ end
883
+ end
884
+
885
+ result
886
+ end
887
+
888
+ promise.execute
889
+ end
890
+
891
+ #
892
+ # Lists all the available namespaces within the subscription irrespective of
893
+ # the resourceGroups.
894
+ #
895
+ # @param next_page_link [String] The NextLink from the previous successful
896
+ # call to List operation.
897
+ # @param [Hash{String => String}] The hash of custom headers need to be
898
+ # applied to HTTP request.
899
+ #
900
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
901
+ # response.
902
+ #
903
+ def list_all_next(next_page_link, custom_headers = nil)
904
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
905
+ request_headers = {}
906
+
907
+ # Set Headers
908
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
909
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
910
+ path_template = '{nextLink}'
911
+ options = {
912
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
913
+ skip_encoding_path_params: {'nextLink' => next_page_link},
914
+ headers: request_headers.merge(custom_headers || {})
915
+ }
916
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
917
+ promise = request.run_promise do |req|
918
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
919
+ end
920
+
921
+ promise = promise.then do |http_response|
922
+ status_code = http_response.status
923
+ response_content = http_response.body
924
+ unless status_code == 200
925
+ error_model = JSON.load(response_content)
926
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
927
+ end
928
+
929
+ # Create Result
930
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
931
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
932
+ # Deserialize Response
933
+ if status_code == 200
934
+ begin
935
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
936
+ unless parsed_response.nil?
937
+ parsed_response = NamespaceListResult.deserialize_object(parsed_response)
938
+ end
939
+ result.body = parsed_response
940
+ rescue Exception => e
941
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
942
+ end
943
+ end
944
+
945
+ result
946
+ end
947
+
948
+ promise.execute
949
+ end
950
+
951
+ #
952
+ # The get authorization rules operation gets the authorization rules for a
953
+ # namespace.
954
+ #
955
+ # @param next_page_link [String] The NextLink from the previous successful
956
+ # call to List operation.
957
+ # @param [Hash{String => String}] The hash of custom headers need to be
958
+ # applied to HTTP request.
959
+ #
960
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
961
+ # response.
962
+ #
963
+ def list_authorization_rules_next(next_page_link, custom_headers = nil)
964
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
965
+ request_headers = {}
966
+
967
+ # Set Headers
968
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
969
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
970
+ path_template = '{nextLink}'
971
+ options = {
972
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
973
+ skip_encoding_path_params: {'nextLink' => next_page_link},
974
+ headers: request_headers.merge(custom_headers || {})
975
+ }
976
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
977
+ promise = request.run_promise do |req|
978
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
979
+ end
980
+
981
+ promise = promise.then do |http_response|
982
+ status_code = http_response.status
983
+ response_content = http_response.body
984
+ unless status_code == 200
985
+ error_model = JSON.load(response_content)
986
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
987
+ end
988
+
989
+ # Create Result
990
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
991
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
992
+ # Deserialize Response
993
+ if status_code == 200
994
+ begin
995
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
996
+ unless parsed_response.nil?
997
+ parsed_response = SharedAccessAuthorizationRuleListResult.deserialize_object(parsed_response)
998
+ end
999
+ result.body = parsed_response
1000
+ rescue Exception => e
1001
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1002
+ end
1003
+ end
1004
+
1005
+ result
1006
+ end
1007
+
1008
+ promise.execute
1009
+ end
1010
+
1011
+ end
1012
+ end