ff-ruby-server-sdk 0.0.2 → 1.0.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.run/sdk_test.rb.run.xml +3 -3
- data/CHANGELOG.md +12 -2
- data/Gemfile +17 -3
- data/README.md +155 -7
- data/api.yaml +736 -0
- data/example/example.rb +100 -3
- data/lib/ff/ruby/server/generated/lib/openapi_client/api/client_api.rb +545 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/api/metrics_api.rb +89 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/api_client.rb +390 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/api_error.rb +57 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/configuration.rb +282 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_request.rb +232 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_request_target.rb +250 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/authentication_response.rb +223 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/clause.rb +281 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/distribution.rb +239 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/error.rb +237 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/evaluation.rb +260 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/feature_config.rb +418 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/feature_state.rb +37 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/key_value.rb +237 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/metrics.rb +231 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/metrics_data.rb +303 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/pagination.rb +274 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/prerequisite.rb +239 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/segment.rb +320 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/serve.rb +227 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/serving_rule.rb +267 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/tag.rb +233 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/target.rb +331 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/target_data.rb +253 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/target_map.rb +232 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/variation.rb +255 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/variation_map.rb +245 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/models/weighted_variation.rb +237 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client/version.rb +15 -0
- data/lib/ff/ruby/server/generated/lib/openapi_client.rb +65 -0
- data/lib/ff/ruby/server/sdk/api/auth_service.rb +91 -0
- data/lib/ff/ruby/server/sdk/api/cf_client.rb +93 -0
- data/lib/ff/ruby/server/sdk/api/client_callback.rb +45 -0
- data/lib/ff/ruby/server/sdk/api/config.rb +140 -0
- data/lib/ff/ruby/server/sdk/api/config_builder.rb +116 -0
- data/lib/ff/ruby/server/sdk/api/default_cache.rb +112 -0
- data/lib/ff/ruby/server/sdk/api/evaluation.rb +29 -0
- data/lib/ff/ruby/server/sdk/api/evaluator.rb +526 -0
- data/lib/ff/ruby/server/sdk/api/file_map_store.rb +60 -0
- data/lib/ff/ruby/server/sdk/api/flag_evaluate_callback.rb +13 -0
- data/lib/ff/ruby/server/sdk/api/inner_client.rb +311 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_flag_evaluate_callback.rb +30 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_metrics_callback.rb +33 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_repository_callback.rb +44 -0
- data/lib/ff/ruby/server/sdk/api/inner_client_updater.rb +63 -0
- data/lib/ff/ruby/server/sdk/api/metrics_callback.rb +19 -0
- data/lib/ff/ruby/server/sdk/api/metrics_event.rb +16 -0
- data/lib/ff/ruby/server/sdk/api/metrics_processor.rb +297 -0
- data/lib/ff/ruby/server/sdk/api/operators.rb +20 -0
- data/lib/ff/ruby/server/sdk/api/polling_processor.rb +164 -0
- data/lib/ff/ruby/server/sdk/api/repository_callback.rb +28 -0
- data/lib/ff/ruby/server/sdk/api/storage_repository.rb +263 -0
- data/lib/ff/ruby/server/sdk/api/summary_metrics.rb +16 -0
- data/lib/ff/ruby/server/sdk/api/update_processor.rb +149 -0
- data/lib/ff/ruby/server/sdk/common/cache.rb +27 -0
- data/lib/ff/ruby/server/sdk/common/closeable.rb +7 -0
- data/lib/ff/ruby/server/sdk/common/destroyable.rb +12 -0
- data/lib/ff/ruby/server/sdk/common/repository.rb +45 -0
- data/lib/ff/ruby/server/sdk/common/storage.rb +29 -0
- data/lib/ff/ruby/server/sdk/connector/connector.rb +44 -0
- data/lib/ff/ruby/server/sdk/connector/events.rb +118 -0
- data/lib/ff/ruby/server/sdk/connector/harness_connector.rb +236 -0
- data/lib/ff/ruby/server/sdk/connector/service.rb +19 -0
- data/lib/ff/ruby/server/sdk/connector/updater.rb +32 -0
- data/lib/ff/ruby/server/sdk/dto/message.rb +13 -0
- data/lib/ff/ruby/server/sdk/dto/target.rb +24 -0
- data/lib/ff/ruby/server/sdk/version.rb +2 -1
- data/lib/ff/ruby/server/sdk.rb +39 -3
- data/openapitools.json +7 -0
- data/scripts/install.sh +8 -2
- data/scripts/openapi.sh +76 -0
- data/scripts/publish.sh +1 -1
- data/scripts/sdk_specs.sh +1 -1
- metadata +263 -11
- data/lib/ff/ruby/server/sdk/cf_client.rb +0 -6
@@ -0,0 +1,320 @@
|
|
1
|
+
=begin
|
2
|
+
#Harness feature flag service client apis
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: cf@harness.io
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class Segment
|
18
|
+
# Unique identifier for the segment.
|
19
|
+
attr_accessor :identifier
|
20
|
+
|
21
|
+
# Name of the segment.
|
22
|
+
attr_accessor :name
|
23
|
+
|
24
|
+
attr_accessor :environment
|
25
|
+
|
26
|
+
attr_accessor :tags
|
27
|
+
|
28
|
+
attr_accessor :included
|
29
|
+
|
30
|
+
attr_accessor :excluded
|
31
|
+
|
32
|
+
# An array of rules that can cause a user to be included in this segment.
|
33
|
+
attr_accessor :rules
|
34
|
+
|
35
|
+
attr_accessor :created_at
|
36
|
+
|
37
|
+
attr_accessor :modified_at
|
38
|
+
|
39
|
+
attr_accessor :version
|
40
|
+
|
41
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
42
|
+
def self.attribute_map
|
43
|
+
{
|
44
|
+
:'identifier' => :'identifier',
|
45
|
+
:'name' => :'name',
|
46
|
+
:'environment' => :'environment',
|
47
|
+
:'tags' => :'tags',
|
48
|
+
:'included' => :'included',
|
49
|
+
:'excluded' => :'excluded',
|
50
|
+
:'rules' => :'rules',
|
51
|
+
:'created_at' => :'createdAt',
|
52
|
+
:'modified_at' => :'modifiedAt',
|
53
|
+
:'version' => :'version'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns all the JSON keys this model knows about
|
58
|
+
def self.acceptable_attributes
|
59
|
+
attribute_map.values
|
60
|
+
end
|
61
|
+
|
62
|
+
# Attribute type mapping.
|
63
|
+
def self.openapi_types
|
64
|
+
{
|
65
|
+
:'identifier' => :'String',
|
66
|
+
:'name' => :'String',
|
67
|
+
:'environment' => :'String',
|
68
|
+
:'tags' => :'Array<Tag>',
|
69
|
+
:'included' => :'Array<Target>',
|
70
|
+
:'excluded' => :'Array<Target>',
|
71
|
+
:'rules' => :'Array<Clause>',
|
72
|
+
:'created_at' => :'Integer',
|
73
|
+
:'modified_at' => :'Integer',
|
74
|
+
:'version' => :'Integer'
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
# List of attributes with nullable: true
|
79
|
+
def self.openapi_nullable
|
80
|
+
Set.new([
|
81
|
+
])
|
82
|
+
end
|
83
|
+
|
84
|
+
# Initializes the object
|
85
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
86
|
+
def initialize(attributes = {})
|
87
|
+
if (!attributes.is_a?(Hash))
|
88
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Segment` initialize method"
|
89
|
+
end
|
90
|
+
|
91
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
92
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
93
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
94
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Segment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
95
|
+
end
|
96
|
+
h[k.to_sym] = v
|
97
|
+
}
|
98
|
+
|
99
|
+
if attributes.key?(:'identifier')
|
100
|
+
self.identifier = attributes[:'identifier']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.key?(:'name')
|
104
|
+
self.name = attributes[:'name']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'environment')
|
108
|
+
self.environment = attributes[:'environment']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'tags')
|
112
|
+
if (value = attributes[:'tags']).is_a?(Array)
|
113
|
+
self.tags = value
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'included')
|
118
|
+
if (value = attributes[:'included']).is_a?(Array)
|
119
|
+
self.included = value
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'excluded')
|
124
|
+
if (value = attributes[:'excluded']).is_a?(Array)
|
125
|
+
self.excluded = value
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:'rules')
|
130
|
+
if (value = attributes[:'rules']).is_a?(Array)
|
131
|
+
self.rules = value
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'created_at')
|
136
|
+
self.created_at = attributes[:'created_at']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'modified_at')
|
140
|
+
self.modified_at = attributes[:'modified_at']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'version')
|
144
|
+
self.version = attributes[:'version']
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
149
|
+
# @return Array for valid properties with the reasons
|
150
|
+
def list_invalid_properties
|
151
|
+
invalid_properties = Array.new
|
152
|
+
if @identifier.nil?
|
153
|
+
invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
|
154
|
+
end
|
155
|
+
|
156
|
+
if @name.nil?
|
157
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
158
|
+
end
|
159
|
+
|
160
|
+
invalid_properties
|
161
|
+
end
|
162
|
+
|
163
|
+
# Check to see if the all the properties in the model are valid
|
164
|
+
# @return true if the model is valid
|
165
|
+
def valid?
|
166
|
+
return false if @identifier.nil?
|
167
|
+
return false if @name.nil?
|
168
|
+
true
|
169
|
+
end
|
170
|
+
|
171
|
+
# Checks equality by comparing each attribute.
|
172
|
+
# @param [Object] Object to be compared
|
173
|
+
def ==(o)
|
174
|
+
return true if self.equal?(o)
|
175
|
+
self.class == o.class &&
|
176
|
+
identifier == o.identifier &&
|
177
|
+
name == o.name &&
|
178
|
+
environment == o.environment &&
|
179
|
+
tags == o.tags &&
|
180
|
+
included == o.included &&
|
181
|
+
excluded == o.excluded &&
|
182
|
+
rules == o.rules &&
|
183
|
+
created_at == o.created_at &&
|
184
|
+
modified_at == o.modified_at &&
|
185
|
+
version == o.version
|
186
|
+
end
|
187
|
+
|
188
|
+
# @see the `==` method
|
189
|
+
# @param [Object] Object to be compared
|
190
|
+
def eql?(o)
|
191
|
+
self == o
|
192
|
+
end
|
193
|
+
|
194
|
+
# Calculates hash code according to all attributes.
|
195
|
+
# @return [Integer] Hash code
|
196
|
+
def hash
|
197
|
+
[identifier, name, environment, tags, included, excluded, rules, created_at, modified_at, version].hash
|
198
|
+
end
|
199
|
+
|
200
|
+
# Builds the object from hash
|
201
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
202
|
+
# @return [Object] Returns the model itself
|
203
|
+
def self.build_from_hash(attributes)
|
204
|
+
new.build_from_hash(attributes)
|
205
|
+
end
|
206
|
+
|
207
|
+
# Builds the object from hash
|
208
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
209
|
+
# @return [Object] Returns the model itself
|
210
|
+
def build_from_hash(attributes)
|
211
|
+
return nil unless attributes.is_a?(Hash)
|
212
|
+
self.class.openapi_types.each_pair do |key, type|
|
213
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
214
|
+
self.send("#{key}=", nil)
|
215
|
+
elsif type =~ /\AArray<(.*)>/i
|
216
|
+
# check to ensure the input is an array given that the attribute
|
217
|
+
# is documented as an array but the input is not
|
218
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
219
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
220
|
+
end
|
221
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
222
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
self
|
227
|
+
end
|
228
|
+
|
229
|
+
# Deserializes the data based on type
|
230
|
+
# @param string type Data type
|
231
|
+
# @param string value Value to be deserialized
|
232
|
+
# @return [Object] Deserialized data
|
233
|
+
def _deserialize(type, value)
|
234
|
+
case type.to_sym
|
235
|
+
when :Time
|
236
|
+
Time.parse(value)
|
237
|
+
when :Date
|
238
|
+
Date.parse(value)
|
239
|
+
when :String
|
240
|
+
value.to_s
|
241
|
+
when :Integer
|
242
|
+
value.to_i
|
243
|
+
when :Float
|
244
|
+
value.to_f
|
245
|
+
when :Boolean
|
246
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
247
|
+
true
|
248
|
+
else
|
249
|
+
false
|
250
|
+
end
|
251
|
+
when :Object
|
252
|
+
# generic object (usually a Hash), return directly
|
253
|
+
value
|
254
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
255
|
+
inner_type = Regexp.last_match[:inner_type]
|
256
|
+
value.map { |v| _deserialize(inner_type, v) }
|
257
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
258
|
+
k_type = Regexp.last_match[:k_type]
|
259
|
+
v_type = Regexp.last_match[:v_type]
|
260
|
+
{}.tap do |hash|
|
261
|
+
value.each do |k, v|
|
262
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
else # model
|
266
|
+
# models (e.g. Pet) or oneOf
|
267
|
+
klass = OpenapiClient.const_get(type)
|
268
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# Returns the string representation of the object
|
273
|
+
# @return [String] String presentation of the object
|
274
|
+
def to_s
|
275
|
+
to_hash.to_s
|
276
|
+
end
|
277
|
+
|
278
|
+
# to_body is an alias to to_hash (backward compatibility)
|
279
|
+
# @return [Hash] Returns the object in the form of hash
|
280
|
+
def to_body
|
281
|
+
to_hash
|
282
|
+
end
|
283
|
+
|
284
|
+
# Returns the object in the form of hash
|
285
|
+
# @return [Hash] Returns the object in the form of hash
|
286
|
+
def to_hash
|
287
|
+
hash = {}
|
288
|
+
self.class.attribute_map.each_pair do |attr, param|
|
289
|
+
value = self.send(attr)
|
290
|
+
if value.nil?
|
291
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
292
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
293
|
+
end
|
294
|
+
|
295
|
+
hash[param] = _to_hash(value)
|
296
|
+
end
|
297
|
+
hash
|
298
|
+
end
|
299
|
+
|
300
|
+
# Outputs non-array value in the form of hash
|
301
|
+
# For object, use to_hash. Otherwise, just return the value
|
302
|
+
# @param [Object] value Any valid value
|
303
|
+
# @return [Hash] Returns the value in the form of hash
|
304
|
+
def _to_hash(value)
|
305
|
+
if value.is_a?(Array)
|
306
|
+
value.compact.map { |v| _to_hash(v) }
|
307
|
+
elsif value.is_a?(Hash)
|
308
|
+
{}.tap do |hash|
|
309
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
310
|
+
end
|
311
|
+
elsif value.respond_to? :to_hash
|
312
|
+
value.to_hash
|
313
|
+
else
|
314
|
+
value
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
=begin
|
2
|
+
#Harness feature flag service client apis
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: cf@harness.io
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module OpenapiClient
|
17
|
+
class Serve
|
18
|
+
attr_accessor :distribution
|
19
|
+
|
20
|
+
attr_accessor :variation
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'distribution' => :'distribution',
|
26
|
+
:'variation' => :'variation'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'distribution' => :'Distribution',
|
39
|
+
:'variation' => :'String'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# List of attributes with nullable: true
|
44
|
+
def self.openapi_nullable
|
45
|
+
Set.new([
|
46
|
+
])
|
47
|
+
end
|
48
|
+
|
49
|
+
# Initializes the object
|
50
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
51
|
+
def initialize(attributes = {})
|
52
|
+
if (!attributes.is_a?(Hash))
|
53
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::Serve` initialize method"
|
54
|
+
end
|
55
|
+
|
56
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
58
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
59
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::Serve`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
60
|
+
end
|
61
|
+
h[k.to_sym] = v
|
62
|
+
}
|
63
|
+
|
64
|
+
if attributes.key?(:'distribution')
|
65
|
+
self.distribution = attributes[:'distribution']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'variation')
|
69
|
+
self.variation = attributes[:'variation']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
distribution == o.distribution &&
|
92
|
+
variation == o.variation
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(o)
|
98
|
+
self == o
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Integer] Hash code
|
103
|
+
def hash
|
104
|
+
[distribution, variation].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def self.build_from_hash(attributes)
|
111
|
+
new.build_from_hash(attributes)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Builds the object from hash
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
116
|
+
# @return [Object] Returns the model itself
|
117
|
+
def build_from_hash(attributes)
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
119
|
+
self.class.openapi_types.each_pair do |key, type|
|
120
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
121
|
+
self.send("#{key}=", nil)
|
122
|
+
elsif type =~ /\AArray<(.*)>/i
|
123
|
+
# check to ensure the input is an array given that the attribute
|
124
|
+
# is documented as an array but the input is not
|
125
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
126
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
127
|
+
end
|
128
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
129
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
# Deserializes the data based on type
|
137
|
+
# @param string type Data type
|
138
|
+
# @param string value Value to be deserialized
|
139
|
+
# @return [Object] Deserialized data
|
140
|
+
def _deserialize(type, value)
|
141
|
+
case type.to_sym
|
142
|
+
when :Time
|
143
|
+
Time.parse(value)
|
144
|
+
when :Date
|
145
|
+
Date.parse(value)
|
146
|
+
when :String
|
147
|
+
value.to_s
|
148
|
+
when :Integer
|
149
|
+
value.to_i
|
150
|
+
when :Float
|
151
|
+
value.to_f
|
152
|
+
when :Boolean
|
153
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
154
|
+
true
|
155
|
+
else
|
156
|
+
false
|
157
|
+
end
|
158
|
+
when :Object
|
159
|
+
# generic object (usually a Hash), return directly
|
160
|
+
value
|
161
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
162
|
+
inner_type = Regexp.last_match[:inner_type]
|
163
|
+
value.map { |v| _deserialize(inner_type, v) }
|
164
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
165
|
+
k_type = Regexp.last_match[:k_type]
|
166
|
+
v_type = Regexp.last_match[:v_type]
|
167
|
+
{}.tap do |hash|
|
168
|
+
value.each do |k, v|
|
169
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
else # model
|
173
|
+
# models (e.g. Pet) or oneOf
|
174
|
+
klass = OpenapiClient.const_get(type)
|
175
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns the string representation of the object
|
180
|
+
# @return [String] String presentation of the object
|
181
|
+
def to_s
|
182
|
+
to_hash.to_s
|
183
|
+
end
|
184
|
+
|
185
|
+
# to_body is an alias to to_hash (backward compatibility)
|
186
|
+
# @return [Hash] Returns the object in the form of hash
|
187
|
+
def to_body
|
188
|
+
to_hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the object in the form of hash
|
192
|
+
# @return [Hash] Returns the object in the form of hash
|
193
|
+
def to_hash
|
194
|
+
hash = {}
|
195
|
+
self.class.attribute_map.each_pair do |attr, param|
|
196
|
+
value = self.send(attr)
|
197
|
+
if value.nil?
|
198
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
199
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
200
|
+
end
|
201
|
+
|
202
|
+
hash[param] = _to_hash(value)
|
203
|
+
end
|
204
|
+
hash
|
205
|
+
end
|
206
|
+
|
207
|
+
# Outputs non-array value in the form of hash
|
208
|
+
# For object, use to_hash. Otherwise, just return the value
|
209
|
+
# @param [Object] value Any valid value
|
210
|
+
# @return [Hash] Returns the value in the form of hash
|
211
|
+
def _to_hash(value)
|
212
|
+
if value.is_a?(Array)
|
213
|
+
value.compact.map { |v| _to_hash(v) }
|
214
|
+
elsif value.is_a?(Hash)
|
215
|
+
{}.tap do |hash|
|
216
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
217
|
+
end
|
218
|
+
elsif value.respond_to? :to_hash
|
219
|
+
value.to_hash
|
220
|
+
else
|
221
|
+
value
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|