forked from googleapis/google-cloud-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Soft deleted bucket restore with sample #32
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
Open
shubhangi-google
wants to merge
106
commits into
main
Choose a base branch
from
soft_deleted_bucket_restore_with_sample
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
106 commits
Select commit
Hold shift + click to select a range
0f5b378
WIP- able to fetch generation and list of soft deleted bucket
shubhangi-google c13c271
wip- fetch soft deleted bucket and restore bucket
shubhangi-google 703a74f
refactor
shubhangi-google 113e074
adding unit tests
shubhangi-google d8389ee
refactor
shubhangi-google 4805dcf
update
shubhangi-google 4628b57
fixing lint issues
shubhangi-google 331713a
refactor
shubhangi-google 7bb513c
removing unwanted changes
shubhangi-google fd595ed
removing commented code
shubhangi-google 5876b21
removing unwanted file change
shubhangi-google 8bb3590
refactor
shubhangi-google 0c7316a
refactor
shubhangi-google dc22c71
WIP-samples
shubhangi-google 45c0bc7
adding samples and tests
shubhangi-google 2e96036
refactor
shubhangi-google 3728dcf
refactor
shubhangi-google 4265f54
updating comments
shubhangi-google 3c89fef
fix lint issues
shubhangi-google d3e3db6
fix lint issues
shubhangi-google 36fbf02
fix review comments
shubhangi-google 69a242b
removing pry
shubhangi-google 46b987e
fix lint
shubhangi-google 0d902d5
try cli issue fix
shubhangi-google b187c21
fix lint
shubhangi-google b608825
removing unwanted code
shubhangi-google cc5dd1e
adding check to see if bucket is deleted or not
shubhangi-google 6700876
debugging
shubhangi-google 9538c91
debugging
shubhangi-google ae9e2af
debugging
shubhangi-google dbdbe58
debugging
shubhangi-google d67ebf4
debugging
shubhangi-google f30c889
debugging
shubhangi-google 8040fab
debugging
shubhangi-google 88438a3
updating gemspec
shubhangi-google 70236f7
debugging
shubhangi-google b2f67ad
debugging
shubhangi-google 6108636
undo adding static email
shubhangi-google 04a56f1
updating gemspec -- debugging
shubhangi-google dcb47e7
updating gem spec -- debugging
shubhangi-google 360f07a
debugging
shubhangi-google f42e11d
debugging
shubhangi-google 49834d4
debugging
shubhangi-google 9b023d0
addressing nit comments
shubhangi-google 2a7f238
debugging
shubhangi-google 63c4106
debugging
shubhangi-google c7a2e76
debugging
shubhangi-google 9191faf
debugging
shubhangi-google 6395dc5
debugging
shubhangi-google 4feec6c
debugging
shubhangi-google 39edb70
debugging
shubhangi-google 25119ab
debugging
shubhangi-google 6af39e7
debugging
shubhangi-google 63b8485
debugging
shubhangi-google 0bc844f
debugging
shubhangi-google a442451
debugging
shubhangi-google 44b3aae
debugging
shubhangi-google 5ba2762
debugging
shubhangi-google e7dcbce
debugging
shubhangi-google 4838eb5
debugging
shubhangi-google 2edc311
debugging
shubhangi-google 7a6f719
debugging
shubhangi-google 199acc5
debugging
shubhangi-google 120d90c
debugging
shubhangi-google 2a48db3
resolving lint issues
shubhangi-google a559a06
resolving lint issue
shubhangi-google 4bdeb8b
lint issue
shubhangi-google da04abb
Merge branch 'main' into soft_deleted_bucket_restore_with_sample
shubhangi-google 0b10a6a
Merge branch 'main' into soft_deleted_bucket_restore_with_sample
shubhangi-google 4172e24
adding retention_period to sample bucket
shubhangi-google 33b3f07
Merge remote-tracking branch 'refs/remotes/origin/soft_deleted_bucket…
shubhangi-google 042c263
adding soft delete policy explicitly
shubhangi-google e84219c
adding soft delete policy explicitly
shubhangi-google 317c79a
recheking soft delete policy
shubhangi-google b099a91
recheking soft delete policy
shubhangi-google f34fbf8
debug...
shubhangi-google e8df7fd
debug...
shubhangi-google 4be3fe1
Merge branch 'main' into soft_deleted_bucket_restore_with_sample
shubhangi-google 22a749f
removing unwanted code
shubhangi-google 1b45f81
fix linnt issue
shubhangi-google 8e68cef
Merge branch 'main' into soft_deleted_bucket_restore_with_sample
shubhangi-google 1c501a5
wip
shubhangi-google ba8ca78
Update storage_get_soft_deleted_bucket.rb
shubhangi-google 707d2c0
wip
shubhangi-google 10fbe1d
wip
shubhangi-google 04f233a
wip
shubhangi-google 78e9579
Update project_test.rb
shubhangi-google 0b76567
Merge branch 'main' into soft_deleted_bucket_restore_with_sample
shubhangi-google 8347f2f
update
shubhangi-google bbf91e6
update
shubhangi-google 0223fd4
update
shubhangi-google dbb81d3
update
shubhangi-google 953be23
try
shubhangi-google 8b96a00
try
shubhangi-google 83336e2
try
shubhangi-google d771df2
try
shubhangi-google 50238be
try
shubhangi-google 3da781e
try
shubhangi-google 71a3c69
try
shubhangi-google f5dd234
try
shubhangi-google cc9b665
try
shubhangi-google a675a90
cleanup
shubhangi-google 7663fa4
try
shubhangi-google 3188d47
try
shubhangi-google f431611
try
shubhangi-google e123edc
cleanup
shubhangi-google File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
google-cloud-storage/samples/storage_get_soft_deleted_bucket.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Copyright 2024 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # [START storage_get_soft_deleted_bucket] | ||
| def get_soft_deleted_bucket bucket_name:, generation: | ||
| # The ID of your GCS bucket | ||
| # bucket_name = "your-unique-bucket-name" | ||
| # The generation no of your GCS bucket | ||
| # generation = "1234567896987" | ||
|
|
||
| require "google/cloud/storage" | ||
|
|
||
| storage = Google::Cloud::Storage.new | ||
| # fetching soft deleted bucket with soft_delete_time and hard_delete_time | ||
| puts "project_name while fetching the deleted bucket" | ||
| puts storage.project | ||
| deleted_bucket_fetch = storage.bucket bucket_name, generation: generation, soft_deleted: true | ||
|
|
||
|
|
||
| soft_delete_time = deleted_bucket_fetch.soft_delete_time | ||
| hard_delete_time = deleted_bucket_fetch.hard_delete_time | ||
|
|
||
| if (soft_delete_time && hard_delete_time).nil? | ||
| puts "Not Found" | ||
| else | ||
| puts "soft_delete_time for #{deleted_bucket_fetch.name} is - #{soft_delete_time}" | ||
| puts "hard_delete_time for #{deleted_bucket_fetch.name} is - #{hard_delete_time}" | ||
| end | ||
|
Comment on lines
+31
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if deleted_bucket_fetch
soft_delete_time = deleted_bucket_fetch.soft_delete_time
hard_delete_time = deleted_bucket_fetch.hard_delete_time
if soft_delete_time && hard_delete_time
puts "soft_delete_time for #{deleted_bucket_fetch.name} is - #{soft_delete_time}"
puts "hard_delete_time for #{deleted_bucket_fetch.name} is - #{hard_delete_time}"
else
puts "Bucket #{bucket_name} found, but it is not in a soft-deleted state."
end
else
puts "Soft-deleted bucket #{bucket_name} with generation #{generation} not found."
end |
||
| end | ||
| # [END storage_get_soft_deleted_bucket] | ||
|
|
||
|
|
||
| get_soft_deleted_bucket bucket_name: ARGV.shift, generation: ARGV.shift if $PROGRAM_NAME == __FILE__ | ||
30 changes: 30 additions & 0 deletions
30
google-cloud-storage/samples/storage_list_soft_deleted_buckets.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Copyright 2024 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # [START storage_list_soft_deleted_buckets] | ||
| def list_soft_deleted_buckets | ||
| require "google/cloud/storage" | ||
|
|
||
| storage = Google::Cloud::Storage.new | ||
|
|
||
| # fetching soft deleted bucket list | ||
| deleted_buckets = storage.buckets soft_deleted: true | ||
|
|
||
| deleted_buckets.each do |bucket| | ||
| puts bucket.name | ||
| end | ||
| end | ||
| # [END storage_list_soft_deleted_buckets] | ||
|
|
||
| list_soft_deleted_buckets if $PROGRAM_NAME == __FILE__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Copyright 2024 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # [START storage_restore_bucket] | ||
| def restore_bucket bucket_name:, generation: | ||
| # The ID of your GCS bucket | ||
| # bucket_name = "your-unique-bucket-name" | ||
| # The generation no of your GCS bucket | ||
| # generation = "1234567896987" | ||
|
|
||
| require "google/cloud/storage" | ||
|
|
||
| storage = Google::Cloud::Storage.new | ||
|
|
||
| bucket_restored = storage.restore_bucket bucket_name, generation | ||
|
|
||
| if bucket_restored.name == bucket_name | ||
| puts "#{bucket_name} Bucket restored" | ||
| else | ||
| puts "#{bucket_name} Bucket not restored" | ||
| end | ||
|
Comment on lines
+28
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| end | ||
| # [END storage_restore_bucket] | ||
|
|
||
| restore_bucket bucket_name: ARGV.shift, generation: ARGV.shift if $PROGRAM_NAME == __FILE__ | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The
putsstatements are for debugging and should be removed.