azure_mgmt_storagecache 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/2019-08-01-preview/generated/azure_mgmt_storagecache.rb +0 -1
  3. data/lib/2019-08-01-preview/generated/azure_mgmt_storagecache/storage_cache_management_client.rb +1 -1
  4. data/lib/2019-11-01/generated/azure_mgmt_storagecache.rb +0 -1
  5. data/lib/2019-11-01/generated/azure_mgmt_storagecache/storage_cache_management_client.rb +1 -1
  6. data/lib/2020-03-01/generated/azure_mgmt_storagecache.rb +72 -0
  7. data/lib/2020-03-01/generated/azure_mgmt_storagecache/caches.rb +1513 -0
  8. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/api_operation.rb +59 -0
  9. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/api_operation_display.rb +69 -0
  10. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/api_operation_list_result.rb +101 -0
  11. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache.rb +238 -0
  12. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_encryption_settings.rb +48 -0
  13. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_health.rb +60 -0
  14. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_identity.rb +72 -0
  15. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_identity_type.rb +16 -0
  16. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_network_settings.rb +73 -0
  17. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_security_settings.rb +46 -0
  18. data/lib/{2019-11-01/generated/azure_mgmt_storagecache/models/cloud_error.rb → 2020-03-01/generated/azure_mgmt_storagecache/models/cache_sku.rb} +11 -12
  19. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cache_upgrade_status.rb +101 -0
  20. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/caches_list_result.rb +100 -0
  21. data/lib/{2019-08-01-preview/generated/azure_mgmt_storagecache/models/cloud_error.rb → 2020-03-01/generated/azure_mgmt_storagecache/models/clfs_target.rb} +11 -12
  22. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/clfs_target_properties.rb +110 -0
  23. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/cloud_error_body.rb +92 -0
  24. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/firmware_status_type.rb +16 -0
  25. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/health_state_type.rb +23 -0
  26. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/key_vault_key_reference.rb +59 -0
  27. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/key_vault_key_reference_source_vault.rb +46 -0
  28. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/namespace_junction.rb +68 -0
  29. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/nfs3target.rb +62 -0
  30. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/nfs3target_properties.rb +110 -0
  31. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/provisioning_state_type.rb +20 -0
  32. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/reason_code.rb +16 -0
  33. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/resource_sku.rb +143 -0
  34. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/resource_sku_capabilities.rb +57 -0
  35. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/resource_sku_location_info.rb +65 -0
  36. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/resource_skus_result.rb +100 -0
  37. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/restriction.rb +86 -0
  38. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/storage_target.rb +155 -0
  39. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/storage_target_properties.rb +130 -0
  40. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/storage_target_resource.rb +72 -0
  41. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/storage_target_type.rb +17 -0
  42. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/storage_targets_result.rb +99 -0
  43. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/unknown_target.rb +55 -0
  44. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/unknown_target_properties.rb +110 -0
  45. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/usage_model.rb +71 -0
  46. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/usage_model_display.rb +46 -0
  47. data/lib/2020-03-01/generated/azure_mgmt_storagecache/models/usage_models_result.rb +99 -0
  48. data/lib/2020-03-01/generated/azure_mgmt_storagecache/module_definition.rb +9 -0
  49. data/lib/2020-03-01/generated/azure_mgmt_storagecache/operations.rb +221 -0
  50. data/lib/2020-03-01/generated/azure_mgmt_storagecache/skus.rb +223 -0
  51. data/lib/2020-03-01/generated/azure_mgmt_storagecache/storage_cache_management_client.rb +153 -0
  52. data/lib/2020-03-01/generated/azure_mgmt_storagecache/storage_targets.rb +703 -0
  53. data/lib/2020-03-01/generated/azure_mgmt_storagecache/usage_models.rb +223 -0
  54. data/lib/azure_mgmt_storagecache.rb +1 -0
  55. data/lib/profiles/latest/modules/storagecache_profile_module.rb +131 -87
  56. data/lib/version.rb +1 -1
  57. metadata +50 -4
