Class: Pvectl::Commands::Get::Handlers::Subscription
- Inherits:
-
Object
- Object
- Pvectl::Commands::Get::Handlers::Subscription
- Includes:
- ResourceHandler
- Defined in:
- lib/pvectl/commands/get/handlers/subscription.rb,
sig/pvectl/commands/get/handlers/subscription.rbs
Overview
Handler for pvectl get subscription.
Aggregates subscription records across cluster nodes via
Repositories::Subscription. Supports filtering to a single node
with --node.
Instance Attribute Summary collapse
-
#repository ⇒ Repositories::Subscription
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #build_repository ⇒ Repositories::Subscription
- #describe(name:, node: nil, args: [], vmid: nil) ⇒ Models::Subscription
-
#initialize(repository: nil) ⇒ Subscription
constructor
A new instance of Subscription.
- #list(node: nil, name: nil, args: [], storage: nil, **_options) ⇒ Array<Models::Subscription>
- #presenter ⇒ Presenters::Subscription
Methods included from ResourceHandler
Constructor Details
#initialize(repository: nil) ⇒ Subscription
Returns a new instance of Subscription.
20 21 22 |
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 20 def initialize(repository: nil) @repository = repository end |
Instance Attribute Details
#repository ⇒ Repositories::Subscription (readonly)
Returns the value of attribute repository.
49 50 51 |
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 49 def repository @repository ||= build_repository end |
Instance Method Details
#build_repository ⇒ Repositories::Subscription
53 54 55 56 57 58 |
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 53 def build_repository config_service = Pvectl::Config::Service.new config_service.load connection = Pvectl::Connection.new(config_service.current_config) Pvectl::Repositories::Subscription.new(connection) end |
#describe(name:, node: nil, args: [], vmid: nil) ⇒ Models::Subscription
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>
26 27 28 |
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 26 def list(node: nil, name: nil, args: [], storage: nil, **) repository.list(node: node) end |
#presenter ⇒ Presenters::Subscription
31 32 33 |
# File 'lib/pvectl/commands/get/handlers/subscription.rb', line 31 def presenter Pvectl::Presenters::Subscription.new end |