azure_mgmt_storagecache 0.17.0

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