Class: RemotionLambda::Client
- Inherits:
-
Object
- Object
- RemotionLambda::Client
- Defined in:
- lib/sdk.rb,
lib/remotion_lambda/sdk.rb
Instance Attribute Summary collapse
-
#bucket_name ⇒ Object
readonly
Returns the value of attribute bucket_name.
-
#serve_url ⇒ Object
readonly
Returns the value of attribute serve_url.
Instance Method Summary collapse
- #cancel_render_on_lambda(bucket_name, render_id) ⇒ Object
- #get_render_progress(function_name, payload) ⇒ Object
-
#initialize(region: ENV.fetch('AWS_REGION', 'us-east-1'), aws_profile: nil, s3_client: nil) ⇒ Client
constructor
A new instance of Client.
- #render_media_on_lambda(function_name, payload) ⇒ Object
- #render_still_on_lambda(function_name, payload) ⇒ Object
Constructor Details
#initialize(region: ENV.fetch('AWS_REGION', 'us-east-1'), aws_profile: nil, s3_client: nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 |
# File 'lib/sdk.rb', line 10 def initialize( region: ENV.fetch('AWS_REGION', 'us-east-1'), aws_profile: nil ) @region = region @aws_profile = aws_profile @lambda_client = create_lambda_client end |
Instance Attribute Details
#bucket_name ⇒ Object (readonly)
Returns the value of attribute bucket_name.
8 9 10 |
# File 'lib/sdk.rb', line 8 def bucket_name @bucket_name end |
#serve_url ⇒ Object (readonly)
Returns the value of attribute serve_url.
8 9 10 |
# File 'lib/sdk.rb', line 8 def serve_url @serve_url end |
Instance Method Details
#cancel_render_on_lambda(bucket_name, render_id) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/remotion_lambda/sdk.rb', line 40 def cancel_render_on_lambda(bucket_name, render_id) progress_response = s3_client.get_object( bucket: bucket_name, key: "renders/#{render_id}/progress.json" ) progress = JSON.parse(progress_response.body.read) unless progress['cancellationEnabled'] == true raise "Cannot cancel render #{render_id}: The render was not started with enableCancellation: true." end s3_client.put_object( bucket: bucket_name, key: "renders/#{render_id}/cancel.json", body: JSON.generate(cancelledAt: (Time.now.to_f * 1000).floor), content_type: 'application/json' ) nil end |
#get_render_progress(function_name, payload) ⇒ Object
19 20 21 22 23 |
# File 'lib/sdk.rb', line 19 def get_render_progress(function_name, payload) body = invoke(function_name, payload) raise "Failed to fetch progress: #{body['message']}" if body["type"] == "error" body end |
#render_media_on_lambda(function_name, payload) ⇒ Object
25 26 27 28 29 |
# File 'lib/sdk.rb', line 25 def render_media_on_lambda(function_name, payload) body = invoke(function_name, payload) raise "Failed to call renderMediaOnLambda: #{body['message']}" if body["type"] == "error" body end |
#render_still_on_lambda(function_name, payload) ⇒ Object
31 32 33 34 35 |
# File 'lib/sdk.rb', line 31 def render_still_on_lambda(function_name, payload) body = invoke(function_name, payload) raise "Failed to call renderStillOnLambda: #{body['message']}" if body["type"] == "error" body end |