azure_mgmt_reservations 0.17.0

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 (112) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/lib/2017-11-01/generated/azure_mgmt_reservations.rb +53 -0
  4. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  5. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  6. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/catalog.rb +166 -0
  7. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/error.rb +48 -0
  8. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  9. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  10. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/kind.rb +15 -0
  11. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  12. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  13. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  14. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  15. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/patch.rb +66 -0
  16. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  17. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  18. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  19. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_order_response.rb +187 -0
  20. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_properties.rb +176 -0
  21. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_response.rb +137 -0
  22. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  23. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_capability.rb +58 -0
  24. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  25. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  26. data/lib/2017-11-01/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  27. data/lib/2017-11-01/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  28. data/lib/2017-11-01/generated/azure_mgmt_reservations/operation.rb +228 -0
  29. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservation.rb +1109 -0
  30. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservation_order.rb +332 -0
  31. data/lib/2017-11-01/generated/azure_mgmt_reservations/reservations_management_client.rb +335 -0
  32. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations.rb +58 -0
  33. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  34. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  35. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/applied_scope_type.rb +16 -0
  36. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/catalog.rb +143 -0
  37. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/error.rb +48 -0
  38. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/error_response_code.rb +69 -0
  39. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  40. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  41. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/instance_flexibility.rb +17 -0
  42. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  43. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  44. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  45. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  46. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/patch.rb +89 -0
  47. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  48. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  49. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  50. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_order_response.rb +184 -0
  51. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_properties.rb +208 -0
  52. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_response.rb +120 -0
  53. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  54. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_status_code.rb +23 -0
  55. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reservation_term.rb +16 -0
  56. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/reserved_resource_type.rb +19 -0
  57. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  58. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_property.rb +58 -0
  59. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  60. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  61. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  62. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/operation.rb +228 -0
  63. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservation.rb +1109 -0
  64. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservation_order.rb +332 -0
  65. data/lib/2018-06-01-preview/generated/azure_mgmt_reservations/reservations_management_client.rb +348 -0
  66. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations.rb +64 -0
  67. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_reservation_list.rb +66 -0
  68. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_reservations.rb +85 -0
  69. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/applied_scope_type.rb +16 -0
  70. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response.rb +48 -0
  71. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties.rb +110 -0
  72. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties_billing_currency_total.rb +59 -0
  73. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/calculate_price_response_properties_pricing_currency_total.rb +59 -0
  74. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/catalog.rb +143 -0
  75. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/error.rb +48 -0
  76. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/error_response_code.rb +69 -0
  77. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/extended_error_info.rb +84 -0
  78. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/extended_status_info.rb +61 -0
  79. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/instance_flexibility.rb +16 -0
  80. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/merge_request.rb +56 -0
  81. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_display.rb +80 -0
  82. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_list.rb +98 -0
  83. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/operation_response.rb +70 -0
  84. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/patch.rb +88 -0
  85. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/purchase_request.rb +159 -0
  86. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/purchase_request_properties_reserved_resource_properties.rb +48 -0
  87. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_list.rb +98 -0
  88. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_merge_properties.rb +70 -0
  89. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_order_list.rb +98 -0
  90. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_order_response.rb +183 -0
  91. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_properties.rb +206 -0
  92. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_response.rb +120 -0
  93. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_split_properties.rb +70 -0
  94. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_status_code.rb +23 -0
  95. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reservation_term.rb +16 -0
  96. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/reserved_resource_type.rb +18 -0
  97. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_name.rb +47 -0
  98. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_property.rb +58 -0
  99. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/sku_restriction.rb +79 -0
  100. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/models/split_request.rb +69 -0
  101. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/module_definition.rb +9 -0
  102. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/operation.rb +228 -0
  103. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservation.rb +1072 -0
  104. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservation_order.rb +594 -0
  105. data/lib/2019-04-01-preview/generated/azure_mgmt_reservations/reservations_management_client.rb +348 -0
  106. data/lib/azure_mgmt_reservations.rb +8 -0
  107. data/lib/module_definition.rb +7 -0
  108. data/lib/profiles/latest/modules/reservations_profile_module.rb +201 -0
  109. data/lib/profiles/latest/reservations_latest_profile_client.rb +40 -0
  110. data/lib/profiles/latest/reservations_module_definition.rb +8 -0
  111. data/lib/version.rb +7 -0
  112. metadata +227 -0
