Module: Cyclid::Client::Organization
- Included in:
- Tilapia
- Defined in:
- lib/cyclid/client/organization.rb
Overview
Organization related methods
Instance Method Summary collapse
-
#org_add(name, email) ⇒ Hash
Create a new organization.
-
#org_config_get(name, type, plugin) ⇒ Hash
Get a plugin configuration for an organization.
-
#org_config_set(name, type, plugin, config) ⇒ Hash
Update a plugin configuration for an organization.
-
#org_delete(name) ⇒ Hash
Delete an organization.
-
#org_get(name) ⇒ Hash
Get details of a specific organization.
-
#org_list ⇒ Array
Retrieve the list of organizations from a server.
-
#org_modify(name, args) ⇒ Hash
Modify an organization.
-
#org_user_get(name, username) ⇒ Hash
Get details of an organization member.
-
#org_user_permissions(name, username, permissions) ⇒ Hash
Modify the permissions for an organization member.
Instance Method Details
#org_add(name, email) ⇒ Hash
Create a new organization. The organization is created without any members; use org_modify to add a set of users to the organization after it has been created.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/cyclid/client/organization.rb', line 57 def org_add(name, email) # Create the organization object org = { 'name' => name, 'owner_email' => email } @logger.debug org # Sign & send the request uri = server_uri('/organizations') res_data = api_json_post(uri, org) @logger.debug res_data return res_data end |
#org_config_get(name, type, plugin) ⇒ Hash
Get a plugin configuration for an organization. organization
org_config_get('example', 'api', 'foo')
151 152 153 154 155 156 157 |
# File 'lib/cyclid/client/organization.rb', line 151 def org_config_get(name, type, plugin) uri = server_uri("/organizations/#{name}/configs/#{type}/#{plugin}") res_data = api_get(uri) @logger.debug res_data return res_data end |
#org_config_set(name, type, plugin, config) ⇒ Hash
Update a plugin configuration for an organization.
166 167 168 169 170 171 172 |
# File 'lib/cyclid/client/organization.rb', line 166 def org_config_set(name, type, plugin, config) uri = server_uri("/organizations/#{name}/configs/#{type}/#{plugin}") res_data = api_json_put(uri, config) @logger.debug res_data return res_data end |
#org_delete(name) ⇒ Hash
The API does not currently support deleting an organization and this method will always fail.
Delete an organization
180 181 182 183 184 185 186 |
# File 'lib/cyclid/client/organization.rb', line 180 def org_delete(name) uri = server_uri("/organizations/#{name}") res_data = api_delete(uri) @logger.debug res_data return res_data end |
#org_get(name) ⇒ Hash
Get details of a specific organization
39 40 41 42 43 44 45 |
# File 'lib/cyclid/client/organization.rb', line 39 def org_get(name) uri = server_uri("/organizations/#{name}") res_data = api_get(uri) @logger.debug res_data return res_data end |
#org_list ⇒ Array
Retrieve the list of organizations from a server
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cyclid/client/organization.rb', line 23 def org_list uri = server_uri('/organizations') res_data = api_get(uri) @logger.debug res_data orgs = [] res_data.each do |item| orgs << item['name'] end return orgs end |
#org_modify(name, args) ⇒ Hash
Setting the organization members will overwrite the existing set; you should ensure the set of members is complete before you set it.
Modify an organization. Only the owner email address and organization members can be changed; you can not change the name of an organization once it has been created.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cyclid/client/organization.rb', line 83 def org_modify(name, args) # Create the organization object org = {} # Add the owner email address if one was supplied org['owner_email'] = args[:owner_email] \ if args.key? :owner_email and args[:owner_email] # Add the list of members if it was supplied org['users'] = args[:members] \ if args.key? :members and args[:members] @logger.debug org # Sign & send the request uri = server_uri("/organizations/#{name}") res_data = api_json_put(uri, org) @logger.debug res_data return res_data end |
#org_user_get(name, username) ⇒ Hash
Get details of an organization member
110 111 112 113 114 115 116 |
# File 'lib/cyclid/client/organization.rb', line 110 def org_user_get(name, username) uri = server_uri("/organizations/#{name}/members/#{username}") res_data = api_get(uri) @logger.debug res_data return res_data end |
#org_user_permissions(name, username, permissions) ⇒ Hash
Modify the permissions for an organization member
130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/cyclid/client/organization.rb', line 130 def (name, username, ) perms = { 'permissions' => } @logger.debug perms uri = server_uri("/organizations/#{name}/members/#{username}") res_data = api_json_put(uri, perms) @logger.debug res_data return res_data end |