twilio-ruby 7.3.0 → 7.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,549 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Assistants
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Assistants < AssistantsBase
19
+ class V1 < Version
20
+ class ToolList < ListResource
21
+
22
+ class AssistantsV1ServiceCreatePolicyRequest
23
+ # @param [description]: [String] The description of the policy.
24
+ # @param [id]: [String] The Policy ID.
25
+ # @param [name]: [String] The name of the policy.
26
+ # @param [policy_details]: [Hash]
27
+ # @param [type]: [String] The description of the policy.
28
+ attr_accessor :description, :id, :name, :policy_details, :type
29
+ def initialize(payload)
30
+ @description = payload["description"]
31
+ @id = payload["id"]
32
+ @name = payload["name"]
33
+ @policy_details = payload["policy_details"]
34
+ @type = payload["type"]
35
+ end
36
+ def to_json(options = {})
37
+ {
38
+ description: @description,
39
+ id: @id,
40
+ name: @name,
41
+ policy_details: @policy_details,
42
+ type: @type,
43
+ }.to_json(options)
44
+ end
45
+ end
46
+
47
+ class AssistantsV1ServiceCreateToolRequest
48
+ # @param [assistant_id]: [String] The Assistant ID.
49
+ # @param [description]: [String] The description of the tool.
50
+ # @param [enabled]: [Boolean] True if the tool is enabled.
51
+ # @param [meta]: [Hash] The metadata related to method, url, input_schema to used with the Tool.
52
+ # @param [name]: [String] The name of the tool.
53
+ # @param [policy]: [ToolList.AssistantsV1ServiceCreatePolicyRequest]
54
+ # @param [type]: [String] The description of the tool.
55
+ attr_accessor :assistant_id, :description, :enabled, :meta, :name, :policy, :type
56
+ def initialize(payload)
57
+ @assistant_id = payload["assistant_id"]
58
+ @description = payload["description"]
59
+ @enabled = payload["enabled"]
60
+ @meta = payload["meta"]
61
+ @name = payload["name"]
62
+ @policy = payload["policy"]
63
+ @type = payload["type"]
64
+ end
65
+ def to_json(options = {})
66
+ {
67
+ assistant_id: @assistant_id,
68
+ description: @description,
69
+ enabled: @enabled,
70
+ meta: @meta,
71
+ name: @name,
72
+ policy: @policy,
73
+ type: @type,
74
+ }.to_json(options)
75
+ end
76
+ end
77
+
78
+ class AssistantsV1ServiceUpdateToolRequest
79
+ # @param [assistant_id]: [String] The Assistant ID.
80
+ # @param [description]: [String] The description of the tool.
81
+ # @param [enabled]: [Boolean] True if the tool is enabled.
82
+ # @param [meta]: [Hash] The metadata related to method, url, input_schema to used with the Tool.
83
+ # @param [name]: [String] The name of the tool.
84
+ # @param [policy]: [ToolList.AssistantsV1ServiceCreatePolicyRequest]
85
+ # @param [type]: [String] The type of the tool.
86
+ attr_accessor :assistant_id, :description, :enabled, :meta, :name, :policy, :type
87
+ def initialize(payload)
88
+ @assistant_id = payload["assistant_id"]
89
+ @description = payload["description"]
90
+ @enabled = payload["enabled"]
91
+ @meta = payload["meta"]
92
+ @name = payload["name"]
93
+ @policy = payload["policy"]
94
+ @type = payload["type"]
95
+ end
96
+ def to_json(options = {})
97
+ {
98
+ assistant_id: @assistant_id,
99
+ description: @description,
100
+ enabled: @enabled,
101
+ meta: @meta,
102
+ name: @name,
103
+ policy: @policy,
104
+ type: @type,
105
+ }.to_json(options)
106
+ end
107
+ end
108
+
109
+ class AssistantsV1ServiceCreatePolicyRequest
110
+ # @param [description]: [String] The description of the policy.
111
+ # @param [id]: [String] The Policy ID.
112
+ # @param [name]: [String] The name of the policy.
113
+ # @param [policy_details]: [Hash]
114
+ # @param [type]: [String] The description of the policy.
115
+ attr_accessor :description, :id, :name, :policy_details, :type
116
+ def initialize(payload)
117
+ @description = payload["description"]
118
+ @id = payload["id"]
119
+ @name = payload["name"]
120
+ @policy_details = payload["policy_details"]
121
+ @type = payload["type"]
122
+ end
123
+ def to_json(options = {})
124
+ {
125
+ description: @description,
126
+ id: @id,
127
+ name: @name,
128
+ policy_details: @policy_details,
129
+ type: @type,
130
+ }.to_json(options)
131
+ end
132
+ end
133
+
134
+ class AssistantsV1ServiceCreateToolRequest
135
+ # @param [assistant_id]: [String] The Assistant ID.
136
+ # @param [description]: [String] The description of the tool.
137
+ # @param [enabled]: [Boolean] True if the tool is enabled.
138
+ # @param [meta]: [Hash] The metadata related to method, url, input_schema to used with the Tool.
139
+ # @param [name]: [String] The name of the tool.
140
+ # @param [policy]: [ToolList.AssistantsV1ServiceCreatePolicyRequest]
141
+ # @param [type]: [String] The description of the tool.
142
+ attr_accessor :assistant_id, :description, :enabled, :meta, :name, :policy, :type
143
+ def initialize(payload)
144
+ @assistant_id = payload["assistant_id"]
145
+ @description = payload["description"]
146
+ @enabled = payload["enabled"]
147
+ @meta = payload["meta"]
148
+ @name = payload["name"]
149
+ @policy = payload["policy"]
150
+ @type = payload["type"]
151
+ end
152
+ def to_json(options = {})
153
+ {
154
+ assistant_id: @assistant_id,
155
+ description: @description,
156
+ enabled: @enabled,
157
+ meta: @meta,
158
+ name: @name,
159
+ policy: @policy,
160
+ type: @type,
161
+ }.to_json(options)
162
+ end
163
+ end
164
+
165
+ class AssistantsV1ServiceUpdateToolRequest
166
+ # @param [assistant_id]: [String] The Assistant ID.
167
+ # @param [description]: [String] The description of the tool.
168
+ # @param [enabled]: [Boolean] True if the tool is enabled.
169
+ # @param [meta]: [Hash] The metadata related to method, url, input_schema to used with the Tool.
170
+ # @param [name]: [String] The name of the tool.
171
+ # @param [policy]: [ToolList.AssistantsV1ServiceCreatePolicyRequest]
172
+ # @param [type]: [String] The type of the tool.
173
+ attr_accessor :assistant_id, :description, :enabled, :meta, :name, :policy, :type
174
+ def initialize(payload)
175
+ @assistant_id = payload["assistant_id"]
176
+ @description = payload["description"]
177
+ @enabled = payload["enabled"]
178
+ @meta = payload["meta"]
179
+ @name = payload["name"]
180
+ @policy = payload["policy"]
181
+ @type = payload["type"]
182
+ end
183
+ def to_json(options = {})
184
+ {
185
+ assistant_id: @assistant_id,
186
+ description: @description,
187
+ enabled: @enabled,
188
+ meta: @meta,
189
+ name: @name,
190
+ policy: @policy,
191
+ type: @type,
192
+ }.to_json(options)
193
+ end
194
+ end
195
+
196
+ ##
197
+ # Initialize the ToolList
198
+ # @param [Version] version Version that contains the resource
199
+ # @return [ToolList] ToolList
200
+ def initialize(version)
201
+ super(version)
202
+ # Path Solution
203
+ @solution = { }
204
+ @uri = "/Tools"
205
+
206
+ end
207
+ ##
208
+ # Create the ToolInstance
209
+ # @param [AssistantsV1ServiceCreateToolRequest] assistants_v1_service_create_tool_request
210
+ # @return [ToolInstance] Created ToolInstance
211
+ def create(assistants_v1_service_create_tool_request: nil
212
+ )
213
+
214
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
215
+ headers['Content-Type'] = 'application/json'
216
+ payload = @version.create('POST', @uri, headers: headers, data: assistants_v1_service_create_tool_request.to_json)
217
+ ToolInstance.new(
218
+ @version,
219
+ payload,
220
+ )
221
+ end
222
+
223
+
224
+ ##
225
+ # Lists ToolInstance records from the API as a list.
226
+ # Unlike stream(), this operation is eager and will load `limit` records into
227
+ # memory before returning.
228
+ # @param [String] assistant_id
229
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
230
+ # guarantees to never return more than limit. Default is no limit
231
+ # @param [Integer] page_size Number of records to fetch per request, when
232
+ # not set will use the default value of 50 records. If no page_size is defined
233
+ # but a limit is defined, stream() will attempt to read the limit with the most
234
+ # efficient page size, i.e. min(limit, 1000)
235
+ # @return [Array] Array of up to limit results
236
+ def list(assistant_id: :unset, limit: nil, page_size: nil)
237
+ self.stream(
238
+ assistant_id: assistant_id,
239
+ limit: limit,
240
+ page_size: page_size
241
+ ).entries
242
+ end
243
+
244
+ ##
245
+ # Streams Instance records from the API as an Enumerable.
246
+ # This operation lazily loads records as efficiently as possible until the limit
247
+ # is reached.
248
+ # @param [String] assistant_id
249
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
250
+ # guarantees to never return more than limit. Default is no limit
251
+ # @param [Integer] page_size Number of records to fetch per request, when
252
+ # not set will use the default value of 50 records. If no page_size is defined
253
+ # but a limit is defined, stream() will attempt to read the limit with the most
254
+ # efficient page size, i.e. min(limit, 1000)
255
+ # @return [Enumerable] Enumerable that will yield up to limit results
256
+ def stream(assistant_id: :unset, limit: nil, page_size: nil)
257
+ limits = @version.read_limits(limit, page_size)
258
+
259
+ page = self.page(
260
+ assistant_id: assistant_id,
261
+ page_size: limits[:page_size], )
262
+
263
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
264
+ end
265
+
266
+ ##
267
+ # When passed a block, yields ToolInstance records from the API.
268
+ # This operation lazily loads records as efficiently as possible until the limit
269
+ # is reached.
270
+ def each
271
+ limits = @version.read_limits
272
+
273
+ page = self.page(page_size: limits[:page_size], )
274
+
275
+ @version.stream(page,
276
+ limit: limits[:limit],
277
+ page_limit: limits[:page_limit]).each {|x| yield x}
278
+ end
279
+
280
+ ##
281
+ # Retrieve a single page of ToolInstance records from the API.
282
+ # Request is executed immediately.
283
+ # @param [String] assistant_id
284
+ # @param [String] page_token PageToken provided by the API
285
+ # @param [Integer] page_number Page Number, this value is simply for client state
286
+ # @param [Integer] page_size Number of records to return, defaults to 50
287
+ # @return [Page] Page of ToolInstance
288
+ def page(assistant_id: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
289
+ params = Twilio::Values.of({
290
+ 'AssistantId' => assistant_id,
291
+ 'PageToken' => page_token,
292
+ 'Page' => page_number,
293
+ 'PageSize' => page_size,
294
+ })
295
+
296
+ response = @version.page('GET', @uri, params: params)
297
+
298
+ ToolPage.new(@version, response, @solution)
299
+ end
300
+
301
+ ##
302
+ # Retrieve a single page of ToolInstance records from the API.
303
+ # Request is executed immediately.
304
+ # @param [String] target_url API-generated URL for the requested results page
305
+ # @return [Page] Page of ToolInstance
306
+ def get_page(target_url)
307
+ response = @version.domain.request(
308
+ 'GET',
309
+ target_url
310
+ )
311
+ ToolPage.new(@version, response, @solution)
312
+ end
313
+
314
+
315
+
316
+ # Provide a user friendly representation
317
+ def to_s
318
+ '#<Twilio.Assistants.V1.ToolList>'
319
+ end
320
+ end
321
+
322
+
323
+ class ToolContext < InstanceContext
324
+ ##
325
+ # Initialize the ToolContext
326
+ # @param [Version] version Version that contains the resource
327
+ # @param [String] id
328
+ # @return [ToolContext] ToolContext
329
+ def initialize(version, id)
330
+ super(version)
331
+
332
+ # Path Solution
333
+ @solution = { id: id, }
334
+ @uri = "/Tools/#{@solution[:id]}"
335
+
336
+
337
+ end
338
+ ##
339
+ # Delete the ToolInstance
340
+ # @return [Boolean] True if delete succeeds, false otherwise
341
+ def delete
342
+
343
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
344
+
345
+ @version.delete('DELETE', @uri, headers: headers)
346
+ end
347
+
348
+ ##
349
+ # Update the ToolInstance
350
+ # @param [AssistantsV1ServiceUpdateToolRequest] assistants_v1_service_update_tool_request
351
+ # @return [ToolInstance] Updated ToolInstance
352
+ def update(assistants_v1_service_update_tool_request: :unset
353
+ )
354
+
355
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
356
+ headers['Content-Type'] = 'application/json'
357
+ payload = @version.update('PUT', @uri, headers: headers, data: assistants_v1_service_update_tool_request.to_json)
358
+ ToolInstance.new(
359
+ @version,
360
+ payload,
361
+ id: @solution[:id],
362
+ )
363
+ end
364
+
365
+
366
+ ##
367
+ # Provide a user friendly representation
368
+ def to_s
369
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
370
+ "#<Twilio.Assistants.V1.ToolContext #{context}>"
371
+ end
372
+
373
+ ##
374
+ # Provide a detailed, user friendly representation
375
+ def inspect
376
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
377
+ "#<Twilio.Assistants.V1.ToolContext #{context}>"
378
+ end
379
+ end
380
+
381
+ class ToolPage < Page
382
+ ##
383
+ # Initialize the ToolPage
384
+ # @param [Version] version Version that contains the resource
385
+ # @param [Response] response Response from the API
386
+ # @param [Hash] solution Path solution for the resource
387
+ # @return [ToolPage] ToolPage
388
+ def initialize(version, response, solution)
389
+ super(version, response)
390
+
391
+ # Path Solution
392
+ @solution = solution
393
+ end
394
+
395
+ ##
396
+ # Build an instance of ToolInstance
397
+ # @param [Hash] payload Payload response from the API
398
+ # @return [ToolInstance] ToolInstance
399
+ def get_instance(payload)
400
+ ToolInstance.new(@version, payload)
401
+ end
402
+
403
+ ##
404
+ # Provide a user friendly representation
405
+ def to_s
406
+ '<Twilio.Assistants.V1.ToolPage>'
407
+ end
408
+ end
409
+ class ToolInstance < InstanceResource
410
+ ##
411
+ # Initialize the ToolInstance
412
+ # @param [Version] version Version that contains the resource
413
+ # @param [Hash] payload payload that contains response from Twilio
414
+ # @param [String] account_sid The SID of the
415
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Tool
416
+ # resource.
417
+ # @param [String] sid The SID of the Call resource to fetch.
418
+ # @return [ToolInstance] ToolInstance
419
+ def initialize(version, payload , id: nil)
420
+ super(version)
421
+
422
+ # Marshaled Properties
423
+ @properties = {
424
+ 'account_sid' => payload['account_sid'],
425
+ 'description' => payload['description'],
426
+ 'enabled' => payload['enabled'],
427
+ 'id' => payload['id'],
428
+ 'meta' => payload['meta'],
429
+ 'name' => payload['name'],
430
+ 'requires_auth' => payload['requires_auth'],
431
+ 'type' => payload['type'],
432
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
433
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
434
+ }
435
+
436
+ # Context
437
+ @instance_context = nil
438
+ @params = { 'id' => id || @properties['id'] , }
439
+ end
440
+
441
+ ##
442
+ # Generate an instance context for the instance, the context is capable of
443
+ # performing various actions. All instance actions are proxied to the context
444
+ # @return [ToolContext] CallContext for this CallInstance
445
+ def context
446
+ unless @instance_context
447
+ @instance_context = ToolContext.new(@version , @params['id'])
448
+ end
449
+ @instance_context
450
+ end
451
+
452
+ ##
453
+ # @return [String] The SID of the [Account](https://www.twilio.com/docs/iam/api/account) that created the Tool resource.
454
+ def account_sid
455
+ @properties['account_sid']
456
+ end
457
+
458
+ ##
459
+ # @return [String] The description of the tool.
460
+ def description
461
+ @properties['description']
462
+ end
463
+
464
+ ##
465
+ # @return [Boolean] True if the tool is enabled.
466
+ def enabled
467
+ @properties['enabled']
468
+ end
469
+
470
+ ##
471
+ # @return [String] The tool ID.
472
+ def id
473
+ @properties['id']
474
+ end
475
+
476
+ ##
477
+ # @return [Hash] The metadata related to method, url, input_schema to used with the Tool.
478
+ def meta
479
+ @properties['meta']
480
+ end
481
+
482
+ ##
483
+ # @return [String] The name of the tool.
484
+ def name
485
+ @properties['name']
486
+ end
487
+
488
+ ##
489
+ # @return [Boolean] The authentication requirement for the tool.
490
+ def requires_auth
491
+ @properties['requires_auth']
492
+ end
493
+
494
+ ##
495
+ # @return [String] The type of the tool. ('WEBHOOK')
496
+ def type
497
+ @properties['type']
498
+ end
499
+
500
+ ##
501
+ # @return [Time] The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
502
+ def date_created
503
+ @properties['date_created']
504
+ end
505
+
506
+ ##
507
+ # @return [Time] The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
508
+ def date_updated
509
+ @properties['date_updated']
510
+ end
511
+
512
+ ##
513
+ # Delete the ToolInstance
514
+ # @return [Boolean] True if delete succeeds, false otherwise
515
+ def delete
516
+
517
+ context.delete
518
+ end
519
+
520
+ ##
521
+ # Update the ToolInstance
522
+ # @param [AssistantsV1ServiceUpdateToolRequest] assistants_v1_service_update_tool_request
523
+ # @return [ToolInstance] Updated ToolInstance
524
+ def update(assistants_v1_service_update_tool_request: :unset
525
+ )
526
+
527
+ context.update(
528
+ )
529
+ end
530
+
531
+ ##
532
+ # Provide a user friendly representation
533
+ def to_s
534
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
535
+ "<Twilio.Assistants.V1.ToolInstance #{values}>"
536
+ end
537
+
538
+ ##
539
+ # Provide a detailed, user friendly representation
540
+ def inspect
541
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
542
+ "<Twilio.Assistants.V1.ToolInstance #{values}>"
543
+ end
544
+ end
545
+
546
+ end
547
+ end
548
+ end
549
+ end
@@ -0,0 +1,100 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Assistants
8
+ # This is the public Twilio REST API.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+ module Twilio
16
+ module REST
17
+ class Assistants
18
+ class V1 < Version
19
+ ##
20
+ # Initialize the V1 version of Assistants
21
+ def initialize(domain)
22
+ super
23
+ @version = 'v1'
24
+ @assistants = nil
25
+ @knowledge = nil
26
+ @policies = nil
27
+ @sessions = nil
28
+ @tools = nil
29
+ end
30
+
31
+ ##
32
+ # @param [String] id
33
+ # @return [Twilio::REST::Assistants::V1::AssistantContext] if id was passed.
34
+ # @return [Twilio::REST::Assistants::V1::AssistantList]
35
+ def assistants(id=:unset)
36
+ if id.nil?
37
+ raise ArgumentError, 'id cannot be nil'
38
+ end
39
+ if id == :unset
40
+ @assistants ||= AssistantList.new self
41
+ else
42
+ AssistantContext.new(self, id)
43
+ end
44
+ end
45
+ ##
46
+ # @param [String] id
47
+ # @return [Twilio::REST::Assistants::V1::KnowledgeContext] if id was passed.
48
+ # @return [Twilio::REST::Assistants::V1::KnowledgeList]
49
+ def knowledge(id=:unset)
50
+ if id.nil?
51
+ raise ArgumentError, 'id cannot be nil'
52
+ end
53
+ if id == :unset
54
+ @knowledge ||= KnowledgeList.new self
55
+ else
56
+ KnowledgeContext.new(self, id)
57
+ end
58
+ end
59
+ ##
60
+ # @return [Twilio::REST::Assistants::V1::PolicyList]
61
+ def policies
62
+ @policies ||= PolicyList.new self
63
+ end
64
+ ##
65
+ # @param [String] id
66
+ # @return [Twilio::REST::Assistants::V1::SessionContext] if id was passed.
67
+ # @return [Twilio::REST::Assistants::V1::SessionList]
68
+ def sessions(id=:unset)
69
+ if id.nil?
70
+ raise ArgumentError, 'id cannot be nil'
71
+ end
72
+ if id == :unset
73
+ @sessions ||= SessionList.new self
74
+ else
75
+ SessionContext.new(self, id)
76
+ end
77
+ end
78
+ ##
79
+ # @param [String] id
80
+ # @return [Twilio::REST::Assistants::V1::ToolContext] if id was passed.
81
+ # @return [Twilio::REST::Assistants::V1::ToolList]
82
+ def tools(id=:unset)
83
+ if id.nil?
84
+ raise ArgumentError, 'id cannot be nil'
85
+ end
86
+ if id == :unset
87
+ @tools ||= ToolList.new self
88
+ else
89
+ ToolContext.new(self, id)
90
+ end
91
+ end
92
+ ##
93
+ # Provide a user friendly representation
94
+ def to_s
95
+ '<Twilio::REST::Assistants::V1>';
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,6 @@
1
+ module Twilio
2
+ module REST
3
+ class Assistants < AssistantsBase;
4
+ end
5
+ end
6
+ end