class Gleis::Sharing

The class implements the methods required for collaborating on a gleis app

Public Class Methods

add(app_name, email, role) click to toggle source
# File lib/gleis/sharing.rb, line 4
def self.add(app_name, email, role)
  token = Token.check
  body = API.request('post', 'sharing', token, 'name': app_name, 'email': email, 'role': role)
  if body['success'] == 1
    puts "Successfully added user to access list for #{app_name}."
  else
    puts "Failed to add user to access list: #{body['message']}"
  end
end
list(app_name) click to toggle source
# File lib/gleis/sharing.rb, line 14
def self.list(app_name)
  token = Token.check
  body = API.request('get', "sharing/#{app_name}", token)
  acls = body ['acl']
  if acls.any?
    puts "Access list for #{app_name}:\n\n"
    acls.each do |acl|
      printf("\t%-45s %s\n", acl['user_name'], acl['role_name'])
    end
  else
    puts 'No access list defined yet.'
  end
end
remove(app_name, email) click to toggle source
# File lib/gleis/sharing.rb, line 28
def self.remove(app_name, email)
  token = Token.check
  body = API.request('delete', "sharing/#{app_name}/#{email}", token)
  if body['success'] == 1
    puts "Successfully removed user from access list for #{app_name}."
  else
    puts "Failed to remove user from access list: #{body['message']}"
  end
end