Class: Temporalio::Contrib::Aws::S3Driver::AwsSdkS3StorageDriverClient

Inherits:
S3StorageDriverClient show all
Defined in:
lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb

Overview

Note:

WARNING: This API is experimental and may change in the future.

S3StorageDriverClient backed by an Aws::S3::Client from the official aws-sdk-s3 gem.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AwsSdkS3StorageDriverClient

Create a client.

Parameters:

  • client (Aws::S3::Client) —

    AWS S3 client to make requests with.



17
18
19
20
# File 'lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb', line 17

def initialize(client)
  super()
  @client = client
end

Instance Method Details

#describe ⇒ Hash<String, String>

Client-specific diagnostic information, such as the region, that the driver appends to error messages to help diagnose misconfiguration.

Returns:

  • (Hash<String, String>) —

    Diagnostic information. Empty by default.



42
43
44
45
# File 'lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb', line 42

def describe
  region = @client.config.region
  region.nil? || region.empty? ? {} : { 'client_region' => region }
end

#get_object(bucket:, key:) ⇒ String

Download the object at the given bucket and key.

Parameters:

  • bucket (String) —

    Bucket name.

  • key (String) —

    Object key.

Returns:

  • (String) —

    Binary object data.



37
38
39
# File 'lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb', line 37

def get_object(bucket:, key:)
  @client.get_object(bucket:, key:).body.read
end

#object_exists?(bucket:, key:) ⇒ Boolean

Check whether an object exists at the given bucket and key.

Parameters:

  • bucket (String) —

    Bucket name.

  • key (String) —

    Object key.

Returns:

  • (Boolean) —

    Whether the object exists.



29
30
31
32
33
34
# File 'lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb', line 29

def object_exists?(bucket:, key:)
  @client.head_object(bucket:, key:)
  true
rescue ::Aws::S3::Errors::NotFound
  false
end

#put_object(bucket:, key:, data:) ⇒ Object

Upload data to the given bucket and key.

Parameters:

  • bucket (String) —

    Bucket name.

  • key (String) —

    Object key.

  • data (String) —

    Binary data to upload.



23
24
25
26
# File 'lib/temporalio/contrib/aws/s3_driver/aws_sdk_s3_storage_driver_client.rb', line 23

def put_object(bucket:, key:, data:)
  @client.put_object(bucket:, key:, body: data)
  nil
end