Class: NexusAPI::List

Inherits:
Thor
  • Object
show all
Includes:
CLIUtils
Defined in:
lib/nexus_api/cli_commands/list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CLIUtils

#if_file_exists?, #print_element, #print_paginating_set, #print_set, #repository_set?, #set, #setup

Instance Attribute Details

#apiObject

Returns the value of attribute api.



3
4
5
# File 'lib/nexus_api/cli_commands/list.rb', line 3

def api
  @api
end

Instance Method Details

#assetObject



10
11
12
# File 'lib/nexus_api/cli_commands/list.rb', line 10

def asset
  print_element(action: :list_asset, params: {id: options[:id]}, filter: 'path')
end

#asset_sizeObject



16
17
18
19
# File 'lib/nexus_api/cli_commands/list.rb', line 16

def asset_size
  setup
  puts @api.get_asset_size(asset_url: options[:url])
end

#assetsObject



23
24
25
26
# File 'lib/nexus_api/cli_commands/list.rb', line 23

def assets
  return false unless repository_set?
  print_paginating_set(action: :list_assets, params: {repository: options[:repository]}, filter: 'path')
end

#componentObject



30
31
32
# File 'lib/nexus_api/cli_commands/list.rb', line 30

def component
  print_element(action: :list_component, params: {id: options[:id]}, filter: 'name')
end

#componentsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/nexus_api/cli_commands/list.rb', line 37

def components
  return false unless repository_set?
  proc = Proc.new do |components|
    components.map do |component|
      version = component['version'].nil? ? 'version is nil' : component['version']
      line = "#{component['name']} (#{version})\n"
      if options[:assets]
        component['assets'].each do |asset|
          line += "  #{asset['path']}\n"
        end
      end
      line
    end
  end
  print_paginating_set(action: :list_components, params: {repository: options[:repository]}, filter: 'name', proc: proc)
end

#privilegesObject



55
56
57
# File 'lib/nexus_api/cli_commands/list.rb', line 55

def privileges
  print_set(action: :list_privileges, filter: 'name')
end

#repositoriesObject



60
61
62
# File 'lib/nexus_api/cli_commands/list.rb', line 60

def repositories
  print_set(action: :list_repositories, filter: 'name')
end

#rolesObject



65
66
67
# File 'lib/nexus_api/cli_commands/list.rb', line 65

def roles
  print_set(action: :list_roles, filter: 'name')
end

#statusObject



70
71
72
73
74
# File 'lib/nexus_api/cli_commands/list.rb', line 70

def status
  setup
  puts "Nexus can respond to read requests:  #{@api.status}"
  puts "Nexus can respond to write requests: #{@api.status_writable}"
end

#usersObject



77
78
79
# File 'lib/nexus_api/cli_commands/list.rb', line 77

def users
  print_set(action: :list_users, filter: 'emailAddress')
end