Class: Pvectl::Commands::Get::Handlers::Backups
- Inherits:
-
Object
- Object
- Pvectl::Commands::Get::Handlers::Backups
- Includes:
- ResourceHandler
- Defined in:
- lib/pvectl/commands/get/handlers/backups.rb,
sig/pvectl/commands/get/handlers/backups.rbs
Overview
Handler for listing backups.
Unlike Snapshots handler, Backups allows listing all backups or filtering by optional VMID.
Instance Method Summary collapse
- #build_service ⇒ Object
-
#initialize(service: nil) ⇒ Backups
constructor
A new instance of Backups.
-
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::Backup>
Lists backups with optional VMID filter.
-
#presenter ⇒ Presenters::Backup
Returns presenter for backups.
- #service ⇒ Object
Methods included from ResourceHandler
Constructor Details
#initialize(service: nil) ⇒ Backups
Returns a new instance of Backups.
19 20 21 |
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 19 def initialize(service: nil) @service = service end |
Instance Method Details
#build_service ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 50 def build_service config_service = Pvectl::Config::Service.new config_service.load connection = Pvectl::Connection.new(config_service.current_config) backup_repo = Pvectl::Repositories::Backup.new(connection) resolver = Pvectl::Utils::ResourceResolver.new(connection) task_repo = Pvectl::Repositories::Task.new(connection) Pvectl::Services::Backup.new( backup_repo: backup_repo, resource_resolver: resolver, task_repo: task_repo ) end |
#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::Backup>
Lists backups with optional VMID filter.
30 31 32 33 34 35 |
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 30 def list(node: nil, name: nil, args: [], storage: nil, **) vmid = args.first&.to_i vmid = nil if vmid&.zero? service.list(vmid: vmid, storage: storage) end |
#presenter ⇒ Presenters::Backup
Returns presenter for backups.
40 41 42 |
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 40 def presenter Pvectl::Presenters::Backup.new end |
#service ⇒ Object
46 47 48 |
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 46 def service @service ||= build_service end |