files.com 1.0.65 → 1.0.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/_VERSION +1 -1
  3. data/docs/auto.md +1 -1
  4. data/docs/behavior.md +5 -1
  5. data/docs/bundle.md +24 -16
  6. data/docs/group_user.md +9 -8
  7. data/docs/sso_strategy.md +4 -4
  8. data/docs/status.md +1 -1
  9. data/docs/user.md +2 -0
  10. data/files.com.gemspec +1 -0
  11. data/lib/files.com.rb +2 -0
  12. data/lib/files.com/api_client.rb +9 -3
  13. data/lib/files.com/models/api_key.rb +3 -0
  14. data/lib/files.com/models/as2_key.rb +3 -0
  15. data/lib/files.com/models/auto.rb +1 -1
  16. data/lib/files.com/models/automation.rb +3 -0
  17. data/lib/files.com/models/behavior.rb +10 -0
  18. data/lib/files.com/models/bundle.rb +52 -37
  19. data/lib/files.com/models/dns_record.rb +3 -0
  20. data/lib/files.com/models/file.rb +3 -2
  21. data/lib/files.com/models/file_comment.rb +3 -0
  22. data/lib/files.com/models/group.rb +3 -0
  23. data/lib/files.com/models/group_user.rb +27 -24
  24. data/lib/files.com/models/history.rb +15 -0
  25. data/lib/files.com/models/history_export.rb +3 -0
  26. data/lib/files.com/models/invoice.rb +3 -0
  27. data/lib/files.com/models/ip_address.rb +3 -0
  28. data/lib/files.com/models/lock.rb +3 -0
  29. data/lib/files.com/models/message.rb +3 -0
  30. data/lib/files.com/models/message_comment.rb +3 -0
  31. data/lib/files.com/models/message_comment_reaction.rb +3 -0
  32. data/lib/files.com/models/message_reaction.rb +3 -0
  33. data/lib/files.com/models/notification.rb +3 -0
  34. data/lib/files.com/models/payment.rb +3 -0
  35. data/lib/files.com/models/permission.rb +3 -0
  36. data/lib/files.com/models/project.rb +3 -0
  37. data/lib/files.com/models/public_key.rb +3 -0
  38. data/lib/files.com/models/remote_server.rb +3 -0
  39. data/lib/files.com/models/request.rb +6 -0
  40. data/lib/files.com/models/sso_strategy.rb +4 -6
  41. data/lib/files.com/models/status.rb +1 -0
  42. data/lib/files.com/models/usage_daily_snapshot.rb +3 -0
  43. data/lib/files.com/models/usage_snapshot.rb +3 -0
  44. data/lib/files.com/models/user.rb +5 -0
  45. data/lib/files.com/models/user_cipher_use.rb +3 -0
  46. data/lib/files.com/sizable_io.rb +32 -0
  47. data/spec/models/file_spec.rb +2 -1
  48. data/spec/spec_helper.rb +1 -0
  49. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8025a8623a1eeaee8f5a1d14abeb2ddee71ab8b25d0c049e1f452f9d1d36be9
4
- data.tar.gz: 233fabd362482a798703dfc07204046994ba710e2b45854e7ddf6ec29fe6b44b
3
+ metadata.gz: 354b517bc5f6ddc6a4755e0abc37559b06219ca42b065681e1b1d4382c9454c9
4
+ data.tar.gz: 3143fda44f1cd72abc7f2de6a7756040f7c9312845ecb0aa79ae01aa121e7e01
5
5
  SHA512:
6
- metadata.gz: b3240bee55e67353135fc32e81e386a33dad2a0a71071c620cf4c6e3b89ee1fd58c4a0ec6ce14040cfad2a537657bfa1e57a3410367aa6f06ce60e581d02a05c
7
- data.tar.gz: 9d570738941bf471ad427f1c081f410eebc2a4a83e93715e0b09eaf25be82bca1c5e80e0bc515f3024aae6c30cb7e576d0c0e536eed9bc8f5e58642b55b50872
6
+ metadata.gz: 3b630b22648bb86650b8d8ecc73f7115583cb17923befb847c56174e48babc102f1f25bf378628c3e8abd577abc0c9abac1e97e26fc092cea722fad8ae4d27af
7
+ data.tar.gz: ea01983e584a06a03d96636d1f1b198aa18660c377732a16d4931673aab4d90a78afbb4e4feec54e4a2e8c284c2d9f6e33d269935f59ebcbf653e9ab945c335b
data/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.65
1
+ 1.0.70
@@ -8,4 +8,4 @@
8
8
  }
9
9
  ```
10
10
 
11
- * `dynamic` (object): Additional data
11
+ * `dynamic` (object):
@@ -105,7 +105,9 @@ Files::Behavior.create(
105
105
  Files::Behavior.webhook_test(
106
106
  url: "https://www.site.com/...",
107
107
  method: "GET",
108
- encoding: "RAW"
108
+ encoding: "RAW",
109
+ headers: "x-test-header => testvalue",
110
+ body: "test-param => testvalue"
109
111
  )
110
112
  ```
111
113
 
