torii-backend 0.0.6 → 0.0.8

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.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/spec/server-v1.json +1 -1
  3. data/src/torii/backend/client.rb +7 -13
  4. data/src/torii/backend/generated/lib/torii_backend_generated/api/invitations_api.rb +336 -0
  5. data/src/torii/backend/generated/lib/torii_backend_generated/api/server_impersonation_api.rb +96 -0
  6. data/src/torii/backend/generated/lib/torii_backend_generated/api/server_users_api.rb +4 -4
  7. data/src/torii/backend/generated/lib/torii_backend_generated/models/create_environment_invitation_server_request.rb +240 -0
  8. data/src/torii/backend/generated/lib/torii_backend_generated/models/create_user_request.rb +3 -3
  9. data/src/torii/backend/generated/lib/torii_backend_generated/models/cursor_page_response_environment_invitation_response.rb +206 -0
  10. data/src/torii/backend/generated/lib/torii_backend_generated/models/environment_invitation_response.rb +338 -0
  11. data/src/torii/backend/generated/lib/torii_backend_generated/models/server_impersonation_token_request.rb +246 -0
  12. data/src/torii/backend/generated/lib/torii_backend_generated/models/server_impersonation_token_response.rb +193 -0
  13. data/src/torii/backend/generated/lib/torii_backend_generated/models/server_user_search_request.rb +27 -3
  14. data/src/torii/backend/generated/lib/torii_backend_generated/models/update_user_metadata_request.rb +3 -3
  15. data/src/torii/backend/generated/lib/torii_backend_generated/models/update_user_request.rb +1 -1
  16. data/src/torii/backend/generated/lib/torii_backend_generated.rb +7 -0
  17. data/src/torii/backend/generated/spec/api/invitations_api_spec.rb +93 -0
  18. data/src/torii/backend/generated/spec/api/server_impersonation_api_spec.rb +48 -0
  19. data/src/torii/backend/generated/spec/models/create_environment_invitation_server_request_spec.rb +60 -0
  20. data/src/torii/backend/generated/spec/models/cursor_page_response_environment_invitation_response_spec.rb +48 -0
  21. data/src/torii/backend/generated/spec/models/environment_invitation_response_spec.rb +82 -0
  22. data/src/torii/backend/generated/spec/models/server_impersonation_token_request_spec.rb +48 -0
  23. data/src/torii/backend/generated/spec/models/server_impersonation_token_response_spec.rb +42 -0
  24. data/src/torii/backend/version.rb +1 -1
  25. metadata +16 -2
