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,245 @@
|
|
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 VariationMap
|
18
|
+
attr_accessor :variation
|
19
|
+
|
20
|
+
attr_accessor :targets
|
21
|
+
|
22
|
+
attr_accessor :target_segments
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'variation' => :'variation',
|
28
|
+
:'targets' => :'targets',
|
29
|
+
:'target_segments' => :'targetSegments'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'variation' => :'String',
|
42
|
+
:'targets' => :'Array<TargetMap>',
|
43
|
+
:'target_segments' => :'Array<String>'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# List of attributes with nullable: true
|
48
|
+
def self.openapi_nullable
|
49
|
+
Set.new([
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
if (!attributes.is_a?(Hash))
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::VariationMap` initialize method"
|
58
|
+
end
|
59
|
+
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
61
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
62
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::VariationMap`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
64
|
+
end
|
65
|
+
h[k.to_sym] = v
|
66
|
+
}
|
67
|
+
|
68
|
+
if attributes.key?(:'variation')
|
69
|
+
self.variation = attributes[:'variation']
|
70
|
+
end
|
71
|
+
|
72
|
+
if attributes.key?(:'targets')
|
73
|
+
if (value = attributes[:'targets']).is_a?(Array)
|
74
|
+
self.targets = value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'target_segments')
|
79
|
+
if (value = attributes[:'target_segments']).is_a?(Array)
|
80
|
+
self.target_segments = value
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
86
|
+
# @return Array for valid properties with the reasons
|
87
|
+
def list_invalid_properties
|
88
|
+
invalid_properties = Array.new
|
89
|
+
if @variation.nil?
|
90
|
+
invalid_properties.push('invalid value for "variation", variation cannot be nil.')
|
91
|
+
end
|
92
|
+
|
93
|
+
invalid_properties
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check to see if the all the properties in the model are valid
|
97
|
+
# @return true if the model is valid
|
98
|
+
def valid?
|
99
|
+
return false if @variation.nil?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
# Checks equality by comparing each attribute.
|
104
|
+
# @param [Object] Object to be compared
|
105
|
+
def ==(o)
|
106
|
+
return true if self.equal?(o)
|
107
|
+
self.class == o.class &&
|
108
|
+
variation == o.variation &&
|
109
|
+
targets == o.targets &&
|
110
|
+
target_segments == o.target_segments
|
111
|
+
end
|
112
|
+
|
113
|
+
# @see the `==` method
|
114
|
+
# @param [Object] Object to be compared
|
115
|
+
def eql?(o)
|
116
|
+
self == o
|
117
|
+
end
|
118
|
+
|
119
|
+
# Calculates hash code according to all attributes.
|
120
|
+
# @return [Integer] Hash code
|
121
|
+
def hash
|
122
|
+
[variation, targets, target_segments].hash
|
123
|
+
end
|
124
|
+
|
125
|
+
# Builds the object from hash
|
126
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
127
|
+
# @return [Object] Returns the model itself
|
128
|
+
def self.build_from_hash(attributes)
|
129
|
+
new.build_from_hash(attributes)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Builds the object from hash
|
133
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
134
|
+
# @return [Object] Returns the model itself
|
135
|
+
def build_from_hash(attributes)
|
136
|
+
return nil unless attributes.is_a?(Hash)
|
137
|
+
self.class.openapi_types.each_pair do |key, type|
|
138
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
139
|
+
self.send("#{key}=", nil)
|
140
|
+
elsif type =~ /\AArray<(.*)>/i
|
141
|
+
# check to ensure the input is an array given that the attribute
|
142
|
+
# is documented as an array but the input is not
|
143
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
144
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
145
|
+
end
|
146
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
147
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
self
|
152
|
+
end
|
153
|
+
|
154
|
+
# Deserializes the data based on type
|
155
|
+
# @param string type Data type
|
156
|
+
# @param string value Value to be deserialized
|
157
|
+
# @return [Object] Deserialized data
|
158
|
+
def _deserialize(type, value)
|
159
|
+
case type.to_sym
|
160
|
+
when :Time
|
161
|
+
Time.parse(value)
|
162
|
+
when :Date
|
163
|
+
Date.parse(value)
|
164
|
+
when :String
|
165
|
+
value.to_s
|
166
|
+
when :Integer
|
167
|
+
value.to_i
|
168
|
+
when :Float
|
169
|
+
value.to_f
|
170
|
+
when :Boolean
|
171
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
172
|
+
true
|
173
|
+
else
|
174
|
+
false
|
175
|
+
end
|
176
|
+
when :Object
|
177
|
+
# generic object (usually a Hash), return directly
|
178
|
+
value
|
179
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
180
|
+
inner_type = Regexp.last_match[:inner_type]
|
181
|
+
value.map { |v| _deserialize(inner_type, v) }
|
182
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
183
|
+
k_type = Regexp.last_match[:k_type]
|
184
|
+
v_type = Regexp.last_match[:v_type]
|
185
|
+
{}.tap do |hash|
|
186
|
+
value.each do |k, v|
|
187
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
else # model
|
191
|
+
# models (e.g. Pet) or oneOf
|
192
|
+
klass = OpenapiClient.const_get(type)
|
193
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Returns the string representation of the object
|
198
|
+
# @return [String] String presentation of the object
|
199
|
+
def to_s
|
200
|
+
to_hash.to_s
|
201
|
+
end
|
202
|
+
|
203
|
+
# to_body is an alias to to_hash (backward compatibility)
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_body
|
206
|
+
to_hash
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the object in the form of hash
|
210
|
+
# @return [Hash] Returns the object in the form of hash
|
211
|
+
def to_hash
|
212
|
+
hash = {}
|
213
|
+
self.class.attribute_map.each_pair do |attr, param|
|
214
|
+
value = self.send(attr)
|
215
|
+
if value.nil?
|
216
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
217
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
218
|
+
end
|
219
|
+
|
220
|
+
hash[param] = _to_hash(value)
|
221
|
+
end
|
222
|
+
hash
|
223
|
+
end
|
224
|
+
|
225
|
+
# Outputs non-array value in the form of hash
|
226
|
+
# For object, use to_hash. Otherwise, just return the value
|
227
|
+
# @param [Object] value Any valid value
|
228
|
+
# @return [Hash] Returns the value in the form of hash
|
229
|
+
def _to_hash(value)
|
230
|
+
if value.is_a?(Array)
|
231
|
+
value.compact.map { |v| _to_hash(v) }
|
232
|
+
elsif value.is_a?(Hash)
|
233
|
+
{}.tap do |hash|
|
234
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
235
|
+
end
|
236
|
+
elsif value.respond_to? :to_hash
|
237
|
+
value.to_hash
|
238
|
+
else
|
239
|
+
value
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
@@ -0,0 +1,237 @@
|
|
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 WeightedVariation
|
18
|
+
attr_accessor :variation
|
19
|
+
|
20
|
+
attr_accessor :weight
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'variation' => :'variation',
|
26
|
+
:'weight' => :'weight'
|
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
|
+
:'variation' => :'String',
|
39
|
+
:'weight' => :'Integer'
|
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::WeightedVariation` 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::WeightedVariation`. 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?(:'variation')
|
65
|
+
self.variation = attributes[:'variation']
|
66
|
+
end
|
67
|
+
|
68
|
+
if attributes.key?(:'weight')
|
69
|
+
self.weight = attributes[:'weight']
|
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
|
+
if @variation.nil?
|
78
|
+
invalid_properties.push('invalid value for "variation", variation cannot be nil.')
|
79
|
+
end
|
80
|
+
|
81
|
+
if @weight.nil?
|
82
|
+
invalid_properties.push('invalid value for "weight", weight cannot be nil.')
|
83
|
+
end
|
84
|
+
|
85
|
+
invalid_properties
|
86
|
+
end
|
87
|
+
|
88
|
+
# Check to see if the all the properties in the model are valid
|
89
|
+
# @return true if the model is valid
|
90
|
+
def valid?
|
91
|
+
return false if @variation.nil?
|
92
|
+
return false if @weight.nil?
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
96
|
+
# Checks equality by comparing each attribute.
|
97
|
+
# @param [Object] Object to be compared
|
98
|
+
def ==(o)
|
99
|
+
return true if self.equal?(o)
|
100
|
+
self.class == o.class &&
|
101
|
+
variation == o.variation &&
|
102
|
+
weight == o.weight
|
103
|
+
end
|
104
|
+
|
105
|
+
# @see the `==` method
|
106
|
+
# @param [Object] Object to be compared
|
107
|
+
def eql?(o)
|
108
|
+
self == o
|
109
|
+
end
|
110
|
+
|
111
|
+
# Calculates hash code according to all attributes.
|
112
|
+
# @return [Integer] Hash code
|
113
|
+
def hash
|
114
|
+
[variation, weight].hash
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def self.build_from_hash(attributes)
|
121
|
+
new.build_from_hash(attributes)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.openapi_types.each_pair do |key, type|
|
130
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
131
|
+
self.send("#{key}=", nil)
|
132
|
+
elsif type =~ /\AArray<(.*)>/i
|
133
|
+
# check to ensure the input is an array given that the attribute
|
134
|
+
# is documented as an array but the input is not
|
135
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
136
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
137
|
+
end
|
138
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
139
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
# Deserializes the data based on type
|
147
|
+
# @param string type Data type
|
148
|
+
# @param string value Value to be deserialized
|
149
|
+
# @return [Object] Deserialized data
|
150
|
+
def _deserialize(type, value)
|
151
|
+
case type.to_sym
|
152
|
+
when :Time
|
153
|
+
Time.parse(value)
|
154
|
+
when :Date
|
155
|
+
Date.parse(value)
|
156
|
+
when :String
|
157
|
+
value.to_s
|
158
|
+
when :Integer
|
159
|
+
value.to_i
|
160
|
+
when :Float
|
161
|
+
value.to_f
|
162
|
+
when :Boolean
|
163
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
164
|
+
true
|
165
|
+
else
|
166
|
+
false
|
167
|
+
end
|
168
|
+
when :Object
|
169
|
+
# generic object (usually a Hash), return directly
|
170
|
+
value
|
171
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
172
|
+
inner_type = Regexp.last_match[:inner_type]
|
173
|
+
value.map { |v| _deserialize(inner_type, v) }
|
174
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
175
|
+
k_type = Regexp.last_match[:k_type]
|
176
|
+
v_type = Regexp.last_match[:v_type]
|
177
|
+
{}.tap do |hash|
|
178
|
+
value.each do |k, v|
|
179
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
else # model
|
183
|
+
# models (e.g. Pet) or oneOf
|
184
|
+
klass = OpenapiClient.const_get(type)
|
185
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# Returns the string representation of the object
|
190
|
+
# @return [String] String presentation of the object
|
191
|
+
def to_s
|
192
|
+
to_hash.to_s
|
193
|
+
end
|
194
|
+
|
195
|
+
# to_body is an alias to to_hash (backward compatibility)
|
196
|
+
# @return [Hash] Returns the object in the form of hash
|
197
|
+
def to_body
|
198
|
+
to_hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the object in the form of hash
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_hash
|
204
|
+
hash = {}
|
205
|
+
self.class.attribute_map.each_pair do |attr, param|
|
206
|
+
value = self.send(attr)
|
207
|
+
if value.nil?
|
208
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
209
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
210
|
+
end
|
211
|
+
|
212
|
+
hash[param] = _to_hash(value)
|
213
|
+
end
|
214
|
+
hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Outputs non-array value in the form of hash
|
218
|
+
# For object, use to_hash. Otherwise, just return the value
|
219
|
+
# @param [Object] value Any valid value
|
220
|
+
# @return [Hash] Returns the value in the form of hash
|
221
|
+
def _to_hash(value)
|
222
|
+
if value.is_a?(Array)
|
223
|
+
value.compact.map { |v| _to_hash(v) }
|
224
|
+
elsif value.is_a?(Hash)
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
227
|
+
end
|
228
|
+
elsif value.respond_to? :to_hash
|
229
|
+
value.to_hash
|
230
|
+
else
|
231
|
+
value
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
@@ -0,0 +1,15 @@
|
|
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
|
+
module OpenapiClient
|
14
|
+
VERSION = '1.0.0'
|
15
|
+
end
|
@@ -0,0 +1,65 @@
|
|
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
|
+
# Common files
|
14
|
+
require 'openapi_client/api_client'
|
15
|
+
require 'openapi_client/api_error'
|
16
|
+
require 'openapi_client/version'
|
17
|
+
require 'openapi_client/configuration'
|
18
|
+
|
19
|
+
# Models
|
20
|
+
require 'openapi_client/models/authentication_request'
|
21
|
+
require 'openapi_client/models/authentication_request_target'
|
22
|
+
require 'openapi_client/models/authentication_response'
|
23
|
+
require 'openapi_client/models/clause'
|
24
|
+
require 'openapi_client/models/distribution'
|
25
|
+
require 'openapi_client/models/error'
|
26
|
+
require 'openapi_client/models/evaluation'
|
27
|
+
require 'openapi_client/models/feature_config'
|
28
|
+
require 'openapi_client/models/feature_state'
|
29
|
+
require 'openapi_client/models/key_value'
|
30
|
+
require 'openapi_client/models/metrics'
|
31
|
+
require 'openapi_client/models/metrics_data'
|
32
|
+
require 'openapi_client/models/pagination'
|
33
|
+
require 'openapi_client/models/prerequisite'
|
34
|
+
require 'openapi_client/models/segment'
|
35
|
+
require 'openapi_client/models/serve'
|
36
|
+
require 'openapi_client/models/serving_rule'
|
37
|
+
require 'openapi_client/models/tag'
|
38
|
+
require 'openapi_client/models/target'
|
39
|
+
require 'openapi_client/models/target_data'
|
40
|
+
require 'openapi_client/models/target_map'
|
41
|
+
require 'openapi_client/models/variation'
|
42
|
+
require 'openapi_client/models/variation_map'
|
43
|
+
require 'openapi_client/models/weighted_variation'
|
44
|
+
|
45
|
+
# APIs
|
46
|
+
require 'openapi_client/api/client_api'
|
47
|
+
require 'openapi_client/api/metrics_api'
|
48
|
+
|
49
|
+
module OpenapiClient
|
50
|
+
class << self
|
51
|
+
# Customize default settings for the SDK using block.
|
52
|
+
# OpenapiClient.configure do |config|
|
53
|
+
# config.username = "xxx"
|
54
|
+
# config.password = "xxx"
|
55
|
+
# end
|
56
|
+
# If no block given, return the default Configuration object.
|
57
|
+
def configure
|
58
|
+
if block_given?
|
59
|
+
yield(Configuration.default)
|
60
|
+
else
|
61
|
+
Configuration.default
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require_relative "../common/closeable"
|
2
|
+
|
3
|
+
class AuthService < Closeable
|
4
|
+
|
5
|
+
def initialize(connector = nil, poll_interval_in_sec = 60, callback = nil, logger = nil)
|
6
|
+
|
7
|
+
unless connector.kind_of?(Connector)
|
8
|
+
|
9
|
+
raise "The 'connector' parameter must be of '" + Connector.to_s + "' data type"
|
10
|
+
end
|
11
|
+
|
12
|
+
unless callback.kind_of?(ClientCallback)
|
13
|
+
|
14
|
+
raise "The 'callback' parameter must be of '" + ClientCallback.to_s + "' data type"
|
15
|
+
end
|
16
|
+
|
17
|
+
@callback = callback
|
18
|
+
@connector = connector
|
19
|
+
@poll_interval_in_sec = poll_interval_in_sec
|
20
|
+
|
21
|
+
if logger != nil
|
22
|
+
|
23
|
+
@logger = logger
|
24
|
+
else
|
25
|
+
|
26
|
+
@logger = Logger.new(STDOUT)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def start_async
|
31
|
+
|
32
|
+
@logger.debug "Async starting: " + self.to_s
|
33
|
+
|
34
|
+
@ready = true
|
35
|
+
|
36
|
+
@thread = Thread.new do
|
37
|
+
|
38
|
+
@logger.debug "Async started: " + self.to_s
|
39
|
+
|
40
|
+
while @ready do
|
41
|
+
|
42
|
+
@logger.debug "Async auth iteration"
|
43
|
+
|
44
|
+
if @connector.authenticate
|
45
|
+
|
46
|
+
@callback.on_auth_success
|
47
|
+
stop_async
|
48
|
+
@logger.info "Stopping Auth service"
|
49
|
+
else
|
50
|
+
|
51
|
+
@logger.error "Exception while authenticating, retry in " + @poll_interval_in_sec.to_s + " seconds"
|
52
|
+
end
|
53
|
+
|
54
|
+
sleep(@poll_interval_in_sec)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
@thread.run
|
59
|
+
end
|
60
|
+
|
61
|
+
def close
|
62
|
+
|
63
|
+
stop_async
|
64
|
+
end
|
65
|
+
|
66
|
+
def on_auth_success
|
67
|
+
|
68
|
+
unless @callback == nil
|
69
|
+
|
70
|
+
unless @callback.kind_of?(ClientCallback)
|
71
|
+
|
72
|
+
raise "Expected '" + ClientCallback.to_s + "' data type for the callback"
|
73
|
+
end
|
74
|
+
|
75
|
+
@callback.on_auth_success
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
protected
|
80
|
+
|
81
|
+
def stop_async
|
82
|
+
|
83
|
+
@ready = false
|
84
|
+
|
85
|
+
if @thread != nil
|
86
|
+
|
87
|
+
@thread.exit
|
88
|
+
@thread = nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|