@@ -0,0 +1,79 @@
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::Reservations::Mgmt::V2017_11_01
7
+ module Models
8
+ #
9
+ # Model object.
10
+ #
11
+ #
12
+ class SkuRestriction
13
+
14
+ include MsRestAzure
15
+
16
+ # @return [String] The type of restrictions.
17
+ attr_accessor :type
18
+
19
+ # @return [Array<String>] The value of restrictions. If the restriction
20
+ # type is set to location. This would be different locations where the
21
+ # SKU is restricted.
22
+ attr_accessor :values
23
+
24
+ # @return [String] The reason for restriction.
25
+ attr_accessor :reason_code
26
+
27
+
28
+ #
29
+ # Mapper for SkuRestriction class as Ruby Hash.
30
+ # This will be used for serialization/deserialization.
31
+ #
32
+ def self.mapper()
33
+ {
34
+ client_side_validation: true,
35
+ required: false,
36
+ serialized_name: 'SkuRestriction',
37
+ type: {
38
+ name: 'Composite',
39
+ class_name: 'SkuRestriction',
40
+ model_properties: {
41
+ type: {
42
+ client_side_validation: true,
43
+ required: false,
44
+ serialized_name: 'type',
45
+ type: {
46
+ name: 'String'
47
+ }
48
+ },
49
+ values: {
50
+ client_side_validation: true,
51
+ required: false,
52
+ serialized_name: 'values',
53
+ type: {
54
+ name: 'Sequence',
55
+ element: {
56
+ client_side_validation: true,
57
+ required: false,
58
+ serialized_name: 'StringElementType',
59
+ type: {
60
+ name: 'String'
61
+ }
62
+ }
63
+ }
64
+ },
65
+ reason_code: {
66
+ client_side_validation: true,
67
+ required: false,
68
+ serialized_name: 'reasonCode',
69
+ type: {
70
+ name: 'String'
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,69 @@
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::Reservations::Mgmt::V2017_11_01
7
+ module Models
8
+ #
9
+ # Model object.
10
+ #
11
+ #
12
+ class SplitRequest
13
+
14
+ include MsRestAzure
15
+
16
+ # @return [Array<Integer>] List of the quantities in the new reservations
17
+ # to create.
18
+ attr_accessor :quantities
19
+
20
+ # @return [String] Resource id of the reservation to be split. Format of
21
+ # the resource id should be
22
+ # /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}
23
+ attr_accessor :reservation_id
24
+
25
+
26
+ #
27
+ # Mapper for SplitRequest class as Ruby Hash.
28
+ # This will be used for serialization/deserialization.
29
+ #
30
+ def self.mapper()
31
+ {
32
+ client_side_validation: true,
33
+ required: false,
34
+ serialized_name: 'SplitRequest',
35
+ type: {
36
+ name: 'Composite',
37
+ class_name: 'SplitRequest',
38
+ model_properties: {
39
+ quantities: {
40
+ client_side_validation: true,
41
+ required: false,
42
+ serialized_name: 'properties.quantities',
43
+ type: {
44
+ name: 'Sequence',
45
+ element: {
46
+ client_side_validation: true,
47
+ required: false,
48
+ serialized_name: 'NumberElementType',
49
+ type: {
50
+ name: 'Number'
51
+ }
52
+ }
53
+ }
54
+ },
55
+ reservation_id: {
56
+ client_side_validation: true,
57
+ required: false,
58
+ serialized_name: 'properties.reservationId',
59
+ type: {
60
+ name: 'String'
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ end
67
+ end
68
+ end
69
+ end
@@ -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::Reservations end
8
+ module Azure::Reservations::Mgmt end
9
+ module Azure::Reservations::Mgmt::V2017_11_01 end
@@ -0,0 +1,228 @@
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::Reservations::Mgmt::V2017_11_01
7
+ #
8
+ # This API describe Azure Reservation
9
+ #
10
+ class Operation
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Operation class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [ReservationsManagementClient] reference to the ReservationsManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Get operations.
26
+ #
27
+ # List all the operations.
28
+ #
29
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
30
+ # will be added to the HTTP request.
31
+ #
32
+ # @return [Array<OperationResponse>] operation results.
33
+ #
34
+ def list(custom_headers:nil)
35
+ first_page = list_as_lazy(custom_headers:custom_headers)
36
+ first_page.get_all_items
37
+ end
38
+
39
+ #
40
+ # Get operations.
41
+ #
42
+ # List all the operations.
43
+ #
44
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
45
+ # will be added to the HTTP request.
46
+ #
47
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
48
+ #
49
+ def list_with_http_info(custom_headers:nil)
50
+ list_async(custom_headers:custom_headers).value!
51
+ end
52
+
53
+ #
54
+ # Get operations.
55
+ #
56
+ # List all the operations.
57
+ #
58
+ # @param [Hash{String => String}] A hash of custom headers that will be added
59
+ # to the HTTP request.
60
+ #
61
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
62
+ #
63
+ def list_async(custom_headers:nil)
64
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
65
+
66
+
67
+ request_headers = {}
68
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
69
+
70
+ # Set Headers
71
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
72
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
73
+ path_template = 'providers/Microsoft.Capacity/operations'
74
+
75
+ request_url = @base_url || @client.base_url
76
+
77
+ options = {
78
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
79
+ query_params: {'api-version' => @client.api_version},
80
+ headers: request_headers.merge(custom_headers || {}),
81
+ base_url: request_url
82
+ }
83
+ promise = @client.make_request_async(:get, path_template, options)
84
+
85
+ promise = promise.then do |result|
86
+ http_response = result.response
87
+ status_code = http_response.status
88
+ response_content = http_response.body
89
+ unless status_code == 200
90
+ error_model = JSON.load(response_content)
91
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
92
+ end
93
+
94
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
95
+ # Deserialize Response
96
+ if status_code == 200
97
+ begin
98
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
99
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::OperationList.mapper()
100
+ result.body = @client.deserialize(result_mapper, parsed_response)
101
+ rescue Exception => e
102
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
103
+ end
104
+ end
105
+
106
+ result
107
+ end
108
+
109
+ promise.execute
110
+ end
111
+
112
+ #
113
+ # Get operations.
114
+ #
115
+ # List all the operations.
116
+ #
117
+ # @param next_page_link [String] The NextLink from the previous successful call
118
+ # to List operation.
119
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
120
+ # will be added to the HTTP request.
121
+ #
122
+ # @return [OperationList] operation results.
123
+ #
124
+ def list_next(next_page_link, custom_headers:nil)
125
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
126
+ response.body unless response.nil?
127
+ end
128
+
129
+ #
130
+ # Get operations.
131
+ #
132
+ # List all the operations.
133
+ #
134
+ # @param next_page_link [String] The NextLink from the previous successful call
135
+ # to List operation.
136
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
137
+ # will be added to the HTTP request.
138
+ #
139
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
140
+ #
141
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
142
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
143
+ end
144
+
145
+ #
146
+ # Get operations.
147
+ #
148
+ # List all the operations.
149
+ #
150
+ # @param next_page_link [String] The NextLink from the previous successful call
151
+ # to List operation.
152
+ # @param [Hash{String => String}] A hash of custom headers that will be added
153
+ # to the HTTP request.
154
+ #
155
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
156
+ #
157
+ def list_next_async(next_page_link, custom_headers:nil)
158
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
159
+
160
+
161
+ request_headers = {}
162
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
163
+
164
+ # Set Headers
165
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
166
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
167
+ path_template = '{nextLink}'
168
+
169
+ request_url = @base_url || @client.base_url
170
+
171
+ options = {
172
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
173
+ skip_encoding_path_params: {'nextLink' => next_page_link},
174
+ headers: request_headers.merge(custom_headers || {}),
175
+ base_url: request_url
176
+ }
177
+ promise = @client.make_request_async(:get, path_template, options)
178
+
179
+ promise = promise.then do |result|
180
+ http_response = result.response
181
+ status_code = http_response.status
182
+ response_content = http_response.body
183
+ unless status_code == 200
184
+ error_model = JSON.load(response_content)
185
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
186
+ end
187
+
188
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
189
+ # Deserialize Response
190
+ if status_code == 200
191
+ begin
192
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
193
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::OperationList.mapper()
194
+ result.body = @client.deserialize(result_mapper, parsed_response)
195
+ rescue Exception => e
196
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
197
+ end
198
+ end
199
+
200
+ result
201
+ end
202
+
203
+ promise.execute
204
+ end
205
+
206
+ #
207
+ # Get operations.
208
+ #
209
+ # List all the operations.
210
+ #
211
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
212
+ # will be added to the HTTP request.
213
+ #
214
+ # @return [OperationList] which provide lazy access to pages of the response.
215
+ #
216
+ def list_as_lazy(custom_headers:nil)
217
+ response = list_async(custom_headers:custom_headers).value!
218
+ unless response.nil?
219
+ page = response.body
220
+ page.next_method = Proc.new do |next_page_link|
221
+ list_next_async(next_page_link, custom_headers:custom_headers)
222
+ end
223
+ page
224
+ end
225
+ end
226
+
227
+ end
228
+ end
@@ -0,0 +1,1109 @@
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::Reservations::Mgmt::V2017_11_01
7
+ #
8
+ # This API describe Azure Reservation
9
+ #
10
+ class Reservation
11
+ include MsRestAzure
12
+
13
+ #
14
+ # Creates and initializes a new instance of the Reservation class.
15
+ # @param client service class for accessing basic functionality.
16
+ #
17
+ def initialize(client)
18
+ @client = client
19
+ end
20
+
21
+ # @return [ReservationsManagementClient] reference to the ReservationsManagementClient
22
+ attr_reader :client
23
+
24
+ #
25
+ # Split the `Reservation`.
26
+ #
27
+ # Split a `Reservation` into two `Reservation`s with specified quantity
28
+ # distribution.
29
+ #
30
+ #
31
+ # @param reservation_order_id [String] Order Id of the reservation
32
+ #
33
+ # @param body [SplitRequest] Information needed to Split a reservation item
34
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
35
+ # will be added to the HTTP request.
36
+ #
37
+ # @return [Array] operation results.
38
+ #
39
+ def split(reservation_order_id, body, custom_headers:nil)
40
+ response = split_async(reservation_order_id, body, custom_headers:custom_headers).value!
41
+ response.body unless response.nil?
42
+ end
43
+
44
+ #
45
+ # @param reservation_order_id [String] Order Id of the reservation
46
+ #
47
+ # @param body [SplitRequest] Information needed to Split a reservation item
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [Concurrent::Promise] promise which provides async access to http
52
+ # response.
53
+ #
54
+ def split_async(reservation_order_id, body, custom_headers:nil)
55
+ # Send request
56
+ promise = begin_split_async(reservation_order_id, body, custom_headers:custom_headers)
57
+
58
+ promise = promise.then do |response|
59
+ # Defining deserialization method.
60
+ deserialize_method = lambda do |parsed_response|
61
+ result_mapper = {
62
+ client_side_validation: true,
63
+ required: false,
64
+ serialized_name: 'parsed_response',
65
+ type: {
66
+ name: 'Sequence',
67
+ element: {
68
+ client_side_validation: true,
69
+ required: false,
70
+ serialized_name: 'ReservationResponseElementType',
71
+ type: {
72
+ name: 'Composite',
73
+ class_name: 'ReservationResponse'
74
+ }
75
+ }
76
+ }
77
+ }
78
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
79
+ end
80
+
81
+ # Waiting for response.
82
+ @client.get_long_running_operation_result(response, deserialize_method)
83
+ end
84
+
85
+ promise
86
+ end
87
+
88
+ #
89
+ # Merges two `Reservation`s.
90
+ #
91
+ # Merge the specified `Reservation`s into a new `Reservation`. The two
92
+ # `Reservation`s being merged must have same properties.
93
+ #
94
+ # @param reservation_order_id [String] Order Id of the reservation
95
+ #
96
+ # @param body [MergeRequest] Information needed for commercial request for a
97
+ # reservation
98
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
99
+ # will be added to the HTTP request.
100
+ #
101
+ # @return [Array] operation results.
102
+ #
103
+ def merge(reservation_order_id, body, custom_headers:nil)
104
+ response = merge_async(reservation_order_id, body, custom_headers:custom_headers).value!
105
+ response.body unless response.nil?
106
+ end
107
+
108
+ #
109
+ # @param reservation_order_id [String] Order Id of the reservation
110
+ #
111
+ # @param body [MergeRequest] Information needed for commercial request for a
112
+ # reservation
113
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
114
+ # will be added to the HTTP request.
115
+ #
116
+ # @return [Concurrent::Promise] promise which provides async access to http
117
+ # response.
118
+ #
119
+ def merge_async(reservation_order_id, body, custom_headers:nil)
120
+ # Send request
121
+ promise = begin_merge_async(reservation_order_id, body, custom_headers:custom_headers)
122
+
123
+ promise = promise.then do |response|
124
+ # Defining deserialization method.
125
+ deserialize_method = lambda do |parsed_response|
126
+ result_mapper = {
127
+ client_side_validation: true,
128
+ required: false,
129
+ serialized_name: 'parsed_response',
130
+ type: {
131
+ name: 'Sequence',
132
+ element: {
133
+ client_side_validation: true,
134
+ required: false,
135
+ serialized_name: 'ReservationResponseElementType',
136
+ type: {
137
+ name: 'Composite',
138
+ class_name: 'ReservationResponse'
139
+ }
140
+ }
141
+ }
142
+ }
143
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
144
+ end
145
+
146
+ # Waiting for response.
147
+ @client.get_long_running_operation_result(response, deserialize_method)
148
+ end
149
+
150
+ promise
151
+ end
152
+
153
+ #
154
+ # Get `Reservation`s in a given reservation Order
155
+ #
156
+ # List `Reservation`s within a single `ReservationOrder`.
157
+ #
158
+ # @param reservation_order_id [String] Order Id of the reservation
159
+ #
160
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
161
+ # will be added to the HTTP request.
162
+ #
163
+ # @return [Array<ReservationResponse>] operation results.
164
+ #
165
+ def list(reservation_order_id, custom_headers:nil)
166
+ first_page = list_as_lazy(reservation_order_id, custom_headers:custom_headers)
167
+ first_page.get_all_items
168
+ end
169
+
170
+ #
171
+ # Get `Reservation`s in a given reservation Order
172
+ #
173
+ # List `Reservation`s within a single `ReservationOrder`.
174
+ #
175
+ # @param reservation_order_id [String] Order Id of the reservation
176
+ #
177
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
178
+ # will be added to the HTTP request.
179
+ #
180
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
181
+ #
182
+ def list_with_http_info(reservation_order_id, custom_headers:nil)
183
+ list_async(reservation_order_id, custom_headers:custom_headers).value!
184
+ end
185
+
186
+ #
187
+ # Get `Reservation`s in a given reservation Order
188
+ #
189
+ # List `Reservation`s within a single `ReservationOrder`.
190
+ #
191
+ # @param reservation_order_id [String] Order Id of the reservation
192
+ #
193
+ # @param [Hash{String => String}] A hash of custom headers that will be added
194
+ # to the HTTP request.
195
+ #
196
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
197
+ #
198
+ def list_async(reservation_order_id, custom_headers:nil)
199
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
200
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
201
+
202
+
203
+ request_headers = {}
204
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
205
+
206
+ # Set Headers
207
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
208
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
209
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations'
210
+
211
+ request_url = @base_url || @client.base_url
212
+
213
+ options = {
214
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
215
+ path_params: {'reservationOrderId' => reservation_order_id},
216
+ query_params: {'api-version' => @client.api_version},
217
+ headers: request_headers.merge(custom_headers || {}),
218
+ base_url: request_url
219
+ }
220
+ promise = @client.make_request_async(:get, path_template, options)
221
+
222
+ promise = promise.then do |result|
223
+ http_response = result.response
224
+ status_code = http_response.status
225
+ response_content = http_response.body
226
+ unless status_code == 200
227
+ error_model = JSON.load(response_content)
228
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
229
+ end
230
+
231
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
232
+ # Deserialize Response
233
+ if status_code == 200
234
+ begin
235
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
236
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationList.mapper()
237
+ result.body = @client.deserialize(result_mapper, parsed_response)
238
+ rescue Exception => e
239
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
240
+ end
241
+ end
242
+
243
+ result
244
+ end
245
+
246
+ promise.execute
247
+ end
248
+
249
+ #
250
+ # Get `Reservation` details.
251
+ #
252
+ # Get specific `Reservation` details.
253
+ #
254
+ # @param reservation_id [String] Id of the Reservation Item
255
+ # @param reservation_order_id [String] Order Id of the reservation
256
+ #
257
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
258
+ # will be added to the HTTP request.
259
+ #
260
+ # @return [ReservationResponse] operation results.
261
+ #
262
+ def get(reservation_id, reservation_order_id, custom_headers:nil)
263
+ response = get_async(reservation_id, reservation_order_id, custom_headers:custom_headers).value!
264
+ response.body unless response.nil?
265
+ end
266
+
267
+ #
268
+ # Get `Reservation` details.
269
+ #
270
+ # Get specific `Reservation` details.
271
+ #
272
+ # @param reservation_id [String] Id of the Reservation Item
273
+ # @param reservation_order_id [String] Order Id of the reservation
274
+ #
275
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
276
+ # will be added to the HTTP request.
277
+ #
278
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
279
+ #
280
+ def get_with_http_info(reservation_id, reservation_order_id, custom_headers:nil)
281
+ get_async(reservation_id, reservation_order_id, custom_headers:custom_headers).value!
282
+ end
283
+
284
+ #
285
+ # Get `Reservation` details.
286
+ #
287
+ # Get specific `Reservation` details.
288
+ #
289
+ # @param reservation_id [String] Id of the Reservation Item
290
+ # @param reservation_order_id [String] Order Id of the reservation
291
+ #
292
+ # @param [Hash{String => String}] A hash of custom headers that will be added
293
+ # to the HTTP request.
294
+ #
295
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
296
+ #
297
+ def get_async(reservation_id, reservation_order_id, custom_headers:nil)
298
+ fail ArgumentError, 'reservation_id is nil' if reservation_id.nil?
299
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
300
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
301
+
302
+
303
+ request_headers = {}
304
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
305
+
306
+ # Set Headers
307
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
308
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
309
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'
310
+
311
+ request_url = @base_url || @client.base_url
312
+
313
+ options = {
314
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
315
+ path_params: {'reservationId' => reservation_id,'reservationOrderId' => reservation_order_id},
316
+ query_params: {'api-version' => @client.api_version},
317
+ headers: request_headers.merge(custom_headers || {}),
318
+ base_url: request_url
319
+ }
320
+ promise = @client.make_request_async(:get, path_template, options)
321
+
322
+ promise = promise.then do |result|
323
+ http_response = result.response
324
+ status_code = http_response.status
325
+ response_content = http_response.body
326
+ unless status_code == 200
327
+ error_model = JSON.load(response_content)
328
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
329
+ end
330
+
331
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-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::Reservations::Mgmt::V2017_11_01::Models::ReservationResponse.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
+ # Updates a `Reservation`.
351
+ #
352
+ # Updates the applied scopes of the `Reservation`.
353
+ #
354
+ # @param reservation_order_id [String] Order Id of the reservation
355
+ #
356
+ # @param reservation_id [String] Id of the Reservation Item
357
+ # @param parameters [Patch] Information needed to patch a reservation item
358
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
359
+ # will be added to the HTTP request.
360
+ #
361
+ # @return [ReservationResponse] operation results.
362
+ #
363
+ def update(reservation_order_id, reservation_id, parameters, custom_headers:nil)
364
+ response = update_async(reservation_order_id, reservation_id, parameters, custom_headers:custom_headers).value!
365
+ response.body unless response.nil?
366
+ end
367
+
368
+ #
369
+ # @param reservation_order_id [String] Order Id of the reservation
370
+ #
371
+ # @param reservation_id [String] Id of the Reservation Item
372
+ # @param parameters [Patch] Information needed to patch a reservation item
373
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
374
+ # will be added to the HTTP request.
375
+ #
376
+ # @return [Concurrent::Promise] promise which provides async access to http
377
+ # response.
378
+ #
379
+ def update_async(reservation_order_id, reservation_id, parameters, custom_headers:nil)
380
+ # Send request
381
+ promise = begin_update_async(reservation_order_id, reservation_id, parameters, custom_headers:custom_headers)
382
+
383
+ promise = promise.then do |response|
384
+ # Defining deserialization method.
385
+ deserialize_method = lambda do |parsed_response|
386
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationResponse.mapper()
387
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
388
+ end
389
+
390
+ # Waiting for response.
391
+ @client.get_long_running_operation_result(response, deserialize_method)
392
+ end
393
+
394
+ promise
395
+ end
396
+
397
+ #
398
+ # Get `Reservation` revisions.
399
+ #
400
+ # List of all the revisions for the `Reservation`.
401
+ #
402
+ #
403
+ # @param reservation_id [String] Id of the Reservation Item
404
+ # @param reservation_order_id [String] Order Id of the reservation
405
+ #
406
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
407
+ # will be added to the HTTP request.
408
+ #
409
+ # @return [Array<ReservationResponse>] operation results.
410
+ #
411
+ def list_revisions(reservation_id, reservation_order_id, custom_headers:nil)
412
+ first_page = list_revisions_as_lazy(reservation_id, reservation_order_id, custom_headers:custom_headers)
413
+ first_page.get_all_items
414
+ end
415
+
416
+ #
417
+ # Get `Reservation` revisions.
418
+ #
419
+ # List of all the revisions for the `Reservation`.
420
+ #
421
+ #
422
+ # @param reservation_id [String] Id of the Reservation Item
423
+ # @param reservation_order_id [String] Order Id of the reservation
424
+ #
425
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
426
+ # will be added to the HTTP request.
427
+ #
428
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
429
+ #
430
+ def list_revisions_with_http_info(reservation_id, reservation_order_id, custom_headers:nil)
431
+ list_revisions_async(reservation_id, reservation_order_id, custom_headers:custom_headers).value!
432
+ end
433
+
434
+ #
435
+ # Get `Reservation` revisions.
436
+ #
437
+ # List of all the revisions for the `Reservation`.
438
+ #
439
+ #
440
+ # @param reservation_id [String] Id of the Reservation Item
441
+ # @param reservation_order_id [String] Order Id of the reservation
442
+ #
443
+ # @param [Hash{String => String}] A hash of custom headers that will be added
444
+ # to the HTTP request.
445
+ #
446
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
447
+ #
448
+ def list_revisions_async(reservation_id, reservation_order_id, custom_headers:nil)
449
+ fail ArgumentError, 'reservation_id is nil' if reservation_id.nil?
450
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
451
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
452
+
453
+
454
+ request_headers = {}
455
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
456
+
457
+ # Set Headers
458
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
459
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
460
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions'
461
+
462
+ request_url = @base_url || @client.base_url
463
+
464
+ options = {
465
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
466
+ path_params: {'reservationId' => reservation_id,'reservationOrderId' => reservation_order_id},
467
+ query_params: {'api-version' => @client.api_version},
468
+ headers: request_headers.merge(custom_headers || {}),
469
+ base_url: request_url
470
+ }
471
+ promise = @client.make_request_async(:get, path_template, options)
472
+
473
+ promise = promise.then do |result|
474
+ http_response = result.response
475
+ status_code = http_response.status
476
+ response_content = http_response.body
477
+ unless status_code == 200
478
+ error_model = JSON.load(response_content)
479
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
480
+ end
481
+
482
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
483
+ # Deserialize Response
484
+ if status_code == 200
485
+ begin
486
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
487
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationList.mapper()
488
+ result.body = @client.deserialize(result_mapper, parsed_response)
489
+ rescue Exception => e
490
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
491
+ end
492
+ end
493
+
494
+ result
495
+ end
496
+
497
+ promise.execute
498
+ end
499
+
500
+ #
501
+ # Split the `Reservation`.
502
+ #
503
+ # Split a `Reservation` into two `Reservation`s with specified quantity
504
+ # distribution.
505
+ #
506
+ #
507
+ # @param reservation_order_id [String] Order Id of the reservation
508
+ #
509
+ # @param body [SplitRequest] Information needed to Split a reservation item
510
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
511
+ # will be added to the HTTP request.
512
+ #
513
+ # @return [Array] operation results.
514
+ #
515
+ def begin_split(reservation_order_id, body, custom_headers:nil)
516
+ response = begin_split_async(reservation_order_id, body, custom_headers:custom_headers).value!
517
+ response.body unless response.nil?
518
+ end
519
+
520
+ #
521
+ # Split the `Reservation`.
522
+ #
523
+ # Split a `Reservation` into two `Reservation`s with specified quantity
524
+ # distribution.
525
+ #
526
+ #
527
+ # @param reservation_order_id [String] Order Id of the reservation
528
+ #
529
+ # @param body [SplitRequest] Information needed to Split a reservation item
530
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
531
+ # will be added to the HTTP request.
532
+ #
533
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
534
+ #
535
+ def begin_split_with_http_info(reservation_order_id, body, custom_headers:nil)
536
+ begin_split_async(reservation_order_id, body, custom_headers:custom_headers).value!
537
+ end
538
+
539
+ #
540
+ # Split the `Reservation`.
541
+ #
542
+ # Split a `Reservation` into two `Reservation`s with specified quantity
543
+ # distribution.
544
+ #
545
+ #
546
+ # @param reservation_order_id [String] Order Id of the reservation
547
+ #
548
+ # @param body [SplitRequest] Information needed to Split a reservation item
549
+ # @param [Hash{String => String}] A hash of custom headers that will be added
550
+ # to the HTTP request.
551
+ #
552
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
553
+ #
554
+ def begin_split_async(reservation_order_id, body, custom_headers:nil)
555
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
556
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
557
+ fail ArgumentError, 'body is nil' if body.nil?
558
+
559
+
560
+ request_headers = {}
561
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
562
+
563
+ # Set Headers
564
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
565
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
566
+
567
+ # Serialize Request
568
+ request_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::SplitRequest.mapper()
569
+ request_content = @client.serialize(request_mapper, body)
570
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
571
+
572
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split'
573
+
574
+ request_url = @base_url || @client.base_url
575
+
576
+ options = {
577
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
578
+ path_params: {'reservationOrderId' => reservation_order_id},
579
+ query_params: {'api-version' => @client.api_version},
580
+ body: request_content,
581
+ headers: request_headers.merge(custom_headers || {}),
582
+ base_url: request_url
583
+ }
584
+ promise = @client.make_request_async(:post, path_template, options)
585
+
586
+ promise = promise.then do |result|
587
+ http_response = result.response
588
+ status_code = http_response.status
589
+ response_content = http_response.body
590
+ unless status_code == 200 || status_code == 202
591
+ error_model = JSON.load(response_content)
592
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
593
+ end
594
+
595
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
596
+ # Deserialize Response
597
+ if status_code == 200
598
+ begin
599
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
600
+ result_mapper = {
601
+ client_side_validation: true,
602
+ required: false,
603
+ serialized_name: 'parsed_response',
604
+ type: {
605
+ name: 'Sequence',
606
+ element: {
607
+ client_side_validation: true,
608
+ required: false,
609
+ serialized_name: 'ReservationResponseElementType',
610
+ type: {
611
+ name: 'Composite',
612
+ class_name: 'ReservationResponse'
613
+ }
614
+ }
615
+ }
616
+ }
617
+ result.body = @client.deserialize(result_mapper, parsed_response)
618
+ rescue Exception => e
619
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
620
+ end
621
+ end
622
+
623
+ result
624
+ end
625
+
626
+ promise.execute
627
+ end
628
+
629
+ #
630
+ # Merges two `Reservation`s.
631
+ #
632
+ # Merge the specified `Reservation`s into a new `Reservation`. The two
633
+ # `Reservation`s being merged must have same properties.
634
+ #
635
+ # @param reservation_order_id [String] Order Id of the reservation
636
+ #
637
+ # @param body [MergeRequest] Information needed for commercial request for a
638
+ # reservation
639
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
640
+ # will be added to the HTTP request.
641
+ #
642
+ # @return [Array] operation results.
643
+ #
644
+ def begin_merge(reservation_order_id, body, custom_headers:nil)
645
+ response = begin_merge_async(reservation_order_id, body, custom_headers:custom_headers).value!
646
+ response.body unless response.nil?
647
+ end
648
+
649
+ #
650
+ # Merges two `Reservation`s.
651
+ #
652
+ # Merge the specified `Reservation`s into a new `Reservation`. The two
653
+ # `Reservation`s being merged must have same properties.
654
+ #
655
+ # @param reservation_order_id [String] Order Id of the reservation
656
+ #
657
+ # @param body [MergeRequest] Information needed for commercial request for a
658
+ # reservation
659
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
660
+ # will be added to the HTTP request.
661
+ #
662
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
663
+ #
664
+ def begin_merge_with_http_info(reservation_order_id, body, custom_headers:nil)
665
+ begin_merge_async(reservation_order_id, body, custom_headers:custom_headers).value!
666
+ end
667
+
668
+ #
669
+ # Merges two `Reservation`s.
670
+ #
671
+ # Merge the specified `Reservation`s into a new `Reservation`. The two
672
+ # `Reservation`s being merged must have same properties.
673
+ #
674
+ # @param reservation_order_id [String] Order Id of the reservation
675
+ #
676
+ # @param body [MergeRequest] Information needed for commercial request for a
677
+ # reservation
678
+ # @param [Hash{String => String}] A hash of custom headers that will be added
679
+ # to the HTTP request.
680
+ #
681
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
682
+ #
683
+ def begin_merge_async(reservation_order_id, body, custom_headers:nil)
684
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
685
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
686
+ fail ArgumentError, 'body is nil' if body.nil?
687
+
688
+
689
+ request_headers = {}
690
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
691
+
692
+ # Set Headers
693
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
694
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
695
+
696
+ # Serialize Request
697
+ request_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::MergeRequest.mapper()
698
+ request_content = @client.serialize(request_mapper, body)
699
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
700
+
701
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge'
702
+
703
+ request_url = @base_url || @client.base_url
704
+
705
+ options = {
706
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
707
+ path_params: {'reservationOrderId' => reservation_order_id},
708
+ query_params: {'api-version' => @client.api_version},
709
+ body: request_content,
710
+ headers: request_headers.merge(custom_headers || {}),
711
+ base_url: request_url
712
+ }
713
+ promise = @client.make_request_async(:post, path_template, options)
714
+
715
+ promise = promise.then do |result|
716
+ http_response = result.response
717
+ status_code = http_response.status
718
+ response_content = http_response.body
719
+ unless status_code == 200 || status_code == 202
720
+ error_model = JSON.load(response_content)
721
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
722
+ end
723
+
724
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
725
+ # Deserialize Response
726
+ if status_code == 200
727
+ begin
728
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
729
+ result_mapper = {
730
+ client_side_validation: true,
731
+ required: false,
732
+ serialized_name: 'parsed_response',
733
+ type: {
734
+ name: 'Sequence',
735
+ element: {
736
+ client_side_validation: true,
737
+ required: false,
738
+ serialized_name: 'ReservationResponseElementType',
739
+ type: {
740
+ name: 'Composite',
741
+ class_name: 'ReservationResponse'
742
+ }
743
+ }
744
+ }
745
+ }
746
+ result.body = @client.deserialize(result_mapper, parsed_response)
747
+ rescue Exception => e
748
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
749
+ end
750
+ end
751
+
752
+ result
753
+ end
754
+
755
+ promise.execute
756
+ end
757
+
758
+ #
759
+ # Updates a `Reservation`.
760
+ #
761
+ # Updates the applied scopes of the `Reservation`.
762
+ #
763
+ # @param reservation_order_id [String] Order Id of the reservation
764
+ #
765
+ # @param reservation_id [String] Id of the Reservation Item
766
+ # @param parameters [Patch] Information needed to patch a reservation item
767
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
768
+ # will be added to the HTTP request.
769
+ #
770
+ # @return [ReservationResponse] operation results.
771
+ #
772
+ def begin_update(reservation_order_id, reservation_id, parameters, custom_headers:nil)
773
+ response = begin_update_async(reservation_order_id, reservation_id, parameters, custom_headers:custom_headers).value!
774
+ response.body unless response.nil?
775
+ end
776
+
777
+ #
778
+ # Updates a `Reservation`.
779
+ #
780
+ # Updates the applied scopes of the `Reservation`.
781
+ #
782
+ # @param reservation_order_id [String] Order Id of the reservation
783
+ #
784
+ # @param reservation_id [String] Id of the Reservation Item
785
+ # @param parameters [Patch] Information needed to patch a reservation item
786
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
787
+ # will be added to the HTTP request.
788
+ #
789
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
790
+ #
791
+ def begin_update_with_http_info(reservation_order_id, reservation_id, parameters, custom_headers:nil)
792
+ begin_update_async(reservation_order_id, reservation_id, parameters, custom_headers:custom_headers).value!
793
+ end
794
+
795
+ #
796
+ # Updates a `Reservation`.
797
+ #
798
+ # Updates the applied scopes of the `Reservation`.
799
+ #
800
+ # @param reservation_order_id [String] Order Id of the reservation
801
+ #
802
+ # @param reservation_id [String] Id of the Reservation Item
803
+ # @param parameters [Patch] Information needed to patch a reservation item
804
+ # @param [Hash{String => String}] A hash of custom headers that will be added
805
+ # to the HTTP request.
806
+ #
807
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
808
+ #
809
+ def begin_update_async(reservation_order_id, reservation_id, parameters, custom_headers:nil)
810
+ fail ArgumentError, 'reservation_order_id is nil' if reservation_order_id.nil?
811
+ fail ArgumentError, 'reservation_id is nil' if reservation_id.nil?
812
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
813
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
814
+
815
+
816
+ request_headers = {}
817
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
818
+
819
+ # Set Headers
820
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
821
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
822
+
823
+ # Serialize Request
824
+ request_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::Patch.mapper()
825
+ request_content = @client.serialize(request_mapper, parameters)
826
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
827
+
828
+ path_template = 'providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'
829
+
830
+ request_url = @base_url || @client.base_url
831
+
832
+ options = {
833
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
834
+ path_params: {'reservationOrderId' => reservation_order_id,'reservationId' => reservation_id},
835
+ query_params: {'api-version' => @client.api_version},
836
+ body: request_content,
837
+ headers: request_headers.merge(custom_headers || {}),
838
+ base_url: request_url
839
+ }
840
+ promise = @client.make_request_async(:patch, path_template, options)
841
+
842
+ promise = promise.then do |result|
843
+ http_response = result.response
844
+ status_code = http_response.status
845
+ response_content = http_response.body
846
+ unless status_code == 200 || status_code == 202
847
+ error_model = JSON.load(response_content)
848
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
849
+ end
850
+
851
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
852
+ # Deserialize Response
853
+ if status_code == 200
854
+ begin
855
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
856
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationResponse.mapper()
857
+ result.body = @client.deserialize(result_mapper, parsed_response)
858
+ rescue Exception => e
859
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
860
+ end
861
+ end
862
+
863
+ result
864
+ end
865
+
866
+ promise.execute
867
+ end
868
+
869
+ #
870
+ # Get `Reservation`s in a given reservation Order
871
+ #
872
+ # List `Reservation`s within a single `ReservationOrder`.
873
+ #
874
+ # @param next_page_link [String] The NextLink from the previous successful call
875
+ # to List operation.
876
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
877
+ # will be added to the HTTP request.
878
+ #
879
+ # @return [ReservationList] operation results.
880
+ #
881
+ def list_next(next_page_link, custom_headers:nil)
882
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
883
+ response.body unless response.nil?
884
+ end
885
+
886
+ #
887
+ # Get `Reservation`s in a given reservation Order
888
+ #
889
+ # List `Reservation`s within a single `ReservationOrder`.
890
+ #
891
+ # @param next_page_link [String] The NextLink from the previous successful call
892
+ # to List operation.
893
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
894
+ # will be added to the HTTP request.
895
+ #
896
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
897
+ #
898
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
899
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
900
+ end
901
+
902
+ #
903
+ # Get `Reservation`s in a given reservation Order
904
+ #
905
+ # List `Reservation`s within a single `ReservationOrder`.
906
+ #
907
+ # @param next_page_link [String] The NextLink from the previous successful call
908
+ # to List operation.
909
+ # @param [Hash{String => String}] A hash of custom headers that will be added
910
+ # to the HTTP request.
911
+ #
912
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
913
+ #
914
+ def list_next_async(next_page_link, custom_headers:nil)
915
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
916
+
917
+
918
+ request_headers = {}
919
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
920
+
921
+ # Set Headers
922
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
923
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
924
+ path_template = '{nextLink}'
925
+
926
+ request_url = @base_url || @client.base_url
927
+
928
+ options = {
929
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
930
+ skip_encoding_path_params: {'nextLink' => next_page_link},
931
+ headers: request_headers.merge(custom_headers || {}),
932
+ base_url: request_url
933
+ }
934
+ promise = @client.make_request_async(:get, path_template, options)
935
+
936
+ promise = promise.then do |result|
937
+ http_response = result.response
938
+ status_code = http_response.status
939
+ response_content = http_response.body
940
+ unless status_code == 200
941
+ error_model = JSON.load(response_content)
942
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
943
+ end
944
+
945
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
946
+ # Deserialize Response
947
+ if status_code == 200
948
+ begin
949
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
950
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationList.mapper()
951
+ result.body = @client.deserialize(result_mapper, parsed_response)
952
+ rescue Exception => e
953
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
954
+ end
955
+ end
956
+
957
+ result
958
+ end
959
+
960
+ promise.execute
961
+ end
962
+
963
+ #
964
+ # Get `Reservation` revisions.
965
+ #
966
+ # List of all the revisions for the `Reservation`.
967
+ #
968
+ #
969
+ # @param next_page_link [String] The NextLink from the previous successful call
970
+ # to List operation.
971
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
972
+ # will be added to the HTTP request.
973
+ #
974
+ # @return [ReservationList] operation results.
975
+ #
976
+ def list_revisions_next(next_page_link, custom_headers:nil)
977
+ response = list_revisions_next_async(next_page_link, custom_headers:custom_headers).value!
978
+ response.body unless response.nil?
979
+ end
980
+
981
+ #
982
+ # Get `Reservation` revisions.
983
+ #
984
+ # List of all the revisions for the `Reservation`.
985
+ #
986
+ #
987
+ # @param next_page_link [String] The NextLink from the previous successful call
988
+ # to List operation.
989
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
990
+ # will be added to the HTTP request.
991
+ #
992
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
993
+ #
994
+ def list_revisions_next_with_http_info(next_page_link, custom_headers:nil)
995
+ list_revisions_next_async(next_page_link, custom_headers:custom_headers).value!
996
+ end
997
+
998
+ #
999
+ # Get `Reservation` revisions.
1000
+ #
1001
+ # List of all the revisions for the `Reservation`.
1002
+ #
1003
+ #
1004
+ # @param next_page_link [String] The NextLink from the previous successful call
1005
+ # to List operation.
1006
+ # @param [Hash{String => String}] A hash of custom headers that will be added
1007
+ # to the HTTP request.
1008
+ #
1009
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
1010
+ #
1011
+ def list_revisions_next_async(next_page_link, custom_headers:nil)
1012
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
1013
+
1014
+
1015
+ request_headers = {}
1016
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
1017
+
1018
+ # Set Headers
1019
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
1020
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
1021
+ path_template = '{nextLink}'
1022
+
1023
+ request_url = @base_url || @client.base_url
1024
+
1025
+ options = {
1026
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
1027
+ skip_encoding_path_params: {'nextLink' => next_page_link},
1028
+ headers: request_headers.merge(custom_headers || {}),
1029
+ base_url: request_url
1030
+ }
1031
+ promise = @client.make_request_async(:get, path_template, options)
1032
+
1033
+ promise = promise.then do |result|
1034
+ http_response = result.response
1035
+ status_code = http_response.status
1036
+ response_content = http_response.body
1037
+ unless status_code == 200
1038
+ error_model = JSON.load(response_content)
1039
+ fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
1040
+ end
1041
+
1042
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
1043
+ # Deserialize Response
1044
+ if status_code == 200
1045
+ begin
1046
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
1047
+ result_mapper = Azure::Reservations::Mgmt::V2017_11_01::Models::ReservationList.mapper()
1048
+ result.body = @client.deserialize(result_mapper, parsed_response)
1049
+ rescue Exception => e
1050
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
1051
+ end
1052
+ end
1053
+
1054
+ result
1055
+ end
1056
+
1057
+ promise.execute
1058
+ end
1059
+
1060
+ #
1061
+ # Get `Reservation`s in a given reservation Order
1062
+ #
1063
+ # List `Reservation`s within a single `ReservationOrder`.
1064
+ #
1065
+ # @param reservation_order_id [String] Order Id of the reservation
1066
+ #
1067
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1068
+ # will be added to the HTTP request.
1069
+ #
1070
+ # @return [ReservationList] which provide lazy access to pages of the response.
1071
+ #
1072
+ def list_as_lazy(reservation_order_id, custom_headers:nil)
1073
+ response = list_async(reservation_order_id, custom_headers:custom_headers).value!
1074
+ unless response.nil?
1075
+ page = response.body
1076
+ page.next_method = Proc.new do |next_page_link|
1077
+ list_next_async(next_page_link, custom_headers:custom_headers)
1078
+ end
1079
+ page
1080
+ end
1081
+ end
1082
+
1083
+ #
1084
+ # Get `Reservation` revisions.
1085
+ #
1086
+ # List of all the revisions for the `Reservation`.
1087
+ #
1088
+ #
1089
+ # @param reservation_id [String] Id of the Reservation Item
1090
+ # @param reservation_order_id [String] Order Id of the reservation
1091
+ #
1092
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
1093
+ # will be added to the HTTP request.
1094
+ #
1095
+ # @return [ReservationList] which provide lazy access to pages of the response.
1096
+ #
1097
+ def list_revisions_as_lazy(reservation_id, reservation_order_id, custom_headers:nil)
1098
+ response = list_revisions_async(reservation_id, reservation_order_id, custom_headers:custom_headers).value!
1099
+ unless response.nil?
1100
+ page = response.body
1101
+ page.next_method = Proc.new do |next_page_link|
1102
+ list_revisions_next_async(next_page_link, custom_headers:custom_headers)
1103
+ end
1104
+ page
1105
+ end
1106
+ end
1107
+
1108
+ end
1109
+ end