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 EC2::Snapshot#wait_until_completed waiter #735

Closed
amw opened this issue Mar 11, 2015 · 5 comments
Closed

Add EC2::Snapshot#wait_until_completed waiter #735

amw opened this issue Mar 11, 2015 · 5 comments
Labels
feature-request A feature should be added or improved.

Comments

@amw
Copy link

amw commented Mar 11, 2015

It's currently possible to use Aws::EC2::Client.new.wait_until(:snapshot_completed, snapshot_ids: [snapshot.id]), I think it would be convenient to also be able to call snapshot.wait_until_completed.

@trevorrowe trevorrowe added feature-request A feature should be added or improved. Version 2 labels Mar 11, 2015
@trevorrowe
Copy link
Member

Thanks for the suggestion. This should be part of the next release.

@sandstrom
Copy link

Is this supposed to work?

irb(main):375:0> snapshot
=> #<struct Aws::EC2::Types::Snapshot data_encryption_key_id=nil, description="test snapshot, safe to del", encrypted=false, kms_key_id=nil, owner_id="773190852875", progress="", snapshot_id="snap-05a0bf6432567996a", start_time=2020-08-07 14:24:29 UTC, state="pending", state_message=nil, volume_id="vol-086363c9646c92e4a", volume_size=1, owner_alias=nil, tags=[]>

irb(main):376:0> snapshot.wait_until_completed
NoMethodError: undefined method `wait_until_completed' for #<Seahorse::Client::Response:0x000056256a69e8e0>

@alextwoods
Copy link
Contributor

The Snapshot#wait_until_completed method is defined only for the Resource snapshot - it looks like you have the snapshot response from a Client call - its confusing and a weakness of the current way we do Resources (the object oriented model for interacting with services).

To use the Resource snapshot you can do something like:

resource = Aws::EC2::Resource.new(region: 'us-west-2')
snapshot = resource.create_snapshot(create_snapshot_opts) # this snapshot will now be an Aws::EC2::Snapshot object and NOT a Aws::EC2::Types::Snapshot
snapshot.wait_until_completed 

# Alternative
snapshot = Aws::EC2::Snapshot.new(id: snapshot_id)
snapshot.wait_until_completed

@sandstrom
Copy link

sandstrom commented Aug 7, 2020

Alright, thanks for explaining!

After reading up on it this is mentioned in the readme/docs, though I must admit it wasn't super-obvious.

Perhaps you can use some method_missing trickery to display a more useful warning message in case the attempted method does not exist on the client call response, but does exist on the equivalent resource. That should be fairly easy to implement across all resources and would go a long way in usability.

Anyway, thanks for helping out @alextwoods! ⭐

@alextwoods
Copy link
Contributor

Yeah - using method_missing is a good idea. I'll add that to our backlog - also happy to accept a PR for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

4 participants