Class: Files::ApiKey

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/api_key.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/api_key.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/api_key.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



257
258
259
# File 'lib/files.com/models/api_key.rb', line 257

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
description - string - User-supplied description of API key.
expires_at - string - API Key expiration date
name (required) - string - Internal name for the API Key.  For your use.
pairing_key - string - The pairing key to use
platform - string
aws_style_credentials - boolean - If `true`, this API key will be usable with AWS-compatible endpoints, such as our Inbound S3-compatible endpoint.
path - string - Folder path restriction for `office_integration` permission set API keys.
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). Keys with the `office_integration` permission set are auto generated, and automatically expire, to allow users to interact with office integration platforms. Keys with the `files_only` permission set can perform file operations as a full-access file user in the key's workspace scope, but cannot use site admin, workspace admin, folder admin, group admin, partner admin, or billing privileges from the owning user.
workspace_id - int64 - Workspace ID for this API Key. `0` means the default workspace.


293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/files.com/models/api_key.rb', line 293

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params[:expires_at] and !params[:expires_at].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: pairing_key must be an String") if params[:pairing_key] and !params[:pairing_key].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: platform must be an String") if params[:platform] and !params[:platform].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params[:permission_set] and !params[:permission_set].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: workspace_id must be an Integer") if params[:workspace_id] and !params[:workspace_id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: name") unless params[:name]

  response, options = Api.send_request("/api_keys", :post, params, options)
  ApiKey.new(response.data, options)
end

.create_export(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `site_id` and `workspace_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `aws_style_credentials` and `expires_at`.
filter_gt - object - If set, return records where the specified field is greater than the supplied value. Valid fields are `expires_at`.
filter_gteq - object - If set, return records where the specified field is greater than or equal the supplied value. Valid fields are `expires_at`.
filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `expires_at`.
filter_lteq - object - If set, return records where the specified field is less than or equal the supplied value. Valid fields are `expires_at`.


317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/files.com/models/api_key.rb', line 317

def self.create_export(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params[:filter_gt] and !params[:filter_gt].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params[:filter_gteq] and !params[:filter_gteq].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params[:filter_lt] and !params[:filter_lt].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params[:filter_lteq] and !params[:filter_lteq].is_a?(Hash)

  response, options = Api.send_request("/api_keys/create_export", :post, params, options)
  Export.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



365
366
367
368
369
370
371
372
373
# File 'lib/files.com/models/api_key.rb', line 365

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/api_keys/#{params[:id]}", :delete, params, options)
  nil
end

.delete_current(params = {}, options = {}) ⇒ Object



360
361
362
363
# File 'lib/files.com/models/api_key.rb', line 360

def self.delete_current(params = {}, options = {})
  Api.send_request("/api_key", :delete, params, options)
  nil
end

.destroy(id, params = {}, options = {}) ⇒ Object



375
376
377
378
# File 'lib/files.com/models/api_key.rb', line 375

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
  nil
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Api Key ID.


268
269
270
271
272
273
274
275
276
# File 'lib/files.com/models/api_key.rb', line 268

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/api_keys/#{params[:id]}", :get, params, options)
  ApiKey.new(response.data, options)
end

.find_current(params = {}, options = {}) ⇒ Object



261
262
263
264
# File 'lib/files.com/models/api_key.rb', line 261

def self.find_current(params = {}, options = {})
  response, options = Api.send_request("/api_key", :get, params, options)
  ApiKey.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



278
279
280
# File 'lib/files.com/models/api_key.rb', line 278

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - User ID.  Provide a value of `0` to operate the current session's user.
cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10000, 1,000 or less is recommended).
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `site_id` and `workspace_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `aws_style_credentials` and `expires_at`.
filter_gt - object - If set, return records where the specified field is greater than the supplied value. Valid fields are `expires_at`.
filter_gteq - object - If set, return records where the specified field is greater than or equal the supplied value. Valid fields are `expires_at`.
filter_lt - object - If set, return records where the specified field is less than the supplied value. Valid fields are `expires_at`.
filter_lteq - object - If set, return records where the specified field is less than or equal the supplied value. Valid fields are `expires_at`.


241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/files.com/models/api_key.rb', line 241

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params[:filter_gt] and !params[:filter_gt].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params[:filter_gteq] and !params[:filter_gteq].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params[:filter_lt] and !params[:filter_lt].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params[:filter_lteq] and !params[:filter_lteq].is_a?(Hash)

  List.new(ApiKey, params) do
    Api.send_request("/api_keys", :get, params, options)
  end
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

description - string - User-supplied description of API key.
expires_at - string - API Key expiration date
name - string - Internal name for the API Key.  For your use.


347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/files.com/models/api_key.rb', line 347

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params[:expires_at] and !params[:expires_at].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/api_keys/#{params[:id]}", :patch, params, options)
  ApiKey.new(response.data, options)
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). Keys with the `office_integration` permission set are auto generated, and automatically expire, to allow users to interact with office integration platforms. Keys with the `files_only` permission set can perform file operations as a full-access file user in the key's workspace scope, but cannot use site admin, workspace admin, folder admin, group admin, partner admin, or billing privileges from the owning user.


