files.com 1.0.92
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTORS +4 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +82 -0
- data/LICENSE +21 -0
- data/README.md +119 -0
- data/Rakefile +12 -0
- data/SECURITY.md +24 -0
- data/_VERSION +1 -0
- data/bin/files +8 -0
- data/bin/files-console +16 -0
- data/docs/account_line_item.md +41 -0
- data/docs/action.md +37 -0
- data/docs/api_key.md +202 -0
- data/docs/app.md +59 -0
- data/docs/as2_key.md +133 -0
- data/docs/auto.md +11 -0
- data/docs/automation.md +190 -0
- data/docs/behavior.md +208 -0
- data/docs/bundle.md +252 -0
- data/docs/bundle_download.md +35 -0
- data/docs/clickwrap.md +143 -0
- data/docs/dns_record.md +35 -0
- data/docs/errors.md +17 -0
- data/docs/file.md +204 -0
- data/docs/file_action.md +126 -0
- data/docs/file_comment.md +116 -0
- data/docs/file_comment_reaction.md +62 -0
- data/docs/file_part_upload.md +37 -0
- data/docs/file_utils.md +4 -0
- data/docs/folder.md +90 -0
- data/docs/group.md +153 -0
- data/docs/group_user.md +124 -0
- data/docs/history.md +171 -0
- data/docs/history_export.md +174 -0
- data/docs/image.md +13 -0
- data/docs/invoice.md +72 -0
- data/docs/invoice_line_item.md +27 -0
- data/docs/ip_address.md +55 -0
- data/docs/lock.md +98 -0
- data/docs/message.md +147 -0
- data/docs/message_comment.md +132 -0
- data/docs/message_comment_reaction.md +94 -0
- data/docs/message_reaction.md +94 -0
- data/docs/notification.md +177 -0
- data/docs/payment.md +72 -0
- data/docs/payment_line_item.md +19 -0
- data/docs/permission.md +95 -0
- data/docs/preview.md +19 -0
- data/docs/project.md +121 -0
- data/docs/public_ip_address.md +13 -0
- data/docs/public_key.md +133 -0
- data/docs/remote_server.md +356 -0
- data/docs/request.md +100 -0
- data/docs/session.md +78 -0
- data/docs/site.md +448 -0
- data/docs/sso_strategy.md +114 -0
- data/docs/status.md +21 -0
- data/docs/style.md +93 -0
- data/docs/usage_daily_snapshot.md +45 -0
- data/docs/usage_snapshot.md +53 -0
- data/docs/user.md +535 -0
- data/docs/user_cipher_use.md +41 -0
- data/docs/user_request.md +93 -0
- data/files.com.gemspec +22 -0
- data/lib/files.com.rb +184 -0
- data/lib/files.com/api.rb +38 -0
- data/lib/files.com/api_client.rb +340 -0
- data/lib/files.com/errors.rb +41 -0
- data/lib/files.com/list.rb +95 -0
- data/lib/files.com/models/account_line_item.rb +82 -0
- data/lib/files.com/models/action.rb +77 -0
- data/lib/files.com/models/api_key.rb +270 -0
- data/lib/files.com/models/app.rb +106 -0
- data/lib/files.com/models/as2_key.rb +179 -0
- data/lib/files.com/models/auto.rb +17 -0
- data/lib/files.com/models/automation.rb +304 -0
- data/lib/files.com/models/behavior.rb +266 -0
- data/lib/files.com/models/bundle.rb +371 -0
- data/lib/files.com/models/bundle_download.rb +49 -0
- data/lib/files.com/models/clickwrap.rb +197 -0
- data/lib/files.com/models/dir.rb +3 -0
- data/lib/files.com/models/dns_record.rb +51 -0
- data/lib/files.com/models/errors.rb +22 -0
- data/lib/files.com/models/file.rb +968 -0
- data/lib/files.com/models/file_action.rb +126 -0
- data/lib/files.com/models/file_comment.rb +146 -0
- data/lib/files.com/models/file_comment_reaction.rb +100 -0
- data/lib/files.com/models/file_part_upload.rb +82 -0
- data/lib/files.com/models/file_utils.rb +118 -0
- data/lib/files.com/models/folder.rb +357 -0
- data/lib/files.com/models/group.rb +208 -0
- data/lib/files.com/models/group_user.rb +171 -0
- data/lib/files.com/models/history.rb +228 -0
- data/lib/files.com/models/history_export.rb +353 -0
- data/lib/files.com/models/image.rb +22 -0
- data/lib/files.com/models/invoice.rb +117 -0
- data/lib/files.com/models/invoice_line_item.rb +57 -0
- data/lib/files.com/models/ip_address.rb +66 -0
- data/lib/files.com/models/lock.rb +173 -0
- data/lib/files.com/models/message.rb +201 -0
- data/lib/files.com/models/message_comment.rb +165 -0
- data/lib/files.com/models/message_comment_reaction.rb +128 -0
- data/lib/files.com/models/message_reaction.rb +128 -0
- data/lib/files.com/models/notification.rb +263 -0
- data/lib/files.com/models/payment.rb +117 -0
- data/lib/files.com/models/payment_line_item.rb +37 -0
- data/lib/files.com/models/permission.rb +172 -0
- data/lib/files.com/models/preview.rb +37 -0
- data/lib/files.com/models/project.rb +140 -0
- data/lib/files.com/models/public_ip_address.rb +22 -0
- data/lib/files.com/models/public_key.rb +179 -0
- data/lib/files.com/models/remote_server.rb +680 -0
- data/lib/files.com/models/request.rb +179 -0
- data/lib/files.com/models/session.rb +247 -0
- data/lib/files.com/models/site.rb +733 -0
- data/lib/files.com/models/sso_strategy.rb +227 -0
- data/lib/files.com/models/status.rb +37 -0
- data/lib/files.com/models/style.rb +131 -0
- data/lib/files.com/models/usage_daily_snapshot.rb +66 -0
- data/lib/files.com/models/usage_snapshot.rb +96 -0
- data/lib/files.com/models/user.rb +876 -0
- data/lib/files.com/models/user_cipher_use.rb +63 -0
- data/lib/files.com/models/user_request.rb +127 -0
- data/lib/files.com/response.rb +25 -0
- data/lib/files.com/sizable_io.rb +32 -0
- data/lib/files.com/system_profiler.rb +56 -0
- data/lib/files.com/util.rb +106 -0
- data/lib/files.com/version.rb +5 -0
- data/spec/list_spec.rb +214 -0
- data/spec/models/file_spec.rb +68 -0
- data/spec/models/folder_spec.rb +40 -0
- data/spec/spec_helper.rb +36 -0
- data/test.sh +8 -0
- data/test/test.rb +75 -0
- metadata +235 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Files
|
4
|
+
class Error < StandardError
|
5
|
+
attr_accessor :response
|
6
|
+
|
7
|
+
attr_reader :code
|
8
|
+
attr_reader :http_body
|
9
|
+
attr_reader :http_headers
|
10
|
+
attr_reader :http_status
|
11
|
+
attr_reader :json_body
|
12
|
+
attr_reader :message
|
13
|
+
attr_reader :request_id
|
14
|
+
|
15
|
+
def initialize(message = nil, http_status: nil, http_body: nil, json_body: nil, http_headers: nil, code: nil)
|
16
|
+
@message = message
|
17
|
+
@http_status = http_status
|
18
|
+
@http_body = http_body
|
19
|
+
@http_headers = http_headers || {}
|
20
|
+
@json_body = json_body
|
21
|
+
@code = code
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"#{@http_status.nil? ? "" : "[HTTP #{@http_status}] "}#{@message}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class APIError < Error; end
|
30
|
+
class AuthenticationError < Error; end
|
31
|
+
class ConnectionError < Error; end
|
32
|
+
class InvalidRequestError < Error; end
|
33
|
+
class NotImplementedError < Error; end
|
34
|
+
class PermissionError < Error; end
|
35
|
+
class RateLimitError < Error; end
|
36
|
+
class TooManyRequestsError < Error; end
|
37
|
+
class ValidationError < Error; end
|
38
|
+
|
39
|
+
class InvalidParameterError < InvalidRequestError; end
|
40
|
+
class MissingParameterError < InvalidRequestError; end
|
41
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Files
|
2
|
+
class List
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(resource_wrapper, params, current_response = nil, current_options = nil, &request_page)
|
6
|
+
@resource_wrapper = resource_wrapper
|
7
|
+
@params = params
|
8
|
+
@current_response = current_response
|
9
|
+
@current_options = current_options
|
10
|
+
@request_page = request_page
|
11
|
+
end
|
12
|
+
|
13
|
+
# Iterates through each resource in all pages, making additional fetches to
|
14
|
+
# the API as necessary.
|
15
|
+
#
|
16
|
+
# Note that this method will make as many API calls as necessary to fetch
|
17
|
+
# all resources. For more granular control, please see +each+ and
|
18
|
+
# +next_page+.
|
19
|
+
def auto_paging_each
|
20
|
+
return enum_for(:auto_paging_each).lazy unless block_given?
|
21
|
+
|
22
|
+
loop do
|
23
|
+
page = next_page
|
24
|
+
break unless page.valid_response?
|
25
|
+
|
26
|
+
page.set_cursor
|
27
|
+
|
28
|
+
page.wrap_data do |data|
|
29
|
+
yield data
|
30
|
+
end
|
31
|
+
break if page.on_last_page?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Iterates through each resource in the current page.
|
36
|
+
#
|
37
|
+
# Note that this method makes no effort to fetch a new page when it gets to
|
38
|
+
# the end of the current page's resources. See also +auto_paging_each+.
|
39
|
+
def each(&block)
|
40
|
+
page = current_page
|
41
|
+
return [] unless page.valid_response?
|
42
|
+
|
43
|
+
page.set_cursor
|
44
|
+
page.wrap_data { |data| block.call data }
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fetches the next page of resources (if there is one).
|
48
|
+
#
|
49
|
+
# This method will try to respect the per_page set. If none
|
50
|
+
# was given, the default per_page will be used.
|
51
|
+
def next_page
|
52
|
+
self.class.new(resource_wrapper, params, *request_page.call, &request_page)
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
attr_reader :resource_wrapper,
|
58
|
+
:params,
|
59
|
+
:request_page
|
60
|
+
|
61
|
+
def current_page
|
62
|
+
@current_page ||= if @current_response and @current_options
|
63
|
+
self
|
64
|
+
else
|
65
|
+
next_page
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def data
|
70
|
+
@current_response.data
|
71
|
+
end
|
72
|
+
|
73
|
+
def wrap_data
|
74
|
+
data.map do |object|
|
75
|
+
yield resource_wrapper.new(object, @current_options)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def set_cursor
|
80
|
+
params[:cursor] = @current_options[:client].cursor
|
81
|
+
end
|
82
|
+
|
83
|
+
def cursor
|
84
|
+
params[:cursor]
|
85
|
+
end
|
86
|
+
|
87
|
+
def valid_response?
|
88
|
+
@current_response.http_status == 200
|
89
|
+
end
|
90
|
+
|
91
|
+
def on_last_page?
|
92
|
+
!cursor or (data.count < params[:per_page])
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Files
|
4
|
+
class AccountLineItem
|
5
|
+
attr_reader :options, :attributes
|
6
|
+
|
7
|
+
def initialize(attributes = {}, options = {})
|
8
|
+
@attributes = attributes || {}
|
9
|
+
@options = options || {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# int64 - Line item Id
|
13
|
+
def id
|
14
|
+
@attributes[:id]
|
15
|
+
end
|
16
|
+
|
17
|
+
# double - Line item amount
|
18
|
+
def amount
|
19
|
+
@attributes[:amount]
|
20
|
+
end
|
21
|
+
|
22
|
+
# double - Line item balance
|
23
|
+
def balance
|
24
|
+
@attributes[:balance]
|
25
|
+
end
|
26
|
+
|
27
|
+
# date-time - Line item created at
|
28
|
+
def created_at
|
29
|
+
@attributes[:created_at]
|
30
|
+
end
|
31
|
+
|
32
|
+
# string - Line item currency
|
33
|
+
def currency
|
34
|
+
@attributes[:currency]
|
35
|
+
end
|
36
|
+
|
37
|
+
# string - Line item download uri
|
38
|
+
def download_uri
|
39
|
+
@attributes[:download_uri]
|
40
|
+
end
|
41
|
+
|
42
|
+
# array - Associated invoice line items
|
43
|
+
def invoice_line_items
|
44
|
+
@attributes[:invoice_line_items]
|
45
|
+
end
|
46
|
+
|
47
|
+
# string - Line item payment method
|
48
|
+
def method
|
49
|
+
@attributes[:method]
|
50
|
+
end
|
51
|
+
|
52
|
+
# array - Associated payment line items
|
53
|
+
def payment_line_items
|
54
|
+
@attributes[:payment_line_items]
|
55
|
+
end
|
56
|
+
|
57
|
+
# date-time - Date/time payment was reversed if applicable
|
58
|
+
def payment_reversed_at
|
59
|
+
@attributes[:payment_reversed_at]
|
60
|
+
end
|
61
|
+
|
62
|
+
# string - Type of payment if applicable
|
63
|
+
def payment_type
|
64
|
+
@attributes[:payment_type]
|
65
|
+
end
|
66
|
+
|
67
|
+
# string - Site name this line item is for
|
68
|
+
def site_name
|
69
|
+
@attributes[:site_name]
|
70
|
+
end
|
71
|
+
|
72
|
+
# string - Type of line item, either payment or invoice
|
73
|
+
def type
|
74
|
+
@attributes[:type]
|
75
|
+
end
|
76
|
+
|
77
|
+
# date-time - Line item updated at
|
78
|
+
def updated_at
|
79
|
+
@attributes[:updated_at]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Files
|
4
|
+
class Action
|
5
|
+
attr_reader :options, :attributes
|
6
|
+
|
7
|
+
def initialize(attributes = {}, options = {})
|
8
|
+
@attributes = attributes || {}
|
9
|
+
@options = options || {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# int64 - Action ID
|
13
|
+
def id
|
14
|
+
@attributes[:id]
|
15
|
+
end
|
16
|
+
|
17
|
+
# string - Path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
18
|
+
def path
|
19
|
+
@attributes[:path]
|
20
|
+
end
|
21
|
+
|
22
|
+
# date-time - Action occurrence date/time
|
23
|
+
def when
|
24
|
+
@attributes[:when]
|
25
|
+
end
|
26
|
+
|
27
|
+
# string - The destination path for this action, if applicable
|
28
|
+
def destination
|
29
|
+
@attributes[:destination]
|
30
|
+
end
|
31
|
+
|
32
|
+
# string - Friendly displayed output
|
33
|
+
def display
|
34
|
+
@attributes[:display]
|
35
|
+
end
|
36
|
+
|
37
|
+
# string - IP Address that performed this action
|
38
|
+
def ip
|
39
|
+
@attributes[:ip]
|
40
|
+
end
|
41
|
+
|
42
|
+
# string - The source path for this action, if applicable
|
43
|
+
def source
|
44
|
+
@attributes[:source]
|
45
|
+
end
|
46
|
+
|
47
|
+
# array - Targets
|
48
|
+
def targets
|
49
|
+
@attributes[:targets]
|
50
|
+
end
|
51
|
+
|
52
|
+
# int64 - User ID
|
53
|
+
def user_id
|
54
|
+
@attributes[:user_id]
|
55
|
+
end
|
56
|
+
|
57
|
+
# string - Username
|
58
|
+
def username
|
59
|
+
@attributes[:username]
|
60
|
+
end
|
61
|
+
|
62
|
+
# string - Type of action
|
63
|
+
def action
|
64
|
+
@attributes[:action]
|
65
|
+
end
|
66
|
+
|
67
|
+
# string - Failure type. If action was a user login or session failure, why did it fail?
|
68
|
+
def failure_type
|
69
|
+
@attributes[:failure_type]
|
70
|
+
end
|
71
|
+
|
72
|
+
# string - Interface on which this action occurred.
|
73
|
+
def interface
|
74
|
+
@attributes[:interface]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,270 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Files
|
4
|
+
class ApiKey
|
5
|
+
attr_reader :options, :attributes
|
6
|
+
|
7
|
+
def initialize(attributes = {}, options = {})
|
8
|
+
@attributes = attributes || {}
|
9
|
+
@options = options || {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# int64 - API Key ID
|
13
|
+
def id
|
14
|
+
@attributes[:id]
|
15
|
+
end
|
16
|
+
|
17
|
+
def id=(value)
|
18
|
+
@attributes[:id] = value
|
19
|
+
end
|
20
|
+
|
21
|
+
# 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
|
+
def descriptive_label
|
23
|
+
@attributes[:descriptive_label]
|
24
|
+
end
|
25
|
+
|
26
|
+
def descriptive_label=(value)
|
27
|
+
@attributes[:descriptive_label] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
# date-time - Time which API Key was created
|
31
|
+
def created_at
|
32
|
+
@attributes[:created_at]
|
33
|
+
end
|
34
|
+
|
35
|
+
# date-time - API Key expiration date
|
36
|
+
def expires_at
|
37
|
+
@attributes[:expires_at]
|
38
|
+
end
|
39
|
+
|
40
|
+
def expires_at=(value)
|
41
|
+
@attributes[:expires_at] = value
|
42
|
+
end
|
43
|
+
|
44
|
+
# string - API Key actual key string
|
45
|
+
def key
|
46
|
+
@attributes[:key]
|
47
|
+
end
|
48
|
+
|
49
|
+
def key=(value)
|
50
|
+
@attributes[:key] = value
|
51
|
+
end
|
52
|
+
|
53
|
+
# 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
|
+
def last_use_at
|
55
|
+
@attributes[:last_use_at]
|
56
|
+
end
|
57
|
+
|
58
|
+
def last_use_at=(value)
|
59
|
+
@attributes[:last_use_at] = value
|
60
|
+
end
|
61
|
+
|
62
|
+
# string - Internal name for the API Key. For your use.
|
63
|
+
def name
|
64
|
+
@attributes[:name]
|
65
|
+
end
|
66
|
+
|
67
|
+
def name=(value)
|
68
|
+
@attributes[:name] = value
|
69
|
+
end
|
70
|
+
|
71
|
+
# 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
|
+
def path
|
73
|
+
@attributes[:path]
|
74
|
+
end
|
75
|
+
|
76
|
+
def path=(value)
|
77
|
+
@attributes[:path] = value
|
78
|
+
end
|
79
|
+
|
80
|
+
# 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
|
+
def permission_set
|
82
|
+
@attributes[:permission_set]
|
83
|
+
end
|
84
|
+
|
85
|
+
def permission_set=(value)
|
86
|
+
@attributes[:permission_set] = value
|
87
|
+
end
|
88
|
+
|
89
|
+
# string - If this API key represents a Desktop app, what platform was it created on?
|
90
|
+
def platform
|
91
|
+
@attributes[:platform]
|
92
|
+
end
|
93
|
+
|
94
|
+
def platform=(value)
|
95
|
+
@attributes[:platform] = value
|
96
|
+
end
|
97
|
+
|
98
|
+
# int64 - User ID for the owner of this API Key. May be blank for Site-wide API Keys.
|
99
|
+
def user_id
|
100
|
+
@attributes[:user_id]
|
101
|
+
end
|
102
|
+
|
103
|
+
def user_id=(value)
|
104
|
+
@attributes[:user_id] = value
|
105
|
+
end
|
106
|
+
|
107
|
+
# Parameters:
|
108
|
+
# name - string - Internal name for the API Key. For your use.
|
109
|
+
# expires_at - string - API Key expiration date
|
110
|
+
# 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
|
+
def update(params = {})
|
112
|
+
params ||= {}
|
113
|
+
params[:id] = @attributes[:id]
|
114
|
+
raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
|
115
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
|
116
|
+
raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
|
117
|
+
raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
|
118
|
+
raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String)
|
119
|
+
raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
|
120
|
+
|
121
|
+
Api.send_request("/api_keys/#{@attributes[:id]}", :patch, params, @options)
|
122
|
+
end
|
123
|
+
|
124
|
+
def delete(params = {})
|
125
|
+
params ||= {}
|
126
|
+
params[:id] = @attributes[:id]
|
127
|
+
raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
|
128
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
|
129
|
+
raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
|
130
|
+
|
131
|
+
Api.send_request("/api_keys/#{@attributes[:id]}", :delete, params, @options)
|
132
|
+
end
|
133
|
+
|
134
|
+
def destroy(params = {})
|
135
|
+
delete(params)
|
136
|
+
end
|
137
|
+
|
138
|
+
def save
|
139
|
+
if @attributes[:id]
|
140
|
+
update(@attributes)
|
141
|
+
else
|
142
|
+
new_obj = ApiKey.create(@attributes, @options)
|
143
|
+
@attributes = new_obj.attributes
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Parameters:
|
148
|
+
# user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
149
|
+
# page - int64 - Current page number.
|
150
|
+
# per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
151
|
+
# action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
|
152
|
+
# 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.
|
153
|
+
# 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`.
|
154
|
+
# filter - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `expires_at`.
|
155
|
+
# filter_gt - object - If set, return records where the specifiied field is greater than the supplied value. Valid fields are `expires_at`.
|
156
|
+
# 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`.
|
157
|
+
# filter_like - object - If set, return records where the specifiied field is equal to the supplied value. Valid fields are `expires_at`.
|
158
|
+
# filter_lt - object - If set, return records where the specifiied field is less than the supplied value. Valid fields are `expires_at`.
|
159
|
+
# 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
|
+
def self.list(params = {}, options = {})
|
161
|
+
raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
|
162
|
+
raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
|
163
|
+
raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
|
164
|
+
raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
|
165
|
+
raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params.dig(:cursor) and !params.dig(:cursor).is_a?(String)
|
166
|
+
raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params.dig(:sort_by) and !params.dig(:sort_by).is_a?(Hash)
|
167
|
+
raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params.dig(:filter) and !params.dig(:filter).is_a?(Hash)
|
168
|
+
raise InvalidParameterError.new("Bad parameter: filter_gt must be an Hash") if params.dig(:filter_gt) and !params.dig(:filter_gt).is_a?(Hash)
|
169
|
+
raise InvalidParameterError.new("Bad parameter: filter_gteq must be an Hash") if params.dig(:filter_gteq) and !params.dig(:filter_gteq).is_a?(Hash)
|
170
|
+
raise InvalidParameterError.new("Bad parameter: filter_like must be an Hash") if params.dig(:filter_like) and !params.dig(:filter_like).is_a?(Hash)
|
171
|
+
raise InvalidParameterError.new("Bad parameter: filter_lt must be an Hash") if params.dig(:filter_lt) and !params.dig(:filter_lt).is_a?(Hash)
|
172
|
+
raise InvalidParameterError.new("Bad parameter: filter_lteq must be an Hash") if params.dig(:filter_lteq) and !params.dig(:filter_lteq).is_a?(Hash)
|
173
|
+
|
174
|
+
List.new(ApiKey, params) do
|
175
|
+
Api.send_request("/api_keys", :get, params, options)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def self.all(params = {}, options = {})
|
180
|
+
list(params, options)
|
181
|
+
end
|
182
|
+
|
183
|
+
def self.find_current(params = {}, options = {})
|
184
|
+
response, options = Api.send_request("/api_key", :get, params, options)
|
185
|
+
ApiKey.new(response.data, options)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Parameters:
|
189
|
+
# id (required) - int64 - Api Key ID.
|
190
|
+
def self.find(id, params = {}, options = {})
|
191
|
+
params ||= {}
|
192
|
+
params[:id] = id
|
193
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
|
194
|
+
raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
|
195
|
+
|
196
|
+
response, options = Api.send_request("/api_keys/#{params[:id]}", :get, params, options)
|
197
|
+
ApiKey.new(response.data, options)
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.get(id, params = {}, options = {})
|
201
|
+
find(id, params, options)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Parameters:
|
205
|
+
# user_id - int64 - User ID. Provide a value of `0` to operate the current session's user.
|
206
|
+
# name - string - Internal name for the API Key. For your use.
|
207
|
+
# expires_at - string - API Key expiration date
|
208
|
+
# 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.
|
209
|
+
# path - string - Folder path restriction for this api key.
|
210
|
+
def self.create(params = {}, options = {})
|
211
|
+
raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
|
212
|
+
raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
|
213
|
+
raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
|
214
|
+
raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String)
|
215
|
+
raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
|
216
|
+
|
217
|
+
response, options = Api.send_request("/api_keys", :post, params, options)
|
218
|
+
ApiKey.new(response.data, options)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Parameters:
|
222
|
+
# expires_at - string - API Key expiration date
|
223
|
+
# name - string - Internal name for the API Key. For your use.
|
224
|
+
# 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.
|
225
|
+
def self.update_current(params = {}, options = {})
|
226
|
+
raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
|
227
|
+
raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
|
228
|
+
raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String)
|
229
|
+
|
230
|
+
response, options = Api.send_request("/api_key", :patch, params, options)
|
231
|
+
ApiKey.new(response.data, options)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Parameters:
|
235
|
+
# name - string - Internal name for the API Key. For your use.
|
236
|
+
# expires_at - string - API Key expiration date
|
237
|
+
# 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.
|
238
|
+
def self.update(id, params = {}, options = {})
|
239
|
+
params ||= {}
|
240
|
+
params[:id] = id
|
241
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
|
242
|
+
raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
|
243
|
+
raise InvalidParameterError.new("Bad parameter: expires_at must be an String") if params.dig(:expires_at) and !params.dig(:expires_at).is_a?(String)
|
244
|
+
raise InvalidParameterError.new("Bad parameter: permission_set must be an String") if params.dig(:permission_set) and !params.dig(:permission_set).is_a?(String)
|
245
|
+
raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
|
246
|
+
|
247
|
+
response, options = Api.send_request("/api_keys/#{params[:id]}", :patch, params, options)
|
248
|
+
ApiKey.new(response.data, options)
|
249
|
+
end
|
250
|
+
|
251
|
+
def self.delete_current(params = {}, options = {})
|
252
|
+
response, _options = Api.send_request("/api_key", :delete, params, options)
|
253
|
+
response.data
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.delete(id, params = {}, options = {})
|
257
|
+
params ||= {}
|
258
|
+
params[:id] = id
|
259
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
|
260
|
+
raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
|
261
|
+
|
262
|
+
response, _options = Api.send_request("/api_keys/#{params[:id]}", :delete, params, options)
|
263
|
+
response.data
|
264
|
+
end
|
265
|
+
|
266
|
+
def self.destroy(id, params = {}, options = {})
|
267
|
+
delete(id, params, options)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|