Class: Pvectl::Commands::Get::Handlers::Backups

Inherits:
Object
  • Object
show all
Includes:
ResourceHandler
Defined in:
lib/pvectl/commands/get/handlers/backups.rb

Overview

Handler for listing backups.

Unlike Snapshots handler, Backups allows listing all backups or filtering by optional VMID.

Examples:

Usage

handler.list(node: nil, name: nil, args: [])        # all backups
handler.list(node: nil, name: nil, args: ["100"])   # backups for VM 100

Instance Method Summary collapse

Methods included from ResourceHandler

#selector_class

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

#list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::Backup>

Lists backups with optional VMID filter.

Parameters:

  • node (String, nil) (defaults to: nil)

    ignored (backups can span nodes)

  • name (String, nil) (defaults to: nil)

    ignored

  • args (Array<String>) (defaults to: [])

    optional VMID filter (first arg only)

  • storage (String, nil) (defaults to: nil)

    filter by storage

Returns:



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, **_options)
  vmid = args.first&.to_i
  vmid = nil if vmid&.zero?

  service.list(vmid: vmid, storage: storage)
end

#presenterPresenters::Backup

Returns presenter for backups.

Returns:



40
41
42
# File 'lib/pvectl/commands/get/handlers/backups.rb', line 40

def presenter
  Pvectl::Presenters::Backup.new
end