Class: Gleis::Sharing

Inherits:
Object
  • Object
show all
Defined in:
lib/gleis/sharing.rb

Overview

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

Class Method Summary collapse

Class Method Details

.add(app_name, email, role) ⇒ Object



4
5
6
7
8
9
10
11
12
# 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) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# 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) ⇒ Object



28
29
30
31
32
33
34
35
36
# 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