Class: Pvectl::Commands::Get::Handlers::Subscription

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

Overview

Handler for ‘pvectl get subscription`.

Aggregates subscription records across cluster nodes via Repositories::Subscription. Supports filtering to a single node with ‘–node`.

Instance Method Summary collapse

Methods included from ResourceHandler

#selector_class

Constructor Details

#initialize(repository: nil) ⇒ Subscription

Returns a new instance of Subscription.

Parameters:



20
21
22
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 20

def initialize(repository: nil)
  @repository = repository
end

Instance Method Details

#describe(name:, node: nil, args: [], vmid: nil) ⇒ Models::Subscription

Parameters:

  • name (String)

    node name to describe

Returns:

Raises:



38
39
40
41
42
43
44
45
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 38

def describe(name:, node: nil, args: [], vmid: nil)
  raise ArgumentError, "Invalid node name" if name.nil? || name.empty?

  record = repository.get(name)
  raise Pvectl::ResourceNotFoundError, "Subscription not found for node: #{name}" if record.nil?

  record
end

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

Parameters:

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

    limit to a single node

Returns:



26
27
28
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 26

def list(node: nil, name: nil, args: [], storage: nil, **_options)
  repository.list(node: node)
end

#presenterPresenters::Subscription



31
32
33
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 31

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