Sha256: f923a7e8ba51e95b7553f7444e59a669fc3743eb3a88ca67f988911411f1d669

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require_relative 'ionoscloud_base'

class Chef
  class Knife
    class IonoscloudPccList < Knife
      include Knife::IonoscloudBase

      banner 'knife ionoscloud pcc list'

      attr_reader :description, :required_options

      def initialize(args = [])
        super(args)
        @description =
        'Lists all Private Cross-Connect instances.'
        @required_options = [:ionoscloud_username, :ionoscloud_password]
      end

      def run
        $stdout.sync = true
        handle_extra_config
        validate_required_params(@required_options, config)

        pcc_list = [
          ui.color('ID', :bold),
          ui.color('Name', :bold),
          ui.color('Description', :bold),
        ]

        pcc_api = Ionoscloud::PrivateCrossConnectsApi.new(api_client)

        pcc_api.pccs_get({ depth: 1 }).items.each do |pcc|
          pcc_list << pcc.id
          pcc_list << pcc.properties.name
          pcc_list << pcc.properties.description || ''
        end

        puts ui.list(pcc_list, :uneven_columns_across, 3)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
knife-ionoscloud-6.0.0 lib/chef/knife/ionoscloud_pcc_list.rb
knife-ionoscloud-6.0.0.beta.2 lib/chef/knife/ionoscloud_pcc_list.rb
knife-ionoscloud-6.0.0.beta.1 lib/chef/knife/ionoscloud_pcc_list.rb