Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RBS signatures for customizations of s3 #3013

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions gems/aws-sdk-s3/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Unreleased Changes

* Feature - Support S3 Access Grants authentication. Access Grants can be enabled with the `access_grants` option, and custom options can be passed into the `access_grants_credentials_provider` option. This feature requires `aws-sdk-s3control` to be installed.

* Feature - Add RBS signatures for customizations of S3.

1.148.0 (2024-04-25)
------------------

Expand Down
19 changes: 19 additions & 0 deletions gems/aws-sdk-s3/sig/customizations/bucket.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Aws
module S3
class Bucket
# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Bucket.html#clear!-instance_method
def clear!: () -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Bucket.html#delete!-instance_method
def delete!: (?max_attempts: ::Integer, ?initial_wait: ::Float) -> void
| (?Hash[Symbol, untyped]) -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Bucket.html#url-instance_method
def url: (?virtual_host: boolish, ?secure: boolish) -> String
| (?Hash[Symbol, untyped]) -> String

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Bucket.html#presigned_post-instance_method
def presigned_post: (Hash[Symbol, untyped]) -> untyped
end
end
end
38 changes: 38 additions & 0 deletions gems/aws-sdk-s3/sig/customizations/object.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module Aws
module S3
class Object
alias size content_length

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#copy_from-instance_method
def copy_from: (untyped source, ?Hash[Symbol, untyped] options) -> void
| ...

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#copy_to-instance_method
def copy_to: (untyped target, ?Hash[Symbol, untyped] options) -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#move_to-instance_method
def move_to: (untyped target, ?Hash[Symbol, untyped] options) -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#presigned_post-instance_method
def presigned_post: (?Hash[Symbol, untyped]) -> untyped

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#presigned_url-instance_method
def presigned_url: (Symbol | String method, ?Hash[Symbol, untyped] params) -> String

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#presigned_request-instance_method
def presigned_request: (Symbol | String method, ?Hash[Symbol, untyped] params) -> [String, Hash[String, String]]

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#public_url-instance_method
def public_url: (?Hash[Symbol, untyped] options) -> String

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#upload_stream-instance_method
def upload_stream: (?Hash[Symbol, untyped] options) { (IO write_stream) -> void } -> bool

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#upload_file-instance_method
def upload_file: (untyped source, ?Hash[Symbol, untyped] options) ?{ (untyped response) -> void } -> bool

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/Object.html#download_file-instance_method
def download_file: (String destination, ?Hash[Symbol, untyped] options) -> bool
end
end
end
35 changes: 35 additions & 0 deletions gems/aws-sdk-s3/sig/customizations/object_summary.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Aws
module S3
class ObjectSummary
alias content_length size

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#copy_from-instance_method
def copy_from: (untyped source, ?Hash[Symbol, untyped] options) -> void
| ...

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#copy_to-instance_method
def copy_to: (untyped target, ?Hash[Symbol, untyped] options) -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#move_to-instance_method
def move_to: (untyped target, ?Hash[Symbol, untyped] options) -> void

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#presigned_post-instance_method
def presigned_post: (Hash[Symbol, untyped]) -> untyped

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#presigned_url-instance_method
def presigned_url: (Symbol | String method, ?Hash[Symbol, untyped] params) -> String

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#public_url-instance_method
def public_url: (?Hash[Symbol, untyped] options) -> String

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#upload_file-instance_method
def upload_file: (untyped source, ?Hash[Symbol, untyped] options) ?{ (untyped response) -> void } -> bool

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#upload_stream-instance_method
def upload_stream: (?Hash[Symbol, untyped] options) { (IO write_stream) -> void } -> bool

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/S3/ObjectSummary.html#download_file-instance_method
def download_file: (String destination, ?Hash[Symbol, untyped] options) -> bool
end
end
end
10 changes: 5 additions & 5 deletions gems/aws-sdk-s3/spec/object_summary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,31 @@ module S3

it 'delegates #presigned_url to #object' do
expect(object).to receive(:presigned_url)
.with('method', { opt_name: 'opt-value' })
.with('method', { opt_name: 'opt-value' }).and_return('return-value')
object_summary.presigned_url('method', opt_name: 'opt-value')
end

it 'delegates #public_url to #object' do
expect(object).to receive(:public_url).with({ opt_name: 'opt-value' })
expect(object).to receive(:public_url).with({ opt_name: 'opt-value' }).and_return('return-value')
object_summary.public_url(opt_name: 'opt-value')
end

it 'delegates #upload_file to #object' do
expect(object).to receive(:upload_file)
.with('source', { opt_name: 'opt-value'})
.with('source', { opt_name: 'opt-value'}).and_return(true)
object_summary.upload_file('source', opt_name: 'opt-value')
end

it 'delegates #upload_stream to #object' do
block = proc { :foo }
expect(object).to receive(:upload_stream)
.with({ opt_name: 'opt-value' }, &block)
.with({ opt_name: 'opt-value' }, &block).and_return(true)
object_summary.upload_stream(opt_name: 'opt-value', &block)
end

it 'delegates #download_file to #object' do
expect(object).to receive(:download_file)
.with('destination', { opt_name: 'opt-value' })
.with('destination', { opt_name: 'opt-value' }).and_return(true)
object_summary.download_file('destination', opt_name: 'opt-value')
end
end
Expand Down