hatchet-sdk 0.13.1 → 0.13.2

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,393 @@
1
+ =begin
2
+ #Hatchet API
3
+
4
+ #The Hatchet API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.14.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module HatchetSdkRest
17
+ class V1CreateSandboxProviderRequest
18
+ # The name of the provider. Unique within the tenant.
19
+ attr_accessor :name
20
+
21
+ attr_accessor :kind
22
+
23
+ # The sandbox provider API key. It is write-only, stored encrypted and never returned.
24
+ attr_accessor :api_key
25
+
26
+ # Provider settings as JSON. Unknown keys are rejected.
27
+ attr_accessor :config
28
+
29
+ attr_accessor :default_template
30
+
31
+ # Defaults to 900.
32
+ attr_accessor :max_idle_ttl_seconds
33
+
34
+ # Default metadata for every sandbox this provider creates.
35
+ attr_accessor :labels
36
+
37
+ # Defaults to true.
38
+ attr_accessor :enabled
39
+
40
+ class EnumAttributeValidator
41
+ attr_reader :datatype
42
+ attr_reader :allowable_values
43
+
44
+ def initialize(datatype, allowable_values)
45
+ @allowable_values = allowable_values.map do |value|
46
+ case datatype.to_s
47
+ when /Integer/i
48
+ value.to_i
49
+ when /Float/i
50
+ value.to_f
51
+ else
52
+ value
53
+ end
54
+ end
55
+ end
56
+
57
+ def valid?(value)
58
+ !value || allowable_values.include?(value)
59
+ end
60
+ end
61
+
62
+ # Attribute mapping from ruby-style variable name to JSON key.
63
+ def self.attribute_map
64
+ {
65
+ :'name' => :'name',
66
+ :'kind' => :'kind',
67
+ :'api_key' => :'apiKey',
68
+ :'config' => :'config',
69
+ :'default_template' => :'defaultTemplate',
70
+ :'max_idle_ttl_seconds' => :'maxIdleTtlSeconds',
71
+ :'labels' => :'labels',
72
+ :'enabled' => :'enabled'
73
+ }
74
+ end
75
+
76
+ # Returns attribute mapping this model knows about
77
+ def self.acceptable_attribute_map
78
+ attribute_map
79
+ end
80
+
81
+ # Returns all the JSON keys this model knows about
82
+ def self.acceptable_attributes
83
+ acceptable_attribute_map.values
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.openapi_types
88
+ {
89
+ :'name' => :'String',
90
+ :'kind' => :'V1SandboxProviderKind',
91
+ :'api_key' => :'String',
92
+ :'config' => :'Hash<String, Object>',
93
+ :'default_template' => :'String',
94
+ :'max_idle_ttl_seconds' => :'Integer',
95
+ :'labels' => :'Hash<String, String>',
96
+ :'enabled' => :'Boolean'
97
+ }
98
+ end
99
+
100
+ # List of attributes with nullable: true
101
+ def self.openapi_nullable
102
+ Set.new([
103
+ ])
104
+ end
105
+
106
+ # Initializes the object
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ def initialize(attributes = {})
109
+ if (!attributes.is_a?(Hash))
110
+ fail ArgumentError, "The input argument (attributes) must be a hash in `HatchetSdkRest::V1CreateSandboxProviderRequest` initialize method"
111
+ end
112
+
113
+ # check to see if the attribute exists and convert string to symbol for hash key
114
+ acceptable_attribute_map = self.class.acceptable_attribute_map
115
+ attributes = attributes.each_with_object({}) { |(k, v), h|
116
+ if (!acceptable_attribute_map.key?(k.to_sym))
117
+ fail ArgumentError, "`#{k}` is not a valid attribute in `HatchetSdkRest::V1CreateSandboxProviderRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
118
+ end
119
+ h[k.to_sym] = v
120
+ }
121
+
122
+ if attributes.key?(:'name')
123
+ self.name = attributes[:'name']
124
+ else
125
+ self.name = nil
126
+ end
127
+
128
+ if attributes.key?(:'kind')
129
+ self.kind = attributes[:'kind']
130
+ else
131
+ self.kind = nil
132
+ end
133
+
134
+ if attributes.key?(:'api_key')
135
+ self.api_key = attributes[:'api_key']
136
+ else
137
+ self.api_key = nil
138
+ end
139
+
140
+ if attributes.key?(:'config')
141
+ if (value = attributes[:'config']).is_a?(Hash)
142
+ self.config = value
143
+ end
144
+ end
145
+
146
+ if attributes.key?(:'default_template')
147
+ self.default_template = attributes[:'default_template']
148
+ end
149
+
150
+ if attributes.key?(:'max_idle_ttl_seconds')
151
+ self.max_idle_ttl_seconds = attributes[:'max_idle_ttl_seconds']
152
+ end
153
+
154
+ if attributes.key?(:'labels')
155
+ if (value = attributes[:'labels']).is_a?(Hash)
156
+ self.labels = value
157
+ end
158
+ end
159
+
160
+ if attributes.key?(:'enabled')
161
+ self.enabled = attributes[:'enabled']
162
+ end
163
+ end
164
+
165
+ # Show invalid properties with the reasons. Usually used together with valid?
166
+ # @return Array for valid properties with the reasons
167
+ def list_invalid_properties
168
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
169
+ invalid_properties = Array.new
170
+ if @name.nil?
171
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
172
+ end
173
+
174
+ if @name.to_s.length > 255
175
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 255.')
176
+ end
177
+
178
+ if @name.to_s.length < 1
179
+ invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
180
+ end
181
+
182
+ if @kind.nil?
183
+ invalid_properties.push('invalid value for "kind", kind cannot be nil.')
184
+ end
185
+
186
+ if @api_key.nil?
187
+ invalid_properties.push('invalid value for "api_key", api_key cannot be nil.')
188
+ end
189
+
190
+ if @api_key.to_s.length < 1
191
+ invalid_properties.push('invalid value for "api_key", the character length must be greater than or equal to 1.')
192
+ end
193
+
194
+ invalid_properties
195
+ end
196
+
197
+ # Check to see if the all the properties in the model are valid
198
+ # @return true if the model is valid
199
+ def valid?
200
+ warn '[DEPRECATED] the `valid?` method is obsolete'
201
+ return false if @name.nil?
202
+ return false if @name.to_s.length > 255
203
+ return false if @name.to_s.length < 1
204
+ return false if @kind.nil?
205
+ return false if @api_key.nil?
206
+ return false if @api_key.to_s.length < 1
207
+ true
208
+ end
209
+
210
+ # Custom attribute writer method with validation
211
+ # @param [Object] name Value to be assigned
212
+ def name=(name)
213
+ if name.nil?
214
+ fail ArgumentError, 'name cannot be nil'
215
+ end
216
+
217
+ if name.to_s.length > 255
218
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.'
219
+ end
220
+
221
+ if name.to_s.length < 1
222
+ fail ArgumentError, 'invalid value for "name", the character length must be greater than or equal to 1.'
223
+ end
224
+
225
+ @name = name
226
+ end
227
+
228
+ # Custom attribute writer method with validation
229
+ # @param [Object] kind Value to be assigned
230
+ def kind=(kind)
231
+ if kind.nil?
232
+ fail ArgumentError, 'kind cannot be nil'
233
+ end
234
+
235
+ @kind = kind
236
+ end
237
+
238
+ # Custom attribute writer method with validation
239
+ # @param [Object] api_key Value to be assigned
240
+ def api_key=(api_key)
241
+ if api_key.nil?
242
+ fail ArgumentError, 'api_key cannot be nil'
243
+ end
244
+
245
+ if api_key.to_s.length < 1
246
+ fail ArgumentError, 'invalid value for "api_key", the character length must be greater than or equal to 1.'
247
+ end
248
+
249
+ @api_key = api_key
250
+ end
251
+
252
+ # Checks equality by comparing each attribute.
253
+ # @param [Object] Object to be compared
254
+ def ==(o)
255
+ return true if self.equal?(o)
256
+ self.class == o.class &&
257
+ name == o.name &&
258
+ kind == o.kind &&
259
+ api_key == o.api_key &&
260
+ config == o.config &&
261
+ default_template == o.default_template &&
262
+ max_idle_ttl_seconds == o.max_idle_ttl_seconds &&
263
+ labels == o.labels &&
264
+ enabled == o.enabled
265
+ end
266
+
267
+ # @see the `==` method
268
+ # @param [Object] Object to be compared
269
+ def eql?(o)
270
+ self == o
271
+ end
272
+
273
+ # Calculates hash code according to all attributes.
274
+ # @return [Integer] Hash code
275
+ def hash
276
+ [name, kind, api_key, config, default_template, max_idle_ttl_seconds, labels, enabled].hash
277
+ end
278
+
279
+ # Builds the object from hash
280
+ # @param [Hash] attributes Model attributes in the form of hash
281
+ # @return [Object] Returns the model itself
282
+ def self.build_from_hash(attributes)
283
+ return nil unless attributes.is_a?(Hash)
284
+ attributes = attributes.transform_keys(&:to_sym)
285
+ transformed_hash = {}
286
+ openapi_types.each_pair do |key, type|
287
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
288
+ transformed_hash["#{key}"] = nil
289
+ elsif type =~ /\AArray<(.*)>/i
290
+ # check to ensure the input is an array given that the attribute
291
+ # is documented as an array but the input is not
292
+ if attributes[attribute_map[key]].is_a?(Array)
293
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
294
+ end
295
+ elsif !attributes[attribute_map[key]].nil?
296
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
297
+ end
298
+ end
299
+ new(transformed_hash)
300
+ end
301
+
302
+ # Deserializes the data based on type
303
+ # @param string type Data type
304
+ # @param string value Value to be deserialized
305
+ # @return [Object] Deserialized data
306
+ def self._deserialize(type, value)
307
+ case type.to_sym
308
+ when :Time
309
+ Time.parse(value)
310
+ when :Date
311
+ Date.parse(value)
312
+ when :String
313
+ value.to_s
314
+ when :Integer
315
+ value.to_i
316
+ when :Float
317
+ value.to_f
318
+ when :Boolean
319
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
320
+ true
321
+ else
322
+ false
323
+ end
324
+ when :Object
325
+ # generic object (usually a Hash), return directly
326
+ value
327
+ when /\AArray<(?<inner_type>.+)>\z/
328
+ inner_type = Regexp.last_match[:inner_type]
329
+ value.map { |v| _deserialize(inner_type, v) }
330
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
331
+ k_type = Regexp.last_match[:k_type]
332
+ v_type = Regexp.last_match[:v_type]
333
+ {}.tap do |hash|
334
+ value.each do |k, v|
335
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
336
+ end
337
+ end
338
+ else # model
339
+ # models (e.g. Pet) or oneOf
340
+ klass = HatchetSdkRest.const_get(type)
341
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
342
+ end
343
+ end
344
+
345
+ # Returns the string representation of the object
346
+ # @return [String] String presentation of the object
347
+ def to_s
348
+ to_hash.to_s
349
+ end
350
+
351
+ # to_body is an alias to to_hash (backward compatibility)
352
+ # @return [Hash] Returns the object in the form of hash
353
+ def to_body
354
+ to_hash
355
+ end
356
+
357
+ # Returns the object in the form of hash
358
+ # @return [Hash] Returns the object in the form of hash
359
+ def to_hash
360
+ hash = {}
361
+ self.class.attribute_map.each_pair do |attr, param|
362
+ value = self.send(attr)
363
+ if value.nil?
364
+ is_nullable = self.class.openapi_nullable.include?(attr)
365
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
366
+ end
367
+
368
+ hash[param] = _to_hash(value)
369
+ end
370
+ hash
371
+ end
372
+
373
+ # Outputs non-array value in the form of hash
374
+ # For object, use to_hash. Otherwise, just return the value
375
+ # @param [Object] value Any valid value
376
+ # @return [Hash] Returns the value in the form of hash
377
+ def _to_hash(value)
378
+ if value.is_a?(Array)
379
+ value.compact.map { |v| _to_hash(v) }
380
+ elsif value.is_a?(Hash)
381
+ {}.tap do |hash|
382
+ value.each { |k, v| hash[k] = _to_hash(v) }
383
+ end
384
+ elsif value.respond_to? :to_hash
385
+ value.to_hash
386
+ else
387
+ value
388
+ end
389
+ end
390
+
391
+ end
392
+
393
+ end