brick_ftp 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/brick_ftp.gemspec +1 -0
- data/lib/brick_ftp.rb +19 -0
- data/lib/brick_ftp/api/authentication.rb +7 -0
- data/lib/brick_ftp/api/file_upload.rb +4 -4
- data/lib/brick_ftp/api/history.rb +1 -1
- data/lib/brick_ftp/client.rb +352 -3
- data/lib/brick_ftp/configuration.rb +10 -0
- data/lib/brick_ftp/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b3bf69a33bce75c836d9f0a892647127e9a52d8
|
4
|
+
data.tar.gz: ac40a241fa853a76d0b156de3d7a5946c00f037d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39d59472f0eee719336531c6f79dad2605d426690452f01875036020c45f990e919674351b807f3794f817c023efa498c888aadac7ddd70f6357c214dcbfd209
|
7
|
+
data.tar.gz: 3512bd4ce61bdcfe14cfca362bbd437f02be765b07aeae1db6e7fff0d7096c0077f90838780ccb13e31f37483739071f948172e566847f936bcd59a944edf73c
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ BrickFTP::API::Authentication.login('koshigoe', 'password')
|
|
47
47
|
|
48
48
|
### Other APIs
|
49
49
|
|
50
|
-
see API document or source code.
|
50
|
+
see [API document](http://www.rubydoc.info/github/koshigoe/brick_ftp/master) or source code.
|
51
51
|
|
52
52
|
## Development
|
53
53
|
|
@@ -57,5 +57,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
57
57
|
|
58
58
|
## Contributing
|
59
59
|
|
60
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
60
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/koshigoe/brick_ftp.
|
61
61
|
|
data/brick_ftp.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
spec.add_development_dependency "webmock", "~> 2.1"
|
25
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
25
26
|
|
26
27
|
spec.add_dependency 'deep_hash_transform', '~> 1.0'
|
27
28
|
end
|
data/lib/brick_ftp.rb
CHANGED
@@ -2,6 +2,7 @@ require 'deep_hash_transform'
|
|
2
2
|
require "brick_ftp/version"
|
3
3
|
require 'brick_ftp/configuration'
|
4
4
|
require 'brick_ftp/http_client'
|
5
|
+
require 'brick_ftp/client'
|
5
6
|
require 'brick_ftp/api'
|
6
7
|
require 'brick_ftp/api/base'
|
7
8
|
require 'brick_ftp/api/authentication'
|
@@ -29,15 +30,33 @@ require 'brick_ftp/api/file_copy'
|
|
29
30
|
require 'brick_ftp/api/file_upload'
|
30
31
|
|
31
32
|
module BrickFTP
|
33
|
+
# Return configuration.
|
34
|
+
# If it has not been configured yet, initialize configuration.
|
35
|
+
# @return [BrickFTP::Configuration] configuration object.
|
32
36
|
def self.config
|
33
37
|
@config ||= BrickFTP::Configuration.new
|
34
38
|
end
|
35
39
|
|
40
|
+
# Set configuration.
|
41
|
+
#
|
42
|
+
# @param config [BrickFTP::Configuration] configuration object.
|
43
|
+
# @return [BrickFTP::Configuration] configuration object.
|
36
44
|
def self.config=(config)
|
37
45
|
raise TypeError unless config.is_a?(BrickFTP::Configuration)
|
38
46
|
@config = config
|
39
47
|
end
|
40
48
|
|
49
|
+
# Configure some settings.
|
50
|
+
#
|
51
|
+
# @yield [config] Given configuration object.
|
52
|
+
# @yieldparam config [BrickFTP::Configuration] configuration object.
|
53
|
+
#
|
54
|
+
# @example
|
55
|
+
# BrickFTP.configure do |c|
|
56
|
+
# c.subdomain = 'koshigoe'
|
57
|
+
# c.api_key = 'xxxxxxxxxx'
|
58
|
+
# end
|
59
|
+
#
|
41
60
|
def self.configure
|
42
61
|
yield(config)
|
43
62
|
end
|
@@ -5,14 +5,21 @@ module BrickFTP
|
|
5
5
|
module Authentication
|
6
6
|
COOKIE_NAME = 'BrickFTP'.freeze
|
7
7
|
|
8
|
+
# Generate authentication cookie.
|
9
|
+
# @param session [BrickFTP::API::Authentication::Session] authentication session object.
|
10
|
+
# @return [CGI::Cookie] authentication cookie.
|
8
11
|
def self.cookie(session)
|
9
12
|
CGI::Cookie.new(COOKIE_NAME, session.id)
|
10
13
|
end
|
11
14
|
|
15
|
+
# Alias for `BrickFTP::API::Authentication::Session.create`.
|
16
|
+
# @param username [String] username of BrickFTP's user.
|
17
|
+
# @param password [String] password of BrickFTP's user.
|
12
18
|
def self.login(username, password)
|
13
19
|
Session.create(username: username, password: password)
|
14
20
|
end
|
15
21
|
|
22
|
+
# Alias for `BrickFTP::API::Authentication::Session#destroy`.
|
16
23
|
def self.logout
|
17
24
|
BrickFTP.config.session.destroy
|
18
25
|
end
|
@@ -26,15 +26,15 @@ module BrickFTP
|
|
26
26
|
:provided_mtime,
|
27
27
|
:permissions
|
28
28
|
|
29
|
-
def self.create(
|
29
|
+
def self.create(path: , source:)
|
30
30
|
api_client = BrickFTP::HTTPClient.new
|
31
|
-
step1 = api_client.post(api_path_for(:create,
|
31
|
+
step1 = api_client.post(api_path_for(:create, path: path), params: { action: 'put' })
|
32
32
|
|
33
33
|
upload_uri = URI.parse(step1['upload_uri'])
|
34
34
|
upload_client = BrickFTP::HTTPClient.new(upload_uri.host)
|
35
|
-
upload_client.put(step1['upload_uri'], params:
|
35
|
+
upload_client.put(step1['upload_uri'], params: source)
|
36
36
|
|
37
|
-
step3 = api_client.post(api_path_for(:create,
|
37
|
+
step3 = api_client.post(api_path_for(:create, path: path), params: { action: 'end', ref: step1['ref'] })
|
38
38
|
|
39
39
|
new(step1.merge(step3).symbolize_keys)
|
40
40
|
end
|
data/lib/brick_ftp/client.rb
CHANGED
@@ -1,9 +1,358 @@
|
|
1
1
|
module BrickFTP
|
2
2
|
class Client
|
3
|
-
|
3
|
+
# Login and store authentication session.
|
4
|
+
# @see https://brickftp.com/ja/docs/rest-api/authentication/
|
5
|
+
# @param username [String] username of BrickFTP's user.
|
6
|
+
# @param password [String] password of BrickFTP's user.
|
7
|
+
def login(username, password)
|
8
|
+
BrickFTP::API::Authentication.login(username, password)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Logout and discard authentication session.
|
12
|
+
# @see https://brickftp.com/ja/docs/rest-api/authentication/
|
13
|
+
def logout
|
14
|
+
BrickFTP::API::Authentication.logout
|
15
|
+
end
|
16
|
+
|
17
|
+
# List all users on the current site.
|
18
|
+
# @see https://brickftp.com/ja/docs/rest-api/users/
|
19
|
+
# @return [Array] array of BrickFTP::API::User
|
20
|
+
def list_users
|
21
|
+
BrickFTP::API::User.all
|
22
|
+
end
|
23
|
+
|
24
|
+
# Show a single user.
|
25
|
+
# @see https://brickftp.com/ja/docs/rest-api/users/
|
26
|
+
# @param id user id.
|
27
|
+
# @return [BrickFTP::API::User] user object.
|
28
|
+
def show_user(id)
|
29
|
+
BrickFTP::API::User.find(id)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a new user on the current site.
|
33
|
+
# @see https://brickftp.com/ja/docs/rest-api/users/
|
34
|
+
# @param attributes [Hash] User's attributes.
|
35
|
+
def create_user(attributes)
|
36
|
+
BrickFTP::API::User.create(attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Update an existing user.
|
40
|
+
# @see https://brickftp.com/ja/docs/rest-api/users/
|
41
|
+
# @param user [BrickFTP::API::User] user object.
|
42
|
+
# @param attributes [Hash] User's attributes.
|
43
|
+
# @return [BrickFTP::API::User] user object.
|
44
|
+
def update_user(user, attributes)
|
45
|
+
user.update(attributes)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Delete a user.
|
49
|
+
# @see https://brickftp.com/ja/docs/rest-api/users/
|
50
|
+
# @param user [BrickFTP::API::User] user object.
|
51
|
+
# @return [Boolean] return true.
|
52
|
+
def delete_user(user)
|
53
|
+
user.destroy
|
54
|
+
end
|
55
|
+
|
56
|
+
# List all groups on the current site.
|
57
|
+
# @see https://brickftp.com/ja/docs/rest-api/groups/
|
58
|
+
def list_groups
|
59
|
+
BrickFTP::API::Group.all
|
60
|
+
end
|
61
|
+
|
62
|
+
# Show a single group.
|
63
|
+
# @see https://brickftp.com/ja/docs/rest-api/groups/
|
64
|
+
# @param id group id.
|
65
|
+
# @return [BrickFTP::API::Group] group object.
|
66
|
+
def show_group(id)
|
67
|
+
BrickFTP::API::Group.find(id)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Create a new group on the current site.
|
71
|
+
# @see https://brickftp.com/ja/docs/rest-api/groups/
|
72
|
+
# @param attributes [Hash] Group's attributes.
|
73
|
+
def create_group(attributes)
|
74
|
+
BrickFTP::API::Group.create(attributes)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Update an existing group.
|
78
|
+
# @see https://brickftp.com/ja/docs/rest-api/groups/
|
79
|
+
# @param group [BrickFTP::API::Group] group object.
|
80
|
+
# @param attributes [Hash] Group's attributes.
|
81
|
+
# @return [BrickFTP::API::Group] group object.
|
82
|
+
def update_group(group, attributes)
|
83
|
+
group.update(attributes)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Delete a group.
|
87
|
+
# @see https://brickftp.com/ja/docs/rest-api/groups/
|
88
|
+
# @param group [BrickFTP::API::Group] group object.
|
89
|
+
# @return [Boolean] return true.
|
90
|
+
def delete_group(group)
|
91
|
+
group.destroy
|
92
|
+
end
|
93
|
+
|
94
|
+
# List all permissions on the current site.
|
95
|
+
# @see https://brickftp.com/ja/docs/rest-api/permissions/
|
96
|
+
def list_permissions
|
97
|
+
BrickFTP::API::Permission.all
|
98
|
+
end
|
99
|
+
|
100
|
+
# Create a new permission on the current site.
|
101
|
+
# @see https://brickftp.com/ja/docs/rest-api/permissions/
|
102
|
+
# @param attributes [Hash] Permission's attributes.
|
103
|
+
def create_permission(attributes)
|
104
|
+
BrickFTP::API::Permission.create(attributes)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Delete a permission.
|
108
|
+
# @see https://brickftp.com/ja/docs/rest-api/permissions/
|
109
|
+
# @param permission [BrickFTP::API::Permission] permission object.
|
110
|
+
# @return [Boolean] return true.
|
111
|
+
def delete_permission(permission)
|
112
|
+
permission.destroy
|
113
|
+
end
|
114
|
+
|
115
|
+
# List all notifications on the current site.
|
116
|
+
# @see https://brickftp.com/ja/docs/rest-api/notifications/
|
117
|
+
def list_notifications
|
118
|
+
BrickFTP::API::Notification.all
|
119
|
+
end
|
120
|
+
|
121
|
+
# Create a new notification on the current site.
|
122
|
+
# @see https://brickftp.com/ja/docs/rest-api/notifications/
|
123
|
+
# @param attributes [Hash] Notification's attributes.
|
124
|
+
def create_notification(attributes)
|
125
|
+
BrickFTP::API::Notification.create(attributes)
|
126
|
+
end
|
127
|
+
|
128
|
+
# Delete a notification.
|
129
|
+
# @see https://brickftp.com/ja/docs/rest-api/notifications/
|
130
|
+
# @param notification [BrickFTP::API::Notification] notification object.
|
131
|
+
# @return [Boolean] return true.
|
132
|
+
def delete_notification(notification)
|
133
|
+
notification.destroy
|
134
|
+
end
|
135
|
+
|
136
|
+
# Show the entire history for the current site.
|
137
|
+
# @see https://brickftp.com/ja/docs/rest-api/history/
|
138
|
+
# @param page [Integer] Page number of items to return in this request.
|
139
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
140
|
+
# @param start_at [String] Date and time in the history to start from.
|
141
|
+
# @return [Array] array of `BrickFTP::API::History::Site`
|
142
|
+
def list_site_history(page: nil, per_page: nil, start_at: nil)
|
143
|
+
query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }
|
144
|
+
BrickFTP::API::History::Site.all(query)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Show login history only.
|
148
|
+
# @see https://brickftp.com/ja/docs/rest-api/history/
|
149
|
+
# @param page [Integer] Page number of items to return in this request.
|
150
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
151
|
+
# @param start_at [String] Date and time in the history to start from.
|
152
|
+
# @return [Array] array of `BrickFTP::API::History::Login`
|
153
|
+
def list_login_history(page: nil, per_page: nil, start_at: nil)
|
154
|
+
query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }
|
155
|
+
BrickFTP::API::History::Login.all(query)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Show all history for a specific user.
|
159
|
+
# @see https://brickftp.com/ja/docs/rest-api/history/
|
160
|
+
# @param page [Integer] Page number of items to return in this request.
|
161
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
162
|
+
# @param start_at [String] Date and time in the history to start from.
|
163
|
+
# @return [Array] array of `BrickFTP::API::History::User`
|
164
|
+
def list_user_history(page: nil, per_page: nil, start_at: nil)
|
165
|
+
query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }
|
166
|
+
BrickFTP::API::History::User.all(query)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Show all history for a specific folder.
|
170
|
+
# @see https://brickftp.com/ja/docs/rest-api/history/
|
171
|
+
# @param path [String] path of folder.
|
172
|
+
# @param page [Integer] Page number of items to return in this request.
|
173
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
174
|
+
# @param start_at [String] Date and time in the history to start from.
|
175
|
+
# @return [Array] array of `BrickFTP::API::History::Folder`
|
176
|
+
def list_folder_history(path:, page: nil, per_page: nil, start_at: nil)
|
177
|
+
query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }
|
178
|
+
BrickFTP::API::History::Folder.all(query)
|
179
|
+
end
|
180
|
+
|
181
|
+
# Show all history for a specific file.
|
182
|
+
# @see https://brickftp.com/ja/docs/rest-api/history/
|
183
|
+
# @param path [String] path of file.
|
184
|
+
# @param page [Integer] Page number of items to return in this request.
|
185
|
+
# @param per_page [Integer] Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
|
186
|
+
# @param start_at [String] Date and time in the history to start from.
|
187
|
+
# @return [Array] array of `BrickFTP::API::History::File`
|
188
|
+
def list_file_history(path:, page: nil, per_page: nil, start_at: nil)
|
189
|
+
query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }
|
190
|
+
BrickFTP::API::History::File.all(query)
|
191
|
+
end
|
192
|
+
|
193
|
+
# List all bundles on the current site.
|
194
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
195
|
+
# @return [Array] array of BrickFTP::API::Bundle
|
196
|
+
def list_bundles
|
197
|
+
BrickFTP::API::Bundle.all
|
198
|
+
end
|
199
|
+
|
200
|
+
# Show a single bundle.
|
201
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
202
|
+
# @param id bundle id.
|
203
|
+
# @return [BrickFTP::API::Bundle] bundle object.
|
204
|
+
def show_bundle(id)
|
205
|
+
BrickFTP::API::Bundle.find(id)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Create a new bundle on the current site.
|
209
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
210
|
+
# @param attributes [Hash] Bundle's attributes.
|
211
|
+
def create_bundle(attributes)
|
212
|
+
BrickFTP::API::Bundle.create(attributes)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Delete a bundle.
|
216
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
217
|
+
# @param bundle [BrickFTP::API::Bundle] bundle object.
|
218
|
+
# @return [Boolean] return true.
|
219
|
+
def delete_bundle(bundle)
|
220
|
+
bundle.destroy
|
221
|
+
end
|
222
|
+
|
223
|
+
# List the contents of a bundle.
|
224
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
225
|
+
# @param path [String]
|
226
|
+
# @param code [String]
|
227
|
+
# @param host [String]
|
228
|
+
# @return [Array] array of `BrickFTP::API::BundleContent`.
|
229
|
+
def list_bundle_contents(path: nil, code:, host:)
|
230
|
+
BrickFTP::API::BundleContent.all(path: path, code: code, host: host)
|
231
|
+
end
|
232
|
+
|
233
|
+
# Provides download URLs that will enable you to download the files in a bundle.
|
234
|
+
# @see https://brickftp.com/ja/docs/rest-api/bundles/
|
235
|
+
# @param code [String]
|
236
|
+
# @param host [String]
|
237
|
+
# @param paths [Array] array of path string.
|
238
|
+
# @return [Array] array of `BrickFTP::API::BundleDownload`.
|
239
|
+
def list_bundle_downloads(code:, host:, paths: [])
|
240
|
+
BrickFTP::API::BundleDownload.all(code: code, host: host, paths: paths)
|
241
|
+
end
|
242
|
+
|
243
|
+
# List all behaviors on the current site.
|
244
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
245
|
+
# @return [Array] array of BrickFTP::API::Behavior
|
246
|
+
def list_behaviors
|
247
|
+
BrickFTP::API::Behavior.all
|
248
|
+
end
|
249
|
+
|
250
|
+
# Show a single behavior.
|
251
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
252
|
+
# @param id behavior id.
|
253
|
+
# @return [BrickFTP::API::Behavior] behavior object.
|
254
|
+
def show_behavior(id)
|
255
|
+
BrickFTP::API::Behavior.find(id)
|
256
|
+
end
|
257
|
+
|
258
|
+
# Create a new behavior on the current site.
|
259
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
260
|
+
# @param attributes [Hash] Behavior's attributes.
|
261
|
+
def create_behavior(attributes)
|
262
|
+
BrickFTP::API::Behavior.create(attributes)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Update an existing behavior.
|
266
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
267
|
+
# @param behavior [BrickFTP::API::Behavior] behavior object.
|
268
|
+
# @param attributes [Hash] Behavior's attributes.
|
269
|
+
# @return [BrickFTP::API::Behavior] behavior object.
|
270
|
+
def update_behavior(behavior, attributes)
|
271
|
+
behavior.update(attributes)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Delete a behavior.
|
275
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
276
|
+
# @param behavior [BrickFTP::API::Behavior] behavior object.
|
277
|
+
# @return [Boolean] return true.
|
278
|
+
def delete_behavior(behavior)
|
279
|
+
behavior.destroy
|
280
|
+
end
|
281
|
+
|
282
|
+
# shows the behaviors that apply to the given path.
|
283
|
+
# @see https://brickftp.com/ja/docs/rest-api/behaviors/
|
284
|
+
# @return [Array] array of BrickFTP::API::BehaviorFolder
|
285
|
+
def list_folder_behaviors(path:)
|
286
|
+
BrickFTP::API::BehaviorFolder.all(path: path)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Lists the contents of the folder provided in the URL.
|
290
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
291
|
+
# @param path [String]
|
292
|
+
# @param page [Integer] Page number of items to return in this request.
|
293
|
+
# @param per_page [Integer] Requested number of items returned per request. Maximum: 5000, leave blank for default (strongly recommended).
|
294
|
+
# @param search [String] Only return items matching the given search text.
|
295
|
+
# @param sort_by_path [String] Sort by file name, and value is either asc or desc to indicate normal or reverse sort. (Note that sort_by[path] = asc is the default.)
|
296
|
+
# @param sort_by_size [String] Sort by file size, and value is either asc or desc to indicate smaller files first or larger files first, respectively.
|
297
|
+
# @param sort_by_modified_at_datetime [String] Sort by modification time, and value is either asc or desc to indicate older files first or newer files first, respectively.
|
298
|
+
# @return [Array] array of BrickFTP::API::Folder.
|
299
|
+
def list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil)
|
300
|
+
query = { path: path, page: page, per_page: per_page, search: search }.reject { |_, v| v.nil? }
|
301
|
+
query[:'sort_by[path]'] = sort_by_path if sort_by_path
|
302
|
+
query[:'sort_by[size]'] = sort_by_size if sort_by_size
|
303
|
+
query[:'sort_by[modified_at_datetime]'] = sort_by_modified_at_datetime if sort_by_modified_at_datetime
|
304
|
+
BrickFTP::API::Folder.all(query)
|
305
|
+
end
|
306
|
+
|
307
|
+
# Create a folder.
|
308
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
309
|
+
# @param path [String]
|
310
|
+
# @return [BrickFTP::API::Folder]
|
311
|
+
def create_folder(path:)
|
312
|
+
BrickFTP::API::Folder.create(path: path)
|
313
|
+
end
|
314
|
+
|
315
|
+
# provides a download URL that will enable you to download a file.
|
316
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
317
|
+
# @param id file id.
|
318
|
+
# @return [BrickFTP::API::File] file object.
|
319
|
+
def show_file(id)
|
320
|
+
BrickFTP::API::File.find(id)
|
321
|
+
end
|
322
|
+
|
323
|
+
# Move or renames a file or folder to the destination provided in the move_destination parameter.
|
324
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
325
|
+
# @param path [String]
|
326
|
+
# @param move_destination [String]
|
327
|
+
# @return [BrickFTP::API::FileMove]
|
328
|
+
def move_file(path:, move_destination:)
|
329
|
+
BrickFTP::API::FileMove.create(path: path, move_destination: move_destination)
|
330
|
+
end
|
331
|
+
|
332
|
+
# Copy a file or folder to the destination provided in the copy_destination parameter.
|
333
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
334
|
+
# @param path [String]
|
335
|
+
# @param copy_destination [String]
|
336
|
+
# @return [BrickFTP::API::FileCopy]
|
337
|
+
def copy_file(path:, copy_destination:)
|
338
|
+
BrickFTP::API::FileCopy.create(path: path, copy_destination: copy_destination)
|
339
|
+
end
|
340
|
+
|
341
|
+
# Delete a file.
|
342
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-operations/
|
343
|
+
# @param file [BrickFTP::API::File] file object.
|
344
|
+
# @return [Boolean] return true.
|
345
|
+
def delete_file(file)
|
346
|
+
file.destroy
|
347
|
+
end
|
4
348
|
|
5
|
-
|
6
|
-
|
349
|
+
# Upload file.
|
350
|
+
# @see https://brickftp.com/ja/docs/rest-api/file-uploading/
|
351
|
+
# @param path [String]
|
352
|
+
# @param source [String] path for source file.
|
353
|
+
# @return [BrickFTP::API::FileUpload]
|
354
|
+
def upload_file(path:, source:)
|
355
|
+
BrickFTP::API::FileUpload.create(path: path, source: source)
|
7
356
|
end
|
8
357
|
end
|
9
358
|
end
|
@@ -2,9 +2,17 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module BrickFTP
|
4
4
|
class Configuration
|
5
|
+
# Subdomain of API endpoint. If not specified, get value from enviroment variable `BRICK_FTP_SUBDOMAIN`.
|
6
|
+
# @return [String] subdomain
|
5
7
|
attr_accessor :subdomain
|
8
|
+
# Access key of API. If not specified, get value from enviroment variable `BRICK_FTP_API_KEY`.
|
9
|
+
# @return [String] API access key
|
6
10
|
attr_accessor :api_key
|
11
|
+
# Authentication session for cookie auth.
|
12
|
+
# @return [BrickFTP::API::Authentication::Session] authentication session object.
|
7
13
|
attr_accessor :session
|
14
|
+
# Logger.
|
15
|
+
# @return [Logger] logger
|
8
16
|
attr_accessor :logger
|
9
17
|
|
10
18
|
def initialize
|
@@ -16,6 +24,8 @@ module BrickFTP
|
|
16
24
|
logger.level = Logger::WARN
|
17
25
|
end
|
18
26
|
|
27
|
+
# Host name of API endpoint.
|
28
|
+
# @return [String] API host
|
19
29
|
def api_host
|
20
30
|
"#{subdomain}.brickftp.com"
|
21
31
|
end
|
data/lib/brick_ftp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick_ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- koshigoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: deep_hash_transform
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
160
|
version: '0'
|
147
161
|
requirements: []
|
148
162
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.5.1
|
163
|
+
rubygems_version: 2.4.5.1
|
150
164
|
signing_key:
|
151
165
|
specification_version: 4
|
152
166
|
summary: BrickFTP's REST API client.
|