334
335
336
337
338
339
340
341
# File 'lib/files.com/models/api_key.rb', line 334

def self.update_current(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params[:expires_at] and !params[:expires_at].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params[:permission_set] and !params[:permission_set].is_a?(String)

  response, options = Api.send_request("/api_key", :patch, params, options)
  ApiKey.new(response.data, options)
end

Instance Method Details

#aws_access_key_idObject

string - AWS Access Key ID to use with AWS-compatible endpoints, such as our Inbound S3-compatible endpoint.



72
73
74
# File 'lib/files.com/models/api_key.rb', line 72

def aws_access_key_id
  @attributes[:aws_access_key_id]
end

#aws_access_key_id=(value) ⇒ Object



76
77
78
# File 'lib/files.com/models/api_key.rb', line 76

def aws_access_key_id=(value)
  @attributes[:aws_access_key_id] = value
end

#aws_secret_keyObject

string - AWS Secret Key to use with AWS-compatible endpoints, such as our Inbound S3-compatible endpoint.



81
82
83
# File 'lib/files.com/models/api_key.rb', line 81

def aws_secret_key
  @attributes[:aws_secret_key]
end

#aws_secret_key=(value) ⇒ Object



85
86
87
# File 'lib/files.com/models/api_key.rb', line 85

def aws_secret_key=(value)
  @attributes[:aws_secret_key] = value
end

#aws_style_credentialsObject

boolean - If true, this API key will be usable with AWS-compatible endpoints, such as our Inbound S3-compatible endpoint.



63
64
65
# File 'lib/files.com/models/api_key.rb', line 63

def aws_style_credentials
  @attributes[:aws_style_credentials]
end

#aws_style_credentials=(value) ⇒ Object



67
68
69
# File 'lib/files.com/models/api_key.rb', line 67

def aws_style_credentials=(value)
  @attributes[:aws_style_credentials] = value
end

#created_atObject

date-time - Time which API Key was created



40
41
42
# File 'lib/files.com/models/api_key.rb', line 40

def created_at
  @attributes[:created_at]
end

#delete(params = {}) ⇒ Object



205
206
207
208
209
210
211
212
213
# File 'lib/files.com/models/api_key.rb', line 205

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[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/api_keys/#{@attributes[:id]}", :delete, params, @options)
end

#descriptionObject

string - User-supplied description of API key.



31
32
33
# File 'lib/files.com/models/api_key.rb', line 31

def description
  @attributes[:description]
end

#description=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/api_key.rb', line 35

def description=(value)
  @attributes[:description] = value
end

#descriptive_labelObject

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



215
216
217
218
# File 'lib/files.com/models/api_key.rb', line 215

def destroy(params = {})
  delete(params)
  nil
end

#expires_atObject

date-time - API Key expiration date



45
46
47
# File 'lib/files.com/models/api_key.rb', line 45

def expires_at
  @attributes[:expires_at]
end

#expires_at=(value) ⇒ Object



49
50
51
# File 'lib/files.com/models/api_key.rb', line 49

def expires_at=(value)
  @attributes[:expires_at] = value
end

#idObject

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

#keyObject

string - API Key actual key string



54
55
56
# File 'lib/files.com/models/api_key.rb', line 54

def key
  @attributes[:key]
end

#key=(value) ⇒ Object



58
59
60
# File 'lib/files.com/models/api_key.rb', line 58

def key=(value)
  @attributes[:key] = value
end

#last_use_atObject

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.



90
91
92
# File 'lib/files.com/models/api_key.rb', line 90

def last_use_at
  @attributes[:last_use_at]
end

#last_use_at=(value) ⇒ Object



94
95
96
# File 'lib/files.com/models/api_key.rb', line 94

def last_use_at=(value)
  @attributes[:last_use_at] = value
end

#nameObject

string - Internal name for the API Key. For your use.



99
100
101
# File 'lib/files.com/models/api_key.rb', line 99

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



103
104
105
# File 'lib/files.com/models/api_key.rb', line 103

def name=(value)
  @attributes[:name] = value
end

#pairing_keyObject

string - The pairing key to use



180
181
182
# File 'lib/files.com/models/api_key.rb', line 180

def pairing_key
  @attributes[:pairing_key]
end

#pairing_key=(value) ⇒ Object



184
185
186
# File 'lib/files.com/models/api_key.rb', line 184

def pairing_key=(value)
  @attributes[:pairing_key] = value
end

#pathObject

string - Folder path restriction for office_integration permission set API keys. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.



108
109
110
# File 'lib/files.com/models/api_key.rb', line 108

def path
  @attributes[:path]
end

#path=(value) ⇒ Object



112
113
114
# File 'lib/files.com/models/api_key.rb', line 112

def path=(value)
  @attributes[:path] = value
end

#permission_setObject

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). Keys with the office_integration permission set are auto generated, and automatically expire, to allow users to interact with office integration platforms. Keys with the files_only permission set can perform file operations as a full-access file user in the key's workspace scope, but cannot use site admin, workspace admin, folder admin, group admin, partner admin, or billing privileges from the owning user.



117
118
119
# File 'lib/files.com/models/api_key.rb', line 117

def permission_set
  @attributes[:permission_set]
end

#permission_set=(value) ⇒ Object



121
122
123
# File 'lib/files.com/models/api_key.rb', line 121

def permission_set=(value)
  @attributes[:permission_set] = value
end

#platformObject

string - If this API key represents a Desktop app, what platform was it created on?



126
127
128
# File 'lib/files.com/models/api_key.rb', line 126

def platform
  @attributes[:platform]
end

#platform=(value) ⇒ Object



130
131
132
# File 'lib/files.com/models/api_key.rb', line 130

def platform=(value)
  @attributes[:platform] = value
end

#saveObject



220
221
222
223
224
225
226
227
228
229
# File 'lib/files.com/models/api_key.rb', line 220

def save
  if @attributes[:id]
    new_obj = update(@attributes)
  else
    new_obj = ApiKey.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#site_idObject

int64 - Site ID



135
136
137
# File 'lib/files.com/models/api_key.rb', line 135

def site_id
  @attributes[:site_id]
end

#site_id=(value) ⇒ Object



139
140
141
# File 'lib/files.com/models/api_key.rb', line 139

def site_id=(value)
  @attributes[:site_id] = value
end

#site_nameObject

string - Site Name



144
145
146
# File 'lib/files.com/models/api_key.rb', line 144

def site_name
  @attributes[:site_name]
end

#site_name=(value) ⇒ Object



148
149
150
# File 'lib/files.com/models/api_key.rb', line 148

def site_name=(value)
  @attributes[:site_name] = value
end

#update(params = {}) ⇒ Object

Parameters:

description - string - User-supplied description of API key.
expires_at - string - API Key expiration date
name - string - Internal name for the API Key.  For your use.


192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/files.com/models/api_key.rb', line 192

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[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: description must be an String") if params[:description] and !params[:description].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params[:expires_at] and !params[:expires_at].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/api_keys/#{@attributes[:id]}", :patch, params, @options)
end

#urlObject

string - URL for API host.



153
154
155
# File 'lib/files.com/models/api_key.rb', line 153

def url
  @attributes[:url]
end

#url=(value) ⇒ Object



157
158
159
# File 'lib/files.com/models/api_key.rb', line 157

def url=(value)
  @attributes[:url] = value
end

#user_idObject

int64 - User ID for the owner of this API Key. May be blank for Site-wide API Keys.



162
163
164
# File 'lib/files.com/models/api_key.rb', line 162

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



166
167
168
# File 'lib/files.com/models/api_key.rb', line 166

def user_id=(value)
  @attributes[:user_id] = value
end

#workspace_idObject

int64 - Workspace ID for this API Key. 0 means the default workspace.



171
172
173
# File 'lib/files.com/models/api_key.rb', line 171

def workspace_id
  @attributes[:workspace_id]
end

#workspace_id=(value) ⇒ Object



175
176
177
# File 'lib/files.com/models/api_key.rb', line 175

def workspace_id=(value)
  @attributes[:workspace_id] = value
end