azure_mgmt_redis 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # Specifies which redis access keys to reset.
10
+ #
11
+ class RedisRegenerateKeyParameters
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [RedisKeyType] Which redis access key to reset. Possible
16
+ # values include: 'Primary', 'Secondary'
17
+ attr_accessor :key_type
18
+
19
+ #
20
+ # Validate the object. Throws ValidationError if validation fails.
21
+ #
22
+ def validate
23
+ fail MsRest::ValidationError, 'property key_type is nil' if @key_type.nil?
24
+ end
25
+
26
+ #
27
+ # Serializes given Model object into Ruby Hash.
28
+ # @param object Model object to serialize.
29
+ # @return [Hash] Serialized object in form of Ruby Hash.
30
+ #
31
+ def self.serialize_object(object)
32
+ object.validate
33
+ output_object = {}
34
+
35
+ serialized_property = object.key_type
36
+ output_object['keyType'] = serialized_property unless serialized_property.nil?
37
+
38
+ output_object
39
+ end
40
+
41
+ #
42
+ # Deserializes given Ruby Hash into Model object.
43
+ # @param object [Hash] Ruby Hash object to deserialize.
44
+ # @return [RedisRegenerateKeyParameters] Deserialized object.
45
+ #
46
+ def self.deserialize_object(object)
47
+ return if object.nil?
48
+ output_object = RedisRegenerateKeyParameters.new
49
+
50
+ deserialized_property = object['keyType']
51
+ if (!deserialized_property.nil? && !deserialized_property.empty?)
52
+ enum_is_valid = RedisKeyType.constants.any? { |e| RedisKeyType.const_get(e).to_s.downcase == deserialized_property.downcase }
53
+ warn 'Enum RedisKeyType does not contain ' + deserialized_property.downcase + ', but was received from the server.' unless enum_is_valid
54
+ end
55
+ output_object.key_type = deserialized_property
56
+
57
+ output_object
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # A single redis item in List or Get Operation.
10
+ #
11
+ class RedisResource < MsRestAzure::Resource
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [RedisReadableProperties] Redis cache properties
16
+ attr_accessor :properties
17
+
18
+ #
19
+ # Validate the object. Throws ValidationError if validation fails.
20
+ #
21
+ def validate
22
+ @properties.validate unless @properties.nil?
23
+ end
24
+
25
+ #
26
+ # Serializes given Model object into Ruby Hash.
27
+ # @param object Model object to serialize.
28
+ # @return [Hash] Serialized object in form of Ruby Hash.
29
+ #
30
+ def self.serialize_object(object)
31
+ object.validate
32
+ output_object = {}
33
+
34
+ serialized_property = object.location
35
+ output_object['location'] = serialized_property unless serialized_property.nil?
36
+
37
+ serialized_property = object.id
38
+ output_object['id'] = serialized_property unless serialized_property.nil?
39
+
40
+ serialized_property = object.name
41
+ output_object['name'] = serialized_property unless serialized_property.nil?
42
+
43
+ serialized_property = object.type
44
+ output_object['type'] = serialized_property unless serialized_property.nil?
45
+
46
+ serialized_property = object.tags
47
+ output_object['tags'] = serialized_property unless serialized_property.nil?
48
+
49
+ serialized_property = object.properties
50
+ unless serialized_property.nil?
51
+ serialized_property = RedisReadableProperties.serialize_object(serialized_property)
52
+ end
53
+ output_object['properties'] = serialized_property unless serialized_property.nil?
54
+
55
+ output_object
56
+ end
57
+
58
+ #
59
+ # Deserializes given Ruby Hash into Model object.
60
+ # @param object [Hash] Ruby Hash object to deserialize.
61
+ # @return [RedisResource] Deserialized object.
62
+ #
63
+ def self.deserialize_object(object)
64
+ return if object.nil?
65
+ output_object = RedisResource.new
66
+
67
+ deserialized_property = object['location']
68
+ output_object.location = deserialized_property
69
+
70
+ deserialized_property = object['id']
71
+ output_object.id = deserialized_property
72
+
73
+ deserialized_property = object['name']
74
+ output_object.name = deserialized_property
75
+
76
+ deserialized_property = object['type']
77
+ output_object.type = deserialized_property
78
+
79
+ deserialized_property = object['tags']
80
+ output_object.tags = deserialized_property
81
+
82
+ deserialized_property = object['properties']
83
+ unless deserialized_property.nil?
84
+ deserialized_property = RedisReadableProperties.deserialize_object(deserialized_property)
85
+ end
86
+ output_object.properties = deserialized_property
87
+
88
+ output_object
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,92 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # A redis item in CreateOrUpdate Operation response.
10
+ #
11
+ class RedisResourceWithAccessKey < MsRestAzure::Resource
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [RedisReadablePropertiesWithAccessKey] Redis cache properties
16
+ attr_accessor :properties
17
+
18
+ #
19
+ # Validate the object. Throws ValidationError if validation fails.
20
+ #
21
+ def validate
22
+ @properties.validate unless @properties.nil?
23
+ end
24
+
25
+ #
26
+ # Serializes given Model object into Ruby Hash.
27
+ # @param object Model object to serialize.
28
+ # @return [Hash] Serialized object in form of Ruby Hash.
29
+ #
30
+ def self.serialize_object(object)
31
+ object.validate
32
+ output_object = {}
33
+
34
+ serialized_property = object.location
35
+ output_object['location'] = serialized_property unless serialized_property.nil?
36
+
37
+ serialized_property = object.id
38
+ output_object['id'] = serialized_property unless serialized_property.nil?
39
+
40
+ serialized_property = object.name
41
+ output_object['name'] = serialized_property unless serialized_property.nil?
42
+
43
+ serialized_property = object.type
44
+ output_object['type'] = serialized_property unless serialized_property.nil?
45
+
46
+ serialized_property = object.tags
47
+ output_object['tags'] = serialized_property unless serialized_property.nil?
48
+
49
+ serialized_property = object.properties
50
+ unless serialized_property.nil?
51
+ serialized_property = RedisReadablePropertiesWithAccessKey.serialize_object(serialized_property)
52
+ end
53
+ output_object['properties'] = serialized_property unless serialized_property.nil?
54
+
55
+ output_object
56
+ end
57
+
58
+ #
59
+ # Deserializes given Ruby Hash into Model object.
60
+ # @param object [Hash] Ruby Hash object to deserialize.
61
+ # @return [RedisResourceWithAccessKey] Deserialized object.
62
+ #
63
+ def self.deserialize_object(object)
64
+ return if object.nil?
65
+ output_object = RedisResourceWithAccessKey.new
66
+
67
+ deserialized_property = object['location']
68
+ output_object.location = deserialized_property
69
+
70
+ deserialized_property = object['id']
71
+ output_object.id = deserialized_property
72
+
73
+ deserialized_property = object['name']
74
+ output_object.name = deserialized_property
75
+
76
+ deserialized_property = object['type']
77
+ output_object.type = deserialized_property
78
+
79
+ deserialized_property = object['tags']
80
+ output_object.tags = deserialized_property
81
+
82
+ deserialized_property = object['properties']
83
+ unless deserialized_property.nil?
84
+ deserialized_property = RedisReadablePropertiesWithAccessKey.deserialize_object(deserialized_property)
85
+ end
86
+ output_object.properties = deserialized_property
87
+
88
+ output_object
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,89 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # Sku parameters supplied to the create redis operation.
10
+ #
11
+ class Sku
12
+
13
+ include MsRestAzure
14
+
15
+ # @return [SkuName] What type of redis cache to deploy. Valid values:
16
+ # (Basic, Standard, Premium). Possible values include: 'Basic',
17
+ # 'Standard', 'Premium'
18
+ attr_accessor :name
19
+
20
+ # @return [SkuFamily] Which family to use. Valid values: (C, P).
21
+ # Possible values include: 'C', 'P'
22
+ attr_accessor :family
23
+
24
+ # @return [Integer] What size of redis cache to deploy. Valid values:
25
+ # for C family (0, 1, 2, 3, 4, 5, 6), for P family (1, 2, 3, 4)
26
+ attr_accessor :capacity
27
+
28
+ #
29
+ # Validate the object. Throws ValidationError if validation fails.
30
+ #
31
+ def validate
32
+ fail MsRest::ValidationError, 'property name is nil' if @name.nil?
33
+ fail MsRest::ValidationError, 'property family is nil' if @family.nil?
34
+ fail MsRest::ValidationError, 'property capacity is nil' if @capacity.nil?
35
+ end
36
+
37
+ #
38
+ # Serializes given Model object into Ruby Hash.
39
+ # @param object Model object to serialize.
40
+ # @return [Hash] Serialized object in form of Ruby Hash.
41
+ #
42
+ def self.serialize_object(object)
43
+ object.validate
44
+ output_object = {}
45
+
46
+ serialized_property = object.name
47
+ output_object['name'] = serialized_property unless serialized_property.nil?
48
+
49
+ serialized_property = object.family
50
+ output_object['family'] = serialized_property unless serialized_property.nil?
51
+
52
+ serialized_property = object.capacity
53
+ output_object['capacity'] = serialized_property unless serialized_property.nil?
54
+
55
+ output_object
56
+ end
57
+
58
+ #
59
+ # Deserializes given Ruby Hash into Model object.
60
+ # @param object [Hash] Ruby Hash object to deserialize.
61
+ # @return [Sku] Deserialized object.
62
+ #
63
+ def self.deserialize_object(object)
64
+ return if object.nil?
65
+ output_object = Sku.new
66
+
67
+ deserialized_property = object['name']
68
+ if (!deserialized_property.nil? && !deserialized_property.empty?)
69
+ enum_is_valid = SkuName.constants.any? { |e| SkuName.const_get(e).to_s.downcase == deserialized_property.downcase }
70
+ warn 'Enum SkuName does not contain ' + deserialized_property.downcase + ', but was received from the server.' unless enum_is_valid
71
+ end
72
+ output_object.name = deserialized_property
73
+
74
+ deserialized_property = object['family']
75
+ if (!deserialized_property.nil? && !deserialized_property.empty?)
76
+ enum_is_valid = SkuFamily.constants.any? { |e| SkuFamily.const_get(e).to_s.downcase == deserialized_property.downcase }
77
+ warn 'Enum SkuFamily does not contain ' + deserialized_property.downcase + ', but was received from the server.' unless enum_is_valid
78
+ end
79
+ output_object.family = deserialized_property
80
+
81
+ deserialized_property = object['capacity']
82
+ deserialized_property = Integer(deserialized_property) unless deserialized_property.to_s.empty?
83
+ output_object.capacity = deserialized_property
84
+
85
+ output_object
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # Defines values for SkuFamily
10
+ #
11
+ module SkuFamily
12
+ C = "C"
13
+ P = "P"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ module Models
8
+ #
9
+ # Defines values for SkuName
10
+ #
11
+ module SkuName
12
+ Basic = "Basic"
13
+ Standard = "Standard"
14
+ Premium = "Premium"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure end
7
+ module Azure::ARM end
8
+ module Azure::ARM::Redis end
@@ -0,0 +1,607 @@
1
+ # encoding: utf-8
2
+ # Code generated by Microsoft (R) AutoRest Code Generator 0.16.0.0
3
+ # Changes may cause incorrect behavior and will be lost if the code is
4
+ # regenerated.
5
+
6
+ module Azure::ARM::Redis
7
+ #
8
+ # .Net client wrapper for the REST API for Azure Redis Cache Management
9
+ # Service
10
+ #
11
+ class Redis
12
+ include Azure::ARM::Redis::Models
13
+ include MsRestAzure
14
+
15
+ #
16
+ # Creates and initializes a new instance of the Redis class.
17
+ # @param client service class for accessing basic functionality.
18
+ #
19
+ def initialize(client)
20
+ @client = client
21
+ end
22
+
23
+ # @return reference to the RedisManagementClient
24
+ attr_reader :client
25
+
26
+ #
27
+ # Create a redis cache, or replace (overwrite/recreate, with potential
28
+ # downtime) an existing cache
29
+ #
30
+ # @param resource_group_name [String] The name of the resource group.
31
+ # @param name [String] The name of the redis cache.
32
+ # @param parameters [RedisCreateOrUpdateParameters] Parameters supplied to the
33
+ # CreateOrUpdate redis operation.
34
+ # @param [Hash{String => String}] The hash of custom headers need to be
35
+ # applied to HTTP request.
36
+ #
37
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
38
+ # response.
39
+ #
40
+ def create_or_update(resource_group_name, name, parameters, custom_headers = nil)
41
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
42
+ fail ArgumentError, 'name is nil' if name.nil?
43
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
44
+ parameters.validate unless parameters.nil?
45
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
46
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
47
+ request_headers = {}
48
+
49
+ # Set Headers
50
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
51
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
52
+
53
+ # Serialize Request
54
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
55
+ unless parameters.nil?
56
+ parameters = RedisCreateOrUpdateParameters.serialize_object(parameters)
57
+ end
58
+ request_content = JSON.generate(parameters, quirks_mode: true)
59
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}'
60
+ options = {
61
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
62
+ path_params: {'resourceGroupName' => resource_group_name,'name' => name,'subscriptionId' => @client.subscription_id},
63
+ query_params: {'api-version' => @client.api_version},
64
+ body: request_content,
65
+ headers: request_headers.merge(custom_headers || {})
66
+ }
67
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :put, options)
68
+ promise = request.run_promise do |req|
69
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
70
+ end
71
+
72
+ promise = promise.then do |http_response|
73
+ status_code = http_response.status
74
+ response_content = http_response.body
75
+ unless status_code == 201 || status_code == 200
76
+ error_model = JSON.load(response_content)
77
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
78
+ end
79
+
80
+ # Create Result
81
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
82
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
83
+ # Deserialize Response
84
+ if status_code == 201
85
+ begin
86
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
87
+ unless parsed_response.nil?
88
+ parsed_response = RedisResourceWithAccessKey.deserialize_object(parsed_response)
89
+ end
90
+ result.body = parsed_response
91
+ rescue Exception => e
92
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
93
+ end
94
+ end
95
+ # Deserialize Response
96
+ if status_code == 200
97
+ begin
98
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
99
+ unless parsed_response.nil?
100
+ parsed_response = RedisResourceWithAccessKey.deserialize_object(parsed_response)
101
+ end
102
+ result.body = parsed_response
103
+ rescue Exception => e
104
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
105
+ end
106
+ end
107
+
108
+ result
109
+ end
110
+
111
+ promise.execute
112
+ end
113
+
114
+ #
115
+ # Deletes a redis cache. This operation takes a while to complete.
116
+ #
117
+ # @param resource_group_name [String] The name of the resource group.
118
+ # @param name [String] The name of the redis cache.
119
+ # @param [Hash{String => String}] The hash of custom headers need to be
120
+ # applied to HTTP request.
121
+ #
122
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
123
+ # response.
124
+ #
125
+ def delete(resource_group_name, name, custom_headers = nil)
126
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
127
+ fail ArgumentError, 'name is nil' if name.nil?
128
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
129
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
130
+ request_headers = {}
131
+
132
+ # Set Headers
133
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
134
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
135
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}'
136
+ options = {
137
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
138
+ path_params: {'resourceGroupName' => resource_group_name,'name' => name,'subscriptionId' => @client.subscription_id},
139
+ query_params: {'api-version' => @client.api_version},
140
+ headers: request_headers.merge(custom_headers || {})
141
+ }
142
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :delete, options)
143
+ promise = request.run_promise do |req|
144
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
145
+ end
146
+
147
+ promise = promise.then do |http_response|
148
+ status_code = http_response.status
149
+ response_content = http_response.body
150
+ unless status_code == 200 || status_code == 202 || status_code == 404
151
+ error_model = JSON.load(response_content)
152
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
153
+ end
154
+
155
+ # Create Result
156
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
157
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
158
+
159
+ result
160
+ end
161
+
162
+ promise.execute
163
+ end
164
+
165
+ #
166
+ # Gets a redis cache (resource description).
167
+ #
168
+ # @param resource_group_name [String] The name of the resource group.
169
+ # @param name [String] The name of the redis cache.
170
+ # @param [Hash{String => String}] The hash of custom headers need to be
171
+ # applied to HTTP request.
172
+ #
173
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
174
+ # response.
175
+ #
176
+ def get(resource_group_name, name, custom_headers = nil)
177
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
178
+ fail ArgumentError, 'name is nil' if name.nil?
179
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
180
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
181
+ request_headers = {}
182
+
183
+ # Set Headers
184
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
185
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
186
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}'
187
+ options = {
188
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
189
+ path_params: {'resourceGroupName' => resource_group_name,'name' => name,'subscriptionId' => @client.subscription_id},
190
+ query_params: {'api-version' => @client.api_version},
191
+ headers: request_headers.merge(custom_headers || {})
192
+ }
193
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
194
+ promise = request.run_promise do |req|
195
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
196
+ end
197
+
198
+ promise = promise.then do |http_response|
199
+ status_code = http_response.status
200
+ response_content = http_response.body
201
+ unless status_code == 200
202
+ error_model = JSON.load(response_content)
203
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
204
+ end
205
+
206
+ # Create Result
207
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
208
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
209
+ # Deserialize Response
210
+ if status_code == 200
211
+ begin
212
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
213
+ unless parsed_response.nil?
214
+ parsed_response = RedisResource.deserialize_object(parsed_response)
215
+ end
216
+ result.body = parsed_response
217
+ rescue Exception => e
218
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
219
+ end
220
+ end
221
+
222
+ result
223
+ end
224
+
225
+ promise.execute
226
+ end
227
+
228
+ #
229
+ # Gets all redis caches in a resource group.
230
+ #
231
+ # @param resource_group_name [String] The name of the resource group.
232
+ # @param [Hash{String => String}] The hash of custom headers need to be
233
+ # applied to HTTP request.
234
+ #
235
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
236
+ # response.
237
+ #
238
+ def list_by_resource_group(resource_group_name, custom_headers = nil)
239
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
240
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
241
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
242
+ request_headers = {}
243
+
244
+ # Set Headers
245
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
246
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
247
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/'
248
+ options = {
249
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
250
+ path_params: {'resourceGroupName' => resource_group_name,'subscriptionId' => @client.subscription_id},
251
+ query_params: {'api-version' => @client.api_version},
252
+ headers: request_headers.merge(custom_headers || {})
253
+ }
254
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
255
+ promise = request.run_promise do |req|
256
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
257
+ end
258
+
259
+ promise = promise.then do |http_response|
260
+ status_code = http_response.status
261
+ response_content = http_response.body
262
+ unless status_code == 200
263
+ error_model = JSON.load(response_content)
264
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
265
+ end
266
+
267
+ # Create Result
268
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
269
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
270
+ # Deserialize Response
271
+ if status_code == 200
272
+ begin
273
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
274
+ unless parsed_response.nil?
275
+ parsed_response = RedisListResult.deserialize_object(parsed_response)
276
+ end
277
+ result.body = parsed_response
278
+ rescue Exception => e
279
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
280
+ end
281
+ end
282
+
283
+ result
284
+ end
285
+
286
+ promise.execute
287
+ end
288
+
289
+ #
290
+ # Gets all redis caches in the specified subscription.
291
+ #
292
+ # @param [Hash{String => String}] The hash of custom headers need to be
293
+ # applied to HTTP request.
294
+ #
295
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
296
+ # response.
297
+ #
298
+ def list(custom_headers = nil)
299
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
300
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
301
+ request_headers = {}
302
+
303
+ # Set Headers
304
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
305
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
306
+ path_template = '/subscriptions/{subscriptionId}/providers/Microsoft.Cache/Redis/'
307
+ options = {
308
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
309
+ path_params: {'subscriptionId' => @client.subscription_id},
310
+ query_params: {'api-version' => @client.api_version},
311
+ headers: request_headers.merge(custom_headers || {})
312
+ }
313
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
314
+ promise = request.run_promise do |req|
315
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
316
+ end
317
+
318
+ promise = promise.then do |http_response|
319
+ status_code = http_response.status
320
+ response_content = http_response.body
321
+ unless status_code == 200
322
+ error_model = JSON.load(response_content)
323
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
324
+ end
325
+
326
+ # Create Result
327
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
328
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
329
+ # Deserialize Response
330
+ if status_code == 200
331
+ begin
332
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
333
+ unless parsed_response.nil?
334
+ parsed_response = RedisListResult.deserialize_object(parsed_response)
335
+ end
336
+ result.body = parsed_response
337
+ rescue Exception => e
338
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
339
+ end
340
+ end
341
+
342
+ result
343
+ end
344
+
345
+ promise.execute
346
+ end
347
+
348
+ #
349
+ # Retrieve a redis cache's access keys. This operation requires write
350
+ # permission to the cache resource.
351
+ #
352
+ # @param resource_group_name [String] The name of the resource group.
353
+ # @param name [String] The name of the redis cache.
354
+ # @param [Hash{String => String}] The hash of custom headers need to be
355
+ # applied to HTTP request.
356
+ #
357
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
358
+ # response.
359
+ #
360
+ def list_keys(resource_group_name, name, custom_headers = nil)
361
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
362
+ fail ArgumentError, 'name is nil' if name.nil?
363
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
364
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
365
+ request_headers = {}
366
+
367
+ # Set Headers
368
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
369
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
370
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/listKeys'
371
+ options = {
372
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
373
+ path_params: {'resourceGroupName' => resource_group_name,'name' => name,'subscriptionId' => @client.subscription_id},
374
+ query_params: {'api-version' => @client.api_version},
375
+ headers: request_headers.merge(custom_headers || {})
376
+ }
377
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
378
+ promise = request.run_promise do |req|
379
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
380
+ end
381
+
382
+ promise = promise.then do |http_response|
383
+ status_code = http_response.status
384
+ response_content = http_response.body
385
+ unless status_code == 200
386
+ error_model = JSON.load(response_content)
387
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
388
+ end
389
+
390
+ # Create Result
391
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
392
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
393
+ # Deserialize Response
394
+ if status_code == 200
395
+ begin
396
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
397
+ unless parsed_response.nil?
398
+ parsed_response = RedisListKeysResult.deserialize_object(parsed_response)
399
+ end
400
+ result.body = parsed_response
401
+ rescue Exception => e
402
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
403
+ end
404
+ end
405
+
406
+ result
407
+ end
408
+
409
+ promise.execute
410
+ end
411
+
412
+ #
413
+ # Regenerate redis cache's access keys. This operation requires write
414
+ # permission to the cache resource.
415
+ #
416
+ # @param resource_group_name [String] The name of the resource group.
417
+ # @param name [String] The name of the redis cache.
418
+ # @param parameters [RedisRegenerateKeyParameters] Specifies which key to
419
+ # reset.
420
+ # @param [Hash{String => String}] The hash of custom headers need to be
421
+ # applied to HTTP request.
422
+ #
423
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
424
+ # response.
425
+ #
426
+ def regenerate_key(resource_group_name, name, parameters, custom_headers = nil)
427
+ fail ArgumentError, 'resource_group_name is nil' if resource_group_name.nil?
428
+ fail ArgumentError, 'name is nil' if name.nil?
429
+ fail ArgumentError, 'parameters is nil' if parameters.nil?
430
+ parameters.validate unless parameters.nil?
431
+ fail ArgumentError, '@client.api_version is nil' if @client.api_version.nil?
432
+ fail ArgumentError, '@client.subscription_id is nil' if @client.subscription_id.nil?
433
+ request_headers = {}
434
+
435
+ # Set Headers
436
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
437
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
438
+
439
+ # Serialize Request
440
+ request_headers['Content-Type'] = 'application/json; charset=utf-8'
441
+ unless parameters.nil?
442
+ parameters = RedisRegenerateKeyParameters.serialize_object(parameters)
443
+ end
444
+ request_content = JSON.generate(parameters, quirks_mode: true)
445
+ path_template = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cache/Redis/{name}/regenerateKey'
446
+ options = {
447
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
448
+ path_params: {'resourceGroupName' => resource_group_name,'name' => name,'subscriptionId' => @client.subscription_id},
449
+ query_params: {'api-version' => @client.api_version},
450
+ body: request_content,
451
+ headers: request_headers.merge(custom_headers || {})
452
+ }
453
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :post, options)
454
+ promise = request.run_promise do |req|
455
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
456
+ end
457
+
458
+ promise = promise.then do |http_response|
459
+ status_code = http_response.status
460
+ response_content = http_response.body
461
+ unless status_code == 200
462
+ error_model = JSON.load(response_content)
463
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
464
+ end
465
+
466
+ # Create Result
467
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
468
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
469
+ # Deserialize Response
470
+ if status_code == 200
471
+ begin
472
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
473
+ unless parsed_response.nil?
474
+ parsed_response = RedisListKeysResult.deserialize_object(parsed_response)
475
+ end
476
+ result.body = parsed_response
477
+ rescue Exception => e
478
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
479
+ end
480
+ end
481
+
482
+ result
483
+ end
484
+
485
+ promise.execute
486
+ end
487
+
488
+ #
489
+ # Gets all redis caches in a resource group.
490
+ #
491
+ # @param next_page_link [String] The NextLink from the previous successful
492
+ # call to List operation.
493
+ # @param [Hash{String => String}] The hash of custom headers need to be
494
+ # applied to HTTP request.
495
+ #
496
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
497
+ # response.
498
+ #
499
+ def list_by_resource_group_next(next_page_link, custom_headers = nil)
500
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
501
+ request_headers = {}
502
+
503
+ # Set Headers
504
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
505
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
506
+ path_template = '{nextLink}'
507
+ options = {
508
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
509
+ skip_encoding_path_params: {'nextLink' => next_page_link},
510
+ headers: request_headers.merge(custom_headers || {})
511
+ }
512
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
513
+ promise = request.run_promise do |req|
514
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
515
+ end
516
+
517
+ promise = promise.then do |http_response|
518
+ status_code = http_response.status
519
+ response_content = http_response.body
520
+ unless status_code == 200
521
+ error_model = JSON.load(response_content)
522
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
523
+ end
524
+
525
+ # Create Result
526
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
527
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
528
+ # Deserialize Response
529
+ if status_code == 200
530
+ begin
531
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
532
+ unless parsed_response.nil?
533
+ parsed_response = RedisListResult.deserialize_object(parsed_response)
534
+ end
535
+ result.body = parsed_response
536
+ rescue Exception => e
537
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
538
+ end
539
+ end
540
+
541
+ result
542
+ end
543
+
544
+ promise.execute
545
+ end
546
+
547
+ #
548
+ # Gets all redis caches in the specified subscription.
549
+ #
550
+ # @param next_page_link [String] The NextLink from the previous successful
551
+ # call to List operation.
552
+ # @param [Hash{String => String}] The hash of custom headers need to be
553
+ # applied to HTTP request.
554
+ #
555
+ # @return [Concurrent::Promise] Promise object which allows to get HTTP
556
+ # response.
557
+ #
558
+ def list_next(next_page_link, custom_headers = nil)
559
+ fail ArgumentError, 'next_page_link is nil' if next_page_link.nil?
560
+ request_headers = {}
561
+
562
+ # Set Headers
563
+ request_headers['x-ms-client-request-id'] = SecureRandom.uuid
564
+ request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
565
+ path_template = '{nextLink}'
566
+ options = {
567
+ middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
568
+ skip_encoding_path_params: {'nextLink' => next_page_link},
569
+ headers: request_headers.merge(custom_headers || {})
570
+ }
571
+ request = MsRest::HttpOperationRequest.new(@base_url || @client.base_url, path_template, :get, options)
572
+ promise = request.run_promise do |req|
573
+ @client.credentials.sign_request(req) unless @client.credentials.nil?
574
+ end
575
+
576
+ promise = promise.then do |http_response|
577
+ status_code = http_response.status
578
+ response_content = http_response.body
579
+ unless status_code == 200
580
+ error_model = JSON.load(response_content)
581
+ fail MsRestAzure::AzureOperationError.new(request, http_response, error_model)
582
+ end
583
+
584
+ # Create Result
585
+ result = MsRestAzure::AzureOperationResponse.new(request, http_response)
586
+ result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
587
+ # Deserialize Response
588
+ if status_code == 200
589
+ begin
590
+ parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
591
+ unless parsed_response.nil?
592
+ parsed_response = RedisListResult.deserialize_object(parsed_response)
593
+ end
594
+ result.body = parsed_response
595
+ rescue Exception => e
596
+ fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
597
+ end
598
+ end
599
+
600
+ result
601
+ end
602
+
603
+ promise.execute
604
+ end
605
+
606
+ end
607
+ end