Class: Bl::Groups

Inherits:
Command show all
Defined in:
lib/bl/groups.rb

Constant Summary

Constants inherited from Command

Command::ACTIVITY_TYPES, Command::CATEGORY_FIELDS, Command::FILE_FIELDS, Command::GIT_REPO_FIELDS, Command::ISSUES_PARAMS, Command::ISSUE_BASE_ATTRIBUTES, Command::ISSUE_FIELDS, Command::MILESTONE_FIELDS, Command::MILESTONE_PARAMS, Command::PROJECT_FIELDS, Command::PROJECT_PARAMS, Command::ROLES, Command::SPACE_DISK_USAGE, Command::SPACE_DISK_USAGE_DETAILS_FIELDS, Command::SPACE_FIELDS, Command::SPACE_NOTIFICATION_FIELDS, Command::TYPE_COLORS, Command::USER_FIELDS, Command::USER_PARAMS, Command::WATCHINGS_PARAMS, Command::WEBHOOK_FIELDS, Command::WEBHOOK_PARAMS, Command::WIKI_FIELDS

Instance Method Summary collapse

Methods included from Formatting

colorize_priority, colorize_status, colorize_type

Methods included from Requestable

client, formatter

Constructor Details

#initializeGroups

Returns a new instance of Groups.



4
5
6
7
8
# File 'lib/bl/groups.rb', line 4

def initialize(*)
  @config = Bl::Config.instance
  @url = 'groups'
  super
end

Instance Method Details

#add(name) ⇒ Object



25
26
27
28
29
# File 'lib/bl/groups.rb', line 25

def add(name)
  res = client.post(@url, {name: name}.merge(delete_class_options(options)))
  puts 'group added'
  print_group_and_members(res.body)
end

#delete(id) ⇒ Object



40
41
42
43
44
# File 'lib/bl/groups.rb', line 40

def delete(id)
  res = client.delete("#{@url}/#{id}")
  puts 'group deleted'
  print_group_and_members(res.body)
end

#listObject



12
13
14
15
# File 'lib/bl/groups.rb', line 12

def list
  res = client.get(@url, options.to_h)
  puts formatter.render(res.body, fields: %i(id name))
end

#show(id) ⇒ Object



18
19
20
21
# File 'lib/bl/groups.rb', line 18

def show(id)
  res = client.get("#{@url}/#{id}")
  puts formatter.render(res.body.members, fields: USER_FIELDS)
end

#update(id) ⇒ Object



33
34
35
36
37
# File 'lib/bl/groups.rb', line 33

def update(id)
  res = client.patch("#{@url}/#{id}", delete_class_options(options.to_h))
  puts 'group updated'
  print_group_and_members(res.body)
end