-
Notifications
You must be signed in to change notification settings - Fork 553
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
feat(storage): Soft deleted Bucket Restore #28102
base: main
Are you sure you want to change the base?
feat(storage): Soft deleted Bucket Restore #28102
Conversation
@generation = @gapi.generation | ||
end | ||
|
||
def soft_delete_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these instance variables?
@@ -3144,7 +3158,7 @@ def lazy? | |||
|
|||
## | |||
# @private New Bucket from a Google API Client object. | |||
def self.from_gapi gapi, service, user_project: nil | |||
def self.from_gapi gapi, service, user_project: nil, generation: nil, soft_deleted: nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why we need these parameters if we're not using them.
buckets = new(Array(gapi_list.items).map do |gapi_object| | ||
Bucket.from_gapi gapi_object, service, user_project: user_project | ||
Bucket.from_gapi gapi_object, service, user_project: user_project, soft_deleted: soft_deleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq: Do we not need to set soft_deleted
instance variable?
@@ -193,11 +193,20 @@ def add_custom_header header_name, header_value | |||
# puts bucket.name | |||
# end | |||
# | |||
def buckets prefix: nil, token: nil, max: nil, user_project: nil | |||
# @example Retrieve soft deleted |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# @example Retrieve soft deleted | |
# @example Retrieve soft deleted buckets |
# | ||
# storage = Google::Cloud::Storage.new | ||
# | ||
# user_buckets = storage.buckets soft_deleted: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# user_buckets = storage.buckets soft_deleted: true | |
# soft_deleted_buckets = storage.buckets soft_deleted: true |
|
||
_(bucket.name).must_equal bucket_name | ||
_(bucket.generation).must_equal generation | ||
_(bucket.gapi.hard_delete_time).wont_be_nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use gapi
here? We added new getter methods for soft and hard delete time.
end | ||
|
||
def find_bucket_gapi name = nil | ||
Google::Apis::StorageV1::Bucket.from_json random_bucket_hash(name: name).to_json | ||
end | ||
|
||
def find_deleted_bucket_gapi name = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we please make it keyword argument?
def list_buckets_gapi count = 2, token = nil | ||
buckets = count.times.map { Google::Apis::StorageV1::Bucket.from_json random_bucket_hash.to_json } | ||
Google::Apis::StorageV1::Buckets.new( | ||
kind: "storage#buckets", items: buckets, next_page_token: token | ||
) | ||
end | ||
|
||
def list_deleted_buckets_gapi count = 2, token = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: can we please make these keyword argument?
) | ||
end | ||
|
||
def restored_bucket_gapi name, _generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need _generation
if we're not using it?
google-cloud-storage/test/helper.rb
Outdated
def === other | ||
return(to_h === other.to_h) if other.respond_to? :to_h | ||
super | ||
module Google |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are making changes to this block?
No region tags are edited in this PR.This comment is generated by snippet-bot.
|
Add support for restoring soft deleted bucket.
Operation Supported: