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.
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cyclid/client/organization.rb', line 55 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')
149 150 151 152 153 154 155 |
# File 'lib/cyclid/client/organization.rb', line 149 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.
164 165 166 167 168 169 170 |
# File 'lib/cyclid/client/organization.rb', line 164 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
178 179 180 181 182 183 184 |
# File 'lib/cyclid/client/organization.rb', line 178 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
37 38 39 40 41 42 43 |
# File 'lib/cyclid/client/organization.rb', line 37 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
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cyclid/client/organization.rb', line 21 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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/cyclid/client/organization.rb', line 81 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
108 109 110 111 112 113 114 |
# File 'lib/cyclid/client/organization.rb', line 108 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
128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cyclid/client/organization.rb', line 128 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 |