-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First step for #249 * Listing of all snapshots
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,34 @@ | ||
module Tugboat | ||
module Middleware | ||
# Check if the client has set-up configuration yet. | ||
class ListSnapshots < Base | ||
def call(env) | ||
ocean = env['droplet_kit'] | ||
|
||
verify_credentials(ocean) | ||
|
||
response = ocean.snapshots.all(per_page: env['per_page']) | ||
|
||
has_one = false | ||
|
||
response.each do |snapshot| | ||
has_one = true | ||
|
||
say "#{snapshot.name} (id: #{snapshot.id}, resource_type: #{snapshot.resource_type}, created_at: #{snapshot.created_at})" | ||
end | ||
|
||
unless has_one | ||
say "You don't appear to have any snapshots.", :red | ||
end | ||
|
||
@app.call(env) | ||
end | ||
|
||
private | ||
|
||
def droplet_id_to_url(id) | ||
", url: 'https://cloud.digitalocean.com/droplets/#{id}'" | ||
end | ||
end | ||
end | ||
end |