Class: Kontena::Plugin::Cloud::Organization::User::AddCommand

Inherits:
Command
  • Object
show all
Includes:
Cli::Common
Defined in:
lib/kontena/plugin/cloud/organization/user/add_command.rb

Constant Summary

Constants included from CloudCommand

CloudCommand::PLATFORM_NOT_SELECTED_ERROR

Instance Method Summary collapse

Methods included from CloudCommand

#verify_current_grid, #verify_current_master, #verify_current_master_token

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kontena/plugin/cloud/organization/user/add_command.rb', line 11

def execute
  members = []
  username_list.each do |u|
    members << {
      type: 'users',
      id: u,
      meta: { role: role }
    }
  end
  spinner "Adding #{pastel.cyan(username_list.join(', '))} to organization #{pastel.cyan(name)} with role #{pastel.cyan(role)}" do
    data = {data: members}
    cloud_client.post("/organizations/#{name}/relationships/members", data)
  end
end