Class: Files::ApiKey
- Inherits:
-
Object
- Object
- Files::ApiKey
- Defined in:
- lib/files.com/models/api_key.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
- .delete(id, params = {}, options = {}) ⇒ Object
-
.delete_current(params = {}, options = {}) ⇒ Object
Parameters: format - string api_key - object.
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Api Key ID.
-
.find_current(params = {}, options = {}) ⇒ Object
Parameters: format - string api_key - object.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: name - string - Internal name for the API Key.
-
.update_current(params = {}, options = {}) ⇒ Object
Parameters: expires_at - string - API Key expiration date name - string - Internal name for the API Key.
Instance Method Summary collapse
-
#created_at ⇒ Object
date-time - Time which API Key was created.
- #delete(params = {}) ⇒ Object
-
#descriptive_label ⇒ Object
string - Unique label that describes this API key.
- #descriptive_label=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#expires_at ⇒ Object
date-time - API Key expiration date.
- #expires_at=(value) ⇒ Object
-
#id ⇒ Object
int64 - API Key ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ ApiKey
constructor
A new instance of ApiKey.
-
#key ⇒ Object
string - API Key actual key string.
- #key=(value) ⇒ Object
-
#last_use_at ⇒ Object
date-time - API Key last used - note this value is only updated once per 3 hour period, so the ‘actual’ time of last use may be up to 3 hours later than this timestamp.
- #last_use_at=(value) ⇒ Object
-
#name ⇒ Object
string - Internal name for the API Key.
- #name=(value) ⇒ Object
-
#path ⇒ Object
string - Folder path restriction for this api key.
- #path=(value) ⇒ Object
-
#permission_set ⇒ Object
string - Permissions for this API Key.
- #permission_set=(value) ⇒ Object
-
#platform ⇒ Object
string - If this API key represents a Desktop app, what platform was it created on?.
- #platform=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: name - string - Internal name for the API Key.
-
#user_id ⇒ Object
int64 - User ID for the owner of this API Key.
- #user_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ ApiKey
Returns a new instance of ApiKey.
7 8 9 10 |
# File 'lib/files.com/models/api_key.rb', line 7 def initialize(attributes = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/api_key.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/api_key.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
179 180 181 |
# File 'lib/files.com/models/api_key.rb', line 179 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
name - string - Internal name for the API Key. For your use.
expires_at - string - API Key expiration date
permission_set - string - Permissions for this API Key. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
path - string - Folder path restriction for this api key.
216 217 218 219 220 221 222 223 224 225 |
# File 'lib/files.com/models/api_key.rb', line 216 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String) raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String) raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) response, = Api.send_request("/api_keys", :post, params, ) ApiKey.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
268 269 270 271 272 273 274 275 276 |
# File 'lib/files.com/models/api_key.rb', line 268 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/api_keys/#{params[:id]}", :delete, params, ) response.data end |
.delete_current(params = {}, options = {}) ⇒ Object
Parameters:
format - string
api_key - object
260 261 262 263 264 265 266 |
# File 'lib/files.com/models/api_key.rb', line 260 def self.delete_current(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: format must be an String") if params.dig(:format) and !params.dig(:format).is_a?(String) raise InvalidParameterError.new("Bad parameter: api_key must be an Hash") if params.dig(:api_key) and !params.dig(:api_key).is_a?(Hash) response, = Api.send_request("/api_key", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
278 279 280 |
# File 'lib/files.com/models/api_key.rb', line 278 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Api Key ID.
196 197 198 199 200 201 202 203 204 |
# File 'lib/files.com/models/api_key.rb', line 196 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/api_keys/#{params[:id]}", :get, params, ) ApiKey.new(response.data, ) end |
.find_current(params = {}, options = {}) ⇒ Object
Parameters:
format - string
api_key - object
186 187 188 189 190 191 192 |
# File 'lib/files.com/models/api_key.rb', line 186 def self.find_current(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: format must be an String") if params.dig(:format) and !params.dig(:format).is_a?(String) raise InvalidParameterError.new("Bad parameter: api_key must be an Hash") if params.dig(:api_key) and !params.dig(:api_key).is_a?(Hash) response, = Api.send_request("/api_key", :get, params, ) ApiKey.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
206 207 208 |
# File 'lib/files.com/models/api_key.rb', line 206 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
page - int64 - Current page number.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
cursor - string - Send cursor to resume an existing list from the point at which you left off. Get a cursor from an existing list via the X-Files-Cursor-Next header.
sort_by - object - If set, sort records by the specified field in either 'asc' or 'desc' direction (e.g. sort_by[last_login_at]=desc). Valid fields are `deleted_at` and `expires_at`.
filter - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `expires_at`.
filter_gt - object - If set, return records where the specifiied field is greater than the supplied value. Valid fields are `expires_at`.
filter_gteq - object - If set, return records where the specifiied field is greater than or equal to the supplied value. Valid fields are `expires_at`.
filter_like - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `expires_at`.
filter_lt - object - If set, return records where the specifiied field is less than the supplied value. Valid fields are `expires_at`.
filter_lteq - object - If set, return records where the specifiied field is less than or equal to the supplied value. Valid fields are `expires_at`.
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/files.com/models/api_key.rb', line 160 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params.dig(:sort_by) and !params.dig(:sort_by).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params.dig(:filter) and !params.dig(:filter).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params.dig(:filter_gt) and !params.dig(:filter_gt).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params.dig(:filter_gteq) and !params.dig(:filter_gteq).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_like must be an Hash") if params.dig(:filter_like) and !params.dig(:filter_like).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params.dig(:filter_lt) and !params.dig(:filter_lt).is_a?(Hash) raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params.dig(:filter_lteq) and !params.dig(:filter_lteq).is_a?(Hash) List.new(ApiKey, params) do Api.send_request("/api_keys", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
name - string - Internal name for the API Key. For your use.
expires_at - string - API Key expiration date
permission_set - string - Permissions for this API Key. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/files.com/models/api_key.rb', line 244 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String) raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/api_keys/#{params[:id]}", :patch, params, ) ApiKey.new(response.data, ) end |
.update_current(params = {}, options = {}) ⇒ Object
Parameters:
expires_at - string - API Key expiration date
name - string - Internal name for the API Key. For your use.
permission_set - string - Permissions for this API Key. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
231 232 233 234 235 236 237 238 |
# File 'lib/files.com/models/api_key.rb', line 231 def self.update_current(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String) response, = Api.send_request("/api_key", :patch, params, ) ApiKey.new(response.data, ) end |
Instance Method Details
#created_at ⇒ Object
date-time - Time which API Key was created
31 32 33 |
# File 'lib/files.com/models/api_key.rb', line 31 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/files.com/models/api_key.rb', line 124 def delete(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/api_keys/#{@attributes[:id]}", :delete, params, @options) end |
#descriptive_label ⇒ Object
string - Unique label that describes this API key. Useful for external systems where you may have API keys from multiple accounts and want a human-readable label for each key.
22 23 24 |
# File 'lib/files.com/models/api_key.rb', line 22 def descriptive_label @attributes[:descriptive_label] end |
#descriptive_label=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/api_key.rb', line 26 def descriptive_label=(value) @attributes[:descriptive_label] = value end |
#destroy(params = {}) ⇒ Object
134 135 136 |
# File 'lib/files.com/models/api_key.rb', line 134 def destroy(params = {}) delete(params) end |
#expires_at ⇒ Object
date-time - API Key expiration date
36 37 38 |
# File 'lib/files.com/models/api_key.rb', line 36 def expires_at @attributes[:expires_at] end |
#expires_at=(value) ⇒ Object
40 41 42 |
# File 'lib/files.com/models/api_key.rb', line 40 def expires_at=(value) @attributes[:expires_at] = value end |
#id ⇒ Object
int64 - API Key ID
13 14 15 |
# File 'lib/files.com/models/api_key.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/api_key.rb', line 17 def id=(value) @attributes[:id] = value end |
#key ⇒ Object
string - API Key actual key string
45 46 47 |
# File 'lib/files.com/models/api_key.rb', line 45 def key @attributes[:key] end |
#key=(value) ⇒ Object
49 50 51 |
# File 'lib/files.com/models/api_key.rb', line 49 def key=(value) @attributes[:key] = value end |
#last_use_at ⇒ Object
date-time - API Key last used - note this value is only updated once per 3 hour period, so the ‘actual’ time of last use may be up to 3 hours later than this timestamp.
54 55 56 |
# File 'lib/files.com/models/api_key.rb', line 54 def last_use_at @attributes[:last_use_at] end |
#last_use_at=(value) ⇒ Object
58 59 60 |
# File 'lib/files.com/models/api_key.rb', line 58 def last_use_at=(value) @attributes[:last_use_at] = value end |
#name ⇒ Object
string - Internal name for the API Key. For your use.
63 64 65 |
# File 'lib/files.com/models/api_key.rb', line 63 def name @attributes[:name] end |
#name=(value) ⇒ Object
67 68 69 |
# File 'lib/files.com/models/api_key.rb', line 67 def name=(value) @attributes[:name] = value end |
#path ⇒ Object
string - Folder path restriction for this api key. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
72 73 74 |
# File 'lib/files.com/models/api_key.rb', line 72 def path @attributes[:path] end |
#path=(value) ⇒ Object
76 77 78 |
# File 'lib/files.com/models/api_key.rb', line 76 def path=(value) @attributes[:path] = value end |
#permission_set ⇒ Object
string - Permissions for this API Key. Keys with the ‘desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
81 82 83 |
# File 'lib/files.com/models/api_key.rb', line 81 def @attributes[:permission_set] end |
#permission_set=(value) ⇒ Object
85 86 87 |
# File 'lib/files.com/models/api_key.rb', line 85 def (value) @attributes[:permission_set] = value end |
#platform ⇒ Object
string - If this API key represents a Desktop app, what platform was it created on?
90 91 92 |
# File 'lib/files.com/models/api_key.rb', line 90 def platform @attributes[:platform] end |
#platform=(value) ⇒ Object
94 95 96 |
# File 'lib/files.com/models/api_key.rb', line 94 def platform=(value) @attributes[:platform] = value end |
#save ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/files.com/models/api_key.rb', line 138 def save if @attributes[:id] update(@attributes) else new_obj = ApiKey.create(@attributes, @options) @attributes = new_obj.attributes end end |
#update(params = {}) ⇒ Object
Parameters:
name - string - Internal name for the API Key. For your use.
expires_at - string - API Key expiration date
permission_set - string - Permissions for this API Key. Keys with the `desktop_app` permission set only have the ability to do the functions provided in our Desktop App (File and Share Link operations). Additional permission sets may become available in the future, such as for a Site Admin to give a key with no administrator privileges. If you have ideas for permission sets, please let us know.
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/files.com/models/api_key.rb', line 111 def update(params = {}) params ||= {} params[:id] = @attributes[:id] raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id] raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String) raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String) raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/api_keys/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID for the owner of this API Key. May be blank for Site-wide API Keys.
99 100 101 |
# File 'lib/files.com/models/api_key.rb', line 99 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
103 104 105 |
# File 'lib/files.com/models/api_key.rb', line 103 def user_id=(value) @attributes[:user_id] = value end |