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,165 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class VideoRendition
6
+ attr_reader :id
7
+ attr_reader :created_at
8
+ attr_reader :updated_at
9
+ attr_reader :video_id
10
+ attr_reader :profile_id
11
+ attr_reader :name
12
+ attr_reader :started_at
13
+ attr_reader :ended_at
14
+ attr_reader :width
15
+ attr_reader :height
16
+ attr_reader :video_bit_rate
17
+ attr_reader :audio_bit_rate
18
+ attr_reader :target_duration
19
+ attr_reader :status
20
+ attr_reader :error
21
+ attr_reader :progress
22
+ attr_reader :output
23
+ attr_reader :codec
24
+ attr_reader :size
25
+
26
+ def initialize(
27
+ id:,
28
+ created_at:,
29
+ updated_at:,
30
+ video_id:,
31
+ profile_id:,
32
+ name:,
33
+ started_at:,
34
+ ended_at:,
35
+ width:,
36
+ height:,
37
+ video_bit_rate:,
38
+ audio_bit_rate:,
39
+ target_duration:,
40
+ status:,
41
+ error:,
42
+ progress:,
43
+ output:,
44
+ codec:,
45
+ size:
46
+ )
47
+ @id = id
48
+ @created_at = created_at
49
+ @updated_at = updated_at
50
+ @video_id = video_id
51
+ @profile_id = profile_id
52
+ @name = name
53
+ @started_at = started_at
54
+ @ended_at = ended_at
55
+ @width = width
56
+ @height = height
57
+ @video_bit_rate = video_bit_rate
58
+ @audio_bit_rate = audio_bit_rate
59
+ @target_duration = target_duration
60
+ @status = validate_status(status)
61
+ @error = error
62
+ @progress = progress
63
+ @output = validate_output(output)
64
+ @codec = validate_codec(codec)
65
+ @size = size
66
+ end
67
+
68
+ def self.from(map:)
69
+ map = { "$id" => "", "$createdAt" => "", "$updatedAt" => "", "videoId" => "", "profileId" => "", "name" => "", "startedAt" => "", "endedAt" => "", "width" => 0, "height" => 0, "videoBitRate" => 0, "audioBitRate" => 0, "targetDuration" => 0, "status" => "pending", "error" => "", "progress" => 0, "output" => "hls", "codec" => "h264", "size" => 0 }.merge(map)
70
+ VideoRendition.new(
71
+ id: map["$id"],
72
+ created_at: map["$createdAt"],
73
+ updated_at: map["$updatedAt"],
74
+ video_id: map["videoId"],
75
+ profile_id: map["profileId"],
76
+ name: map["name"],
77
+ started_at: map["startedAt"],
78
+ ended_at: map["endedAt"],
79
+ width: map["width"],
80
+ height: map["height"],
81
+ video_bit_rate: map["videoBitRate"],
82
+ audio_bit_rate: map["audioBitRate"],
83
+ target_duration: map["targetDuration"],
84
+ status: map["status"],
85
+ error: map["error"],
86
+ progress: map["progress"],
87
+ output: map["output"],
88
+ codec: map["codec"],
89
+ size: map["size"]
90
+ )
91
+ end
92
+
93
+ def to_map
94
+ {
95
+ "$id": @id,
96
+ "$createdAt": @created_at,
97
+ "$updatedAt": @updated_at,
98
+ "videoId": @video_id,
99
+ "profileId": @profile_id,
100
+ "name": @name,
101
+ "startedAt": @started_at,
102
+ "endedAt": @ended_at,
103
+ "width": @width,
104
+ "height": @height,
105
+ "videoBitRate": @video_bit_rate,
106
+ "audioBitRate": @audio_bit_rate,
107
+ "targetDuration": @target_duration,
108
+ "status": @status,
109
+ "error": @error,
110
+ "progress": @progress,
111
+ "output": @output,
112
+ "codec": @codec,
113
+ "size": @size
114
+ }
115
+ end
116
+
117
+ private
118
+
119
+ def validate_status(status)
120
+ valid_status = [
121
+ Appwrite::Enums::VideoRenditionStatus::PENDING,
122
+ Appwrite::Enums::VideoRenditionStatus::STARTED,
123
+ Appwrite::Enums::VideoRenditionStatus::ENDED,
124
+ Appwrite::Enums::VideoRenditionStatus::READY,
125
+ Appwrite::Enums::VideoRenditionStatus::ERROR,
126
+ Appwrite::Enums::VideoRenditionStatus::ABORTED,
127
+ ]
128
+
129
+ unless valid_status.include?(status)
130
+ raise ArgumentError, "Invalid " + status + ". Must be one of: " + valid_status.join(', ')
131
+ end
132
+
133
+ status
134
+ end
135
+
136
+ def validate_output(output)
137
+ valid_output = [
138
+ Appwrite::Enums::VideoOutput::HLS,
139
+ Appwrite::Enums::VideoOutput::DASH,
140
+ Appwrite::Enums::VideoOutput::CMAF,
141
+ ]
142
+
143
+ unless valid_output.include?(output)
144
+ raise ArgumentError, "Invalid " + output + ". Must be one of: " + valid_output.join(', ')
145
+ end
146
+
147
+ output
148
+ end
149
+
150
+ def validate_codec(codec)
151
+ valid_codec = [
152
+ Appwrite::Enums::VideoCodecId::H264,
153
+ Appwrite::Enums::VideoCodecId::HEVC,
154
+ Appwrite::Enums::VideoCodecId::VP9,
155
+ ]
156
+
157
+ unless valid_codec.include?(codec)
158
+ raise ArgumentError, "Invalid " + codec + ". Must be one of: " + valid_codec.join(', ')
159
+ end
160
+
161
+ codec
162
+ end
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appwrite
4
+ module Models
5
+ class VideoRenditionList
6
+ attr_reader :total
7
+ attr_reader :renditions
8
+
9
+ def initialize(
10
+ total:,
11
+ renditions:
12
+ )
13
+ @total = total
14
+ @renditions = renditions
15
+ end
16
+
17
+ def self.from(map:)
18
+ map = { "total" => 0, "renditions" => [] }.merge(map)
19
+ VideoRenditionList.new(
20
+ total: map["total"],
21
+ renditions: map["renditions"].map { |it| VideoRendition.from(map: it) }
22
+ )
23
+ end
24
+
25
+ def to_map
26
+ {
27
+ "total": @total,
28
+ "renditions": @renditions.map { |it| it.to_map }
29
+ }
30
+ end
31
+ end
32
+ end
33
+ end
@@ -5791,5 +5791,238 @@ module Appwrite
5791
5791
  params: api_params,
