appwrite 30.5.0 → 30.6.0

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,966 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ class Videos < Service
5
+ def initialize(client)
6
+ @client = client
7
+ end
8
+
9
+ # Get a list of videos in the current project. Sessions receive only videos
10
+ # they can read according to each video&#039;s `$permissions`. API keys and admins
11
+ # receive the full project catalog. Playback uses the same document read ACL
12
+ # plus the `videos.play` (or `videos.read`) scope: a guest can stream a video
13
+ # that grants `read(&quot;any&quot;)` or `read(&quot;guests&quot;)` even though guests lack
14
+ # `videos.read` and will not see it in this list.
15
+ #
16
+ #
17
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: bucketId, fileId, name, size, format, duration, width, height, videoCodec, videoBitRate, audioCodec, audioBitRate, search
18
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
19
+ #
20
+ # @return [VideoList]
21
+ def list(
22
+ queries: nil,
23
+ total: nil
24
+ )
25
+ api_path = '/videos'
26
+
27
+ api_params = {
28
+ queries: queries,
29
+ total: total,
30
+ }
31
+
32
+ api_headers = {
33
+ "X-Appwrite-Project": @client.get_config('project'),
34
+ "accept": 'application/json',
35
+ }
36
+
37
+ @client.call(
38
+ method: 'GET',
39
+ path: api_path,
40
+ headers: api_headers,
41
+ params: api_params,
42
+ response_type: Models::VideoList
43
+ )
44
+ end
45
+
46
+ # Create a video resource from an existing file in a storage bucket. The
47
+ # source file must be a video or audio file, and the caller must be able to
48
+ # read that file. Creating a video stores the document and queues timeline
49
+ # generation. The worker downloads the source, probes metadata, extracts
50
+ # embedded captions once, and deletes its working copy when finished. Sources
51
+ # with a video track also get a thumbnail timeline. Call create-rendition to
52
+ # package a streaming output.
53
+ #
54
+ # An optional `name` defaults to the source file name. An optional
55
+ # `permissions` array sets the video document ACL (list, get, update, delete,
56
+ # manage child resources, and playback). By default, only the current user is
57
+ # granted all permissions; API keys and admins create with empty permissions
58
+ # when omitted. Guests with `videos.play` can stream when the video grants
59
+ # them read (`read(&quot;any&quot;)` or `read(&quot;guests&quot;)`).
60
+ #
61
+ # Uploaded caption files stay listed alongside auto-extracted tracks for the
62
+ # same language; when the current default is an auto-extracted track with
63
+ # that code, the upload takes the default flag.
64
+ #
65
+ #
66
+ # @param [String] video_id Video ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
67
+ # @param [String] bucket_id Storage bucket unique ID holding the source file.
68
+ # @param [String] file_id Source file unique ID.
69
+ # @param [String] name Video name. Defaults to the source file name. Max length: 2048 chars.
70
+ # @param [Array] permissions An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
71
+ #
72
+ # @return [Video]
73
+ def create(
74
+ video_id:,
75
+ bucket_id:,
76
+ file_id:,
77
+ name: nil,
78
+ permissions: nil
79
+ )
80
+ if video_id.nil?
81
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
82
+ end
83
+
84
+ if bucket_id.nil?
85
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
86
+ end
87
+
88
+ if file_id.nil?
89
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
90
+ end
91
+
92
+ api_path = '/videos'
93
+
94
+ api_params = {
95
+ videoId: video_id,
96
+ bucketId: bucket_id,
97
+ fileId: file_id,
98
+ name: name,
99
+ permissions: permissions,
100
+ }
101
+
102
+ api_headers = {
103
+ "X-Appwrite-Project": @client.get_config('project'),
104
+ "content-type": 'application/json',
105
+ "accept": 'application/json',
106
+ }
107
+
108
+ @client.call(
109
+ method: 'POST',
110
+ path: api_path,
111
+ headers: api_headers,
112
+ params: api_params,
113
+ response_type: Models::Video
114
+ )
115
+ end
116
+
117
+ # Get a list of video encode codecs enabled on this instance. Each codec
118
+ # includes the output formats it may be packaged into.
119
+ #
120
+ #
121
+ #
122
+ # @return [VideoCodecList]
123
+ def list_codecs()
124
+ api_path = '/videos/codecs'
125
+
126
+ api_params = {}
127
+
128
+ api_headers = {
129
+ "X-Appwrite-Project": @client.get_config('project'),
130
+ "accept": 'application/json',
131
+ }
132
+
133
+ @client.call(
134
+ method: 'GET',
135
+ path: api_path,
136
+ headers: api_headers,
137
+ params: api_params,
138
+ response_type: Models::VideoCodecList
139
+ )
140
+ end
141
+
142
+ # Get a video by its unique ID. This endpoint response returns a JSON object
143
+ # with the video metadata.
144
+ #
145
+ #
146
+ # @param [String] video_id Video unique ID.
147
+ #
148
+ # @return [Video]
149
+ def get(
150
+ video_id:
151
+ )
152
+ if video_id.nil? || video_id == ''
153
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
154
+ end
155
+
156
+ api_path = '/videos/{videoId}'
157
+ .gsub('{videoId}', @client.encode_path(video_id))
158
+
159
+ api_params = {}
160
+
161
+ api_headers = {
162
+ "X-Appwrite-Project": @client.get_config('project'),
163
+ "accept": 'application/json',
164
+ }
165
+
166
+ @client.call(
167
+ method: 'GET',
168
+ path: api_path,
169
+ headers: api_headers,
170
+ params: api_params,
171
+ response_type: Models::Video
172
+ )
173
+ end
174
+
175
+ # Update a video&#039;s name, permissions, or both. Only the fields you pass are
176
+ # changed: omit `name` to keep the current name and `permissions` to keep the
177
+ # current ACL. The caller must hold update permission on the video document.
178
+ # The source file cannot be replaced; delete the video and create a new one
179
+ # to point at a different file.
180
+ #
181
+ #
182
+ # @param [String] video_id Video unique ID.
183
+ # @param [String] name Video name. Max length: 2048 chars.
184
+ # @param [Array] permissions An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
185
+ #
186
+ # @return [Video]
187
+ def update(
188
+ video_id:,
189
+ name: nil,
190
+ permissions: nil
191
+ )
192
+ if video_id.nil? || video_id == ''
193
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
194
+ end
195
+
196
+ api_path = '/videos/{videoId}'
197
+ .gsub('{videoId}', @client.encode_path(video_id))
198
+
199
+ api_params = {
200
+ name: name,
201
+ permissions: permissions,
202
+ }
203
+
204
+ api_headers = {
205
+ "X-Appwrite-Project": @client.get_config('project'),
206
+ "content-type": 'application/json',
207
+ "accept": 'application/json',
208
+ }
209
+
210
+ @client.call(
211
+ method: 'PATCH',
212
+ path: api_path,
213
+ headers: api_headers,
214
+ params: api_params,
215
+ response_type: Models::Video
216
+ )
217
+ end
218
+
219
+ # Delete a video by its unique ID. This also removes every rendition,
220
+ # caption, preview and transcoded artifact derived from it. Fails with
221
+ # `video_rendition_in_progress` while a rendition is started or ended, unless
222
+ # that rendition has not been updated within the rendition retention window.
223
+ # Fails with `video_timeline_in_progress` while the video&#039;s timeline is being
224
+ # generated, unless the video has not been updated within the same window.
225
+ #
226
+ #
227
+ # @param [String] video_id Video unique ID.
228
+ #
229
+ # @return []
230
+ def delete(
231
+ video_id:
232
+ )
233
+ if video_id.nil? || video_id == ''
234
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
235
+ end
236
+
237
+ api_path = '/videos/{videoId}'
238
+ .gsub('{videoId}', @client.encode_path(video_id))
239
+
240
+ api_params = {}
241
+
242
+ api_headers = {
243
+ "X-Appwrite-Project": @client.get_config('project'),
244
+ "content-type": 'application/json',
245
+ "accept": 'application/json',
246
+ }
247
+
248
+ @client.call(
249
+ method: 'DELETE',
250
+ path: api_path,
251
+ headers: api_headers,
252
+ params: api_params,
253
+ )
254
+ end
255
+
256
+ # Get a list of all the caption tracks attached to a video. You can use the
257
+ # query params to filter your results.
258
+ #
259
+ #
260
+ # @param [String] video_id Video unique ID.
261
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, language, default, status, size, bucketId, fileId
262
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
263
+ #
264
+ # @return [VideoCaptionList]
265
+ def list_captions(
266
+ video_id:,
267
+ queries: nil,
268
+ total: nil
269
+ )
270
+ if video_id.nil? || video_id == ''
271
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
272
+ end
273
+
274
+ api_path = '/videos/{videoId}/captions'
275
+ .gsub('{videoId}', @client.encode_path(video_id))
276
+
277
+ api_params = {
278
+ queries: queries,
279
+ total: total,
280
+ }
281
+
282
+ api_headers = {
283
+ "X-Appwrite-Project": @client.get_config('project'),
284
+ "accept": 'application/json',
285
+ }
286
+
287
+ @client.call(
288
+ method: 'GET',
289
+ path: api_path,
290
+ headers: api_headers,
291
+ params: api_params,
292
+ response_type: Models::VideoCaptionList
293
+ )
294
+ end
295
+
296
+ # Add a caption track to a video from a WebVTT or SubRip file in a storage
297
+ # bucket. The file is normalised to WebVTT and segmented in the background.
298
+ # Subscribe to `videos.[videoId].captions.[captionId].update` for `started`,
299
+ # `ready`, and `error` status changes instead of only polling the caption
300
+ # document.
301
+ #
302
+ # Uploaded tracks are listed alongside auto-extracted embedded tracks
303
+ # (`embedded: true`). When the current default is an auto-extracted track for
304
+ # the same language code, the upload takes the default flag so players pick
305
+ # the authored file first. Auto-extracted tracks are never removed
306
+ # automatically — delete a track explicitly to remove it. Extraction runs
307
+ # once per video, so a deleted extracted track is not re-created.
308
+ #
309
+ #
310
+ # @param [String] video_id Video unique ID.
311
+ # @param [String] bucket_id Storage bucket unique ID holding the caption file.
312
+ # @param [String] file_id Caption file unique ID.
313
+ # @param [String] name Caption display name. Allowed characters: a-z, A-Z, 0-9, space, and - . , ( ) _ &#039;
314
+ # @param [String] language Caption ISO 639-2 three-letter language code.
315
+ # @param [] default Make this the default caption track for the video.
316
+ #
317
+ # @return [VideoCaption]
318
+ def create_caption(
319
+ video_id:,
320
+ bucket_id:,
321
+ file_id:,
322
+ name:,
323
+ language:,
324
+ default: nil
325
+ )
326
+ if video_id.nil? || video_id == ''
327
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
328
+ end
329
+
330
+ if bucket_id.nil?
331
+ raise Appwrite::Exception.new('Missing required parameter: "bucketId"')
332
+ end
333
+
334
+ if file_id.nil?
335
+ raise Appwrite::Exception.new('Missing required parameter: "fileId"')
336
+ end
337
+
338
+ if name.nil?
339
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
340
+ end
341
+
342
+ if language.nil?
343
+ raise Appwrite::Exception.new('Missing required parameter: "language"')
344
+ end
345
+
346
+ api_path = '/videos/{videoId}/captions'
347
+ .gsub('{videoId}', @client.encode_path(video_id))
348
+
349
+ api_params = {
350
+ bucketId: bucket_id,
351
+ fileId: file_id,
352
+ name: name,
353
+ language: language,
354
+ default: default,
355
+ }
356
+
357
+ api_headers = {
358
+ "X-Appwrite-Project": @client.get_config('project'),
359
+ "content-type": 'application/json',
360
+ "accept": 'application/json',
361
+ }
362
+
363
+ @client.call(
364
+ method: 'POST',
365
+ path: api_path,
366
+ headers: api_headers,
367
+ params: api_params,
368
+ response_type: Models::VideoCaption
369
+ )
370
+ end
371
+
372
+ # Update a caption track by its unique ID. Pass only `name`, `language`,
373
+ # and/or `default` to retag an extracted track (for example `und` → `heb`
374
+ # for Hebrew) without replacing the file. Changing `bucketId`/`fileId`
375
+ # re-packages the track in the background.
376
+ #
377
+ #
378
+ # @param [String] video_id Video unique ID.
379
+ # @param [String] caption_id Caption unique ID.
380
+ # @param [String] bucket_id Storage bucket unique ID holding the caption file. Omit together with fileId to only update name, language, or default.
381
+ # @param [String] file_id Caption file unique ID. Omit together with bucketId to only update name, language, or default.
382
+ # @param [String] name Caption display name. Allowed characters: a-z, A-Z, 0-9, space, and - . , ( ) _ &#039;
383
+ # @param [String] language Caption ISO 639-2 three-letter language code (for example `heb` for Hebrew).
384
+ # @param [] default Make this the default caption track for the video. Omit to leave unchanged.
385
+ #
386
+ # @return [VideoCaption]
387
+ def update_caption(
388
+ video_id:,
389
+ caption_id:,
390
+ bucket_id: nil,
391
+ file_id: nil,
392
+ name: nil,
393
+ language: nil,
394
+ default: nil
395
+ )
396
+ if video_id.nil? || video_id == ''
397
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
398
+ end
399
+
400
+ if caption_id.nil? || caption_id == ''
401
+ raise Appwrite::Exception.new('Missing required parameter: "captionId"')
402
+ end
403
+
404
+ api_path = '/videos/{videoId}/captions/{captionId}'
405
+ .gsub('{videoId}', @client.encode_path(video_id))
406
+ .gsub('{captionId}', @client.encode_path(caption_id))
407
+
408
+ api_params = {
409
+ bucketId: bucket_id,
410
+ fileId: file_id,
411
+ name: name,
412
+ language: language,
413
+ default: default,
414
+ }
415
+
416
+ api_headers = {
417
+ "X-Appwrite-Project": @client.get_config('project'),
418
+ "content-type": 'application/json',
419
+ "accept": 'application/json',
420
+ }
421
+
422
+ @client.call(
423
+ method: 'PATCH',
424
+ path: api_path,
425
+ headers: api_headers,
426
+ params: api_params,
427
+ response_type: Models::VideoCaption
428
+ )
429
+ end
430
+
431
+ # Delete a caption track by its unique ID, along with its packaged segments.
432
+ #
433
+ #
434
+ # @param [String] video_id Video unique ID.
435
+ # @param [String] caption_id Caption unique ID.
436
+ #
437
+ # @return []
438
+ def delete_caption(
439
+ video_id:,
440
+ caption_id:
441
+ )
442
+ if video_id.nil? || video_id == ''
443
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
444
+ end
445
+
446
+ if caption_id.nil? || caption_id == ''
447
+ raise Appwrite::Exception.new('Missing required parameter: "captionId"')
448
+ end
449
+
450
+ api_path = '/videos/{videoId}/captions/{captionId}'
451
+ .gsub('{videoId}', @client.encode_path(video_id))
452
+ .gsub('{captionId}', @client.encode_path(caption_id))
453
+
454
+ api_params = {}
455
+
456
+ api_headers = {
457
+ "X-Appwrite-Project": @client.get_config('project'),
458
+ "content-type": 'application/json',
459
+ "accept": 'application/json',
460
+ }
461
+
462
+ @client.call(
463
+ method: 'DELETE',
464
+ path: api_path,
465
+ headers: api_headers,
466
+ params: api_params,
467
+ )
468
+ end
469
+
470
+ # Get the top-level streaming manifest for a video output: an HLS master
471
+ # playlist (`master.m3u8`) or a DASH MPD (`master.mpd`). Hand this URL to a
472
+ # player to begin adaptive playback.
473
+ #
474
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
475
+ # **and** the video document grants them read. A video with `read(&quot;any&quot;)` or
476
+ # `read(&quot;guests&quot;)` is playable without a session.
477
+ #
478
+ # For CMAF renditions, use `getCmafHlsManifest` or `getCmafDashManifest`.
479
+ # Both masters point at the same fMP4 segment set.
480
+ #
481
+ #
482
+ # @param [String] video_id Video unique ID.
483
+ #
484
+ # @return []
485
+ def get_cmaf_hls_manifest(
486
+ video_id:
487
+ )
488
+ if video_id.nil? || video_id == ''
489
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
490
+ end
491
+
492
+ api_path = '/videos/{videoId}/outputs/cmaf/master.m3u8'
493
+ .gsub('{videoId}', @client.encode_path(video_id))
494
+
495
+ api_params = {}
496
+
497
+ api_headers = {
498
+ "X-Appwrite-Project": @client.get_config('project'),
499
+ "accept": '*/*',
500
+ }
501
+
502
+ @client.call(
503
+ method: 'GET',
504
+ path: api_path,
505
+ headers: api_headers,
506
+ params: api_params,
507
+ )
508
+ end
509
+
510
+ # Get the top-level streaming manifest for a video output: an HLS master
511
+ # playlist (`master.m3u8`) or a DASH MPD (`master.mpd`). Hand this URL to a
512
+ # player to begin adaptive playback.
513
+ #
514
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
515
+ # **and** the video document grants them read. A video with `read(&quot;any&quot;)` or
516
+ # `read(&quot;guests&quot;)` is playable without a session.
517
+ #
518
+ # For CMAF renditions, use `getCmafHlsManifest` or `getCmafDashManifest`.
519
+ # Both masters point at the same fMP4 segment set.
520
+ #
521
+ #
522
+ # @param [String] video_id Video unique ID.
523
+ #
524
+ # @return []
525
+ def get_cmaf_dash_manifest(
526
+ video_id:
527
+ )
528
+ if video_id.nil? || video_id == ''
529
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
530
+ end
531
+
532
+ api_path = '/videos/{videoId}/outputs/cmaf/master.mpd'
533
+ .gsub('{videoId}', @client.encode_path(video_id))
534
+
535
+ api_params = {}
536
+
537
+ api_headers = {
538
+ "X-Appwrite-Project": @client.get_config('project'),
539
+ "accept": '*/*',
540
+ }
541
+
542
+ @client.call(
543
+ method: 'GET',
544
+ path: api_path,
545
+ headers: api_headers,
546
+ params: api_params,
547
+ )
548
+ end
549
+
550
+ # Get the top-level streaming manifest for a video output: an HLS master
551
+ # playlist (`master.m3u8`) or a DASH MPD (`master.mpd`). Hand this URL to a
552
+ # player to begin adaptive playback.
553
+ #
554
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
555
+ # **and** the video document grants them read. A video with `read(&quot;any&quot;)` or
556
+ # `read(&quot;guests&quot;)` is playable without a session.
557
+ #
558
+ # For CMAF renditions, use `getCmafHlsManifest` or `getCmafDashManifest`.
559
+ # Both masters point at the same fMP4 segment set.
560
+ #
561
+ #
562
+ # @param [String] video_id Video unique ID.
563
+ #
564
+ # @return []
565
+ def get_dash_manifest(
566
+ video_id:
567
+ )
568
+ if video_id.nil? || video_id == ''
569
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
570
+ end
571
+
572
+ api_path = '/videos/{videoId}/outputs/dash/master.mpd'
573
+ .gsub('{videoId}', @client.encode_path(video_id))
574
+
575
+ api_params = {}
576
+
577
+ api_headers = {
578
+ "X-Appwrite-Project": @client.get_config('project'),
579
+ "accept": '*/*',
580
+ }
581
+
582
+ @client.call(
583
+ method: 'GET',
584
+ path: api_path,
585
+ headers: api_headers,
586
+ params: api_params,
587
+ )
588
+ end
589
+
590
+ # Get the top-level streaming manifest for a video output: an HLS master
591
+ # playlist (`master.m3u8`) or a DASH MPD (`master.mpd`). Hand this URL to a
592
+ # player to begin adaptive playback.
593
+ #
594
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
595
+ # **and** the video document grants them read. A video with `read(&quot;any&quot;)` or
596
+ # `read(&quot;guests&quot;)` is playable without a session.
597
+ #
598
+ # For CMAF renditions, use `getCmafHlsManifest` or `getCmafDashManifest`.
599
+ # Both masters point at the same fMP4 segment set.
600
+ #
601
+ #
602
+ # @param [String] video_id Video unique ID.
603
+ #
604
+ # @return []
605
+ def get_hls_manifest(
606
+ video_id:
607
+ )
608
+ if video_id.nil? || video_id == ''
609
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
610
+ end
611
+
612
+ api_path = '/videos/{videoId}/outputs/hls/master.m3u8'
613
+ .gsub('{videoId}', @client.encode_path(video_id))
614
+
615
+ api_params = {}
616
+
617
+ api_headers = {
618
+ "X-Appwrite-Project": @client.get_config('project'),
619
+ "accept": '*/*',
620
+ }
621
+
622
+ @client.call(
623
+ method: 'GET',
624
+ path: api_path,
625
+ headers: api_headers,
626
+ params: api_params,
627
+ )
628
+ end
629
+
630
+ # Get the playable caption resource for a video output: an HLS captions
631
+ # playlist, or the WebVTT file itself for DASH.
632
+ #
633
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
634
+ # **and** the video document grants them read.
635
+ #
636
+ #
637
+ # @param [String] video_id Video unique ID.
638
+ # @param [VideoOutput] output Streaming output format.
639
+ # @param [String] caption_id Caption unique ID.
640
+ #
641
+ # @return []
642
+ def get_caption_manifest(
643
+ video_id:,
644
+ output:,
645
+ caption_id:
646
+ )
647
+ if video_id.nil? || video_id == ''
648
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
649
+ end
650
+
651
+ if output.nil?
652
+ raise Appwrite::Exception.new('Missing required parameter: "output"')
653
+ end
654
+
655
+ if caption_id.nil? || caption_id == ''
656
+ raise Appwrite::Exception.new('Missing required parameter: "captionId"')
657
+ end
658
+
659
+ api_path = '/videos/{videoId}/outputs/{output}/captions/{captionId}/manifest'
660
+ .gsub('{videoId}', @client.encode_path(video_id))
661
+ .gsub('{output}', @client.encode_path(output))
662
+ .gsub('{captionId}', @client.encode_path(caption_id))
663
+
664
+ api_params = {}
665
+
666
+ api_headers = {
667
+ "X-Appwrite-Project": @client.get_config('project'),
668
+ "accept": '*/*',
669
+ }
670
+
671
+ @client.call(
672
+ method: 'GET',
673
+ path: api_path,
674
+ headers: api_headers,
675
+ params: api_params,
676
+ )
677
+ end
678
+
679
+ # Get a list of all the renditions of a video. You can use the query params
680
+ # to filter your results.
681
+ #
682
+ #
683
+ # @param [String] video_id Video unique ID.
684
+ # @param [Array] queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: profileId, name, status, output, codec, width, height, videoBitRate, audioBitRate, size, startedAt, endedAt
685
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
686
+ #
687
+ # @return [VideoRenditionList]
688
+ def list_renditions(
689
+ video_id:,
690
+ queries: nil,
691
+ total: nil
692
+ )
693
+ if video_id.nil? || video_id == ''
694
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
695
+ end
696
+
697
+ api_path = '/videos/{videoId}/renditions'
698
+ .gsub('{videoId}', @client.encode_path(video_id))
699
+
700
+ api_params = {
701
+ queries: queries,
702
+ total: total,
703
+ }
704
+
705
+ api_headers = {
706
+ "X-Appwrite-Project": @client.get_config('project'),
707
+ "accept": 'application/json',
708
+ }
709
+
710
+ @client.call(
711
+ method: 'GET',
712
+ path: api_path,
713
+ headers: api_headers,
714
+ params: api_params,
715
+ response_type: Models::VideoRenditionList
716
+ )
717
+ end
718
+
719
+ # Request a new rendition of a video, encoded against a video profile and
720
+ # packaged for HLS, DASH, or CMAF. The rendition is created immediately with
721
+ # a `pending` status and transcoded in the background; poll it or subscribe
722
+ # to realtime events to follow its progress. The worker downloads the source
723
+ # file for this job, probes metadata and extracts embedded captions when
724
+ # needed, then deletes the working copy when the job ends.
725
+ #
726
+ # The profile codec must be enabled on this instance. A disabled codec fails
727
+ # with `video_codec_disabled`.
728
+ #
729
+ # Each video may have only one rendition per profile and output combination.
730
+ # Creating a duplicate fails with `video_rendition_already_exists`. After an
731
+ # encode fails or is aborted, delete the rendition and create it again. The
732
+ # same profile may still be encoded for different outputs (for example HLS
733
+ # and DASH).
734
+ #
735
+ # A video accepts 10 rendition creates per hour. The next create returns
736
+ # `general_rate_limit_exceeded`.
737
+ #
738
+ # CMAF packs shared fMP4 segments once and exposes both HLS
739
+ # (`/outputs/cmaf/master.m3u8`) and DASH (`/outputs/cmaf/master.mpd`) masters
740
+ # for the same encode.
741
+ #
742
+ # Renditions can only be created from the Console or a server SDK with an API
743
+ # key that has the `videos.write` scope. Each encode spends the project&#039;s
744
+ # compute, so client sessions receive `user_unauthorized`.
745
+ #
746
+ #
747
+ # @param [String] video_id Video unique ID.
748
+ # @param [String] profile_id Video profile unique ID to encode against.
749
+ # @param [VideoOutput] output Streaming output format to package as.
750
+ #
751
+ # @return [VideoRendition]
752
+ def create_rendition(
753
+ video_id:,
754
+ profile_id:,
755
+ output:
756
+ )
757
+ if video_id.nil? || video_id == ''
758
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
759
+ end
760
+
761
+ if profile_id.nil?
762
+ raise Appwrite::Exception.new('Missing required parameter: "profileId"')
763
+ end
764
+
765
+ if output.nil?
766
+ raise Appwrite::Exception.new('Missing required parameter: "output"')
767
+ end
768
+
769
+ api_path = '/videos/{videoId}/renditions'
770
+ .gsub('{videoId}', @client.encode_path(video_id))
771
+
772
+ api_params = {
773
+ profileId: profile_id,
774
+ output: output,
775
+ }
776
+
777
+ api_headers = {
778
+ "X-Appwrite-Project": @client.get_config('project'),
779
+ "content-type": 'application/json',
780
+ "accept": 'application/json',
781
+ }
782
+
783
+ @client.call(
784
+ method: 'POST',
785
+ path: api_path,
786
+ headers: api_headers,
787
+ params: api_params,
788
+ response_type: Models::VideoRendition
789
+ )
790
+ end
791
+
792
+ # Get a rendition by its unique ID, including its current transcoding status
793
+ # and progress.
794
+ #
795
+ #
796
+ # @param [String] video_id Video unique ID.
797
+ # @param [String] rendition_id Rendition unique ID.
798
+ #
799
+ # @return [VideoRendition]
800
+ def get_rendition(
801
+ video_id:,
802
+ rendition_id:
803
+ )
804
+ if video_id.nil? || video_id == ''
805
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
806
+ end
807
+
808
+ if rendition_id.nil? || rendition_id == ''
809
+ raise Appwrite::Exception.new('Missing required parameter: "renditionId"')
810
+ end
811
+
812
+ api_path = '/videos/{videoId}/renditions/{renditionId}'
813
+ .gsub('{videoId}', @client.encode_path(video_id))
814
+ .gsub('{renditionId}', @client.encode_path(rendition_id))
815
+
816
+ api_params = {}
817
+
818
+ api_headers = {
819
+ "X-Appwrite-Project": @client.get_config('project'),
820
+ "accept": 'application/json',
821
+ }
822
+
823
+ @client.call(
824
+ method: 'GET',
825
+ path: api_path,
826
+ headers: api_headers,
827
+ params: api_params,
828
+ response_type: Models::VideoRendition
829
+ )
830
+ end
831
+
832
+ # Delete a rendition by its unique ID, along with its packaged segments and
833
+ # transcoded output. Fails with `video_rendition_in_progress` while the
834
+ # rendition is started or ended, unless it has not been updated within the
835
+ # rendition retention window.
836
+ #
837
+ #
838
+ # @param [String] video_id Video unique ID.
839
+ # @param [String] rendition_id Rendition unique ID.
840
+ #
841
+ # @return []
842
+ def delete_rendition(
843
+ video_id:,
844
+ rendition_id:
845
+ )
846
+ if video_id.nil? || video_id == ''
847
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
848
+ end
849
+
850
+ if rendition_id.nil? || rendition_id == ''
851
+ raise Appwrite::Exception.new('Missing required parameter: "renditionId"')
852
+ end
853
+
854
+ api_path = '/videos/{videoId}/renditions/{renditionId}'
855
+ .gsub('{videoId}', @client.encode_path(video_id))
856
+ .gsub('{renditionId}', @client.encode_path(rendition_id))
857
+
858
+ api_params = {}
859
+
860
+ api_headers = {
861
+ "X-Appwrite-Project": @client.get_config('project'),
862
+ "content-type": 'application/json',
863
+ "accept": 'application/json',
864
+ }
865
+
866
+ @client.call(
867
+ method: 'DELETE',
868
+ path: api_path,
869
+ headers: api_headers,
870
+ params: api_params,
871
+ )
872
+ end
873
+
874
+ # Get a single thumbnail sheet from a video&#039;s timeline as an image. You can
875
+ # resize the returned image and choose its output format.
876
+ #
877
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
878
+ # **and** the video document grants them read.
879
+ #
880
+ #
881
+ # @param [String] video_id Video unique ID.
882
+ # @param [String] thumbnail_id Thumbnail unique ID.
883
+ # @param [Integer] width Resize thumbnail image width, in pixels.
884
+ # @param [Integer] height Resize thumbnail image height, in pixels.
885
+ # @param [ImageFormat] output Output format type (jpeg, jpg, png, gif and webp).
886
+ #
887
+ # @return []
888
+ def get_thumbnail(
889
+ video_id:,
890
+ thumbnail_id:,
891
+ width: nil,
892
+ height: nil,
893
+ output: nil
894
+ )
895
+ if video_id.nil? || video_id == ''
896
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
897
+ end
898
+
899
+ if thumbnail_id.nil? || thumbnail_id == ''
900
+ raise Appwrite::Exception.new('Missing required parameter: "thumbnailId"')
901
+ end
902
+
903
+ api_path = '/videos/{videoId}/thumbnails/{thumbnailId}'
904
+ .gsub('{videoId}', @client.encode_path(video_id))
905
+ .gsub('{thumbnailId}', @client.encode_path(thumbnail_id))
906
+
907
+ api_params = {
908
+ width: width,
909
+ height: height,
910
+ output: output,
911
+ }
912
+
913
+ api_headers = {
914
+ "X-Appwrite-Project": @client.get_config('project'),
915
+ "accept": 'image/*',
916
+ }
917
+
918
+ @client.call(
919
+ method: 'GET',
920
+ path: api_path,
921
+ headers: api_headers,
922
+ params: api_params,
923
+ )
924
+ end
925
+
926
+ # Get the WebVTT thumbnail timeline for a video, used to render scrubbing
927
+ # thumbnails in a player. Timeline generation is queued when the video is
928
+ # created. Subscribe to `videos.[videoId].timelines.update` for probe and
929
+ # terminal updates, or poll this endpoint until it returns a WebVTT document.
930
+ # Audio-only sources produce no timeline and this endpoint returns
931
+ # `video_timelines_not_found`.
932
+ #
933
+ # Guests can request this URL when they hold `videos.play` (or `videos.read`)
934
+ # **and** the video document grants them read. A video with `read(&quot;any&quot;)` or
935
+ # `read(&quot;guests&quot;)` is playable without a session.
936
+ #
937
+ #
938
+ # @param [String] video_id Video unique ID.
939
+ #
940
+ # @return []
941
+ def get_timeline(
942
+ video_id:
943
+ )
944
+ if video_id.nil? || video_id == ''
945
+ raise Appwrite::Exception.new('Missing required parameter: "videoId"')
946
+ end
947
+
948
+ api_path = '/videos/{videoId}/timeline'
949
+ .gsub('{videoId}', @client.encode_path(video_id))
950
+
951
+ api_params = {}
952
+
953
+ api_headers = {
954
+ "X-Appwrite-Project": @client.get_config('project'),
955
+ "accept": '*/*',
956
+ }
957
+
958
+ @client.call(
959
+ method: 'GET',
960
+ path: api_path,
961
+ headers: api_headers,
962
+ params: api_params,
963
+ )
964
+ end
965
+ end
966
+ end