azure_mgmt_subscriptions 0.18.2 → 0.18.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2016-06-01/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  3. data/lib/2017-11-01-preview/generated/azure_mgmt_subscriptions/subscription_definitions_client.rb +1 -1
  4. data/lib/2018-03-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  5. data/lib/2018-11-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  6. data/lib/2019-03-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  7. data/lib/2019-06-01/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  8. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions.rb +44 -0
  9. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/ad_principal.rb +47 -0
  10. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/canceled_subscription_id.rb +47 -0
  11. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/enabled_subscription_id.rb +47 -0
  12. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/error_response.rb +57 -0
  13. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/modern_csp_subscription_creation_parameters.rb +70 -0
  14. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/modern_subscription_creation_parameters.rb +117 -0
  15. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/offer_type.rb +16 -0
  16. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/operation.rb +58 -0
  17. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/operation_display.rb +69 -0
  18. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/operation_list_result.rb +68 -0
  19. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/renamed_subscription_id.rb +47 -0
  20. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/subscription_creation_parameters.rb +115 -0
  21. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/subscription_creation_result.rb +47 -0
  22. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/models/subscription_name.rb +46 -0
  23. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/module_definition.rb +9 -0
  24. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/operations.rb +110 -0
  25. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/subscription.rb +788 -0
  26. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/subscription_client.rb +137 -0
  27. data/lib/2019-10-01-preview/generated/azure_mgmt_subscriptions/subscription_operation.rb +118 -0
  28. data/lib/2019-11-01/generated/azure_mgmt_subscriptions/subscription_client.rb +1 -1
  29. data/lib/azure_mgmt_subscriptions.rb +1 -0
  30. data/lib/version.rb +1 -1
  31. metadata +22 -2
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::Subscriptions end
8
+ module Azure::Subscriptions::Mgmt end
9
+ module Azure::Subscriptions::Mgmt::V2019_10_01_preview end
@@ -0,0 +1,110 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Subscriptions::Mgmt::V2019_10_01_preview
7
+ #
8
+ # Subscription client provides an interface to create and manage Azure
9
+ # subscriptions programmatically.
10
+ #
11
+ class Operations
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Operations class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [SubscriptionClient] reference to the SubscriptionClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Lists all of the available Microsoft.Subscription API operations.
27
+ #
28
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
29
+ # will be added to the HTTP request.
30
+ #
31
+ # @return [OperationListResult] operation results.
32
+ #
33
+ def list(custom_headers:nil)
34
+ response = list_async(custom_headers:custom_headers).value!
35
+ response.body unless response.nil?
36
+ end
37
+
38
+ #
39
+ # Lists all of the available Microsoft.Subscription API operations.
40
+ #
41
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
42
+ # will be added to the HTTP request.
43
+ #
44
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
45
+ #
46
+ def list_with_http_info(custom_headers:nil)
47
+ list_async(custom_headers:custom_headers).value!
48
+ end
49
+
50
+ #
51
+ # Lists all of the available Microsoft.Subscription API operations.
52
+ #
53
+ # @param [Hash{String => String}] A hash of custom headers that will be added
54
+ # to the HTTP request.
55
+ #
56
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
57
+ #
58
+ def list_async(custom_headers:nil)
59
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
60
+
61
+
62
+ request_headers = {}
63
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
64
+
65
+ # Set Headers
66
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
67
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
68
+ path_template = 'providers/Microsoft.Subscription/operations'
69
+
70
+ request_url = @base_url || @client.base_url
71
+
72
+ options = {
73
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
74
+ query_params: {'api-version' => @client.api_version},
75
+ headers: request_headers.merge(custom_headers || {}),
76
+ base_url: request_url
77
+ }
78
+ promise = @client.make_request_async(:get, path_template, options)
79
+
80
+ promise = promise.then do |result|
81
+ http_response = result.response
82
+ status_code = http_response.status
83
+ response_content = http_response.body
84
+ unless status_code == 200
85
+ error_model = JSON.load(response_content)
86
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
87
+ end
88
+
89
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
90
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
91
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
92
+ # Deserialize Response
93
+ if status_code == 200
94
+ begin
95
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
96
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::OperationListResult.mapper()
97
+ result.body = @client.deserialize(result_mapper, parsed_response)
98
+ rescue Exception => e
99
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
100
+ end
101
+ end
102
+
103
+ result
104
+ end
105
+
106
+ promise.execute
107
+ end
108
+
109
+ end
110
+ end
@@ -0,0 +1,788 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator.
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::Subscriptions::Mgmt::V2019_10_01_preview
7
+ #
8
+ # Subscription client provides an interface to create and manage Azure
9
+ # subscriptions programmatically.
10
+ #
11
+ class Subscription
12
+ include MsRestAzure
13
+
14
+ #
15
+ # Creates and initializes a new instance of the Subscription class.
16
+ # @param client service class for accessing basic functionality.
17
+ #
18
+ def initialize(client)
19
+ @client = client
20
+ end
21
+
22
+ # @return [SubscriptionClient] reference to the SubscriptionClient
23
+ attr_reader :client
24
+
25
+ #
26
+ # Creates an Azure subscription
27
+ #
28
+ # @param enrollment_account_name [String] The name of the enrollment account to
29
+ # which the subscription will be billed.
30
+ # @param body [SubscriptionCreationParameters] The subscription creation
31
+ # parameters.
32
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
33
+ # will be added to the HTTP request.
34
+ #
35
+ # @return [SubscriptionCreationResult] operation results.
36
+ #
37
+ def create_subscription_in_enrollment_account(enrollment_account_name, body, custom_headers:nil)
38
+ response = create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:custom_headers).value!
39
+ response.body unless response.nil?
40
+ end
41
+
42
+ #
43
+ # @param enrollment_account_name [String] The name of the enrollment account to
44
+ # which the subscription will be billed.
45
+ # @param body [SubscriptionCreationParameters] The subscription creation
46
+ # parameters.
47
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
48
+ # will be added to the HTTP request.
49
+ #
50
+ # @return [Concurrent::Promise] promise which provides async access to http
51
+ # response.
52
+ #
53
+ def create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:nil)
54
+ # Send request
55
+ promise = begin_create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:custom_headers)
56
+
57
+ promise = promise.then do |response|
58
+ # Defining deserialization method.
59
+ deserialize_method = lambda do |parsed_response|
60
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
61
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
62
+ end
63
+
64
+ # Waiting for response.
65
+ @client.get_long_running_operation_result(response, deserialize_method)
66
+ end
67
+
68
+ promise
69
+ end
70
+
71
+ #
72
+ # The operation to cancel a subscription
73
+ #
74
+ # @param subscription_id [String] Subscription Id.
75
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
76
+ # will be added to the HTTP request.
77
+ #
78
+ # @return [CanceledSubscriptionId] operation results.
79
+ #
80
+ def cancel(subscription_id, custom_headers:nil)
81
+ response = cancel_async(subscription_id, custom_headers:custom_headers).value!
82
+ response.body unless response.nil?
83
+ end
84
+
85
+ #
86
+ # The operation to cancel a subscription
87
+ #
88
+ # @param subscription_id [String] Subscription Id.
89
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
90
+ # will be added to the HTTP request.
91
+ #
92
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
93
+ #
94
+ def cancel_with_http_info(subscription_id, custom_headers:nil)
95
+ cancel_async(subscription_id, custom_headers:custom_headers).value!
96
+ end
97
+
98
+ #
99
+ # The operation to cancel a subscription
100
+ #
101
+ # @param subscription_id [String] Subscription Id.
102
+ # @param [Hash{String => String}] A hash of custom headers that will be added
103
+ # to the HTTP request.
104
+ #
105
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
106
+ #
107
+ def cancel_async(subscription_id, custom_headers:nil)
108
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
109
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
110
+
111
+
112
+ request_headers = {}
113
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
114
+
115
+ # Set Headers
116
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
117
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
118
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Subscription/cancel'
119
+
120
+ request_url = @base_url || @client.base_url
121
+
122
+ options = {
123
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
124
+ path_params: {'subscriptionId' => subscription_id},
125
+ query_params: {'api-version' => @client.api_version},
126
+ headers: request_headers.merge(custom_headers || {}),
127
+ base_url: request_url
128
+ }
129
+ promise = @client.make_request_async(:post, path_template, options)
130
+
131
+ promise = promise.then do |result|
132
+ http_response = result.response
133
+ status_code = http_response.status
134
+ response_content = http_response.body
135
+ unless status_code == 200
136
+ error_model = JSON.load(response_content)
137
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
138
+ end
139
+
140
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
141
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
142
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
143
+ # Deserialize Response
144
+ if status_code == 200
145
+ begin
146
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
147
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::CanceledSubscriptionId.mapper()
148
+ result.body = @client.deserialize(result_mapper, parsed_response)
149
+ rescue Exception => e
150
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
151
+ end
152
+ end
153
+
154
+ result
155
+ end
156
+
157
+ promise.execute
158
+ end
159
+
160
+ #
161
+ # The operation to rename a subscription
162
+ #
163
+ # @param subscription_id [String] Subscription Id.
164
+ # @param body [SubscriptionName] Subscription Name
165
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
166
+ # will be added to the HTTP request.
167
+ #
168
+ # @return [RenamedSubscriptionId] operation results.
169
+ #
170
+ def rename(subscription_id, body, custom_headers:nil)
171
+ response = rename_async(subscription_id, body, custom_headers:custom_headers).value!
172
+ response.body unless response.nil?
173
+ end
174
+
175
+ #
176
+ # The operation to rename a subscription
177
+ #
178
+ # @param subscription_id [String] Subscription Id.
179
+ # @param body [SubscriptionName] Subscription Name
180
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
181
+ # will be added to the HTTP request.
182
+ #
183
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
184
+ #
185
+ def rename_with_http_info(subscription_id, body, custom_headers:nil)
186
+ rename_async(subscription_id, body, custom_headers:custom_headers).value!
187
+ end
188
+
189
+ #
190
+ # The operation to rename a subscription
191
+ #
192
+ # @param subscription_id [String] Subscription Id.
193
+ # @param body [SubscriptionName] Subscription Name
194
+ # @param [Hash{String => String}] A hash of custom headers that will be added
195
+ # to the HTTP request.
196
+ #
197
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
198
+ #
199
+ def rename_async(subscription_id, body, custom_headers:nil)
200
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
201
+ fail ArgumentError, 'body is nil' if body.nil?
202
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
203
+
204
+
205
+ request_headers = {}
206
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
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
+
212
+ # Serialize Request
213
+ request_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionName.mapper()
214
+ request_content = @client.serialize(request_mapper, body)
215
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
216
+
217
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Subscription/rename'
218
+
219
+ request_url = @base_url || @client.base_url
220
+
221
+ options = {
222
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
223
+ path_params: {'subscriptionId' => subscription_id},
224
+ query_params: {'api-version' => @client.api_version},
225
+ body: request_content,
226
+ headers: request_headers.merge(custom_headers || {}),
227
+ base_url: request_url
228
+ }
229
+ promise = @client.make_request_async(:post, path_template, options)
230
+
231
+ promise = promise.then do |result|
232
+ http_response = result.response
233
+ status_code = http_response.status
234
+ response_content = http_response.body
235
+ unless status_code == 200
236
+ error_model = JSON.load(response_content)
237
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
238
+ end
239
+
240
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
241
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
242
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
243
+ # Deserialize Response
244
+ if status_code == 200
245
+ begin
246
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
247
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::RenamedSubscriptionId.mapper()
248
+ result.body = @client.deserialize(result_mapper, parsed_response)
249
+ rescue Exception => e
250
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
251
+ end
252
+ end
253
+
254
+ result
255
+ end
256
+
257
+ promise.execute
258
+ end
259
+
260
+ #
261
+ # The operation to enable a subscription
262
+ #
263
+ # @param subscription_id [String] Subscription Id.
264
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
265
+ # will be added to the HTTP request.
266
+ #
267
+ # @return [EnabledSubscriptionId] operation results.
268
+ #
269
+ def enable(subscription_id, custom_headers:nil)
270
+ response = enable_async(subscription_id, custom_headers:custom_headers).value!
271
+ response.body unless response.nil?
272
+ end
273
+
274
+ #
275
+ # The operation to enable a subscription
276
+ #
277
+ # @param subscription_id [String] Subscription Id.
278
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
279
+ # will be added to the HTTP request.
280
+ #
281
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
282
+ #
283
+ def enable_with_http_info(subscription_id, custom_headers:nil)
284
+ enable_async(subscription_id, custom_headers:custom_headers).value!
285
+ end
286
+
287
+ #
288
+ # The operation to enable a subscription
289
+ #
290
+ # @param subscription_id [String] Subscription Id.
291
+ # @param [Hash{String => String}] A hash of custom headers that will be added
292
+ # to the HTTP request.
293
+ #
294
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
295
+ #
296
+ def enable_async(subscription_id, custom_headers:nil)
297
+ fail ArgumentError, 'subscription_id is nil' if subscription_id.nil?
298
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
299
+
300
+
301
+ request_headers = {}
302
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
303
+
304
+ # Set Headers
305
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
306
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
307
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.Subscription/enable'
308
+
309
+ request_url = @base_url || @client.base_url
310
+
311
+ options = {
312
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
313
+ path_params: {'subscriptionId' => subscription_id},
314
+ query_params: {'api-version' => @client.api_version},
315
+ headers: request_headers.merge(custom_headers || {}),
316
+ base_url: request_url
317
+ }
318
+ promise = @client.make_request_async(:post, path_template, options)
319
+
320
+ promise = promise.then do |result|
321
+ http_response = result.response
322
+ status_code = http_response.status
323
+ response_content = http_response.body
324
+ unless status_code == 200
325
+ error_model = JSON.load(response_content)
326
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
327
+ end
328
+
329
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
330
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
331
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
332
+ # Deserialize Response
333
+ if status_code == 200
334
+ begin
335
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
336
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::EnabledSubscriptionId.mapper()
337
+ result.body = @client.deserialize(result_mapper, parsed_response)
338
+ rescue Exception => e
339
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
340
+ end
341
+ end
342
+
343
+ result
344
+ end
345
+
346
+ promise.execute
347
+ end
348
+
349
+ #
350
+ # The operation to create a new WebDirect or EA Azure subscription.
351
+ #
352
+ # @param billing_account_name [String] The name of the Microsoft Customer
353
+ # Agreement billing account for which you want to create the subscription.
354
+ # @param billing_profile_name [String] The name of the billing profile in the
355
+ # billing account for which you want to create the subscription.
356
+ # @param invoice_section_name [String] The name of the invoice section in the
357
+ # billing account for which you want to create the subscription.
358
+ # @param body [ModernSubscriptionCreationParameters] The subscription creation
359
+ # parameters.
360
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
361
+ # will be added to the HTTP request.
362
+ #
363
+ # @return [SubscriptionCreationResult] operation results.
364
+ #
365
+ def create_subscription(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:nil)
366
+ response = create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:custom_headers).value!
367
+ response.body unless response.nil?
368
+ end
369
+
370
+ #
371
+ # @param billing_account_name [String] The name of the Microsoft Customer
372
+ # Agreement billing account for which you want to create the subscription.
373
+ # @param billing_profile_name [String] The name of the billing profile in the
374
+ # billing account for which you want to create the subscription.
375
+ # @param invoice_section_name [String] The name of the invoice section in the
376
+ # billing account for which you want to create the subscription.
377
+ # @param body [ModernSubscriptionCreationParameters] The subscription creation
378
+ # parameters.
379
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
380
+ # will be added to the HTTP request.
381
+ #
382
+ # @return [Concurrent::Promise] promise which provides async access to http
383
+ # response.
384
+ #
385
+ def create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:nil)
386
+ # Send request
387
+ promise = begin_create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:custom_headers)
388
+
389
+ promise = promise.then do |response|
390
+ # Defining deserialization method.
391
+ deserialize_method = lambda do |parsed_response|
392
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
393
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
394
+ end
395
+
396
+ # Waiting for response.
397
+ @client.get_long_running_operation_result(response, deserialize_method)
398
+ end
399
+
400
+ promise
401
+ end
402
+
403
+ #
404
+ # The operation to create a new CSP subscription.
405
+ #
406
+ # @param billing_account_name [String] The name of the Microsoft Customer
407
+ # Agreement billing account for which you want to create the subscription.
408
+ # @param customer_name [String] The name of the customer.
409
+ # @param body [ModernCspSubscriptionCreationParameters] The subscription
410
+ # creation parameters.
411
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
412
+ # will be added to the HTTP request.
413
+ #
414
+ # @return [SubscriptionCreationResult] operation results.
415
+ #
416
+ def create_csp_subscription(billing_account_name, customer_name, body, custom_headers:nil)
417
+ response = create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:custom_headers).value!
418
+ response.body unless response.nil?
419
+ end
420
+
421
+ #
422
+ # @param billing_account_name [String] The name of the Microsoft Customer
423
+ # Agreement billing account for which you want to create the subscription.
424
+ # @param customer_name [String] The name of the customer.
425
+ # @param body [ModernCspSubscriptionCreationParameters] The subscription
426
+ # creation parameters.
427
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
428
+ # will be added to the HTTP request.
429
+ #
430
+ # @return [Concurrent::Promise] promise which provides async access to http
431
+ # response.
432
+ #
433
+ def create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:nil)
434
+ # Send request
435
+ promise = begin_create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:custom_headers)
436
+
437
+ promise = promise.then do |response|
438
+ # Defining deserialization method.
439
+ deserialize_method = lambda do |parsed_response|
440
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
441
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
442
+ end
443
+
444
+ # Waiting for response.
445
+ @client.get_long_running_operation_result(response, deserialize_method)
446
+ end
447
+
448
+ promise
449
+ end
450
+
451
+ #
452
+ # Creates an Azure subscription
453
+ #
454
+ # @param enrollment_account_name [String] The name of the enrollment account to
455
+ # which the subscription will be billed.
456
+ # @param body [SubscriptionCreationParameters] The subscription creation
457
+ # parameters.
458
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
459
+ # will be added to the HTTP request.
460
+ #
461
+ # @return [SubscriptionCreationResult] operation results.
462
+ #
463
+ def begin_create_subscription_in_enrollment_account(enrollment_account_name, body, custom_headers:nil)
464
+ response = begin_create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:custom_headers).value!
465
+ response.body unless response.nil?
466
+ end
467
+
468
+ #
469
+ # Creates an Azure subscription
470
+ #
471
+ # @param enrollment_account_name [String] The name of the enrollment account to
472
+ # which the subscription will be billed.
473
+ # @param body [SubscriptionCreationParameters] The subscription creation
474
+ # parameters.
475
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
476
+ # will be added to the HTTP request.
477
+ #
478
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
479
+ #
480
+ def begin_create_subscription_in_enrollment_account_with_http_info(enrollment_account_name, body, custom_headers:nil)
481
+ begin_create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:custom_headers).value!
482
+ end
483
+
484
+ #
485
+ # Creates an Azure subscription
486
+ #
487
+ # @param enrollment_account_name [String] The name of the enrollment account to
488
+ # which the subscription will be billed.
489
+ # @param body [SubscriptionCreationParameters] The subscription creation
490
+ # parameters.
491
+ # @param [Hash{String => String}] A hash of custom headers that will be added
492
+ # to the HTTP request.
493
+ #
494
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
495
+ #
496
+ def begin_create_subscription_in_enrollment_account_async(enrollment_account_name, body, custom_headers:nil)
497
+ fail ArgumentError, 'enrollment_account_name is nil' if enrollment_account_name.nil?
498
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
499
+ fail ArgumentError, 'body is nil' if body.nil?
500
+
501
+
502
+ request_headers = {}
503
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
504
+
505
+ # Set Headers
506
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
507
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
508
+
509
+ # Serialize Request
510
+ request_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationParameters.mapper()
511
+ request_content = @client.serialize(request_mapper, body)
512
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
513
+
514
+ path_template = 'providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountName}/providers/Microsoft.Subscription/createSubscription'
515
+
516
+ request_url = @base_url || @client.base_url
517
+
518
+ options = {
519
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
520
+ path_params: {'enrollmentAccountName' => enrollment_account_name},
521
+ query_params: {'api-version' => @client.api_version},
522
+ body: request_content,
523
+ headers: request_headers.merge(custom_headers || {}),
524
+ base_url: request_url
525
+ }
526
+ promise = @client.make_request_async(:post, path_template, options)
527
+
528
+ promise = promise.then do |result|
529
+ http_response = result.response
530
+ status_code = http_response.status
531
+ response_content = http_response.body
532
+ unless status_code == 200 || status_code == 202
533
+ error_model = JSON.load(response_content)
534
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
535
+ end
536
+
537
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
538
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
539
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
540
+ # Deserialize Response
541
+ if status_code == 200
542
+ begin
543
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
544
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
545
+ result.body = @client.deserialize(result_mapper, parsed_response)
546
+ rescue Exception => e
547
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
548
+ end
549
+ end
550
+
551
+ result
552
+ end
553
+
554
+ promise.execute
555
+ end
556
+
557
+ #
558
+ # The operation to create a new WebDirect or EA Azure subscription.
559
+ #
560
+ # @param billing_account_name [String] The name of the Microsoft Customer
561
+ # Agreement billing account for which you want to create the subscription.
562
+ # @param billing_profile_name [String] The name of the billing profile in the
563
+ # billing account for which you want to create the subscription.
564
+ # @param invoice_section_name [String] The name of the invoice section in the
565
+ # billing account for which you want to create the subscription.
566
+ # @param body [ModernSubscriptionCreationParameters] The subscription creation
567
+ # parameters.
568
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
569
+ # will be added to the HTTP request.
570
+ #
571
+ # @return [SubscriptionCreationResult] operation results.
572
+ #
573
+ def begin_create_subscription(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:nil)
574
+ response = begin_create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:custom_headers).value!
575
+ response.body unless response.nil?
576
+ end
577
+
578
+ #
579
+ # The operation to create a new WebDirect or EA Azure subscription.
580
+ #
581
+ # @param billing_account_name [String] The name of the Microsoft Customer
582
+ # Agreement billing account for which you want to create the subscription.
583
+ # @param billing_profile_name [String] The name of the billing profile in the
584
+ # billing account for which you want to create the subscription.
585
+ # @param invoice_section_name [String] The name of the invoice section in the
586
+ # billing account for which you want to create the subscription.
587
+ # @param body [ModernSubscriptionCreationParameters] The subscription creation
588
+ # parameters.
589
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
590
+ # will be added to the HTTP request.
591
+ #
592
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
593
+ #
594
+ def begin_create_subscription_with_http_info(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:nil)
595
+ begin_create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:custom_headers).value!
596
+ end
597
+
598
+ #
599
+ # The operation to create a new WebDirect or EA Azure subscription.
600
+ #
601
+ # @param billing_account_name [String] The name of the Microsoft Customer
602
+ # Agreement billing account for which you want to create the subscription.
603
+ # @param billing_profile_name [String] The name of the billing profile in the
604
+ # billing account for which you want to create the subscription.
605
+ # @param invoice_section_name [String] The name of the invoice section in the
606
+ # billing account for which you want to create the subscription.
607
+ # @param body [ModernSubscriptionCreationParameters] The subscription creation
608
+ # parameters.
609
+ # @param [Hash{String => String}] A hash of custom headers that will be added
610
+ # to the HTTP request.
611
+ #
612
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
613
+ #
614
+ def begin_create_subscription_async(billing_account_name, billing_profile_name, invoice_section_name, body, custom_headers:nil)
615
+ fail ArgumentError, 'billing_account_name is nil' if billing_account_name.nil?
616
+ fail ArgumentError, 'billing_profile_name is nil' if billing_profile_name.nil?
617
+ fail ArgumentError, 'invoice_section_name is nil' if invoice_section_name.nil?
618
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
619
+ fail ArgumentError, 'body is nil' if body.nil?
620
+
621
+
622
+ request_headers = {}
623
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
624
+
625
+ # Set Headers
626
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
627
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
628
+
629
+ # Serialize Request
630
+ request_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::ModernSubscriptionCreationParameters.mapper()
631
+ request_content = @client.serialize(request_mapper, body)
632
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
633
+
634
+ path_template = 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/providers/Microsoft.Subscription/createSubscription'
635
+
636
+ request_url = @base_url || @client.base_url
637
+
638
+ options = {
639
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
640
+ path_params: {'billingAccountName' => billing_account_name,'billingProfileName' => billing_profile_name,'invoiceSectionName' => invoice_section_name},
641
+ query_params: {'api-version' => @client.api_version},
642
+ body: request_content,
643
+ headers: request_headers.merge(custom_headers || {}),
644
+ base_url: request_url
645
+ }
646
+ promise = @client.make_request_async(:post, path_template, options)
647
+
648
+ promise = promise.then do |result|
649
+ http_response = result.response
650
+ status_code = http_response.status
651
+ response_content = http_response.body
652
+ unless status_code == 200 || status_code == 202
653
+ error_model = JSON.load(response_content)
654
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
655
+ end
656
+
657
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
658
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
659
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
660
+ # Deserialize Response
661
+ if status_code == 200
662
+ begin
663
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
664
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
665
+ result.body = @client.deserialize(result_mapper, parsed_response)
666
+ rescue Exception => e
667
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
668
+ end
669
+ end
670
+
671
+ result
672
+ end
673
+
674
+ promise.execute
675
+ end
676
+
677
+ #
678
+ # The operation to create a new CSP subscription.
679
+ #
680
+ # @param billing_account_name [String] The name of the Microsoft Customer
681
+ # Agreement billing account for which you want to create the subscription.
682
+ # @param customer_name [String] The name of the customer.
683
+ # @param body [ModernCspSubscriptionCreationParameters] The subscription
684
+ # creation parameters.
685
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
686
+ # will be added to the HTTP request.
687
+ #
688
+ # @return [SubscriptionCreationResult] operation results.
689
+ #
690
+ def begin_create_csp_subscription(billing_account_name, customer_name, body, custom_headers:nil)
691
+ response = begin_create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:custom_headers).value!
692
+ response.body unless response.nil?
693
+ end
694
+
695
+ #
696
+ # The operation to create a new CSP subscription.
697
+ #
698
+ # @param billing_account_name [String] The name of the Microsoft Customer
699
+ # Agreement billing account for which you want to create the subscription.
700
+ # @param customer_name [String] The name of the customer.
701
+ # @param body [ModernCspSubscriptionCreationParameters] The subscription
702
+ # creation parameters.
703
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
704
+ # will be added to the HTTP request.
705
+ #
706
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
707
+ #
708
+ def begin_create_csp_subscription_with_http_info(billing_account_name, customer_name, body, custom_headers:nil)
709
+ begin_create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:custom_headers).value!
710
+ end
711
+
712
+ #
713
+ # The operation to create a new CSP subscription.
714
+ #
715
+ # @param billing_account_name [String] The name of the Microsoft Customer
716
+ # Agreement billing account for which you want to create the subscription.
717
+ # @param customer_name [String] The name of the customer.
718
+ # @param body [ModernCspSubscriptionCreationParameters] The subscription
719
+ # creation parameters.
720
+ # @param [Hash{String => String}] A hash of custom headers that will be added
721
+ # to the HTTP request.
722
+ #
723
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
724
+ #
725
+ def begin_create_csp_subscription_async(billing_account_name, customer_name, body, custom_headers:nil)
726
+ fail ArgumentError, 'billing_account_name is nil' if billing_account_name.nil?
727
+ fail ArgumentError, 'customer_name is nil' if customer_name.nil?
728
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
729
+ fail ArgumentError, 'body is nil' if body.nil?
730
+
731
+
732
+ request_headers = {}
733
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
734
+
735
+ # Set Headers
736
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
737
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
738
+
739
+ # Serialize Request
740
+ request_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::ModernCspSubscriptionCreationParameters.mapper()
741
+ request_content = @client.serialize(request_mapper, body)
742
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
743
+
744
+ path_template = 'providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/providers/Microsoft.Subscription/createSubscription'
745
+
746
+ request_url = @base_url || @client.base_url
747
+
748
+ options = {
749
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
750
+ path_params: {'billingAccountName' => billing_account_name,'customerName' => customer_name},
751
+ query_params: {'api-version' => @client.api_version},
752
+ body: request_content,
753
+ headers: request_headers.merge(custom_headers || {}),
754
+ base_url: request_url
755
+ }
756
+ promise = @client.make_request_async(:post, path_template, options)
757
+
758
+ promise = promise.then do |result|
759
+ http_response = result.response
760
+ status_code = http_response.status
761
+ response_content = http_response.body
762
+ unless status_code == 200 || status_code == 202
763
+ error_model = JSON.load(response_content)
764
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
765
+ end
766
+
767
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
768
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
769
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
770
+ # Deserialize Response
771
+ if status_code == 200
772
+ begin
773
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
774
+ result_mapper = Azure::Subscriptions::Mgmt::V2019_10_01_preview::Models::SubscriptionCreationResult.mapper()
775
+ result.body = @client.deserialize(result_mapper, parsed_response)
776
+ rescue Exception => e
777
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
778
+ end
779
+ end
780
+
781
+ result
782
+ end
783
+
784
+ promise.execute
785
+ end
786
+
787
+ end
788
+ end