5792
5792
  )
5793
5793
  end
5794
+
5795
+ # Get a list of video profiles in the current project (`GET
5796
+ # /v1/project/videos/profiles`). Every profile is returned regardless of
5797
+ # codec. Filter with `queries`, for example `Query.equal('codec', ['h264'])`
5798
+ # for one encode ladder, or on `name`, `width`, `height`, `videoBitRate` and
5799
+ # `audioBitRate`. Search with `Query.search()` on the `search` attribute.
5800
+ #
5801
+ #
5802
+ # @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, codec, width, height, videoBitRate, audioBitRate, search
5803
+ # @param [] total When set to false, the total count returned will be 0 and will not be calculated.
5804
+ #
5805
+ # @return [VideoProfileList]
5806
+ def list_video_profiles(
5807
+ queries: nil,
5808
+ total: nil
5809
+ )
5810
+ api_path = '/project/videos/profiles'
5811
+
5812
+ api_params = {
5813
+ queries: queries,
5814
+ total: total,
5815
+ }
5816
+
5817
+ api_headers = {
5818
+ "X-Appwrite-Project": @client.get_config('project'),
5819
+ "accept": 'application/json',
5820
+ }
5821
+
5822
+ @client.call(
5823
+ method: 'GET',
5824
+ path: api_path,
5825
+ headers: api_headers,
5826
+ params: api_params,
5827
+ response_type: Models::VideoProfileList
5828
+ )
5829
+ end
5830
+
5831
+ # Create a video profile (`POST /v1/project/videos/profiles`) describing an
5832
+ # encoding target: output dimensions, video/audio bitrates, and encode codec.
5833
+ # Only codecs enabled on this instance are accepted; the default is `h264`. A
5834
+ # disabled codec is rejected. Creating a profile with the same width, height,
5835
+ # bitrates, and codec fails with `video_profile_already_exists`. Bitrates are
5836
+ # in bits per second and must be multiples of 1000. Renditions are encoded
5837
+ # against a profile.
5838
+ #
5839
+ #
5840
+ # @param [String] profile_id Video profile 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't start with a special char. Max length is 36 chars.
5841
+ # @param [String] name Video profile name.
5842
+ # @param [Integer] video_bit_rate Target video bitrate in bits per second. Must be a multiple of 1000.
5843
+ # @param [Integer] audio_bit_rate Target audio bitrate in bits per second. Must be a multiple of 1000.
5844
+ # @param [Integer] width Target video width in pixels. Must be an even number.
5845
+ # @param [Integer] height Target video height in pixels. Must be an even number.
5846
+ # @param [VideoCodecId] codec Video encode codec. Codecs not enabled on this instance are rejected. Defaults to `h264`.
5847
+ #
5848
+ # @return [VideoProfile]
5849
+ def create_video_profile(
5850
+ profile_id:,
5851
+ name:,
5852
+ video_bit_rate:,
5853
+ audio_bit_rate:,
5854
+ width:,
5855
+ height:,
5856
+ codec: nil
5857
+ )
5858
+ if profile_id.nil?
5859
+ raise Appwrite::Exception.new('Missing required parameter: "profileId"')
5860
+ end
5861
+
5862
+ if name.nil?
5863
+ raise Appwrite::Exception.new('Missing required parameter: "name"')
5864
+ end
5865
+
5866
+ if video_bit_rate.nil?
5867
+ raise Appwrite::Exception.new('Missing required parameter: "videoBitRate"')
5868
+ end
5869
+
5870
+ if audio_bit_rate.nil?
5871
+ raise Appwrite::Exception.new('Missing required parameter: "audioBitRate"')
5872
+ end
5873
+
5874
+ if width.nil?
5875
+ raise Appwrite::Exception.new('Missing required parameter: "width"')
5876
+ end
5877
+
5878
+ if height.nil?
5879
+ raise Appwrite::Exception.new('Missing required parameter: "height"')
5880
+ end
5881
+
5882
+ api_path = '/project/videos/profiles'
5883
+
5884
+ api_params = {
5885
+ profileId: profile_id,
5886
+ name: name,
5887
+ videoBitRate: video_bit_rate,
5888
+ audioBitRate: audio_bit_rate,
5889
+ width: width,
5890
+ height: height,
5891
+ codec: codec,
5892
+ }
5893
+
5894
+ api_headers = {
5895
+ "X-Appwrite-Project": @client.get_config('project'),
5896
+ "content-type": 'application/json',
5897
+ "accept": 'application/json',
5898
+ }
5899
+
5900
+ @client.call(
5901
+ method: 'POST',
5902
+ path: api_path,
5903
+ headers: api_headers,
5904
+ params: api_params,
5905
+ response_type: Models::VideoProfile
5906
+ )
5907
+ end
5908
+
5909
+ # Get a video profile by its unique ID (`GET
5910
+ # /v1/project/videos/profiles/:profileId`).
5911
+ #
5912
+ #
5913
+ # @param [String] profile_id Video profile unique ID.
5914
+ #
5915
+ # @return [VideoProfile]
5916
+ def get_video_profile(
5917
+ profile_id:
5918
+ )
5919
+ if profile_id.nil? || profile_id == ''
5920
+ raise Appwrite::Exception.new('Missing required parameter: "profileId"')
5921
+ end
5922
+
5923
+ api_path = '/project/videos/profiles/{profileId}'
5924
+ .gsub('{profileId}', @client.encode_path(profile_id))
5925
+
5926
+ api_params = {}
5927
+
5928
+ api_headers = {
5929
+ "X-Appwrite-Project": @client.get_config('project'),
5930
+ "accept": 'application/json',
5931
+ }
5932
+
5933
+ @client.call(
5934
+ method: 'GET',
5935
+ path: api_path,
5936
+ headers: api_headers,
5937
+ params: api_params,
5938
+ response_type: Models::VideoProfile
5939
+ )
5940
+ end
5941
+
5942
+ # Update a video profile by its unique ID (`PATCH
5943
+ # /v1/project/videos/profiles/:profileId`). Existing renditions are not
5944
+ # re-encoded. Changing the profile onto the same width, height, bitrates, and
5945
+ # codec as another profile fails with `video_profile_already_exists`.
5946
+ #
5947
+ #
5948
+ # @param [String] profile_id Video profile unique ID.
5949
+ # @param [String] name Video profile name.
5950
+ # @param [Integer] video_bit_rate Target video bitrate in bits per second. Must be a multiple of 1000.
5951
+ # @param [Integer] audio_bit_rate Target audio bitrate in bits per second. Must be a multiple of 1000.
5952
+ # @param [Integer] width Target video width in pixels. Must be an even number.
5953
+ # @param [Integer] height Target video height in pixels. Must be an even number.
5954
+ #
5955
+ # @return [VideoProfile]
5956
+ def update_video_profile(
5957
+ profile_id:,
5958
+ name: nil,
5959
+ video_bit_rate: nil,
5960
+ audio_bit_rate: nil,
5961
+ width: nil,
5962
+ height: nil
5963
+ )
5964
+ if profile_id.nil? || profile_id == ''
5965
+ raise Appwrite::Exception.new('Missing required parameter: "profileId"')
5966
+ end
5967
+
5968
+ api_path = '/project/videos/profiles/{profileId}'
5969
+ .gsub('{profileId}', @client.encode_path(profile_id))
5970
+
5971
+ api_params = {
5972
+ name: name,
5973
+ videoBitRate: video_bit_rate,
5974
+ audioBitRate: audio_bit_rate,
5975
+ width: width,
5976
+ height: height,
5977
+ }
5978
+
5979
+ api_headers = {
5980
+ "X-Appwrite-Project": @client.get_config('project'),
5981
+ "content-type": 'application/json',
5982
+ "accept": 'application/json',
5983
+ }
5984
+
5985
+ @client.call(
5986
+ method: 'PATCH',
5987
+ path: api_path,
5988
+ headers: api_headers,
5989
+ params: api_params,
5990
+ response_type: Models::VideoProfile
5991
+ )
5992
+ end
5993
+
5994
+ # Delete a video profile by its unique ID (`DELETE
5995
+ # /v1/project/videos/profiles/:profileId`). Renditions already encoded
5996
+ # against it are left in place.
5997
+ #
5998
+ #
5999
+ # @param [String] profile_id Video profile unique ID.
6000
+ #
6001
+ # @return []
6002
+ def delete_video_profile(
6003
+ profile_id:
6004
+ )
6005
+ if profile_id.nil? || profile_id == ''
6006
+ raise Appwrite::Exception.new('Missing required parameter: "profileId"')
6007
+ end
6008
+
6009
+ api_path = '/project/videos/profiles/{profileId}'
6010
+ .gsub('{profileId}', @client.encode_path(profile_id))
6011
+
6012
+ api_params = {}
6013
+
6014
+ api_headers = {
6015
+ "X-Appwrite-Project": @client.get_config('project'),
6016
+ "content-type": 'application/json',
6017
+ "accept": 'application/json',
6018
+ }
6019
+
6020
+ @client.call(
6021
+ method: 'DELETE',
6022
+ path: api_path,
6023
+ headers: api_headers,
6024
+ params: api_params,
6025
+ )
6026
+ end
5794
6027
  end
5795
6028
  end