Skip to content

Commit 612371c

Browse files
try get request
1 parent 15512f2 commit 612371c

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

google-cloud-storage-control/samples/storage_control_create_anywhere_cache.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@ def create_anywhere_cache bucket_name:, zone:
4040
# The cache is created in the specified bucket.
4141
begin
4242
operation = storage_control_client.create_anywhere_cache request
43+
if operation.response? == false
4344

4445
puts "********************AnywhereCache operation created - #{operation.name}"
45-
while !operation.done?
46-
sleep 1800 # Wait for 1/2 hour before checking again
47-
operation.refresh!
48-
puts "********************AnywhereCache operation refreshed"
49-
puts "********************AnywhereCache operation status check retried"
46+
if !operation.done?
47+
get_request = Google::Cloud::Storage::Control::V2::GetAnywhereCacheRequest.new(
48+
name: name
49+
)
50+
result = storage_control_client.get_anywhere_cache get_request
51+
while result.state == "creating"
52+
sleep 1800 # Wait for 1/2 hour before checking again
53+
result = storage_control_client.get_anywhere_cache get_request
54+
puts "********************AnywhereCache operation refreshed"
55+
puts "********************AnywhereCache operation status check retried"
56+
end
5057
end
5158
puts "********************AnywhereCache create operation completed - #{operation.name}"
5259

0 commit comments

Comments
 (0)