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