Sha256: 83c2bc557b8a5eedf693c29a9fc80db23481c75b3d47d9a5ad72d457763e7873

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require_relative 'ionoscloud_base'

class Chef
  class Knife
    class IonoscloudBackupunitList < Knife
      include Knife::IonoscloudBase

      banner 'knife ionoscloud backupunit list'

      def initialize(args = [])
        super(args)
        @description =
        'Retrieve a list of all the backup units the supplied credentials have access to.'
        @directory = 'backup'
        @required_options = [:ionoscloud_username, :ionoscloud_password]
      end

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

        backupunit_list = [
          ui.color('ID', :bold),
          ui.color('Name', :bold),
          ui.color('Email', :bold),
        ]

        backupunit_api = Ionoscloud::BackupUnitsApi.new(api_client)

        backupunit_api.backupunits_get({ depth: 1 }).items.each do |backupunit|
          backupunit_list << backupunit.id
          backupunit_list << backupunit.properties.name
          backupunit_list << backupunit.properties.email
        end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
knife-ionoscloud-6.1.1 lib/chef/knife/ionoscloud_backupunit_list.rb
knife-ionoscloud-6.1.0 lib/chef/knife/ionoscloud_backupunit_list.rb