@@ -0,0 +1,223 @@
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::StorageCache::Mgmt::V2020_03_01
7
+ #
8
+ # A Storage Cache provides scalable caching service for NAS clients, serving
9
+ # data from either NFSv3 or Blob at-rest storage (referred to as "Storage
10
+ # Targets"). These operations allow you to manage Caches.
11
+ #
12
+ class Skus
13
+ include MsRestAzure
14
+
15
+ #
16
+ # Creates and initializes a new instance of the Skus class.
17
+ # @param client service class for accessing basic functionality.
18
+ #
19
+ def initialize(client)
20
+ @client = client
21
+ end
22
+
23
+ # @return [StorageCacheManagementClient] reference to the StorageCacheManagementClient
24
+ attr_reader :client
25
+
26
+ #
27
+ # Get the list of StorageCache.Cache SKUs available to this subscription.
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<ResourceSku>] 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 the list of StorageCache.Cache SKUs available to this subscription.
41
+ #
42
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
43
+ # will be added to the HTTP request.
44
+ #
45
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
46
+ #
47
+ def list_with_http_info(custom_headers:nil)
48
+ list_async(custom_headers:custom_headers).value!
49
+ end
50
+
51
+ #
52
+ # Get the list of StorageCache.Cache SKUs available to this subscription.
53
+ #
54
+ # @param [Hash{String => String}] A hash of custom headers that will be added
55
+ # to the HTTP request.
56
+ #
57
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
58
+ #
59
+ def list_async(custom_headers:nil)
60
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
61
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
62
+
63
+
64
+ request_headers = {}
65
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
66
+
67
+ # Set Headers
68
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
69
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
70
+ path_template = 'subscriptions/{subscriptionId}/providers/Microsoft.StorageCache/skus'
71
+
72
+ request_url = @base_url || @client.base_url
73
+
74
+ options = {
75
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
76
+ path_params: {'subscriptionId' => @client.subscription_id},
77
+ query_params: {'api-version' => @client.api_version},
78
+ headers: request_headers.merge(custom_headers || {}),
79
+ base_url: request_url
80
+ }
81
+ promise = @client.make_request_async(:get, path_template, options)
82
+
83
+ promise = promise.then do |result|
84
+ http_response = result.response
85
+ status_code = http_response.status
86
+ response_content = http_response.body
87
+ unless status_code == 200
88
+ error_model = JSON.load(response_content)
89
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
90
+ end
91
+
92
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
93
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
94
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-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::StorageCache::Mgmt::V2020_03_01::Models::ResourceSkusResult.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 the list of StorageCache.Cache SKUs available to this subscription.
114
+ #
115
+ # @param next_page_link [String] The NextLink from the previous successful call
116
+ # to List operation.
117
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
118
+ # will be added to the HTTP request.
119
+ #
120
+ # @return [ResourceSkusResult] operation results.
121
+ #
122
+ def list_next(next_page_link, custom_headers:nil)
123
+ response = list_next_async(next_page_link, custom_headers:custom_headers).value!
124
+ response.body unless response.nil?
125
+ end
126
+
127
+ #
128
+ # Get the list of StorageCache.Cache SKUs available to this subscription.
129
+ #
130
+ # @param next_page_link [String] The NextLink from the previous successful call
131
+ # to List operation.
132
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
133
+ # will be added to the HTTP request.
134
+ #
135
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
136
+ #
137
+ def list_next_with_http_info(next_page_link, custom_headers:nil)
138
+ list_next_async(next_page_link, custom_headers:custom_headers).value!
139
+ end
140
+
141
+ #
142
+ # Get the list of StorageCache.Cache SKUs available to this subscription.
143
+ #
144
+ # @param next_page_link [String] The NextLink from the previous successful call
145
+ # to List operation.
146
+ # @param [Hash{String => String}] A hash of custom headers that will be added
147
+ # to the HTTP request.
148
+ #
149
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
150
+ #
151
+ def list_next_async(next_page_link, custom_headers:nil)
152
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
153
+
154
+
155
+ request_headers = {}
156
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
157
+
158
+ # Set Headers
159
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
160
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
161
+ path_template = '{nextLink}'
162
+
163
+ request_url = @base_url || @client.base_url
164
+
165
+ options = {
166
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
167
+ skip_encoding_path_params: {'nextLink' => next_page_link},
168
+ headers: request_headers.merge(custom_headers || {}),
169
+ base_url: request_url
170
+ }
171
+ promise = @client.make_request_async(:get, path_template, options)
172
+
173
+ promise = promise.then do |result|
174
+ http_response = result.response
175
+ status_code = http_response.status
176
+ response_content = http_response.body
177
+ unless status_code == 200
178
+ error_model = JSON.load(response_content)
179
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
180
+ end
181
+
182
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
183
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
184
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
185
+ # Deserialize Response
186
+ if status_code == 200
187
+ begin
188
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
189
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::ResourceSkusResult.mapper()
190
+ result.body = @client.deserialize(result_mapper, parsed_response)
191
+ rescue Exception => e
192
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
193
+ end
194
+ end
195
+
196
+ result
197
+ end
198
+
199
+ promise.execute
200
+ end
201
+
202
+ #
203
+ # Get the list of StorageCache.Cache SKUs available to this subscription.
204
+ #
205
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
206
+ # will be added to the HTTP request.
207
+ #
208
+ # @return [ResourceSkusResult] which provide lazy access to pages of the
209
+ # response.
210
+ #
211
+ def list_as_lazy(custom_headers:nil)
212
+ response = list_async(custom_headers:custom_headers).value!
213
+ unless response.nil?
214
+ page = response.body
215
+ page.next_method = Proc.new do |next_page_link|
216
+ list_next_async(next_page_link, custom_headers:custom_headers)
217
+ end
218
+ page
219
+ end
220
+ end
221
+
222
+ end
223
+ end
@@ -0,0 +1,153 @@
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::StorageCache::Mgmt::V2020_03_01
7
+ #
8
+ # A service client - single point of access to the REST API.
9
+ #
10
+ class StorageCacheManagementClient < MsRestAzure::AzureServiceClient
11
+ include MsRestAzure
12
+ include MsRestAzure::Serialization
13
+
14
+ # @return [String] the base URI of the service.
15
+ attr_accessor :base_url
16
+
17
+ # @return Credentials needed for the client to connect to Azure.
18
+ attr_reader :credentials1
19
+
20
+ # @return [String] Subscription credentials which uniquely identify
21
+ # Microsoft Azure subscription. The subscription ID forms part of the URI
22
+ # for every service call.
23
+ attr_accessor :subscription_id
24
+
25
+ # @return [String] Client API version.
26
+ attr_reader :api_version
27
+
28
+ # @return Subscription credentials which uniquely identify client
29
+ # subscription.
30
+ attr_accessor :credentials
31
+
32
+ # @return [String] The preferred language for the response.
33
+ attr_accessor :accept_language
34
+
35
+ # @return [Integer] The retry timeout in seconds for Long Running
36
+ # Operations. Default value is 30.
37
+ attr_accessor :long_running_operation_retry_timeout
38
+
39
+ # @return [Boolean] Whether a unique x-ms-client-request-id should be
40
+ # generated. When set to true a unique x-ms-client-request-id value is
41
+ # generated and included in each request. Default is true.
42
+ attr_accessor :generate_client_request_id
43
+
44
+ # @return [Operations] operations
45
+ attr_reader :operations
46
+
47
+ # @return [Skus] skus
48
+ attr_reader :skus
49
+
50
+ # @return [UsageModels] usage_models
51
+ attr_reader :usage_models
52
+
53
+ # @return [Caches] caches
54
+ attr_reader :caches
55
+
56
+ # @return [StorageTargets] storage_targets
57
+ attr_reader :storage_targets
58
+
59
+ #
60
+ # Creates initializes a new instance of the StorageCacheManagementClient class.
61
+ # @param credentials [MsRest::ServiceClientCredentials] credentials to authorize HTTP requests made by the service client.
62
+ # @param base_url [String] the base URI of the service.
63
+ # @param options [Array] filters to be applied to the HTTP requests.
64
+ #
65
+ def initialize(credentials = nil, base_url = nil, options = nil)
66
+ super(credentials, options)
67
+ @base_url = base_url || 'https://management.azure.com/'
68
+
69
+ fail ArgumentError, 'invalid type of credentials input parameter' unless credentials.is_a?(MsRest::ServiceClientCredentials) unless credentials.nil?
70
+ @credentials = credentials
71
+
72
+ @operations = Operations.new(self)
73
+ @skus = Skus.new(self)
74
+ @usage_models = UsageModels.new(self)
75
+ @caches = Caches.new(self)
76
+ @storage_targets = StorageTargets.new(self)
77
+ @api_version = '2020-03-01'
78
+ @accept_language = 'en-US'
79
+ @long_running_operation_retry_timeout = 30
80
+ @generate_client_request_id = true
81
+ add_telemetry
82
+ end
83
+
84
+ #
85
+ # Makes a request and returns the body of the response.
86
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
87
+ # @param path [String] the path, relative to {base_url}.
88
+ # @param options [Hash{String=>String}] specifying any request options like :body.
89
+ # @return [Hash{String=>String}] containing the body of the response.
90
+ # Example:
91
+ #
92
+ # request_content = "{'location':'westus','tags':{'tag1':'val1','tag2':'val2'}}"
93
+ # path = "/path"
94
+ # options = {
95
+ # body: request_content,
96
+ # query_params: {'api-version' => '2016-02-01'}
97
+ # }
98
+ # result = @client.make_request(:put, path, options)
99
+ #
100
+ def make_request(method, path, options = {})
101
+ result = make_request_with_http_info(method, path, options)
102
+ result.body unless result.nil?
103
+ end
104
+
105
+ #
106
+ # Makes a request and returns the operation response.
107
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
108
+ # @param path [String] the path, relative to {base_url}.
109
+ # @param options [Hash{String=>String}] specifying any request options like :body.
110
+ # @return [MsRestAzure::AzureOperationResponse] Operation response containing the request, response and status.
111
+ #
112
+ def make_request_with_http_info(method, path, options = {})
113
+ result = make_request_async(method, path, options).value!
114
+ result.body = result.response.body.to_s.empty? ? nil : JSON.load(result.response.body)
115
+ result
116
+ end
117
+
118
+ #
119
+ # Makes a request asynchronously.
120
+ # @param method [Symbol] with any of the following values :get, :put, :post, :patch, :delete.
121
+ # @param path [String] the path, relative to {base_url}.
122
+ # @param options [Hash{String=>String}] specifying any request options like :body.
123
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
124
+ #
125
+ def make_request_async(method, path, options = {})
126
+ fail ArgumentError, 'method is nil' if method.nil?
127
+ fail ArgumentError, 'path is nil' if path.nil?
128
+
129
+ request_url = options[:base_url] || @base_url
130
+ if(!options[:headers].nil? && !options[:headers]['Content-Type'].nil?)
131
+ @request_headers['Content-Type'] = options[:headers]['Content-Type']
132
+ end
133
+
134
+ request_headers = @request_headers
135
+ request_headers.merge!({'accept-language' => @accept_language}) unless @accept_language.nil?
136
+ options.merge!({headers: request_headers.merge(options[:headers] || {})})
137
+ options.merge!({credentials: @credentials}) unless @credentials.nil?
138
+
139
+ super(request_url, method, path, options)
140
+ end
141
+
142
+
143
+ private
144
+ #
145
+ # Adds telemetry information.
146
+ #
147
+ def add_telemetry
148
+ sdk_information = 'azure_mgmt_storagecache'
149
+ sdk_information = "#{sdk_information}/0.18.0"
150
+ add_user_agent_information(sdk_information)
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,703 @@
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::StorageCache::Mgmt::V2020_03_01
7
+ #
8
+ # A Storage Cache provides scalable caching service for NAS clients, serving
9
+ # data from either NFSv3 or Blob at-rest storage (referred to as "Storage
10
+ # Targets"). These operations allow you to manage Caches.
11
+ #
12
+ class StorageTargets
13
+ include MsRestAzure
14
+
15
+ #
16
+ # Creates and initializes a new instance of the StorageTargets class.
17
+ # @param client service class for accessing basic functionality.
18
+ #
19
+ def initialize(client)
20
+ @client = client
21
+ end
22
+
23
+ # @return [StorageCacheManagementClient] reference to the StorageCacheManagementClient
24
+ attr_reader :client
25
+
26
+ #
27
+ # Returns a list of Storage Targets for the specified Cache.
28
+ #
29
+ # @param resource_group_name [String] Target resource group.
30
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
31
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
32
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
33
+ # will be added to the HTTP request.
34
+ #
35
+ # @return [Array<StorageTarget>] operation results.
36
+ #
37
+ def list_by_cache(resource_group_name, cache_name, custom_headers:nil)
38
+ first_page = list_by_cache_as_lazy(resource_group_name, cache_name, custom_headers:custom_headers)
39
+ first_page.get_all_items
40
+ end
41
+
42
+ #
43
+ # Returns a list of Storage Targets for the specified Cache.
44
+ #
45
+ # @param resource_group_name [String] Target resource group.
46
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
47
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
48
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
49
+ # will be added to the HTTP request.
50
+ #
51
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
52
+ #
53
+ def list_by_cache_with_http_info(resource_group_name, cache_name, custom_headers:nil)
54
+ list_by_cache_async(resource_group_name, cache_name, custom_headers:custom_headers).value!
55
+ end
56
+
57
+ #
58
+ # Returns a list of Storage Targets for the specified Cache.
59
+ #
60
+ # @param resource_group_name [String] Target resource group.
61
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
62
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
63
+ # @param [Hash{String => String}] A hash of custom headers that will be added
64
+ # to the HTTP request.
65
+ #
66
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
67
+ #
68
+ def list_by_cache_async(resource_group_name, cache_name, custom_headers:nil)
69
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
70
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
71
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
72
+ fail ArgumentError, 'cache_name is nil' if cache_name.nil?
73
+ fail ArgumentError, "'cache_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !cache_name.nil? && cache_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
74
+
75
+
76
+ request_headers = {}
77
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
78
+
79
+ # Set Headers
80
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
81
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
82
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets'
83
+
84
+ request_url = @base_url || @client.base_url
85
+
86
+ options = {
87
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
88
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id,'cacheName' => cache_name},
89
+ query_params: {'api-version' => @client.api_version},
90
+ headers: request_headers.merge(custom_headers || {}),
91
+ base_url: request_url
92
+ }
93
+ promise = @client.make_request_async(:get, path_template, options)
94
+
95
+ promise = promise.then do |result|
96
+ http_response = result.response
97
+ status_code = http_response.status
98
+ response_content = http_response.body
99
+ unless status_code == 200
100
+ error_model = JSON.load(response_content)
101
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
102
+ end
103
+
104
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
105
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
106
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
107
+ # Deserialize Response
108
+ if status_code == 200
109
+ begin
110
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
111
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTargetsResult.mapper()
112
+ result.body = @client.deserialize(result_mapper, parsed_response)
113
+ rescue Exception => e
114
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
115
+ end
116
+ end
117
+
118
+ result
119
+ end
120
+
121
+ promise.execute
122
+ end
123
+
124
+ #
125
+ # Removes a Storage Target from a Cache. This operation is allowed at any time,
126
+ # but if the Cache is down or unhealthy, the actual removal of the Storage
127
+ # Target may be delayed until the Cache is healthy again. Note that if the
128
+ # Cache has data to flush to the Storage Target, the data will be flushed
129
+ # before the Storage Target will be deleted.
130
+ #
131
+ # @param resource_group_name [String] Target resource group.
132
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
133
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
134
+ # @param storage_target_name [String] Name of Storage Target.
135
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
136
+ # will be added to the HTTP request.
137
+ #
138
+ # @return [Object] operation results.
139
+ #
140
+ def delete(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
141
+ response = delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers).value!
142
+ response.body unless response.nil?
143
+ end
144
+
145
+ #
146
+ # @param resource_group_name [String] Target resource group.
147
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
148
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
149
+ # @param storage_target_name [String] Name of Storage Target.
150
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
151
+ # will be added to the HTTP request.
152
+ #
153
+ # @return [Concurrent::Promise] promise which provides async access to http
154
+ # response.
155
+ #
156
+ def delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
157
+ # Send request
158
+ promise = begin_delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers)
159
+
160
+ promise = promise.then do |response|
161
+ # Defining deserialization method.
162
+ deserialize_method = lambda do |parsed_response|
163
+ result_mapper = {
164
+ client_side_validation: true,
165
+ required: false,
166
+ serialized_name: 'parsed_response',
167
+ type: {
168
+ name: 'Object'
169
+ }
170
+ }
171
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
172
+ end
173
+
174
+ # Waiting for response.
175
+ @client.get_long_running_operation_result(response, deserialize_method)
176
+ end
177
+
178
+ promise
179
+ end
180
+
181
+ #
182
+ # Returns a Storage Target from a Cache.
183
+ #
184
+ # @param resource_group_name [String] Target resource group.
185
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
186
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
187
+ # @param storage_target_name [String] Name of the Storage Target. Length of
188
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
189
+ # char class.
190
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
191
+ # will be added to the HTTP request.
192
+ #
193
+ # @return [StorageTarget] operation results.
194
+ #
195
+ def get(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
196
+ response = get_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers).value!
197
+ response.body unless response.nil?
198
+ end
199
+
200
+ #
201
+ # Returns a Storage Target from a Cache.
202
+ #
203
+ # @param resource_group_name [String] Target resource group.
204
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
205
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
206
+ # @param storage_target_name [String] Name of the Storage Target. Length of
207
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
208
+ # char class.
209
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
210
+ # will be added to the HTTP request.
211
+ #
212
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
213
+ #
214
+ def get_with_http_info(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
215
+ get_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers).value!
216
+ end
217
+
218
+ #
219
+ # Returns a Storage Target from a Cache.
220
+ #
221
+ # @param resource_group_name [String] Target resource group.
222
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
223
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
224
+ # @param storage_target_name [String] Name of the Storage Target. Length of
225
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
226
+ # char class.
227
+ # @param [Hash{String => String}] A hash of custom headers that will be added
228
+ # to the HTTP request.
229
+ #
230
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
231
+ #
232
+ def get_async(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
233
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
234
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
235
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
236
+ fail ArgumentError, 'cache_name is nil' if cache_name.nil?
237
+ fail ArgumentError, "'cache_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !cache_name.nil? && cache_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
238
+ fail ArgumentError, 'storage_target_name is nil' if storage_target_name.nil?
239
+ fail ArgumentError, "'storage_target_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !storage_target_name.nil? && storage_target_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
240
+
241
+
242
+ request_headers = {}
243
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
244
+
245
+ # Set Headers
246
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
247
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
248
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'
249
+
250
+ request_url = @base_url || @client.base_url
251
+
252
+ options = {
253
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
254
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id,'cacheName' => cache_name,'storageTargetName' => storage_target_name},
255
+ query_params: {'api-version' => @client.api_version},
256
+ headers: request_headers.merge(custom_headers || {}),
257
+ base_url: request_url
258
+ }
259
+ promise = @client.make_request_async(:get, path_template, options)
260
+
261
+ promise = promise.then do |result|
262
+ http_response = result.response
263
+ status_code = http_response.status
264
+ response_content = http_response.body
265
+ unless status_code == 200
266
+ error_model = JSON.load(response_content)
267
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
268
+ end
269
+
270
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
271
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
272
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
273
+ # Deserialize Response
274
+ if status_code == 200
275
+ begin
276
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
277
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTarget.mapper()
278
+ result.body = @client.deserialize(result_mapper, parsed_response)
279
+ rescue Exception => e
280
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
281
+ end
282
+ end
283
+
284
+ result
285
+ end
286
+
287
+ promise.execute
288
+ end
289
+
290
+ #
291
+ # Create or update a Storage Target. This operation is allowed at any time, but
292
+ # if the Cache is down or unhealthy, the actual creation/modification of the
293
+ # Storage Target may be delayed until the Cache is healthy again.
294
+ #
295
+ # @param resource_group_name [String] Target resource group.
296
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
297
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
298
+ # @param storage_target_name [String] Name of the Storage Target. Length of
299
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
300
+ # char class.
301
+ # @param storagetarget [StorageTarget] Object containing the definition of a
302
+ # Storage Target.
303
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
304
+ # will be added to the HTTP request.
305
+ #
306
+ # @return [StorageTarget] operation results.
307
+ #
308
+ def create_or_update(resource_group_name, cache_name, storage_target_name, storagetarget:nil, custom_headers:nil)
309
+ response = create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:storagetarget, custom_headers:custom_headers).value!
310
+ response.body unless response.nil?
311
+ end
312
+
313
+ #
314
+ # @param resource_group_name [String] Target resource group.
315
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
316
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
317
+ # @param storage_target_name [String] Name of the Storage Target. Length of
318
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
319
+ # char class.
320
+ # @param storagetarget [StorageTarget] Object containing the definition of a
321
+ # Storage Target.
322
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
323
+ # will be added to the HTTP request.
324
+ #
325
+ # @return [Concurrent::Promise] promise which provides async access to http
326
+ # response.
327
+ #
328
+ def create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:nil, custom_headers:nil)
329
+ # Send request
330
+ promise = begin_create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:storagetarget, custom_headers:custom_headers)
331
+
332
+ promise = promise.then do |response|
333
+ # Defining deserialization method.
334
+ deserialize_method = lambda do |parsed_response|
335
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTarget.mapper()
336
+ parsed_response = @client.deserialize(result_mapper, parsed_response)
337
+ end
338
+
339
+ # Waiting for response.
340
+ @client.get_long_running_operation_result(response, deserialize_method)
341
+ end
342
+
343
+ promise
344
+ end
345
+
346
+ #
347
+ # Removes a Storage Target from a Cache. This operation is allowed at any time,
348
+ # but if the Cache is down or unhealthy, the actual removal of the Storage
349
+ # Target may be delayed until the Cache is healthy again. Note that if the
350
+ # Cache has data to flush to the Storage Target, the data will be flushed
351
+ # before the Storage Target will be deleted.
352
+ #
353
+ # @param resource_group_name [String] Target resource group.
354
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
355
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
356
+ # @param storage_target_name [String] Name of Storage Target.
357
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
358
+ # will be added to the HTTP request.
359
+ #
360
+ # @return [Object] operation results.
361
+ #
362
+ def begin_delete(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
363
+ response = begin_delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers).value!
364
+ response.body unless response.nil?
365
+ end
366
+
367
+ #
368
+ # Removes a Storage Target from a Cache. This operation is allowed at any time,
369
+ # but if the Cache is down or unhealthy, the actual removal of the Storage
370
+ # Target may be delayed until the Cache is healthy again. Note that if the
371
+ # Cache has data to flush to the Storage Target, the data will be flushed
372
+ # before the Storage Target will be deleted.
373
+ #
374
+ # @param resource_group_name [String] Target resource group.
375
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
376
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
377
+ # @param storage_target_name [String] Name of Storage Target.
378
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
379
+ # will be added to the HTTP request.
380
+ #
381
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
382
+ #
383
+ def begin_delete_with_http_info(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
384
+ begin_delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:custom_headers).value!
385
+ end
386
+
387
+ #
388
+ # Removes a Storage Target from a Cache. This operation is allowed at any time,
389
+ # but if the Cache is down or unhealthy, the actual removal of the Storage
390
+ # Target may be delayed until the Cache is healthy again. Note that if the
391
+ # Cache has data to flush to the Storage Target, the data will be flushed
392
+ # before the Storage Target will be deleted.
393
+ #
394
+ # @param resource_group_name [String] Target resource group.
395
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
396
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
397
+ # @param storage_target_name [String] Name of Storage Target.
398
+ # @param [Hash{String => String}] A hash of custom headers that will be added
399
+ # to the HTTP request.
400
+ #
401
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
402
+ #
403
+ def begin_delete_async(resource_group_name, cache_name, storage_target_name, custom_headers:nil)
404
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
405
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
406
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
407
+ fail ArgumentError, 'cache_name is nil' if cache_name.nil?
408
+ fail ArgumentError, "'cache_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !cache_name.nil? && cache_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
409
+ fail ArgumentError, 'storage_target_name is nil' if storage_target_name.nil?
410
+ fail ArgumentError, "'storage_target_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !storage_target_name.nil? && storage_target_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
411
+
412
+
413
+ request_headers = {}
414
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
415
+
416
+ # Set Headers
417
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
418
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
419
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'
420
+
421
+ request_url = @base_url || @client.base_url
422
+
423
+ options = {
424
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
425
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id,'cacheName' => cache_name,'storageTargetName' => storage_target_name},
426
+ query_params: {'api-version' => @client.api_version},
427
+ headers: request_headers.merge(custom_headers || {}),
428
+ base_url: request_url
429
+ }
430
+ promise = @client.make_request_async(:delete, path_template, options)
431
+
432
+ promise = promise.then do |result|
433
+ http_response = result.response
434
+ status_code = http_response.status
435
+ response_content = http_response.body
436
+ unless status_code == 200 || status_code == 202 || status_code == 204
437
+ error_model = JSON.load(response_content)
438
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
439
+ end
440
+
441
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
442
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
443
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
444
+
445
+ result
446
+ end
447
+
448
+ promise.execute
449
+ end
450
+
451
+ #
452
+ # Create or update a Storage Target. This operation is allowed at any time, but
453
+ # if the Cache is down or unhealthy, the actual creation/modification of the
454
+ # Storage Target may be delayed until the Cache is healthy again.
455
+ #
456
+ # @param resource_group_name [String] Target resource group.
457
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
458
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
459
+ # @param storage_target_name [String] Name of the Storage Target. Length of
460
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
461
+ # char class.
462
+ # @param storagetarget [StorageTarget] Object containing the definition of a
463
+ # Storage Target.
464
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
465
+ # will be added to the HTTP request.
466
+ #
467
+ # @return [StorageTarget] operation results.
468
+ #
469
+ def begin_create_or_update(resource_group_name, cache_name, storage_target_name, storagetarget:nil, custom_headers:nil)
470
+ response = begin_create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:storagetarget, custom_headers:custom_headers).value!
471
+ response.body unless response.nil?
472
+ end
473
+
474
+ #
475
+ # Create or update a Storage Target. This operation is allowed at any time, but
476
+ # if the Cache is down or unhealthy, the actual creation/modification of the
477
+ # Storage Target may be delayed until the Cache is healthy again.
478
+ #
479
+ # @param resource_group_name [String] Target resource group.
480
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
481
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
482
+ # @param storage_target_name [String] Name of the Storage Target. Length of
483
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
484
+ # char class.
485
+ # @param storagetarget [StorageTarget] Object containing the definition of a
486
+ # Storage Target.
487
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
488
+ # will be added to the HTTP request.
489
+ #
490
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
491
+ #
492
+ def begin_create_or_update_with_http_info(resource_group_name, cache_name, storage_target_name, storagetarget:nil, custom_headers:nil)
493
+ begin_create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:storagetarget, custom_headers:custom_headers).value!
494
+ end
495
+
496
+ #
497
+ # Create or update a Storage Target. This operation is allowed at any time, but
498
+ # if the Cache is down or unhealthy, the actual creation/modification of the
499
+ # Storage Target may be delayed until the Cache is healthy again.
500
+ #
501
+ # @param resource_group_name [String] Target resource group.
502
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
503
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
504
+ # @param storage_target_name [String] Name of the Storage Target. Length of
505
+ # name must be not greater than 80 and chars must be in list of [-0-9a-zA-Z_]
506
+ # char class.
507
+ # @param storagetarget [StorageTarget] Object containing the definition of a
508
+ # Storage Target.
509
+ # @param [Hash{String => String}] A hash of custom headers that will be added
510
+ # to the HTTP request.
511
+ #
512
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
513
+ #
514
+ def begin_create_or_update_async(resource_group_name, cache_name, storage_target_name, storagetarget:nil, custom_headers:nil)
515
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
516
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
517
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
518
+ fail ArgumentError, 'cache_name is nil' if cache_name.nil?
519
+ fail ArgumentError, "'cache_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !cache_name.nil? && cache_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
520
+ fail ArgumentError, 'storage_target_name is nil' if storage_target_name.nil?
521
+ fail ArgumentError, "'storage_target_name' should satisfy the constraint - 'Pattern': '^[-0-9a-zA-Z_]{1,80}$'" if !storage_target_name.nil? && storage_target_name.match(Regexp.new('^^[-0-9a-zA-Z_]{1,80}$$')).nil?
522
+
523
+
524
+ request_headers = {}
525
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
526
+
527
+ # Set Headers
528
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
529
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
530
+
531
+ # Serialize Request
532
+ request_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTarget.mapper()
533
+ request_content = @client.serialize(request_mapper, storagetarget)
534
+ request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
535
+
536
+ path_template = 'subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.StorageCache/caches/{cacheName}/storageTargets/{storageTargetName}'
537
+
538
+ request_url = @base_url || @client.base_url
539
+
540
+ options = {
541
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
542
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id,'cacheName' => cache_name,'storageTargetName' => storage_target_name},
543
+ query_params: {'api-version' => @client.api_version},
544
+ body: request_content,
545
+ headers: request_headers.merge(custom_headers || {}),
546
+ base_url: request_url
547
+ }
548
+ promise = @client.make_request_async(:put, path_template, options)
549
+
550
+ promise = promise.then do |result|
551
+ http_response = result.response
552
+ status_code = http_response.status
553
+ response_content = http_response.body
554
+ unless status_code == 200 || status_code == 201
555
+ error_model = JSON.load(response_content)
556
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
557
+ end
558
+
559
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
560
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
561
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
562
+ # Deserialize Response
563
+ if status_code == 200
564
+ begin
565
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
566
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTarget.mapper()
567
+ result.body = @client.deserialize(result_mapper, parsed_response)
568
+ rescue Exception => e
569
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
570
+ end
571
+ end
572
+ # Deserialize Response
573
+ if status_code == 201
574
+ begin
575
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
576
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTarget.mapper()
577
+ result.body = @client.deserialize(result_mapper, parsed_response)
578
+ rescue Exception => e
579
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
580
+ end
581
+ end
582
+
583
+ result
584
+ end
585
+
586
+ promise.execute
587
+ end
588
+
589
+ #
590
+ # Returns a list of Storage Targets for the specified Cache.
591
+ #
592
+ # @param next_page_link [String] The NextLink from the previous successful call
593
+ # to List operation.
594
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
595
+ # will be added to the HTTP request.
596
+ #
597
+ # @return [StorageTargetsResult] operation results.
598
+ #
599
+ def list_by_cache_next(next_page_link, custom_headers:nil)
600
+ response = list_by_cache_next_async(next_page_link, custom_headers:custom_headers).value!
601
+ response.body unless response.nil?
602
+ end
603
+
604
+ #
605
+ # Returns a list of Storage Targets for the specified Cache.
606
+ #
607
+ # @param next_page_link [String] The NextLink from the previous successful call
608
+ # to List operation.
609
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
610
+ # will be added to the HTTP request.
611
+ #
612
+ # @return [MsRestAzure::AzureOperationResponse] HTTP response information.
613
+ #
614
+ def list_by_cache_next_with_http_info(next_page_link, custom_headers:nil)
615
+ list_by_cache_next_async(next_page_link, custom_headers:custom_headers).value!
616
+ end
617
+
618
+ #
619
+ # Returns a list of Storage Targets for the specified Cache.
620
+ #
621
+ # @param next_page_link [String] The NextLink from the previous successful call
622
+ # to List operation.
623
+ # @param [Hash{String => String}] A hash of custom headers that will be added
624
+ # to the HTTP request.
625
+ #
626
+ # @return [Concurrent::Promise] Promise object which holds the HTTP response.
627
+ #
628
+ def list_by_cache_next_async(next_page_link, custom_headers:nil)
629
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
630
+
631
+
632
+ request_headers = {}
633
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
634
+
635
+ # Set Headers
636
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
637
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
638
+ path_template = '{nextLink}'
639
+
640
+ request_url = @base_url || @client.base_url
641
+
642
+ options = {
643
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
644
+ skip_encoding_path_params: {'nextLink' => next_page_link},
645
+ headers: request_headers.merge(custom_headers || {}),
646
+ base_url: request_url
647
+ }
648
+ promise = @client.make_request_async(:get, path_template, options)
649
+
650
+ promise = promise.then do |result|
651
+ http_response = result.response
652
+ status_code = http_response.status
653
+ response_content = http_response.body
654
+ unless status_code == 200
655
+ error_model = JSON.load(response_content)
656
+ fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
657
+ end
658
+
659
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
660
+ result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
661
+ result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
662
+ # Deserialize Response
663
+ if status_code == 200
664
+ begin
665
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
666
+ result_mapper = Azure::StorageCache::Mgmt::V2020_03_01::Models::StorageTargetsResult.mapper()
667
+ result.body = @client.deserialize(result_mapper, parsed_response)
668
+ rescue Exception => e
669
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
670
+ end
671
+ end
672
+
673
+ result
674
+ end
675
+
676
+ promise.execute
677
+ end
678
+
679
+ #
680
+ # Returns a list of Storage Targets for the specified Cache.
681
+ #
682
+ # @param resource_group_name [String] Target resource group.
683
+ # @param cache_name [String] Name of Cache. Length of name must be not greater
684
+ # than 80 and chars must be in list of [-0-9a-zA-Z_] char class.
685
+ # @param custom_headers [Hash{String => String}] A hash of custom headers that
686
+ # will be added to the HTTP request.
687
+ #
688
+ # @return [StorageTargetsResult] which provide lazy access to pages of the
689
+ # response.
690
+ #
691
+ def list_by_cache_as_lazy(resource_group_name, cache_name, custom_headers:nil)
692
+ response = list_by_cache_async(resource_group_name, cache_name, custom_headers:custom_headers).value!
693
+ unless response.nil?
694
+ page = response.body
695
+ page.next_method = Proc.new do |next_page_link|
696
+ list_by_cache_next_async(next_page_link, custom_headers:custom_headers)
697
+ end
698
+ page
699
+ end
700
+ end
701
+
702
+ end
703
+ end