@@ -0,0 +1,338 @@
1
+ =begin
2
+ #Torii Backend API
3
+
4
+ #Server-to-server API (BAPI) for backend SDKs. Authenticated with a secret key (Bearer sk_live_* / sk_test_*).
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ToriiBackendGenerated
17
+ class EnvironmentInvitationResponse < ApiModelBase
18
+ attr_accessor :id
19
+
20
+ attr_accessor :environment_id
21
+
22
+ attr_accessor :email
23
+
24
+ attr_accessor :status
25
+
26
+ attr_accessor :expires_at
27
+
28
+ attr_accessor :created_at
29
+
30
+ attr_accessor :accepted_at
31
+
32
+ attr_accessor :revoked_at
33
+
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
56
+ # Attribute mapping from ruby-style variable name to JSON key.
57
+ def self.attribute_map
58
+ {
59
+ :'id' => :'id',
60
+ :'environment_id' => :'environmentId',
61
+ :'email' => :'email',
62
+ :'status' => :'status',
63
+ :'expires_at' => :'expiresAt',
64
+ :'created_at' => :'createdAt',
65
+ :'accepted_at' => :'acceptedAt',
66
+ :'revoked_at' => :'revokedAt'
67
+ }
68
+ end
69
+
70
+ # Returns attribute mapping this model knows about
71
+ def self.acceptable_attribute_map
72
+ attribute_map
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ acceptable_attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'id' => :'String',
84
+ :'environment_id' => :'String',
85
+ :'email' => :'String',
86
+ :'status' => :'String',
87
+ :'expires_at' => :'Time',
88
+ :'created_at' => :'Time',
89
+ :'accepted_at' => :'Time',
90
+ :'revoked_at' => :'Time'
91
+ }
92
+ end
93
+
94
+ # List of attributes with nullable: true
95
+ def self.openapi_nullable
96
+ Set.new([
97
+ :'accepted_at',
98
+ :'revoked_at'
99
+ ])
100
+ end
101
+
102
+ # Initializes the object
103
+ # @param [Hash] attributes Model attributes in the form of hash
104
+ def initialize(attributes = {})
105
+ if (!attributes.is_a?(Hash))
106
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ToriiBackendGenerated::EnvironmentInvitationResponse` initialize method"
107
+ end
108
+
109
+ # check to see if the attribute exists and convert string to symbol for hash key
110
+ acceptable_attribute_map = self.class.acceptable_attribute_map
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!acceptable_attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ToriiBackendGenerated::EnvironmentInvitationResponse`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'id')
119
+ self.id = attributes[:'id']
120
+ else
121
+ self.id = nil
122
+ end
123
+
124
+ if attributes.key?(:'environment_id')
125
+ self.environment_id = attributes[:'environment_id']
126
+ else
127
+ self.environment_id = nil
128
+ end
129
+
130
+ if attributes.key?(:'email')
131
+ self.email = attributes[:'email']
132
+ else
133
+ self.email = nil
134
+ end
135
+
136
+ if attributes.key?(:'status')
137
+ self.status = attributes[:'status']
138
+ else
139
+ self.status = nil
140
+ end
141
+
142
+ if attributes.key?(:'expires_at')
143
+ self.expires_at = attributes[:'expires_at']
144
+ else
145
+ self.expires_at = nil
146
+ end
147
+
148
+ if attributes.key?(:'created_at')
149
+ self.created_at = attributes[:'created_at']
150
+ else
151
+ self.created_at = nil
152
+ end
153
+
154
+ if attributes.key?(:'accepted_at')
155
+ self.accepted_at = attributes[:'accepted_at']
156
+ end
157
+
158
+ if attributes.key?(:'revoked_at')
159
+ self.revoked_at = attributes[:'revoked_at']
160
+ end
161
+ end
162
+
163
+ # Show invalid properties with the reasons. Usually used together with valid?
164
+ # @return Array for valid properties with the reasons
165
+ def list_invalid_properties
166
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
167
+ invalid_properties = Array.new
168
+ if @id.nil?
169
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
170
+ end
171
+
172
+ if @environment_id.nil?
173
+ invalid_properties.push('invalid value for "environment_id", environment_id cannot be nil.')
174
+ end
175
+
176
+ if @email.nil?
177
+ invalid_properties.push('invalid value for "email", email cannot be nil.')
178
+ end
179
+
180
+ if @status.nil?
181
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
182
+ end
183
+
184
+ if @expires_at.nil?
185
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
186
+ end
187
+
188
+ if @created_at.nil?
189
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
190
+ end
191
+
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ warn '[DEPRECATED] the `valid?` method is obsolete'
199
+ return false if @id.nil?
200
+ return false if @environment_id.nil?
201
+ return false if @email.nil?
202
+ return false if @status.nil?
203
+ status_validator = EnumAttributeValidator.new('String', ["PENDING", "ACCEPTED", "REVOKED", "EXPIRED"])
204
+ return false unless status_validator.valid?(@status)
205
+ return false if @expires_at.nil?
206
+ return false if @created_at.nil?
207
+ true
208
+ end
209
+
210
+ # Custom attribute writer method with validation
211
+ # @param [Object] id Value to be assigned
212
+ def id=(id)
213
+ if id.nil?
214
+ fail ArgumentError, 'id cannot be nil'
215
+ end
216
+
217
+ @id = id
218
+ end
219
+
220
+ # Custom attribute writer method with validation
221
+ # @param [Object] environment_id Value to be assigned
222
+ def environment_id=(environment_id)
223
+ if environment_id.nil?
224
+ fail ArgumentError, 'environment_id cannot be nil'
225
+ end
226
+
227
+ @environment_id = environment_id
228
+ end
229
+
230
+ # Custom attribute writer method with validation
231
+ # @param [Object] email Value to be assigned
232
+ def email=(email)
233
+ if email.nil?
234
+ fail ArgumentError, 'email cannot be nil'
235
+ end
236
+
237
+ @email = email
238
+ end
239
+
240
+ # Custom attribute writer method checking allowed values (enum).
241
+ # @param [Object] status Object to be assigned
242
+ def status=(status)
243
+ validator = EnumAttributeValidator.new('String', ["PENDING", "ACCEPTED", "REVOKED", "EXPIRED"])
244
+ unless validator.valid?(status)
245
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
246
+ end
247
+ @status = status
248
+ end
249
+
250
+ # Custom attribute writer method with validation
251
+ # @param [Object] expires_at Value to be assigned
252
+ def expires_at=(expires_at)
253
+ if expires_at.nil?
254
+ fail ArgumentError, 'expires_at cannot be nil'
255
+ end
256
+
257
+ @expires_at = expires_at
258
+ end
259
+
260
+ # Custom attribute writer method with validation
261
+ # @param [Object] created_at Value to be assigned
262
+ def created_at=(created_at)
263
+ if created_at.nil?
264
+ fail ArgumentError, 'created_at cannot be nil'
265
+ end
266
+
267
+ @created_at = created_at
268
+ end
269
+
270
+ # Checks equality by comparing each attribute.
271
+ # @param [Object] Object to be compared
272
+ def ==(o)
273
+ return true if self.equal?(o)
274
+ self.class == o.class &&
275
+ id == o.id &&
276
+ environment_id == o.environment_id &&
277
+ email == o.email &&
278
+ status == o.status &&
279
+ expires_at == o.expires_at &&
280
+ created_at == o.created_at &&
281
+ accepted_at == o.accepted_at &&
282
+ revoked_at == o.revoked_at
283
+ end
284
+
285
+ # @see the `==` method
286
+ # @param [Object] Object to be compared
287
+ def eql?(o)
288
+ self == o
289
+ end
290
+
291
+ # Calculates hash code according to all attributes.
292
+ # @return [Integer] Hash code
293
+ def hash
294
+ [id, environment_id, email, status, expires_at, created_at, accepted_at, revoked_at].hash
295
+ end
296
+
297
+ # Builds the object from hash
298
+ # @param [Hash] attributes Model attributes in the form of hash
299
+ # @return [Object] Returns the model itself
300
+ def self.build_from_hash(attributes)
301
+ return nil unless attributes.is_a?(Hash)
302
+ attributes = attributes.transform_keys(&:to_sym)
303
+ transformed_hash = {}
304
+ openapi_types.each_pair do |key, type|
305
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
306
+ transformed_hash["#{key}"] = nil
307
+ elsif type =~ /\AArray<(.*)>/i
308
+ # check to ensure the input is an array given that the attribute
309
+ # is documented as an array but the input is not
310
+ if attributes[attribute_map[key]].is_a?(Array)
311
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
312
+ end
313
+ elsif !attributes[attribute_map[key]].nil?
314
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
315
+ end
316
+ end
317
+ new(transformed_hash)
318
+ end
319
+
320
+ # Returns the object in the form of hash
321
+ # @return [Hash] Returns the object in the form of hash
322
+ def to_hash
323
+ hash = {}
324
+ self.class.attribute_map.each_pair do |attr, param|
325
+ value = self.send(attr)
326
+ if value.nil?
327
+ is_nullable = self.class.openapi_nullable.include?(attr)
328
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
329
+ end
330
+
331
+ hash[param] = _to_hash(value)
332
+ end
333
+ hash
334
+ end
335
+
336
+ end
337
+
338
+ end
@@ -0,0 +1,246 @@
1
+ =begin
2
+ #Torii Backend API
3
+
4
+ #Server-to-server API (BAPI) for backend SDKs. Authenticated with a secret key (Bearer sk_live_* / sk_test_*).
5
+
6
+ The version of the OpenAPI document: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ToriiBackendGenerated
17
+ # Body for minting an impersonation token.
18
+ class ServerImpersonationTokenRequest < ApiModelBase
19
+ # The principal the impersonation is on behalf of (recorded for accountability). Must be a user in this environment.
20
+ attr_accessor :actor_user_id
21
+
22
+ # Mandatory justification (GDPR purpose limitation); recorded in the audit log on mint and redeem.
23
+ attr_accessor :reason
24
+
25
+ # Optional token lifetime in seconds, 60..600. Omit for the 60s default.
26
+ attr_accessor :expires_in_seconds
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'actor_user_id' => :'actorUserId',
32
+ :'reason' => :'reason',
33
+ :'expires_in_seconds' => :'expiresInSeconds'
34
+ }
35
+ end
36
+
37
+ # Returns attribute mapping this model knows about
38
+ def self.acceptable_attribute_map
39
+ attribute_map
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ acceptable_attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'actor_user_id' => :'String',
51
+ :'reason' => :'String',
52
+ :'expires_in_seconds' => :'Integer'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ :'expires_in_seconds'
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ToriiBackendGenerated::ServerImpersonationTokenRequest` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ acceptable_attribute_map = self.class.acceptable_attribute_map
72
+ attributes = attributes.each_with_object({}) { |(k, v), h|
73
+ if (!acceptable_attribute_map.key?(k.to_sym))
74
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ToriiBackendGenerated::ServerImpersonationTokenRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
75
+ end
76
+ h[k.to_sym] = v
77
+ }
78
+
79
+ if attributes.key?(:'actor_user_id')
80
+ self.actor_user_id = attributes[:'actor_user_id']
81
+ else
82
+ self.actor_user_id = nil
83
+ end
84
+
85
+ if attributes.key?(:'reason')
86
+ self.reason = attributes[:'reason']
87
+ else
88
+ self.reason = nil
89
+ end
90
+
91
+ if attributes.key?(:'expires_in_seconds')
92
+ self.expires_in_seconds = attributes[:'expires_in_seconds']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
100
+ invalid_properties = Array.new
101
+ if @actor_user_id.nil?
102
+ invalid_properties.push('invalid value for "actor_user_id", actor_user_id cannot be nil.')
103
+ end
104
+
105
+ if @reason.nil?
106
+ invalid_properties.push('invalid value for "reason", reason cannot be nil.')
107
+ end
108
+
109
+ if @reason.to_s.length > 500
110
+ invalid_properties.push('invalid value for "reason", the character length must be smaller than or equal to 500.')
111
+ end
112
+
113
+ if @reason.to_s.length < 0
114
+ invalid_properties.push('invalid value for "reason", the character length must be greater than or equal to 0.')
115
+ end
116
+
117
+ if !@expires_in_seconds.nil? && @expires_in_seconds > 600
118
+ invalid_properties.push('invalid value for "expires_in_seconds", must be smaller than or equal to 600.')
119
+ end
120
+
121
+ if !@expires_in_seconds.nil? && @expires_in_seconds < 60
122
+ invalid_properties.push('invalid value for "expires_in_seconds", must be greater than or equal to 60.')
123
+ end
124
+
125
+ invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ warn '[DEPRECATED] the `valid?` method is obsolete'
132
+ return false if @actor_user_id.nil?
133
+ return false if @reason.nil?
134
+ return false if @reason.to_s.length > 500
135
+ return false if @reason.to_s.length < 0
136
+ return false if !@expires_in_seconds.nil? && @expires_in_seconds > 600
137
+ return false if !@expires_in_seconds.nil? && @expires_in_seconds < 60
138
+ true
139
+ end
140
+
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] actor_user_id Value to be assigned
143
+ def actor_user_id=(actor_user_id)
144
+ if actor_user_id.nil?
145
+ fail ArgumentError, 'actor_user_id cannot be nil'
146
+ end
147
+
148
+ @actor_user_id = actor_user_id
149
+ end
150
+
151
+ # Custom attribute writer method with validation
152
+ # @param [Object] reason Value to be assigned
153
+ def reason=(reason)
154
+ if reason.nil?
155
+ fail ArgumentError, 'reason cannot be nil'
156
+ end
157
+
158
+ if reason.to_s.length > 500
159
+ fail ArgumentError, 'invalid value for "reason", the character length must be smaller than or equal to 500.'
160
+ end
161
+
162
+ if reason.to_s.length < 0
163
+ fail ArgumentError, 'invalid value for "reason", the character length must be greater than or equal to 0.'
164
+ end
165
+
166
+ @reason = reason
167
+ end
168
+
169
+ # Custom attribute writer method with validation
170
+ # @param [Object] expires_in_seconds Value to be assigned
171
+ def expires_in_seconds=(expires_in_seconds)
172
+ if !expires_in_seconds.nil? && expires_in_seconds > 600
173
+ fail ArgumentError, 'invalid value for "expires_in_seconds", must be smaller than or equal to 600.'
174
+ end
175
+
176
+ if !expires_in_seconds.nil? && expires_in_seconds < 60
177
+ fail ArgumentError, 'invalid value for "expires_in_seconds", must be greater than or equal to 60.'
178
+ end
179
+
180
+ @expires_in_seconds = expires_in_seconds
181
+ end
182
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(o)
186
+ return true if self.equal?(o)
187
+ self.class == o.class &&
188
+ actor_user_id == o.actor_user_id &&
189
+ reason == o.reason &&
190
+ expires_in_seconds == o.expires_in_seconds
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Integer] Hash code
201
+ def hash
202
+ [actor_user_id, reason, expires_in_seconds].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def self.build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ attributes = attributes.transform_keys(&:to_sym)
211
+ transformed_hash = {}
212
+ openapi_types.each_pair do |key, type|
213
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
214
+ transformed_hash["#{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[attribute_map[key]].is_a?(Array)
219
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
220
+ end
221
+ elsif !attributes[attribute_map[key]].nil?
222
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
223
+ end
224
+ end
225
+ new(transformed_hash)
226
+ end
227
+
228
+ # Returns the object in the form of hash
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_hash
231
+ hash = {}
232
+ self.class.attribute_map.each_pair do |attr, param|
233
+ value = self.send(attr)
234
+ if value.nil?
235
+ is_nullable = self.class.openapi_nullable.include?(attr)
236
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
237
+ end
238
+
239
+ hash[param] = _to_hash(value)
240
+ end
241
+ hash
242
+ end
243
+
244
+ end
245
+
246
+ end