@@ -114,6 +116,8 @@ Files::Behavior.webhook_test(
114
116
  * `url` (string): Required - URL for testing the webhook.
115
117
  * `method` (string): HTTP method(GET or POST).
116
118
  * `encoding` (string): HTTP encoding method. Can be JSON, XML, or RAW (form data).
119
+ * `headers` (object): Additional request headers.
120
+ * `body` (object): Additional body parameters.
117
121
 
118
122
 
119
123
  ---
@@ -4,33 +4,35 @@
4
4
 
5
5
  ```
6
6
  {
7
- "id": 1,
8
7
  "code": "abc123",
9
- "created_at": "2000-01-01T01:00:00Z",
8
+ "url": "https://subdomain.files.com/f/12345678",
10
9
  "description": "The public description of the bundle.",
10
+ "password_protected": true,
11
+ "require_registration": true,
12
+ "id": 1,
13
+ "created_at": "2000-01-01T01:00:00Z",
11
14
  "expires_at": "2000-01-01T01:00:00Z",
12
- "paths": [
13
-
14
- ],
15
15
  "note": "The internal note on the bundle.",
16
- "password_protected": true,
17
- "url": "https://subdomain.files.com/f/12345678",
18
16
  "user_id": 1,
19
- "username": "user"
17
+ "username": "user",
18
+ "paths": [
19
+
20
+ ]
20
21
  }
21
22
  ```
22
23
 
23
- * `id` (int64): Bundle ID
24
24
  * `code` (string): Bundle code. This code forms the end part of the Public URL.
25
- * `created_at` (date-time): Bundle created at date/time
25
+ * `url` (string): Public URL of Share Link
26
26
  * `description` (string): Public description
27
+ * `password_protected` (boolean): Is this bundle password protected?
28
+ * `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
29
+ * `id` (int64): Bundle ID
30
+ * `created_at` (date-time): Bundle created at date/time
27
31
  * `expires_at` (date-time): Bundle expiration date/time
28
- * `paths` (array): A list of paths in this bundle
29
32
  * `note` (string): Bundle internal note
30
- * `password_protected` (boolean): Is this bundle password protected?
31
- * `url` (string): Public URL of Share Link
32
33
  * `user_id` (int64): Bundle creator user ID
33
34
  * `username` (string): Bundle creator username
35
+ * `paths` (array): A list of paths in this bundle
34
36
  * `password` (string): Password for this bundle.
35
37
 
36
38
 
@@ -79,7 +81,8 @@ Files::Bundle.create(
79
81
  expires_at: "2000-01-01T01:00:00Z",
80
82
  description: "The public description of the bundle.",
81
83
  note: "The internal note on the bundle.",
82
- code: "abc123"
84
+ code: "abc123",
85
+ require_registration: true
83
86
  )
84
87
  ```
85
88
 
@@ -92,6 +95,7 @@ Files::Bundle.create(
92
95
  * `description` (string): Public description
93
96
  * `note` (string): Bundle internal note
94
97
  * `code` (string): Bundle code. This code forms the end part of the Public URL.
98
+ * `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
95
99
 
96
100
 
97
101
  ---
@@ -122,7 +126,8 @@ Files::Bundle.update(id,
122
126
  expires_at: "2000-01-01T01:00:00Z",
123
127
  description: "The public description of the bundle.",
124
128
  note: "The internal note on the bundle.",
125
- code: "abc123"
129
+ code: "abc123",
130
+ require_registration: true
126
131
  )
127
132
  ```
128
133
 
@@ -134,6 +139,7 @@ Files::Bundle.update(id,
134
139
  * `description` (string): Public description
135
140
  * `note` (string): Bundle internal note
136
141
  * `code` (string): Bundle code. This code forms the end part of the Public URL.
142
+ * `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
137
143
 
138
144
 
139
145
  ---
@@ -181,7 +187,8 @@ bundle.update(
181
187
  expires_at: "2000-01-01T01:00:00Z",
182
188
  description: "The public description of the bundle.",
183
189
  note: "The internal note on the bundle.",
184
- code: "abc123"
190
+ code: "abc123",
191
+ require_registration: true
185
192
  )
186
193
  ```
187
194
 
@@ -193,6 +200,7 @@ bundle.update(
193
200
  * `description` (string): Public description
194
201
  * `note` (string): Bundle internal note
195
202
  * `code` (string): Bundle code. This code forms the end part of the Public URL.
203
+ * `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
196
204
 
197
205
 
198
206
  ---
@@ -4,8 +4,9 @@
4
4
 
5
5
  ```
6
6
  {
7
- "name": "My Group",
8
- "id": 1,
7
+ "group_name": "My Group",
8
+ "group_id": 1,
9
+ "user_id": 1,
9
10
  "admin": true,
10
11
  "usernames": [
11
12
 
@@ -13,12 +14,12 @@
13
14
  }
14
15
  ```
15
16
 
16
- * `name` (string): Group name
17
- * `id` (int64): Group ID
17
+ * `group_name` (string): Group name
18
+ * `group_id` (int64): Group ID
19
+ * `user_id` (int64): User ID
18
20
  * `admin` (boolean): Is this user an administrator of this group?
19
21
  * `usernames` (array): A list of usernames for users in this group
20
- * `group_id` (int64): Group ID to add user to.
21
- * `user_id` (int64): User ID to add to group.
22
+ * `id` (int64): Group User ID.
22
23
 
23
24
 
24
25
  ---
@@ -36,11 +37,11 @@ Files::GroupUser.list(
36
37
 
37
38
  ### Parameters
38
39
 
39
- * `user_id` (int64): User ID. If provided, will return groups of which this user is a member.
40
+ * `user_id` (int64): User ID. If provided, will return group_users of this user.
40
41
  * `page` (int64): Current page number.
41
42
  * `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
42
43
  * `action` (string): Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
43
- * `group_id` (int64): Group ID. If provided, will return members of this group.
44
+ * `group_id` (int64): Group ID. If provided, will return group_users of this group.
44
45
 
45
46
 
46
47
  ---
@@ -4,7 +4,9 @@
4
4
 
5
5
  ```
6
6
  {
7
- "protocol": "okta",
7
+ "protocol": [
8
+
9
+ ],
8
10
  "provider": "okta",
9
11
  "label": "My Corporate SSO Provider",
10
12
  "logo_url": "https://mysite.files.com/.../logo.png",
@@ -38,13 +40,12 @@
38
40
  "ldap_host_3": "ldap3.site.com",
39
41
  "ldap_port": 1,
40
42
  "ldap_secure": true,
41
- "ldap_user_include_groups": "",
42
43
  "ldap_username": "[ldap username]",
43
44
  "ldap_username_field": "sAMAccountName"
44
45
  }
45
46
  ```
46
47
 
47
- * `protocol` (string): SSO Protocol
48
+ * `protocol` (array): SSO Protocol
48
49
  * `provider` (string): Provider name
49
50
  * `label` (string): Custom label for the SSO provider on the login page.
50
51
  * `logo_url` (string): URL holding a custom logo for the SSO provider on the login page.
@@ -78,7 +79,6 @@
78
79
  * `ldap_host_3` (string): LDAP backup host
79
80
  * `ldap_port` (int64): LDAP port
80
81
  * `ldap_secure` (boolean): Use secure LDAP?
81
- * `ldap_user_include_groups` (string): Comma or newline separated list of group names (with optional wildcards) - if provided, only users in these groups will be added or synced.
82
82
  * `ldap_username` (string): Username for signing in to LDAP server.
83
83
  * `ldap_username_field` (string): LDAP username field
84
84
 
@@ -17,5 +17,5 @@
17
17
  * `code` (int64): Status http code
18
18
  * `message` (string): Error message
19
19
  * `status` (string): Status message
20
- * `data`:
20
+ * `data`: Additional data
21
21
  * `errors` (array): A list of api errors
@@ -132,6 +132,8 @@ Files::User.list(
132
132
  * `q[password_validity_days]` (string): If set, list only users with overridden password validity days setting.
133
133
  * `q[ssl_required]` (string): If set, list only users with overridden SSL required setting.
134
134
  * `search` (string): Searches for partial matches of name, username, or email.
135
+ * `sort_by[last_login_at]` (string): If set, sort users by 'last_login_at' in either 'asc' or 'desc' direction
136
+ * `sort_by[authenticate_until]` (string): If set, sort users by 'authenticate_until' in either 'asc' or 'desc' direction
135
137
 
136
138
 
137
139
  ---
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.add_dependency 'faraday', ">= 1.0.1"
15
15
  s.add_dependency 'net-http-persistent'
16
16
  s.add_dependency 'addressable', ">= 2.7.0"
17
+ s.add_dependency 'concurrent-ruby', ">= 1.1.3"
17
18
 
18
19
  s.files = `find *`.split("\n").uniq.sort.reject(&:empty?)
19
20
  s.executables = [ "files", "files-console" ]
@@ -11,11 +11,13 @@ require "set"
11
11
  require "socket"
12
12
  require "uri"
13
13
  require "addressable/uri"
14
+ require "concurrent/promise"
14
15
 
15
16
  $LOAD_PATH.push __dir__
16
17
 
17
18
  require "files.com/version"
18
19
 
20
+ require "files.com/sizable_io"
19
21
  require "files.com/api"
20
22
  require "files.com/api_client"
21
23
  require "files.com/errors"
@@ -146,13 +146,19 @@ module Files
146
146
 
147
147
  def stream_download(uri, io)
148
148
  if conn.adapter == Faraday::Adapter::NetHttp
149
- remote_request(:get, uri) do |req|
150
- req.options.on_data = proc do |chunk, _overall_received_bytes|
151
- io.write(chunk.encode!)
149
+ uri = URI(uri)
150
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
151
+ request = Net::HTTP::Get.new uri
152
+ http.request request do |response|
153
+ io.fulfill_content_length(response.content_length) if io.respond_to?(:fulfill_content_length)
154
+ response.read_body do |chunk|
155
+ io << chunk.encode!
156
+ end
152
157
  end
153
158
  end
154
159
  else
155
160
  response = remote_request(:get, uri)
161
+ io.fulfill_content_length(response.content_length) if io.respond_to?(:fulfill_content_length)
156
162
  io.write(response.body)
157
163
  end
158
164
  end
@@ -147,6 +147,9 @@ module Files
147
147
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
148
148
 
149
149
  response, options = Api.send_request("/api_keys", :get, params, options)
150
+ response.data.map do |entity_data|
151
+ ApiKey.new(entity_data, options)
152
+ end
150
153
  end
151
154
 
152
155
  def self.all(params = {}, options = {})
@@ -108,6 +108,9 @@ module Files
108
108
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
109
109
 
110
110
  response, options = Api.send_request("/as2_keys", :get, params, options)
111
+ response.data.map do |entity_data|
112
+ As2Key.new(entity_data, options)
113
+ end
111
114
  end
112
115
 
113
116
  def self.all(params = {}, options = {})
@@ -9,7 +9,7 @@ module Files
9
9
  @options = options || {}
10
10
  end
11
11
 
12
- # object - Additional data
12
+ # object
13
13
  def dynamic
14
14
  @attributes[:dynamic]
15
15
  end
@@ -191,6 +191,9 @@ module Files
191
191
  raise InvalidParameterError.new("Bad parameter: automation must be an String") if params.dig(:automation) and !params.dig(:automation).is_a?(String)
192
192
 
193
193
  response, options = Api.send_request("/automations", :get, params, options)
194
+ response.data.map do |entity_data|
195
+ Automation.new(entity_data, options)
196
+ end
194
197
  end
195
198
 
196
199
  def self.all(params = {}, options = {})
@@ -112,6 +112,9 @@ module Files
112
112
  raise InvalidParameterError.new("Bad parameter: behavior must be an String") if params.dig(:behavior) and !params.dig(:behavior).is_a?(String)
113
113
 
114
114
  response, options = Api.send_request("/behaviors", :get, params, options)
115
+ response.data.map do |entity_data|
116
+ Behavior.new(entity_data, options)
117
+ end
115
118
  end
116
119
 
117
120
  def self.all(params = {}, options = {})
@@ -137,6 +140,9 @@ module Files
137
140
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
138
141
 
139
142
  response, options = Api.send_request("/behaviors/folders/#{Addressable::URI.encode_component(params[:path])}", :get, params, options)
143
+ response.data.map do |entity_data|
144
+ Behavior.new(entity_data, options)
145
+ end
140
146
  end
141
147
 
142
148
  # Parameters:
@@ -175,10 +181,14 @@ module Files
175
181
  # url (required) - string - URL for testing the webhook.
176
182
  # method - string - HTTP method(GET or POST).
177
183
  # encoding - string - HTTP encoding method. Can be JSON, XML, or RAW (form data).
184
+ # headers - object - Additional request headers.
185
+ # body - object - Additional body parameters.
178
186
  def self.webhook_test(params = {}, options = {})
179
187
  raise InvalidParameterError.new("Bad parameter: url must be an String") if params.dig(:url) and !params.dig(:url).is_a?(String)
180
188
  raise InvalidParameterError.new("Bad parameter: method must be an String") if params.dig(:method) and !params.dig(:method).is_a?(String)
181
189
  raise InvalidParameterError.new("Bad parameter: encoding must be an String") if params.dig(:encoding) and !params.dig(:encoding).is_a?(String)
190
+ raise InvalidParameterError.new("Bad parameter: headers must be an Hash") if params.dig(:headers) and !params.dig(:headers).is_a?(Hash)
191
+ raise InvalidParameterError.new("Bad parameter: body must be an Hash") if params.dig(:body) and !params.dig(:body).is_a?(Hash)
182
192
  raise MissingParameterError.new("Parameter missing: url") unless params.dig(:url)
183
193
 
184
194
  response, _options = Api.send_request("/behaviors/webhook/test", :post, params, options)
@@ -9,15 +9,6 @@ module Files
9
9
  @options = options || {}
10
10
  end
11
11
 
12
- # int64 - Bundle ID
13
- def id
14
- @attributes[:id]
15
- end
16
-
17
- def id=(value)
18
- @attributes[:id] = value
19
- end
20
-
21
12
  # string - Bundle code. This code forms the end part of the Public URL.
22
13
  def code
23
14
  @attributes[:code]
@@ -27,9 +18,13 @@ module Files
27
18
  @attributes[:code] = value
28
19
  end
29
20
 
30
- # date-time - Bundle created at date/time
31
- def created_at
32
- @attributes[:created_at]
21
+ # string - Public URL of Share Link
22
+ def url
23
+ @attributes[:url]
24
+ end
25
+
26
+ def url=(value)
27
+ @attributes[:url] = value
33
28
  end
34
29
 
35
30
  # string - Public description
@@ -41,49 +36,54 @@ module Files
41
36
  @attributes[:description] = value
42
37
  end
43
38
 
44
- # date-time - Bundle expiration date/time
45
- def expires_at
46
- @attributes[:expires_at]
39
+ # boolean - Is this bundle password protected?
40
+ def password_protected
41
+ @attributes[:password_protected]
47
42
  end
48
43
 
49
- def expires_at=(value)
50
- @attributes[:expires_at] = value
44
+ def password_protected=(value)
45
+ @attributes[:password_protected] = value
51
46
  end
52
47
 
53
- # array - A list of paths in this bundle
54
- def paths
55
- @attributes[:paths]
48
+ # boolean - Show a registration page that captures the downloader's name and email address?
49
+ def require_registration
50
+ @attributes[:require_registration]
56
51
  end
57
52
 
58
- def paths=(value)
59
- @attributes[:paths] = value
53
+ def require_registration=(value)
54
+ @attributes[:require_registration] = value
60
55
  end
61
56
 
62
- # string - Bundle internal note
63
- def note
64
- @attributes[:note]
57
+ # int64 - Bundle ID
58
+ def id
59
+ @attributes[:id]
65
60
  end
66
61
 
67
- def note=(value)
68
- @attributes[:note] = value
62
+ def id=(value)
63
+ @attributes[:id] = value
69
64
  end
70
65
 
71
- # boolean - Is this bundle password protected?
72
- def password_protected
73
- @attributes[:password_protected]
66
+ # date-time - Bundle created at date/time
67
+ def created_at
68
+ @attributes[:created_at]
74
69
  end
75
70
 
76
- def password_protected=(value)
77
- @attributes[:password_protected] = value
71
+ # date-time - Bundle expiration date/time
72
+ def expires_at
73
+ @attributes[:expires_at]
78
74
  end
79
75
 
80
- # string - Public URL of Share Link
81
- def url
82
- @attributes[:url]
76
+ def expires_at=(value)
77
+ @attributes[:expires_at] = value
83
78
  end
84
79
 
85
- def url=(value)
86
- @attributes[:url] = value
80
+ # string - Bundle internal note
81
+ def note
82
+ @attributes[:note]
83
+ end
84
+
85
+ def note=(value)
86
+ @attributes[:note] = value
87
87
  end
88
88
 
89
89
  # int64 - Bundle creator user ID
@@ -104,6 +104,15 @@ module Files
104
104
  @attributes[:username] = value
105
105
  end
106
106
 
107
+ # array - A list of paths in this bundle
108
+ def paths
109
+ @attributes[:paths]
110
+ end
111
+
112
+ def paths=(value)
113
+ @attributes[:paths] = value
114
+ end
115
+
107
116
  # string - Password for this bundle.
108
117
  def password
109
118
  @attributes[:password]
@@ -137,6 +146,7 @@ module Files
137
146
  # description - string - Public description
138
147
  # note - string - Bundle internal note
139
148
  # code - string - Bundle code. This code forms the end part of the Public URL.
149
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
140
150
  def update(params = {})
141
151
  params ||= {}
142
152
  params[:id] = @attributes[:id]
@@ -187,6 +197,9 @@ module Files
187
197
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
188
198
 
189
199
  response, options = Api.send_request("/bundles", :get, params, options)
200
+ response.data.map do |entity_data|
201
+ Bundle.new(entity_data, options)
202
+ end
190
203
  end
191
204
 
192
205
  def self.all(params = {}, options = {})
@@ -217,6 +230,7 @@ module Files
217
230
  # description - string - Public description
218
231
  # note - string - Bundle internal note
219
232
  # code - string - Bundle code. This code forms the end part of the Public URL.
233
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
220
234
  def self.create(params = {}, options = {})
221
235
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
222
236
  raise InvalidParameterError.new("Bad parameter: paths must be an Array") if params.dig(:paths) and !params.dig(:paths).is_a?(Array)
@@ -255,6 +269,7 @@ module Files
255
269
  # description - string - Public description
256
270
  # note - string - Bundle internal note
257
271
  # code - string - Bundle code. This code forms the end part of the Public URL.
272
+ # require_registration - boolean - Show a registration page that captures the downloader's name and email address?
258
273
  def self.update(id, params = {}, options = {})
259
274
  params ||= {}
260
275
  params[:id] = id
@@ -39,6 +39,9 @@ module Files
39
39
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
40
40
 
41
41
  response, options = Api.send_request("/dns_records", :get, params, options)
42
+ response.data.map do |entity_data|
43
+ DnsRecord.new(entity_data, options)
44
+ end
42
45
  end
43
46
 
44
47
  def self.all(params = {}, options = {})
@@ -151,7 +151,8 @@ module Files
151
151
  etags ||= []
152
152
  bytes_written = 0
153
153
  loop do
154
- upload = FileAction.begin_upload(path, { ref: upload&.ref, part: (upload&.part_number || 0) + 1 }, options)
154
+ begin_upload = FileAction.begin_upload(path, { ref: upload&.ref, part: (upload&.part_number || 0) + 1 }, options)
155
+ upload = begin_upload.is_a?(Enumerable) ? begin_upload.first : begin_upload
155
156
  buf = io.read(upload.partsize) || ""
156
157
  bytes_written += buf.length
157
158
  method = upload.http_method.downcase.to_sym
@@ -389,7 +390,7 @@ module Files
389
390
 
390
391
  def read_io
391
392
  @read_io ||= begin
392
- r, w = IO.pipe
393
+ r, w = SizableIO.pipe
393
394
  Thread.new do
394
395
  download_content(w)
395
396
  ensure
@@ -97,6 +97,9 @@ module Files
97
97
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
98
98
 
99
99
  response, options = Api.send_request("/file_comments/files/#{Addressable::URI.encode_component(params[:path])}", :get, params, options)
100
+ response.data.map do |entity_data|
101
+ FileComment.new(entity_data, options)
102
+ end
100
103
  end
101
104
 
102
105
  # Parameters:
@@ -117,6 +117,9 @@ module Files
117
117
  raise InvalidParameterError.new("Bad parameter: ids must be an String") if params.dig(:ids) and !params.dig(:ids).is_a?(String)
118
118
 
119
119
  response, options = Api.send_request("/groups", :get, params, options)
120
+ response.data.map do |entity_data|
121
+ Group.new(entity_data, options)
122
+ end
120
123
  end
121
124
 
122
125
  def self.all(params = {}, options = {})
@@ -10,21 +10,30 @@ module Files
10
10
  end
11
11
 
12
12
  # string - Group name
13
- def name
14
- @attributes[:name]
13
+ def group_name
14
+ @attributes[:group_name]
15
15
  end
16
16
 
17
- def name=(value)
18
- @attributes[:name] = value
17
+ def group_name=(value)
18
+ @attributes[:group_name] = value
19
19
  end
20
20
 
21
21
  # int64 - Group ID
22
- def id
23
- @attributes[:id]
22
+ def group_id
23
+ @attributes[:group_id]
24
24
  end
25
25
 
26
- def id=(value)
27
- @attributes[:id] = value
26
+ def group_id=(value)
27
+ @attributes[:group_id] = value
28
+ end
29
+
30
+ # int64 - User ID
31
+ def user_id
32
+ @attributes[:user_id]
33
+ end
34
+
35
+ def user_id=(value)
36
+ @attributes[:user_id] = value
28
37
  end
29
38
 
30
39
  # boolean - Is this user an administrator of this group?
@@ -45,22 +54,13 @@ module Files
45
54
  @attributes[:usernames] = value
46
55
  end
47
56
 
48
- # int64 - Group ID to add user to.
49
- def group_id
50
- @attributes[:group_id]
51
- end
52
-
53
- def group_id=(value)
54
- @attributes[:group_id] = value
55
- end
56
-
57
- # int64 - User ID to add to group.
58
- def user_id
59
- @attributes[:user_id]
57
+ # int64 - Group User ID.
58
+ def id
59
+ @attributes[:id]
60
60
  end
61
61
 
62
- def user_id=(value)
63
- @attributes[:user_id] = value
62
+ def id=(value)
63
+ @attributes[:id] = value
64
64
  end
65
65
 
66
66
  # Parameters:
@@ -100,11 +100,11 @@ module Files
100
100
  end
101
101
 
102
102
  # Parameters:
103
- # user_id - int64 - User ID. If provided, will return groups of which this user is a member.
103
+ # user_id - int64 - User ID. If provided, will return group_users of this user.
104
104
  # page - int64 - Current page number.
105
105
  # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
106
106
  # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
107
- # group_id - int64 - Group ID. If provided, will return members of this group.
107
+ # group_id - int64 - Group ID. If provided, will return group_users of this group.
108
108
  def self.list(params = {}, options = {})
109
109
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
110
110
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
@@ -113,6 +113,9 @@ module Files
113
113
  raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer)
114
114
 
115
115
  response, options = Api.send_request("/group_users", :get, params, options)
116
+ response.data.map do |entity_data|
117
+ GroupUser.new(entity_data, options)
118
+ end
116
119
  end
117
120
 
118
121
  def self.all(params = {}, options = {})
@@ -95,6 +95,9 @@ module Files
95
95
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
96
96
 
97
97
  response, options = Api.send_request("/history/files(/*path)", :get, params, options)
98
+ response.data.map do |entity_data|
99
+ Action.new(entity_data, options)
100
+ end
98
101
  end
99
102
 
100
103
  # Parameters:
@@ -118,6 +121,9 @@ module Files
118
121
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
119
122
 
120
123
  response, options = Api.send_request("/history/folders(/*path)", :get, params, options)
124
+ response.data.map do |entity_data|
125
+ Action.new(entity_data, options)
126
+ end
121
127
  end
122
128
 
123
129
  # Parameters:
@@ -141,6 +147,9 @@ module Files
141
147
  raise MissingParameterError.new("Parameter missing: user_id") unless params.dig(:user_id)
142
148
 
143
149
  response, options = Api.send_request("/history/users/#{params[:user_id]}", :get, params, options)
150
+ response.data.map do |entity_data|
151
+ Action.new(entity_data, options)
152
+ end
144
153
  end
145
154
 
146
155
  # Parameters:
@@ -159,6 +168,9 @@ module Files
159
168
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
160
169
 
161
170
  response, options = Api.send_request("/history/login", :get, params, options)
171
+ response.data.map do |entity_data|
172
+ Action.new(entity_data, options)
173
+ end
162
174
  end
163
175
 
164
176
  # Parameters:
@@ -177,6 +189,9 @@ module Files
177
189
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
178
190
 
179
191
  response, options = Api.send_request("/history", :get, params, options)
192
+ response.data.map do |entity_data|
193
+ Action.new(entity_data, options)
194
+ end
180
195
  end
181
196
 
182
197
  def self.all(params = {}, options = {})
@@ -260,6 +260,9 @@ module Files
260
260
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
261
261
 
262
262
  response, options = Api.send_request("/history_exports", :get, params, options)
263
+ response.data.map do |entity_data|
264
+ HistoryExport.new(entity_data, options)
265
+ end
263
266
  end
264
267
 
265
268
  def self.all(params = {}, options = {})
@@ -89,6 +89,9 @@ module Files
89
89
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
90
90
 
91
91
  response, options = Api.send_request("/invoices", :get, params, options)
92
+ response.data.map do |entity_data|
93
+ AccountLineItem.new(entity_data, options)
94
+ end
92
95
  end
93
96
 
94
97
  def self.all(params = {}, options = {})
@@ -39,6 +39,9 @@ module Files
39
39
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
40
40
 
41
41
  response, options = Api.send_request("/ip_addresses", :get, params, options)
42
+ response.data.map do |entity_data|
43
+ IpAddress.new(entity_data, options)
44
+ end
42
45
  end
43
46
 
44
47
  def self.all(params = {}, options = {})
@@ -133,6 +133,9 @@ module Files
133
133
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
134
134
 
135
135
  response, options = Api.send_request("/locks/#{Addressable::URI.encode_component(params[:path])}", :get, params, options)
136
+ response.data.map do |entity_data|
137
+ Lock.new(entity_data, options)
138
+ end
136
139
  end
137
140
 
138
141
  # Parameters:
@@ -121,6 +121,9 @@ module Files
121
121
  raise MissingParameterError.new("Parameter missing: project_id") unless params.dig(:project_id)
122
122
 
123
123
  response, options = Api.send_request("/messages", :get, params, options)
124
+ response.data.map do |entity_data|
125
+ Message.new(entity_data, options)
126
+ end
124
127
  end
125
128
 
126
129
  def self.all(params = {}, options = {})
@@ -97,6 +97,9 @@ module Files
97
97
  raise MissingParameterError.new("Parameter missing: message_id") unless params.dig(:message_id)
98
98
 
99
99
  response, options = Api.send_request("/message_comments", :get, params, options)
100
+ response.data.map do |entity_data|
101
+ MessageComment.new(entity_data, options)
102
+ end
100
103
  end
101
104
 
102
105
  def self.all(params = {}, options = {})
@@ -74,6 +74,9 @@ module Files
74
74
  raise MissingParameterError.new("Parameter missing: message_comment_id") unless params.dig(:message_comment_id)
75
75
 
76
76
  response, options = Api.send_request("/message_comment_reactions", :get, params, options)
77
+ response.data.map do |entity_data|
78
+ MessageCommentReaction.new(entity_data, options)
79
+ end
77
80
  end
78
81
 
79
82
  def self.all(params = {}, options = {})
@@ -74,6 +74,9 @@ module Files
74
74
  raise MissingParameterError.new("Parameter missing: message_id") unless params.dig(:message_id)
75
75
 
76
76
  response, options = Api.send_request("/message_reactions", :get, params, options)
77
+ response.data.map do |entity_data|
78
+ MessageReaction.new(entity_data, options)
79
+ end
77
80
  end
78
81
 
79
82
  def self.all(params = {}, options = {})
@@ -172,6 +172,9 @@ module Files
172
172
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
173
173
 
174
174
  response, options = Api.send_request("/notifications", :get, params, options)
175
+ response.data.map do |entity_data|
176
+ Notification.new(entity_data, options)
177
+ end
175
178
  end
176
179
 
177
180
  def self.all(params = {}, options = {})
@@ -89,6 +89,9 @@ module Files
89
89
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
90
90
 
91
91
  response, options = Api.send_request("/payments", :get, params, options)
92
+ response.data.map do |entity_data|
93
+ AccountLineItem.new(entity_data, options)
94
+ end
92
95
  end
93
96
 
94
97
  def self.all(params = {}, options = {})
@@ -109,6 +109,9 @@ module Files
109
109
  raise InvalidParameterError.new("Bad parameter: user_id must be an String") if params.dig(:user_id) and !params.dig(:user_id).is_a?(String)
110
110
 
111
111
  response, options = Api.send_request("/permissions", :get, params, options)
112
+ response.data.map do |entity_data|
113
+ Permission.new(entity_data, options)
114
+ end
112
115
  end
113
116
 
114
117
  def self.all(path, params = {}, options = {})
@@ -74,6 +74,9 @@ module Files
74
74
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
75
75
 
76
76
  response, options = Api.send_request("/projects", :get, params, options)
77
+ response.data.map do |entity_data|
78
+ Project.new(entity_data, options)
79
+ end
77
80
  end
78
81
 
79
82
  def self.all(params = {}, options = {})
@@ -108,6 +108,9 @@ module Files
108
108
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
109
109
 
110
110
  response, options = Api.send_request("/public_keys", :get, params, options)
111
+ response.data.map do |entity_data|
112
+ PublicKey.new(entity_data, options)
113
+ end
111
114
  end
112
115
 
113
116
  def self.all(params = {}, options = {})
@@ -357,6 +357,9 @@ module Files
357
357
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
358
358
 
359
359
  response, options = Api.send_request("/remote_servers", :get, params, options)
360
+ response.data.map do |entity_data|
361
+ RemoteServer.new(entity_data, options)
362
+ end
360
363
  end
361
364
 
362
365
  def self.all(params = {}, options = {})
@@ -124,6 +124,9 @@ module Files
124
124
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
125
125
 
126
126
  response, options = Api.send_request("/requests", :get, params, options)
127
+ response.data.map do |entity_data|
128
+ Request.new(entity_data, options)
129
+ end
127
130
  end
128
131
 
129
132
  def self.all(path, params = {}, options = {})
@@ -146,6 +149,9 @@ module Files
146
149
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
147
150
 
148
151
  response, options = Api.send_request("/requests/folders/#{Addressable::URI.encode_component(params[:path])}", :get, params, options)
152
+ response.data.map do |entity_data|
153
+ Request.new(entity_data, options)
154
+ end
149
155
  end
150
156
 
151
157
  # Parameters:
@@ -9,7 +9,7 @@ module Files
9
9
  @options = options || {}
10
10
  end
11
11
 
12
- # string - SSO Protocol
12
+ # array - SSO Protocol
13
13
  def protocol
14
14
  @attributes[:protocol]
15
15
  end
@@ -179,11 +179,6 @@ module Files
179
179
  @attributes[:ldap_secure]
180
180
  end
181
181
 
182
- # string - Comma or newline separated list of group names (with optional wildcards) - if provided, only users in these groups will be added or synced.
183
- def ldap_user_include_groups
184
- @attributes[:ldap_user_include_groups]
185
- end
186
-
187
182
  # string - Username for signing in to LDAP server.
188
183
  def ldap_username
189
184
  @attributes[:ldap_username]
@@ -204,6 +199,9 @@ module Files
204
199
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
205
200
 
206
201
  response, options = Api.send_request("/sso_strategies", :get, params, options)
202
+ response.data.map do |entity_data|
203
+ SsoStrategy.new(entity_data, options)
204
+ end
207
205
  end
208
206
 
209
207
  def self.all(params = {}, options = {})
@@ -24,6 +24,7 @@ module Files
24
24
  @attributes[:status]
25
25
  end
26
26
 
27
+ # Additional data
27
28
  def data
28
29
  @attributes[:data]
29
30
  end
@@ -39,6 +39,9 @@ module Files
39
39
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
40
40
 
41
41
  response, options = Api.send_request("/usage_daily_snapshots", :get, params, options)
42
+ response.data.map do |entity_data|
43
+ UsageDailySnapshot.new(entity_data, options)
44
+ end
42
45
  end
43
46
 
44
47
  def self.all(params = {}, options = {})
@@ -84,6 +84,9 @@ module Files
84
84
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
85
85
 
86
86
  response, options = Api.send_request("/usage_snapshots", :get, params, options)
87
+ response.data.map do |entity_data|
88
+ UsageSnapshot.new(entity_data, options)
89
+ end
87
90
  end
88
91
 
89
92
  def self.all(params = {}, options = {})
@@ -612,6 +612,8 @@ module Files
612
612
  # q[password_validity_days] - string - If set, list only users with overridden password validity days setting.
613
613
  # q[ssl_required] - string - If set, list only users with overridden SSL required setting.
614
614
  # search - string - Searches for partial matches of name, username, or email.
615
+ # sort_by[last_login_at] - string - If set, sort users by 'last_login_at' in either 'asc' or 'desc' direction
616
+ # sort_by[authenticate_until] - string - If set, sort users by 'authenticate_until' in either 'asc' or 'desc' direction
615
617
  def self.list(params = {}, options = {})
616
618
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
617
619
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
@@ -619,6 +621,9 @@ module Files
619
621
  raise InvalidParameterError.new("Bad parameter: search must be an String") if params.dig(:search) and !params.dig(:search).is_a?(String)
620
622
 
621
623
  response, options = Api.send_request("/users", :get, params, options)
624
+ response.data.map do |entity_data|
625
+ User.new(entity_data, options)
626
+ end
622
627
  end
623
628
 
624
629
  def self.all(params = {}, options = {})
@@ -51,6 +51,9 @@ module Files
51
51
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
52
52
 
53
53
  response, options = Api.send_request("/user_cipher_uses", :get, params, options)
54
+ response.data.map do |entity_data|
55
+ UserCipherUse.new(entity_data, options)
56
+ end
54
57
  end
55
58
 
56
59
  def self.all(params = {}, options = {})
@@ -0,0 +1,32 @@
1
+ module Files
2
+ class SizableIO < IO
3
+ def self.pipe
4
+ r, w = super
5
+
6
+ w.instance_variable_set(:@read_io, r)
7
+
8
+ [r, w]
9
+ end
10
+
11
+ def size
12
+ read_io.content_length_promise.wait.value
13
+ end
14
+
15
+ def fulfill_content_length(length)
16
+ read_io.content_length = length
17
+ read_io.content_length_promise.execute
18
+ end
19
+
20
+ protected
21
+
22
+ attr_accessor :content_length
23
+
24
+ def content_length_promise
25
+ @content_length_promise ||= Concurrent::Promise.new { content_length }
26
+ end
27
+
28
+ def read_io
29
+ @read_io || self
30
+ end
31
+ end
32
+ end
@@ -24,8 +24,9 @@ RSpec.describe Files::File, :with_test_folder do
24
24
 
25
25
  it "returns an IO Object" do
26
26
  file = Files::File.find(test_folder.join("read.txt").to_s, {}, options)
27
- expect(file.read_io.class).to eq(IO)
27
+ expect(file.read_io).to be_a_kind_of(IO)
28
28
  expect(file.read_io.read).to eq("contents")
29
+ expect(file.read_io.size).to eq("contents".length)
29
30
  end
30
31
  end
31
32
 
@@ -27,6 +27,7 @@ RSpec.configure do |config|
27
27
  Files::Folder.mkdir("files_regional_worker", {}, api_key: @api_key) unless Files::Folder.exist?("files_regional_worker", api_key: @api_key)
28
28
  Files::Folder.mkdir(@test_folder.to_s, {}, api_key: @api_key)
29
29
  all.run
30
+ ensure
30
31
  Files::Folder.delete(@test_folder.to_s, { recursive: true }, api_key: @api_key)
31
32
  end
32
33
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: files.com
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.65
4
+ version: 1.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - files.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.7.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: concurrent-ruby
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.1.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.1.3
55
69
  description: The Files.com Ruby client.
56
70
  email:
57
71
  - support@files.com
@@ -173,6 +187,7 @@ files:
173
187
  - lib/files.com/models/user.rb
174
188
  - lib/files.com/models/user_cipher_use.rb
175
189
  - lib/files.com/response.rb
190
+ - lib/files.com/sizable_io.rb
176
191
  - lib/files.com/system_profiler.rb
177
192
  - lib/files.com/util.rb
178
193
  - lib/files.com/version.rb