Class: Cloudinary::AccountApi
- Extended by:
- BaseApi
- Defined in:
- lib/cloudinary/account_api.rb
Class Method Summary collapse
-
.access_keys(sub_account_id, options = {}) ⇒ Object
Lists access keys.
-
.add_user_to_group(group_id, user_id, options = {}) ⇒ Object
Adds a user to a group with the specified ID.
-
.create_sub_account(name, cloud_name = nil, custom_attributes = {}, enabled = nil, base_account = nil, options = {}) ⇒ Object
Creates a new sub-account.
-
.create_user(name, email, role, sub_account_ids = [], options = {}) ⇒ Object
Creates a new user in the account.
-
.create_user_group(name, options = {}) ⇒ Object
Creates a new user group.
-
.delete_access_key(sub_account_id, api_key = nil, name = nil, options = {}) ⇒ Object
Deletes access key.
-
.delete_sub_account(sub_account_id, options = {}) ⇒ Object
Deletes the specified sub-account.
-
.delete_user(user_id, options = {}) ⇒ Object
Deletes an existing user.
-
.delete_user_group(group_id, options = {}) ⇒ Object
Deletes the user group with the specified ID.
-
.generate_access_key(sub_account_id, name = nil, enabled = nil, options = {}) ⇒ Object
Generates access key.
-
.remove_user_from_group(group_id, user_id, options = {}) ⇒ Object
Removes a user from a group with the specified ID.
-
.sub_account(sub_account_id, options = {}) ⇒ Object
Retrieves the details of the specified sub-account.
-
.sub_accounts(enabled = nil, ids = [], prefix = nil, options = {}) ⇒ Object
Lists sub-accounts.
-
.update_access_key(sub_account_id, api_key, name = nil, enabled = nil, options = {}) ⇒ Object
Updates access key.
-
.update_sub_account(sub_account_id, name = nil, cloud_name = nil, custom_attributes = nil, enabled = nil, options = {}) ⇒ Object
Updates the specified details of the sub-account.
-
.update_user(user_id, name = nil, email = nil, role = nil, sub_account_ids = nil, options = {}) ⇒ Object
Updates the details of the specified user.
-
.update_user_group(group_id, name, options = {}) ⇒ Object
Updates the specified user group.
-
.user(user_id, options = {}) ⇒ Object
Returns the user with the specified ID.
-
.user_group(group_id, options = {}) ⇒ Object
Retrieves the details of the specified user group.
-
.user_group_users(group_id, options = {}) ⇒ Object
Lists users in the specified user group.
-
.user_groups(options = {}) ⇒ Object
Lists user groups in the account.
-
.users(pending = nil, user_ids = [], prefix = nil, sub_account_id = nil, options = {}) ⇒ Cloudinary::Api::Response
Get a list of the users according to filters.
Methods included from BaseApi
Class Method Details
.access_keys(sub_account_id, options = {}) ⇒ Object
Lists access keys.
229 230 231 232 |
# File 'lib/cloudinary/account_api.rb', line 229 def self.access_keys(sub_account_id, = {}) params = Cloudinary::Api.only(, :page_size, :page, :sort_by, :sort_order) call_account_api(:get, ['sub_accounts', sub_account_id, 'access_keys'], params, ) end |
.add_user_to_group(group_id, user_id, options = {}) ⇒ Object
Adds a user to a group with the specified ID.
186 187 188 |
# File 'lib/cloudinary/account_api.rb', line 186 def self.add_user_to_group(group_id, user_id, = {}) call_account_api(:post, ['user_groups', group_id, 'users', user_id], {}, .merge(content_type: :json)) end |
.create_sub_account(name, cloud_name = nil, custom_attributes = {}, enabled = nil, base_account = nil, options = {}) ⇒ Object
Creates a new sub-account. Any users that have access to all sub-accounts will also automatically have access to the new sub-account.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cloudinary/account_api.rb', line 14 def self.create_sub_account(name, cloud_name = nil, custom_attributes = {}, enabled = nil, base_account = nil, = {}) params = { name: name, cloud_name: cloud_name, custom_attributes: custom_attributes, enabled: enabled, base_sub_account_id: base_account } call_account_api(:post, 'sub_accounts', params, .merge(content_type: :json)) end |
.create_user(name, email, role, sub_account_ids = [], options = {}) ⇒ Object
Creates a new user in the account.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cloudinary/account_api.rb', line 85 def self.create_user(name, email, role, sub_account_ids = [], = {}) params = { name: name, email: email, role: role, sub_account_ids: sub_account_ids } call_account_api(:post, 'users', params, .merge(content_type: :json)) end |
.create_user_group(name, options = {}) ⇒ Object
Creates a new user group.
162 163 164 165 166 167 168 |
# File 'lib/cloudinary/account_api.rb', line 162 def self.create_user_group(name, = {}) params = { name: name } call_account_api(:post, 'user_groups', params, .merge(content_type: :json)) end |
.delete_access_key(sub_account_id, api_key = nil, name = nil, options = {}) ⇒ Object
Deletes access key.
269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/cloudinary/account_api.rb', line 269 def self.delete_access_key(sub_account_id, api_key = nil, name = nil, = {}) uri = ['sub_accounts', sub_account_id, 'access_keys'] unless api_key.blank? uri.append(api_key) end params = { name: name, } call_account_api(:delete, uri, params, .merge(content_type: :json)) end |
.delete_sub_account(sub_account_id, options = {}) ⇒ Object
Deletes the specified sub-account. Supported only for accounts with fewer than 1000 assets.
73 74 75 |
# File 'lib/cloudinary/account_api.rb', line 73 def self.delete_sub_account(sub_account_id, = {}) call_account_api(:delete, ['sub_accounts', sub_account_id], {}, ) end |
.delete_user(user_id, options = {}) ⇒ Object
Deletes an existing user.
99 100 101 |
# File 'lib/cloudinary/account_api.rb', line 99 def self.delete_user(user_id, = {}) call_account_api(:delete, ['users', user_id], {}, ) end |
.delete_user_group(group_id, options = {}) ⇒ Object
Deletes the user group with the specified ID.
201 202 203 |
# File 'lib/cloudinary/account_api.rb', line 201 def self.delete_user_group(group_id, = {}) call_account_api(:delete, ['user_groups', group_id], {}, ) end |
.generate_access_key(sub_account_id, name = nil, enabled = nil, options = {}) ⇒ Object
Generates access key.
240 241 242 243 244 245 246 |
# File 'lib/cloudinary/account_api.rb', line 240 def self.generate_access_key(sub_account_id, name = nil, enabled = nil, = {}) params = { name: name, enabled: enabled, } call_account_api(:post, ['sub_accounts', sub_account_id, 'access_keys'], params, .merge(content_type: :json)) end |
.remove_user_from_group(group_id, user_id, options = {}) ⇒ Object
Removes a user from a group with the specified ID.
194 195 196 |
# File 'lib/cloudinary/account_api.rb', line 194 def self.remove_user_from_group(group_id, user_id, = {}) call_account_api(:delete, ['user_groups', group_id, 'users', user_id], {}, .merge(content_type: :json)) end |
.sub_account(sub_account_id, options = {}) ⇒ Object
Retrieves the details of the specified sub-account.
66 67 68 |
# File 'lib/cloudinary/account_api.rb', line 66 def self.sub_account(sub_account_id, = {}) call_account_api(:get, ['sub_accounts', sub_account_id], {}, .merge(content_type: :json)) end |
.sub_accounts(enabled = nil, ids = [], prefix = nil, options = {}) ⇒ Object
Lists sub-accounts.
53 54 55 56 57 58 59 60 61 |
# File 'lib/cloudinary/account_api.rb', line 53 def self.sub_accounts(enabled = nil, ids = [], prefix = nil, = {}) params = { enabled: enabled, ids: ids, prefix: prefix } call_account_api(:get, 'sub_accounts', params, .merge(content_type: :json)) end |
.update_access_key(sub_account_id, api_key, name = nil, enabled = nil, options = {}) ⇒ Object
Updates access key.
255 256 257 258 259 260 261 |
# File 'lib/cloudinary/account_api.rb', line 255 def self.update_access_key(sub_account_id, api_key, name = nil, enabled = nil, = {}) params = { name: name, enabled: enabled, } call_account_api(:put, ['sub_accounts', sub_account_id, 'access_keys', api_key], params, .merge(content_type: :json)) end |
.update_sub_account(sub_account_id, name = nil, cloud_name = nil, custom_attributes = nil, enabled = nil, options = {}) ⇒ Object
Updates the specified details of the sub-account.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cloudinary/account_api.rb', line 36 def self.update_sub_account(sub_account_id, name = nil, cloud_name = nil, custom_attributes = nil, enabled = nil, = {}) params = { name: name, cloud_name: cloud_name, custom_attributes: custom_attributes, enabled: enabled } call_account_api(:put, ['sub_accounts', sub_account_id], params, .merge(content_type: :json)) end |
.update_user(user_id, name = nil, email = nil, role = nil, sub_account_ids = nil, options = {}) ⇒ Object
Updates the details of the specified user.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/cloudinary/account_api.rb', line 112 def self.update_user(user_id, name = nil, email = nil, role = nil, sub_account_ids = nil, = {}) params = { name: name, email: email, role: role, sub_account_ids: sub_account_ids } call_account_api(:put, ['users', user_id], params, .merge(content_type: :json)) end |
.update_user_group(group_id, name, options = {}) ⇒ Object
Updates the specified user group.
174 175 176 177 178 179 180 |
# File 'lib/cloudinary/account_api.rb', line 174 def self.update_user_group(group_id, name, = {}) params = { name: name } call_account_api(:put, ['user_groups', group_id], params, .merge(content_type: :json)) end |
.user(user_id, options = {}) ⇒ Object
Returns the user with the specified ID.
126 127 128 |
# File 'lib/cloudinary/account_api.rb', line 126 def self.user(user_id, = {}) call_account_api(:get, ['users', user_id], {}, .merge(content_type: :json)) end |
.user_group(group_id, options = {}) ⇒ Object
Retrieves the details of the specified user group.
214 215 216 |
# File 'lib/cloudinary/account_api.rb', line 214 def self.user_group(group_id, = {}) call_account_api(:get, ['user_groups', group_id], {}, .merge(content_type: :json)) end |
.user_group_users(group_id, options = {}) ⇒ Object
Lists users in the specified user group.
221 222 223 |
# File 'lib/cloudinary/account_api.rb', line 221 def self.user_group_users(group_id, = {}) call_account_api(:get, ['user_groups', group_id, 'users'], {}, .merge(content_type: :json)) end |
.user_groups(options = {}) ⇒ Object
Lists user groups in the account.
207 208 209 |
# File 'lib/cloudinary/account_api.rb', line 207 def self.user_groups( = {}) call_account_api(:get, 'user_groups', {}, .merge(content_type: :json)) end |
.users(pending = nil, user_ids = [], prefix = nil, sub_account_id = nil, options = {}) ⇒ Cloudinary::Api::Response
Get a list of the users according to filters.
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/cloudinary/account_api.rb', line 145 def self.users(pending = nil, user_ids = [], prefix = nil, sub_account_id = nil, = {}) params = { ids: user_ids, prefix: prefix, sub_account_id: sub_account_id, pending: pending, last_login: [:last_login].to_s, from: Cloudinary::Utils.to_usage_api_date_format([:from]), to: Cloudinary::Utils.to_usage_api_date_format([:to]) } call_account_api(:get, 'users', params, .merge(content_type: :json)) end |