rbflagr 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Makefile +9 -0
- data/README.md +143 -0
- data/Rakefile +8 -0
- data/docs/Constraint.md +11 -0
- data/docs/ConstraintApi.md +211 -0
- data/docs/CreateConstraintRequest.md +10 -0
- data/docs/CreateFlagRequest.md +8 -0
- data/docs/CreateSegmentRequest.md +9 -0
- data/docs/CreateVariantRequest.md +9 -0
- data/docs/Distribution.md +12 -0
- data/docs/DistributionApi.md +109 -0
- data/docs/Error.md +8 -0
- data/docs/EvalContext.md +12 -0
- data/docs/EvalDebugLog.md +9 -0
- data/docs/EvalResult.md +16 -0
- data/docs/EvaluationApi.md +98 -0
- data/docs/EvaluationBatchRequest.md +10 -0
- data/docs/EvaluationBatchResponse.md +8 -0
- data/docs/EvaluationEntity.md +10 -0
- data/docs/Flag.md +13 -0
- data/docs/FlagApi.md +337 -0
- data/docs/FlagSnapshot.md +11 -0
- data/docs/HealthApi.md +46 -0
- data/docs/PutDistributionsRequest.md +8 -0
- data/docs/PutFlagRequest.md +9 -0
- data/docs/PutSegmentReorderRequest.md +8 -0
- data/docs/PutSegmentRequest.md +9 -0
- data/docs/PutVariantRequest.md +9 -0
- data/docs/Segment.md +13 -0
- data/docs/SegmentApi.md +246 -0
- data/docs/SegmentDebugLog.md +9 -0
- data/docs/SetFlagEnabledRequest.md +8 -0
- data/docs/Variant.md +10 -0
- data/docs/VariantApi.md +199 -0
- data/git_push.sh +55 -0
- data/lib/rbflagr.rb +70 -0
- data/lib/rbflagr/api/constraint_api.rb +310 -0
- data/lib/rbflagr/api/distribution_api.rb +159 -0
- data/lib/rbflagr/api/evaluation_api.rb +123 -0
- data/lib/rbflagr/api/flag_api.rb +413 -0
- data/lib/rbflagr/api/health_api.rb +66 -0
- data/lib/rbflagr/api/segment_api.rb +329 -0
- data/lib/rbflagr/api/variant_api.rb +270 -0
- data/lib/rbflagr/api_client.rb +388 -0
- data/lib/rbflagr/api_error.rb +38 -0
- data/lib/rbflagr/configuration.rb +202 -0
- data/lib/rbflagr/models/constraint.rb +317 -0
- data/lib/rbflagr/models/create_constraint_request.rb +273 -0
- data/lib/rbflagr/models/create_flag_request.rb +207 -0
- data/lib/rbflagr/models/create_segment_request.rb +249 -0
- data/lib/rbflagr/models/create_variant_request.rb +216 -0
- data/lib/rbflagr/models/distribution.rb +330 -0
- data/lib/rbflagr/models/error.rb +207 -0
- data/lib/rbflagr/models/eval_context.rb +268 -0
- data/lib/rbflagr/models/eval_debug_log.rb +194 -0
- data/lib/rbflagr/models/eval_result.rb +385 -0
- data/lib/rbflagr/models/evaluation_batch_request.rb +215 -0
- data/lib/rbflagr/models/evaluation_batch_response.rb +190 -0
- data/lib/rbflagr/models/evaluation_entity.rb +225 -0
- data/lib/rbflagr/models/flag.rb +282 -0
- data/lib/rbflagr/models/flag_snapshot.rb +263 -0
- data/lib/rbflagr/models/put_distributions_request.rb +190 -0
- data/lib/rbflagr/models/put_flag_request.rb +217 -0
- data/lib/rbflagr/models/put_segment_reorder_request.rb +190 -0
- data/lib/rbflagr/models/put_segment_request.rb +249 -0
- data/lib/rbflagr/models/put_variant_request.rb +221 -0
- data/lib/rbflagr/models/segment.rb +328 -0
- data/lib/rbflagr/models/segment_debug_log.rb +207 -0
- data/lib/rbflagr/models/set_flag_enabled_request.rb +188 -0
- data/lib/rbflagr/models/variant.rb +240 -0
- data/lib/rbflagr/version.rb +15 -0
- data/rbflagr.gemspec +45 -0
- data/spec/api/constraint_api_spec.rb +91 -0
- data/spec/api/distribution_api_spec.rb +62 -0
- data/spec/api/evaluation_api_spec.rb +47 -0
- data/spec/api/flag_api_spec.rb +108 -0
- data/spec/api/health_api_spec.rb +44 -0
- data/spec/api/segment_api_spec.rb +87 -0
- data/spec/api/variant_api_spec.rb +87 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/constraint_spec.rb +64 -0
- data/spec/models/create_constraint_request_spec.rb +54 -0
- data/spec/models/create_flag_request_spec.rb +42 -0
- data/spec/models/create_segment_request_spec.rb +48 -0
- data/spec/models/create_variant_request_spec.rb +48 -0
- data/spec/models/distribution_spec.rb +66 -0
- data/spec/models/error_spec.rb +42 -0
- data/spec/models/eval_context_spec.rb +66 -0
- data/spec/models/eval_debug_log_spec.rb +48 -0
- data/spec/models/eval_result_spec.rb +78 -0
- data/spec/models/evaluation_batch_request_spec.rb +54 -0
- data/spec/models/evaluation_batch_response_spec.rb +42 -0
- data/spec/models/evaluation_entity_spec.rb +54 -0
- data/spec/models/flag_snapshot_spec.rb +60 -0
- data/spec/models/flag_spec.rb +66 -0
- data/spec/models/put_distributions_request_spec.rb +42 -0
- data/spec/models/put_flag_request_spec.rb +42 -0
- data/spec/models/put_segment_reorder_request_spec.rb +42 -0
- data/spec/models/put_segment_request_spec.rb +48 -0
- data/spec/models/put_variant_request_spec.rb +48 -0
- data/spec/models/segment_debug_log_spec.rb +48 -0
- data/spec/models/segment_spec.rb +72 -0
- data/spec/models/set_flag_enabled_request_spec.rb +42 -0
- data/spec/models/variant_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger.yaml +1135 -0
- data/swagger_ruby.json +6 -0
- data/tags +618 -0
- metadata +362 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
=begin
|
2
|
+
#Flagr
|
3
|
+
|
4
|
+
#Flagr is a feature flagging, A/B testing and dynamic configuration microservice
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.8
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Flagr
|
16
|
+
class EvalDebugLog
|
17
|
+
attr_accessor :segment_debug_logs
|
18
|
+
|
19
|
+
attr_accessor :msg
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'segment_debug_logs' => :'segmentDebugLogs',
|
25
|
+
:'msg' => :'msg'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.swagger_types
|
31
|
+
{
|
32
|
+
:'segment_debug_logs' => :'Array<SegmentDebugLog>',
|
33
|
+
:'msg' => :'String'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
return unless attributes.is_a?(Hash)
|
41
|
+
|
42
|
+
# convert string to symbol for hash key
|
43
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
44
|
+
|
45
|
+
if attributes.has_key?(:'segmentDebugLogs')
|
46
|
+
if (value = attributes[:'segmentDebugLogs']).is_a?(Array)
|
47
|
+
self.segment_debug_logs = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'msg')
|
52
|
+
self.msg = attributes[:'msg']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properties with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
invalid_properties
|
61
|
+
end
|
62
|
+
|
63
|
+
# Check to see if the all the properties in the model are valid
|
64
|
+
# @return true if the model is valid
|
65
|
+
def valid?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
69
|
+
# Checks equality by comparing each attribute.
|
70
|
+
# @param [Object] Object to be compared
|
71
|
+
def ==(o)
|
72
|
+
return true if self.equal?(o)
|
73
|
+
self.class == o.class &&
|
74
|
+
segment_debug_logs == o.segment_debug_logs &&
|
75
|
+
msg == o.msg
|
76
|
+
end
|
77
|
+
|
78
|
+
# @see the `==` method
|
79
|
+
# @param [Object] Object to be compared
|
80
|
+
def eql?(o)
|
81
|
+
self == o
|
82
|
+
end
|
83
|
+
|
84
|
+
# Calculates hash code according to all attributes.
|
85
|
+
# @return [Fixnum] Hash code
|
86
|
+
def hash
|
87
|
+
[segment_debug_logs, msg].hash
|
88
|
+
end
|
89
|
+
|
90
|
+
# Builds the object from hash
|
91
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
92
|
+
# @return [Object] Returns the model itself
|
93
|
+
def build_from_hash(attributes)
|
94
|
+
return nil unless attributes.is_a?(Hash)
|
95
|
+
self.class.swagger_types.each_pair do |key, type|
|
96
|
+
if type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
100
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
101
|
+
end
|
102
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
103
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
104
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
105
|
+
end
|
106
|
+
|
107
|
+
self
|
108
|
+
end
|
109
|
+
|
110
|
+
# Deserializes the data based on type
|
111
|
+
# @param string type Data type
|
112
|
+
# @param string value Value to be deserialized
|
113
|
+
# @return [Object] Deserialized data
|
114
|
+
def _deserialize(type, value)
|
115
|
+
case type.to_sym
|
116
|
+
when :DateTime
|
117
|
+
DateTime.parse(value)
|
118
|
+
when :Date
|
119
|
+
Date.parse(value)
|
120
|
+
when :String
|
121
|
+
value.to_s
|
122
|
+
when :Integer
|
123
|
+
value.to_i
|
124
|
+
when :Float
|
125
|
+
value.to_f
|
126
|
+
when :BOOLEAN
|
127
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
128
|
+
true
|
129
|
+
else
|
130
|
+
false
|
131
|
+
end
|
132
|
+
when :Object
|
133
|
+
# generic object (usually a Hash), return directly
|
134
|
+
value
|
135
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
136
|
+
inner_type = Regexp.last_match[:inner_type]
|
137
|
+
value.map { |v| _deserialize(inner_type, v) }
|
138
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
139
|
+
k_type = Regexp.last_match[:k_type]
|
140
|
+
v_type = Regexp.last_match[:v_type]
|
141
|
+
{}.tap do |hash|
|
142
|
+
value.each do |k, v|
|
143
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
else # model
|
147
|
+
temp_model = Flagr.const_get(type).new
|
148
|
+
temp_model.build_from_hash(value)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the string representation of the object
|
153
|
+
# @return [String] String presentation of the object
|
154
|
+
def to_s
|
155
|
+
to_hash.to_s
|
156
|
+
end
|
157
|
+
|
158
|
+
# to_body is an alias to to_hash (backward compatibility)
|
159
|
+
# @return [Hash] Returns the object in the form of hash
|
160
|
+
def to_body
|
161
|
+
to_hash
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns the object in the form of hash
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_hash
|
167
|
+
hash = {}
|
168
|
+
self.class.attribute_map.each_pair do |attr, param|
|
169
|
+
value = self.send(attr)
|
170
|
+
next if value.nil?
|
171
|
+
hash[param] = _to_hash(value)
|
172
|
+
end
|
173
|
+
hash
|
174
|
+
end
|
175
|
+
|
176
|
+
# Outputs non-array value in the form of hash
|
177
|
+
# For object, use to_hash. Otherwise, just return the value
|
178
|
+
# @param [Object] value Any valid value
|
179
|
+
# @return [Hash] Returns the value in the form of hash
|
180
|
+
def _to_hash(value)
|
181
|
+
if value.is_a?(Array)
|
182
|
+
value.compact.map { |v| _to_hash(v) }
|
183
|
+
elsif value.is_a?(Hash)
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
186
|
+
end
|
187
|
+
elsif value.respond_to? :to_hash
|
188
|
+
value.to_hash
|
189
|
+
else
|
190
|
+
value
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,385 @@
|
|
1
|
+
=begin
|
2
|
+
#Flagr
|
3
|
+
|
4
|
+
#Flagr is a feature flagging, A/B testing and dynamic configuration microservice
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.8
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.4.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Flagr
|
16
|
+
class EvalResult
|
17
|
+
attr_accessor :flag_id
|
18
|
+
|
19
|
+
attr_accessor :flag_snapshot_id
|
20
|
+
|
21
|
+
attr_accessor :segment_id
|
22
|
+
|
23
|
+
attr_accessor :variant_id
|
24
|
+
|
25
|
+
attr_accessor :variant_key
|
26
|
+
|
27
|
+
attr_accessor :variant_attachment
|
28
|
+
|
29
|
+
attr_accessor :eval_context
|
30
|
+
|
31
|
+
attr_accessor :timestamp
|
32
|
+
|
33
|
+
attr_accessor :eval_debug_log
|
34
|
+
|
35
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
36
|
+
def self.attribute_map
|
37
|
+
{
|
38
|
+
:'flag_id' => :'flagID',
|
39
|
+
:'flag_snapshot_id' => :'flagSnapshotID',
|
40
|
+
:'segment_id' => :'segmentID',
|
41
|
+
:'variant_id' => :'variantID',
|
42
|
+
:'variant_key' => :'variantKey',
|
43
|
+
:'variant_attachment' => :'variantAttachment',
|
44
|
+
:'eval_context' => :'evalContext',
|
45
|
+
:'timestamp' => :'timestamp',
|
46
|
+
:'eval_debug_log' => :'evalDebugLog'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.swagger_types
|
52
|
+
{
|
53
|
+
:'flag_id' => :'Integer',
|
54
|
+
:'flag_snapshot_id' => :'Integer',
|
55
|
+
:'segment_id' => :'Integer',
|
56
|
+
:'variant_id' => :'Integer',
|
57
|
+
:'variant_key' => :'String',
|
58
|
+
:'variant_attachment' => :'Object',
|
59
|
+
:'eval_context' => :'EvalContext',
|
60
|
+
:'timestamp' => :'String',
|
61
|
+
:'eval_debug_log' => :'EvalDebugLog'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# Initializes the object
|
66
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
67
|
+
def initialize(attributes = {})
|
68
|
+
return unless attributes.is_a?(Hash)
|
69
|
+
|
70
|
+
# convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
72
|
+
|
73
|
+
if attributes.has_key?(:'flagID')
|
74
|
+
self.flag_id = attributes[:'flagID']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'flagSnapshotID')
|
78
|
+
self.flag_snapshot_id = attributes[:'flagSnapshotID']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'segmentID')
|
82
|
+
self.segment_id = attributes[:'segmentID']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.has_key?(:'variantID')
|
86
|
+
self.variant_id = attributes[:'variantID']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'variantKey')
|
90
|
+
self.variant_key = attributes[:'variantKey']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.has_key?(:'variantAttachment')
|
94
|
+
self.variant_attachment = attributes[:'variantAttachment']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.has_key?(:'evalContext')
|
98
|
+
self.eval_context = attributes[:'evalContext']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.has_key?(:'timestamp')
|
102
|
+
self.timestamp = attributes[:'timestamp']
|
103
|
+
end
|
104
|
+
|
105
|
+
if attributes.has_key?(:'evalDebugLog')
|
106
|
+
self.eval_debug_log = attributes[:'evalDebugLog']
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
111
|
+
# @return Array for valid properties with the reasons
|
112
|
+
def list_invalid_properties
|
113
|
+
invalid_properties = Array.new
|
114
|
+
if @flag_id.nil?
|
115
|
+
invalid_properties.push('invalid value for "flag_id", flag_id cannot be nil.')
|
116
|
+
end
|
117
|
+
|
118
|
+
if @flag_id < 1
|
119
|
+
invalid_properties.push('invalid value for "flag_id", must be greater than or equal to 1.')
|
120
|
+
end
|
121
|
+
|
122
|
+
if @segment_id.nil?
|
123
|
+
invalid_properties.push('invalid value for "segment_id", segment_id cannot be nil.')
|
124
|
+
end
|
125
|
+
|
126
|
+
if @segment_id < 1
|
127
|
+
invalid_properties.push('invalid value for "segment_id", must be greater than or equal to 1.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @variant_id.nil?
|
131
|
+
invalid_properties.push('invalid value for "variant_id", variant_id cannot be nil.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @variant_id < 1
|
135
|
+
invalid_properties.push('invalid value for "variant_id", must be greater than or equal to 1.')
|
136
|
+
end
|
137
|
+
|
138
|
+
if @variant_key.nil?
|
139
|
+
invalid_properties.push('invalid value for "variant_key", variant_key cannot be nil.')
|
140
|
+
end
|
141
|
+
|
142
|
+
if @variant_key.to_s.length < 1
|
143
|
+
invalid_properties.push('invalid value for "variant_key", the character length must be great than or equal to 1.')
|
144
|
+
end
|
145
|
+
|
146
|
+
if @variant_attachment.nil?
|
147
|
+
invalid_properties.push('invalid value for "variant_attachment", variant_attachment cannot be nil.')
|
148
|
+
end
|
149
|
+
|
150
|
+
if @eval_context.nil?
|
151
|
+
invalid_properties.push('invalid value for "eval_context", eval_context cannot be nil.')
|
152
|
+
end
|
153
|
+
|
154
|
+
if @timestamp.nil?
|
155
|
+
invalid_properties.push('invalid value for "timestamp", timestamp cannot be nil.')
|
156
|
+
end
|
157
|
+
|
158
|
+
if @timestamp.to_s.length < 1
|
159
|
+
invalid_properties.push('invalid value for "timestamp", the character length must be great than or equal to 1.')
|
160
|
+
end
|
161
|
+
|
162
|
+
invalid_properties
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check to see if the all the properties in the model are valid
|
166
|
+
# @return true if the model is valid
|
167
|
+
def valid?
|
168
|
+
return false if @flag_id.nil?
|
169
|
+
return false if @flag_id < 1
|
170
|
+
return false if @segment_id.nil?
|
171
|
+
return false if @segment_id < 1
|
172
|
+
return false if @variant_id.nil?
|
173
|
+
return false if @variant_id < 1
|
174
|
+
return false if @variant_key.nil?
|
175
|
+
return false if @variant_key.to_s.length < 1
|
176
|
+
return false if @variant_attachment.nil?
|
177
|
+
return false if @eval_context.nil?
|
178
|
+
return false if @timestamp.nil?
|
179
|
+
return false if @timestamp.to_s.length < 1
|
180
|
+
true
|
181
|
+
end
|
182
|
+
|
183
|
+
# Custom attribute writer method with validation
|
184
|
+
# @param [Object] flag_id Value to be assigned
|
185
|
+
def flag_id=(flag_id)
|
186
|
+
if flag_id.nil?
|
187
|
+
fail ArgumentError, 'flag_id cannot be nil'
|
188
|
+
end
|
189
|
+
|
190
|
+
if flag_id < 1
|
191
|
+
fail ArgumentError, 'invalid value for "flag_id", must be greater than or equal to 1.'
|
192
|
+
end
|
193
|
+
|
194
|
+
@flag_id = flag_id
|
195
|
+
end
|
196
|
+
|
197
|
+
# Custom attribute writer method with validation
|
198
|
+
# @param [Object] segment_id Value to be assigned
|
199
|
+
def segment_id=(segment_id)
|
200
|
+
if segment_id.nil?
|
201
|
+
fail ArgumentError, 'segment_id cannot be nil'
|
202
|
+
end
|
203
|
+
|
204
|
+
if segment_id < 1
|
205
|
+
fail ArgumentError, 'invalid value for "segment_id", must be greater than or equal to 1.'
|
206
|
+
end
|
207
|
+
|
208
|
+
@segment_id = segment_id
|
209
|
+
end
|
210
|
+
|
211
|
+
# Custom attribute writer method with validation
|
212
|
+
# @param [Object] variant_id Value to be assigned
|
213
|
+
def variant_id=(variant_id)
|
214
|
+
if variant_id.nil?
|
215
|
+
fail ArgumentError, 'variant_id cannot be nil'
|
216
|
+
end
|
217
|
+
|
218
|
+
if variant_id < 1
|
219
|
+
fail ArgumentError, 'invalid value for "variant_id", must be greater than or equal to 1.'
|
220
|
+
end
|
221
|
+
|
222
|
+
@variant_id = variant_id
|
223
|
+
end
|
224
|
+
|
225
|
+
# Custom attribute writer method with validation
|
226
|
+
# @param [Object] variant_key Value to be assigned
|
227
|
+
def variant_key=(variant_key)
|
228
|
+
if variant_key.nil?
|
229
|
+
fail ArgumentError, 'variant_key cannot be nil'
|
230
|
+
end
|
231
|
+
|
232
|
+
if variant_key.to_s.length < 1
|
233
|
+
fail ArgumentError, 'invalid value for "variant_key", the character length must be great than or equal to 1.'
|
234
|
+
end
|
235
|
+
|
236
|
+
@variant_key = variant_key
|
237
|
+
end
|
238
|
+
|
239
|
+
# Custom attribute writer method with validation
|
240
|
+
# @param [Object] timestamp Value to be assigned
|
241
|
+
def timestamp=(timestamp)
|
242
|
+
if timestamp.nil?
|
243
|
+
fail ArgumentError, 'timestamp cannot be nil'
|
244
|
+
end
|
245
|
+
|
246
|
+
if timestamp.to_s.length < 1
|
247
|
+
fail ArgumentError, 'invalid value for "timestamp", the character length must be great than or equal to 1.'
|
248
|
+
end
|
249
|
+
|
250
|
+
@timestamp = timestamp
|
251
|
+
end
|
252
|
+
|
253
|
+
# Checks equality by comparing each attribute.
|
254
|
+
# @param [Object] Object to be compared
|
255
|
+
def ==(o)
|
256
|
+
return true if self.equal?(o)
|
257
|
+
self.class == o.class &&
|
258
|
+
flag_id == o.flag_id &&
|
259
|
+
flag_snapshot_id == o.flag_snapshot_id &&
|
260
|
+
segment_id == o.segment_id &&
|
261
|
+
variant_id == o.variant_id &&
|
262
|
+
variant_key == o.variant_key &&
|
263
|
+
variant_attachment == o.variant_attachment &&
|
264
|
+
eval_context == o.eval_context &&
|
265
|
+
timestamp == o.timestamp &&
|
266
|
+
eval_debug_log == o.eval_debug_log
|
267
|
+
end
|
268
|
+
|
269
|
+
# @see the `==` method
|
270
|
+
# @param [Object] Object to be compared
|
271
|
+
def eql?(o)
|
272
|
+
self == o
|
273
|
+
end
|
274
|
+
|
275
|
+
# Calculates hash code according to all attributes.
|
276
|
+
# @return [Fixnum] Hash code
|
277
|
+
def hash
|
278
|
+
[flag_id, flag_snapshot_id, segment_id, variant_id, variant_key, variant_attachment, eval_context, timestamp, eval_debug_log].hash
|
279
|
+
end
|
280
|
+
|
281
|
+
# Builds the object from hash
|
282
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
283
|
+
# @return [Object] Returns the model itself
|
284
|
+
def build_from_hash(attributes)
|
285
|
+
return nil unless attributes.is_a?(Hash)
|
286
|
+
self.class.swagger_types.each_pair do |key, type|
|
287
|
+
if type =~ /\AArray<(.*)>/i
|
288
|
+
# check to ensure the input is an array given that the the attribute
|
289
|
+
# is documented as an array but the input is not
|
290
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
291
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
292
|
+
end
|
293
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
294
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
295
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
296
|
+
end
|
297
|
+
|
298
|
+
self
|
299
|
+
end
|
300
|
+
|
301
|
+
# Deserializes the data based on type
|
302
|
+
# @param string type Data type
|
303
|
+
# @param string value Value to be deserialized
|
304
|
+
# @return [Object] Deserialized data
|
305
|
+
def _deserialize(type, value)
|
306
|
+
case type.to_sym
|
307
|
+
when :DateTime
|
308
|
+
DateTime.parse(value)
|
309
|
+
when :Date
|
310
|
+
Date.parse(value)
|
311
|
+
when :String
|
312
|
+
value.to_s
|
313
|
+
when :Integer
|
314
|
+
value.to_i
|
315
|
+
when :Float
|
316
|
+
value.to_f
|
317
|
+
when :BOOLEAN
|
318
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
319
|
+
true
|
320
|
+
else
|
321
|
+
false
|
322
|
+
end
|
323
|
+
when :Object
|
324
|
+
# generic object (usually a Hash), return directly
|
325
|
+
value
|
326
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
327
|
+
inner_type = Regexp.last_match[:inner_type]
|
328
|
+
value.map { |v| _deserialize(inner_type, v) }
|
329
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
330
|
+
k_type = Regexp.last_match[:k_type]
|
331
|
+
v_type = Regexp.last_match[:v_type]
|
332
|
+
{}.tap do |hash|
|
333
|
+
value.each do |k, v|
|
334
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
else # model
|
338
|
+
temp_model = Flagr.const_get(type).new
|
339
|
+
temp_model.build_from_hash(value)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# Returns the string representation of the object
|
344
|
+
# @return [String] String presentation of the object
|
345
|
+
def to_s
|
346
|
+
to_hash.to_s
|
347
|
+
end
|
348
|
+
|
349
|
+
# to_body is an alias to to_hash (backward compatibility)
|
350
|
+
# @return [Hash] Returns the object in the form of hash
|
351
|
+
def to_body
|
352
|
+
to_hash
|
353
|
+
end
|
354
|
+
|
355
|
+
# Returns the object in the form of hash
|
356
|
+
# @return [Hash] Returns the object in the form of hash
|
357
|
+
def to_hash
|
358
|
+
hash = {}
|
359
|
+
self.class.attribute_map.each_pair do |attr, param|
|
360
|
+
value = self.send(attr)
|
361
|
+
next if value.nil?
|
362
|
+
hash[param] = _to_hash(value)
|
363
|
+
end
|
364
|
+
hash
|
365
|
+
end
|
366
|
+
|
367
|
+
# Outputs non-array value in the form of hash
|
368
|
+
# For object, use to_hash. Otherwise, just return the value
|
369
|
+
# @param [Object] value Any valid value
|
370
|
+
# @return [Hash] Returns the value in the form of hash
|
371
|
+
def _to_hash(value)
|
372
|
+
if value.is_a?(Array)
|
373
|
+
value.compact.map { |v| _to_hash(v) }
|
374
|
+
elsif value.is_a?(Hash)
|
375
|
+
{}.tap do |hash|
|
376
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
377
|
+
end
|
378
|
+
elsif value.respond_to? :to_hash
|
379
|
+
value.to_hash
|
380
|
+
else
|
381
|
+
value
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|