brick_ftp 1.0.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +8 -11
- data/.github/action/publish_gem/Dockerfile +14 -0
- data/.github/action/publish_gem/entrypoint.sh +18 -0
- data/.github/action/write_github_release/Dockerfile +14 -0
- data/.github/action/write_github_release/entrypoint.sh +48 -0
- data/.github/main.workflow +14 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +7 -0
- data/CHANGELOG.md +99 -2
- data/README.md +10 -11
- data/brick_ftp.gemspec +2 -3
- data/docker-compose.yml +7 -0
- data/lib/brick_ftp/client.rb +17 -4
- data/lib/brick_ftp/core_ext/hash/symbolize_keys.rb +4 -4
- data/lib/brick_ftp/restful_api/add_group_member.rb +2 -2
- data/lib/brick_ftp/restful_api/client.rb +23 -9
- data/lib/brick_ftp/restful_api/complete_upload.rb +2 -2
- data/lib/brick_ftp/restful_api/continue_upload.rb +2 -2
- data/lib/brick_ftp/restful_api/copy_folder.rb +1 -1
- data/lib/brick_ftp/restful_api/count_folder_contents.rb +3 -3
- data/lib/brick_ftp/restful_api/count_users.rb +1 -1
- data/lib/brick_ftp/restful_api/create_api_key.rb +2 -2
- data/lib/brick_ftp/restful_api/create_behavior.rb +2 -2
- data/lib/brick_ftp/restful_api/create_bundle.rb +2 -2
- data/lib/brick_ftp/restful_api/create_folder.rb +1 -1
- data/lib/brick_ftp/restful_api/create_group.rb +2 -2
- data/lib/brick_ftp/restful_api/create_notification.rb +2 -2
- data/lib/brick_ftp/restful_api/create_permission.rb +2 -2
- data/lib/brick_ftp/restful_api/create_public_key.rb +2 -2
- data/lib/brick_ftp/restful_api/create_user.rb +2 -2
- data/lib/brick_ftp/restful_api/create_user_in_group.rb +2 -2
- data/lib/brick_ftp/restful_api/delete_api_key.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_behavior.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_bundle.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_folder.rb +5 -7
- data/lib/brick_ftp/restful_api/delete_group.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_notification.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_permission.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_public_key.rb +1 -1
- data/lib/brick_ftp/restful_api/delete_user.rb +1 -1
- data/lib/brick_ftp/restful_api/download_file.rb +2 -2
- data/lib/brick_ftp/restful_api/get_api_key.rb +2 -2
- data/lib/brick_ftp/restful_api/get_behavior.rb +2 -2
- data/lib/brick_ftp/restful_api/get_bundle.rb +2 -2
- data/lib/brick_ftp/restful_api/get_bundle_zip.rb +2 -2
- data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +2 -2
- data/lib/brick_ftp/restful_api/get_folder_size.rb +1 -1
- data/lib/brick_ftp/restful_api/get_group.rb +2 -2
- data/lib/brick_ftp/restful_api/get_public_key.rb +2 -2
- data/lib/brick_ftp/restful_api/get_site_usage.rb +1 -1
- data/lib/brick_ftp/restful_api/get_user.rb +2 -2
- data/lib/brick_ftp/restful_api/list_api_keys.rb +2 -2
- data/lib/brick_ftp/restful_api/list_behaviors.rb +2 -2
- data/lib/brick_ftp/restful_api/list_bundle_contents.rb +2 -2
- data/lib/brick_ftp/restful_api/list_bundles.rb +2 -2
- data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +2 -2
- data/lib/brick_ftp/restful_api/list_folders.rb +2 -2
- data/lib/brick_ftp/restful_api/list_groups.rb +2 -2
- data/lib/brick_ftp/restful_api/list_notifications.rb +2 -2
- data/lib/brick_ftp/restful_api/list_permissions.rb +2 -2
- data/lib/brick_ftp/restful_api/list_public_keys.rb +2 -2
- data/lib/brick_ftp/restful_api/list_users.rb +2 -2
- data/lib/brick_ftp/restful_api/move_folder.rb +1 -1
- data/lib/brick_ftp/restful_api/remove_group_member.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_file_history.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_folder_history.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_history.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_login_history.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_site_history.rb +1 -1
- data/lib/brick_ftp/restful_api/retrieve_user_history.rb +1 -1
- data/lib/brick_ftp/restful_api/search_user.rb +2 -2
- data/lib/brick_ftp/restful_api/start_upload.rb +2 -2
- data/lib/brick_ftp/restful_api/unlock_user.rb +2 -2
- data/lib/brick_ftp/restful_api/update_behavior.rb +2 -2
- data/lib/brick_ftp/restful_api/update_group.rb +2 -2
- data/lib/brick_ftp/restful_api/update_group_member.rb +2 -2
- data/lib/brick_ftp/restful_api/update_user.rb +3 -3
- data/lib/brick_ftp/restful_api/upload_file.rb +5 -5
- data/lib/brick_ftp/restful_api.rb +11 -11
- data/lib/brick_ftp/types/behavior.rb +1 -1
- data/lib/brick_ftp/types/bundle.rb +1 -1
- data/lib/brick_ftp/types/bundle_content.rb +1 -1
- data/lib/brick_ftp/types/bundle_zip.rb +1 -1
- data/lib/brick_ftp/types/file.rb +1 -1
- data/lib/brick_ftp/types/file_in_bundle.rb +1 -1
- data/lib/brick_ftp/types/folder_contents_count.rb +2 -2
- data/lib/brick_ftp/types/group.rb +1 -1
- data/lib/brick_ftp/types/group_membership.rb +1 -1
- data/lib/brick_ftp/types/history.rb +1 -1
- data/lib/brick_ftp/types/notification.rb +1 -1
- data/lib/brick_ftp/types/permission.rb +1 -1
- data/lib/brick_ftp/types/upload.rb +1 -1
- data/lib/brick_ftp/types/user.rb +1 -1
- data/lib/brick_ftp/types/user_api_key.rb +1 -1
- data/lib/brick_ftp/types/user_public_key.rb +1 -1
- data/lib/brick_ftp/version.rb +1 -1
- data/lib/brick_ftp.rb +1 -1
- metadata +15 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e1dc7450ed459157341a4f98a354fc3e11f284b8f369074121a39b325eb273
|
4
|
+
data.tar.gz: 8767ddfafc2935647b1fee4df01777bd2b6e7f29dbacfc8f6ad70994fb77318c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221abadce34fd474a3719889f5771f53269740efe469ca39bf349e8132b73761fba543dff5cb7c8fc00f1ba295ce236a134d9265fe5d87d5fa49d8a378b5a538
|
7
|
+
data.tar.gz: 86e766d25b7aefdf346b4755412e6e2bd4def47e5f4136eab984851e11de9899e9d4f5d646d00fc4fe581bb5623c3534f94d3d5cba3e165173ec4ae4dcdb4c85
|
data/.circleci/config.yml
CHANGED
@@ -18,26 +18,23 @@ jobs:
|
|
18
18
|
- run:
|
19
19
|
name: RSpec
|
20
20
|
command: rspec
|
21
|
-
|
22
|
-
path: coverage
|
23
|
-
destination: coverage
|
24
|
-
ruby-2.3:
|
21
|
+
ruby-2.5:
|
25
22
|
<<: *build
|
26
23
|
docker:
|
27
|
-
- image: circleci/ruby:2.
|
28
|
-
ruby-2.
|
24
|
+
- image: circleci/ruby:2.5
|
25
|
+
ruby-2.6:
|
29
26
|
<<: *build
|
30
27
|
docker:
|
31
|
-
- image: circleci/ruby:2.
|
32
|
-
ruby-2.
|
28
|
+
- image: circleci/ruby:2.6
|
29
|
+
ruby-2.7:
|
33
30
|
<<: *build
|
34
31
|
docker:
|
35
|
-
- image: circleci/ruby:2.
|
32
|
+
- image: circleci/ruby:2.7
|
36
33
|
|
37
34
|
workflows:
|
38
35
|
version: 2
|
39
36
|
build-using-multi-rubies:
|
40
37
|
jobs:
|
41
|
-
- ruby-2.3
|
42
|
-
- ruby-2.4
|
43
38
|
- ruby-2.5
|
39
|
+
- ruby-2.6
|
40
|
+
- ruby-2.7
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM ruby:alpine
|
2
|
+
LABEL "com.github.actions.name"="Publish Gem"
|
3
|
+
LABEL "com.github.actions.description"="Publish gem to rubygems.org"
|
4
|
+
LABEL "com.github.actions.icon"="truck"
|
5
|
+
LABEL "com.github.actions.color"="green"
|
6
|
+
LABEL "repository"="https://github.com/koshigoe/brick_ftp"
|
7
|
+
LABEL "homepage"="https://github.com/koshigoe/brick_ftp"
|
8
|
+
LABEL "maintainer"="koshigoe <koshigoeb@gmail.com>"
|
9
|
+
|
10
|
+
RUN apk update -q \
|
11
|
+
&& apk add -q --no-cache curl jq git
|
12
|
+
|
13
|
+
ADD entrypoint.sh /entrypoint.sh
|
14
|
+
ENTRYPOINT ["/entrypoint.sh"]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/bin/ash -eu
|
2
|
+
|
3
|
+
action=$(jq -r '.action' $GITHUB_EVENT_PATH)
|
4
|
+
if [ "$action" != "published" ]; then
|
5
|
+
exit 0
|
6
|
+
fi
|
7
|
+
|
8
|
+
cd $GITHUB_WORKSPACE
|
9
|
+
|
10
|
+
mkdir -p ~/.gem
|
11
|
+
cat <<EOF > ~/.gem/credentials
|
12
|
+
---
|
13
|
+
:rubygems_api_key: $RUBYGEMS_TOKEN
|
14
|
+
EOF
|
15
|
+
chmod 0600 ~/.gem/credentials
|
16
|
+
|
17
|
+
gem build *.gemspec
|
18
|
+
gem push *.gem
|
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM alpine:3.8
|
2
|
+
LABEL "com.github.actions.name"="Write GitHub Release"
|
3
|
+
LABEL "com.github.actions.description"="Write merged PRs into latest GitHub Release"
|
4
|
+
LABEL "com.github.actions.icon"="edit"
|
5
|
+
LABEL "com.github.actions.color"="blue"
|
6
|
+
LABEL "repository"="https://github.com/koshigoe/brick_ftp"
|
7
|
+
LABEL "homepage"="https://github.com/koshigoe/brick_ftp"
|
8
|
+
LABEL "maintainer"="koshigoe <koshigoeb@gmail.com>"
|
9
|
+
|
10
|
+
RUN apk update -q \
|
11
|
+
&& apk add -q --no-cache curl jq
|
12
|
+
|
13
|
+
ADD entrypoint.sh /entrypoint.sh
|
14
|
+
ENTRYPOINT ["/entrypoint.sh"]
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/bin/ash -eu
|
2
|
+
|
3
|
+
action=$(jq -r '.action' $GITHUB_EVENT_PATH)
|
4
|
+
if [ "$action" != "published" ]; then
|
5
|
+
exit 0
|
6
|
+
fi
|
7
|
+
|
8
|
+
# Get previous GitHub Release.
|
9
|
+
curl --fail -s \
|
10
|
+
-u $GITHUB_ACTOR:$GITHUB_TOKEN \
|
11
|
+
https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
|
12
|
+
| jq -r '.[1]' \
|
13
|
+
> previous_release.json
|
14
|
+
previous_published_date=$(jq -r '.published_at' previous_release.json)
|
15
|
+
|
16
|
+
# Get latest published date.
|
17
|
+
latest_published_date=$(jq -r '.release.published_at' $GITHUB_EVENT_PATH)
|
18
|
+
|
19
|
+
# Get latest GitHub Release ID.
|
20
|
+
latest_release_id=$(jq -r '.release.id' $GITHUB_EVENT_PATH)
|
21
|
+
|
22
|
+
# Get merged PRs
|
23
|
+
merged_pr_list=$(
|
24
|
+
curl --fail -s \
|
25
|
+
-u $GITHUB_ACTOR:$GITHUB_TOKEN \
|
26
|
+
"https://api.github.com/search/issues?q=repo:${GITHUB_REPOSITORY}+is:pr+base:master+merged:${previous_published_date}..${latest_published_date}" \
|
27
|
+
| jq -r '.items[] | ["- #" + (.number | tostring) + " " + .title] | @tsv' \
|
28
|
+
| sort -k 3)
|
29
|
+
|
30
|
+
# Get comparable tags
|
31
|
+
previous_tag_name=$(jq -r '.tag_name' previous_release.json)
|
32
|
+
latest_tag_name=$(jq -r '.release.tag_name' $GITHUB_EVENT_PATH)
|
33
|
+
|
34
|
+
# Make release note.
|
35
|
+
release_note=$(cat <<EOF | sed ':a;N;$!ba;s/\n/\\n/g')
|
36
|
+
https://github.com/$GITHUB_REPOSITORY/compare/${previous_tag_name}...${latest_tag_name}
|
37
|
+
|
38
|
+
### Merged
|
39
|
+
|
40
|
+
$merged_pr_list
|
41
|
+
EOF
|
42
|
+
|
43
|
+
# Update body of latest GitHub Release.
|
44
|
+
curl --fail -s \
|
45
|
+
-u $GITHUB_ACTOR:$GITHUB_TOKEN \
|
46
|
+
-X PATCH \
|
47
|
+
-d "{\"body\":\"${release_note}\"}" \
|
48
|
+
https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$latest_release_id
|
@@ -0,0 +1,14 @@
|
|
1
|
+
workflow "Release" {
|
2
|
+
on = "release"
|
3
|
+
resolves = ["Write GitHub Release", "Publish Gem"]
|
4
|
+
}
|
5
|
+
|
6
|
+
action "Write GitHub Release" {
|
7
|
+
uses = "./.github/action/write_github_release"
|
8
|
+
secrets = ["GITHUB_TOKEN"]
|
9
|
+
}
|
10
|
+
|
11
|
+
action "Publish Gem" {
|
12
|
+
uses = "./.github/action/publish_gem"
|
13
|
+
secrets = ["GITHUB_TOKEN", "RUBYGEMS_TOKEN"]
|
14
|
+
}
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,111 @@
|
|
1
1
|
Changelog
|
2
2
|
====
|
3
3
|
|
4
|
+
The official Ruby SDK released by Files.com
|
4
5
|
|
5
|
-
|
6
|
+
> SDKs in Ruby and PHP are available for download using the typical package manager for each language.
|
7
|
+
> https://developers.files.com/?ruby#introduction
|
8
|
+
|
9
|
+
Its usage like:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Files.api_key = 'YOUR_API_KEY'
|
13
|
+
|
14
|
+
# Alternatively, you can specify the API key on a per-request basis in the final parameter to any method or initializer.
|
15
|
+
Files::User.new(params, api_key: 'YOUR_API_KEY')
|
16
|
+
```
|
17
|
+
|
18
|
+
I will archive this repository after found official SDK.
|
19
|
+
|
20
|
+
|
21
|
+
[v2.1.1](https://github.com/koshigoe/brick_ftp/compare/v2.1.0...v2.1.1)
|
6
22
|
----
|
7
23
|
|
8
|
-
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/
|
24
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.1.0...v2.1.1)
|
9
25
|
|
10
26
|
### Enhancements:
|
11
27
|
|
28
|
+
- [#136](https://github.com/koshigoe/brick_ftp/pull/136) Use `PATCH` instead of `PUT` to update User.
|
29
|
+
- see https://developers.files.com/#update-user
|
30
|
+
|
31
|
+
### Fixed Bugs:
|
32
|
+
|
33
|
+
### Deprecate
|
34
|
+
|
35
|
+
### Breaking Changes:
|
36
|
+
|
37
|
+
|
38
|
+
[v2.1.0](https://github.com/koshigoe/brick_ftp/compare/v2.0.3...v2.1.0)
|
39
|
+
----
|
40
|
+
|
41
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.3...v2.1.0)
|
42
|
+
|
43
|
+
### Enhancements:
|
44
|
+
|
45
|
+
### Fixed Bugs:
|
46
|
+
|
47
|
+
### Deprecate
|
48
|
+
|
49
|
+
- Deprecate keyword argument `subdomain:` of `BrickFTP::Client#initialize`
|
50
|
+
- To enable to specify base URL of REST API (e.g. `http://127.0.0.1:40410/`)
|
51
|
+
|
52
|
+
### Breaking Changes:
|
53
|
+
|
54
|
+
- Dropping support for Ruby 2.3, 2.4
|
55
|
+
|
56
|
+
|
57
|
+
[v2.0.3](https://github.com/koshigoe/brick_ftp/compare/v2.0.2...v2.0.3)
|
58
|
+
----
|
59
|
+
|
60
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.2...v2.0.3)
|
61
|
+
|
62
|
+
### Enhancements:
|
63
|
+
|
64
|
+
### Fixed Bugs:
|
65
|
+
|
66
|
+
- [#133](https://github.com/koshigoe/brick_ftp/pull/133) Fix to enable to delete folders recursively
|
67
|
+
|
68
|
+
### Breaking Changes:
|
69
|
+
|
70
|
+
|
71
|
+
[v2.0.2](https://github.com/koshigoe/brick_ftp/compare/v2.0.1...v2.0.2)
|
72
|
+
----
|
73
|
+
|
74
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.1...v2.0.2)
|
75
|
+
|
76
|
+
### Enhancements:
|
77
|
+
|
78
|
+
- [#132](https://github.com/koshigoe/brick_ftp/pull/132) Suppress warnings in Ruby 2.7
|
79
|
+
|
80
|
+
### Fixed Bugs:
|
81
|
+
|
82
|
+
### Breaking Changes:
|
83
|
+
|
84
|
+
|
85
|
+
[v2.0.1](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...v2.0.1)
|
86
|
+
----
|
87
|
+
|
88
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v2.0.0...v2.0.1)
|
89
|
+
|
90
|
+
### Enhancements:
|
91
|
+
|
92
|
+
### Fixed Bugs:
|
93
|
+
|
94
|
+
- [#124](https://github.com/koshigoe/brick_ftp/pull/124) Handle response 204 No Content avoid to parse error.
|
95
|
+
|
96
|
+
### Breaking Changes:
|
97
|
+
|
98
|
+
|
99
|
+
[v2.0.0](https://github.com/koshigoe/brick_ftp/compare/v1.0.1...v2.0.0)
|
100
|
+
----
|
101
|
+
|
102
|
+
[Full Changelog](https://github.com/koshigoe/brick_ftp/compare/v1.0.1...v2.0.0)
|
103
|
+
|
104
|
+
### Enhancements:
|
105
|
+
|
106
|
+
- [#119](https://github.com/koshigoe/brick_ftp/pull/119) Change domain of API endpoint.
|
107
|
+
- _**Please check your SSL cert of new custom domain before update this gem.**_
|
108
|
+
|
12
109
|
### Fixed Bugs:
|
13
110
|
|
14
111
|
### Breaking Changes:
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
[![CircleCI](https://circleci.com/gh/koshigoe/brick_ftp/tree/master.svg?style=svg)](https://circleci.com/gh/koshigoe/brick_ftp/tree/master)
|
2
|
-
[![
|
2
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/b996c388d3d32b7ec953/maintainability)](https://codeclimate.com/github/koshigoe/brick_ftp/maintainability)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/b996c388d3d32b7ec953/test_coverage)](https://codeclimate.com/github/koshigoe/brick_ftp/test_coverage)
|
3
4
|
|
4
5
|
|
5
|
-
BrickFTP
|
6
|
+
Files.com (BrickFTP)
|
6
7
|
====
|
7
8
|
|
8
|
-
This is a [BrickFTP](https://
|
9
|
+
This is a [File.com (BrickFTP)](https://files.com/)'s _unofficial_ [RESTful API](https://developers.files.com/) Client.
|
10
|
+
|
11
|
+
**I recommend official SDK: [Files-com/files-sdk-ruby](https://github.com/Files-com/files-sdk-ruby)**
|
9
12
|
|
10
13
|
|
11
14
|
Installation
|
@@ -30,22 +33,18 @@ Usage
|
|
30
33
|
----
|
31
34
|
|
32
35
|
```
|
36
|
+
$ docker compose up -d
|
33
37
|
$ bin/console
|
34
|
-
> client = BrickFTP::Client.new
|
38
|
+
> client = BrickFTP::Client.new(base_url: 'http://localhost:40410', api_key: 'dummy')
|
35
39
|
> client.list_users
|
36
40
|
```
|
37
41
|
|
38
|
-
```
|
39
|
-
$ bin/console
|
40
|
-
> api_client = BrickFTP::RESTfulAPI::Client.new(ENV['BRICK_FTP_SUBDOMAIN'], ENV['BRICK_FTP_API_KEY'])
|
41
|
-
> BrickFTP::RESTfulAPI::ListUsers.new(api_client).call
|
42
|
-
```
|
43
|
-
|
44
42
|
### Environment Variables
|
45
43
|
|
46
44
|
Name | Description
|
47
45
|
--------------------- | -----------
|
48
|
-
`BRICK_FTP_SUBDOMAIN` | Default subdomain
|
46
|
+
`BRICK_FTP_SUBDOMAIN` | Default subdomain (deprecated)
|
47
|
+
`BRICK_FTP_BASE_URL` | Base URL of Files.com's REST API (e.g. `https://{subdomain}.files.com/`)
|
49
48
|
`BRICK_FTP_API_KEY` | Default API key
|
50
49
|
|
51
50
|
|
data/brick_ftp.gemspec
CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
23
|
+
spec.required_ruby_version = '>= 2.5.0'
|
24
24
|
|
25
|
-
spec.add_development_dependency 'bundler', '
|
26
|
-
spec.add_development_dependency 'codecov', '~> 0.1.10'
|
25
|
+
spec.add_development_dependency 'bundler', '>= 1.16'
|
27
26
|
spec.add_development_dependency 'pry', '~> 0.11'
|
28
27
|
spec.add_development_dependency 'rake', '~> 12.0'
|
29
28
|
spec.add_development_dependency 'redcarpet', '~> 3.4'
|
data/docker-compose.yml
ADDED
data/lib/brick_ftp/client.rb
CHANGED
@@ -10,14 +10,26 @@ module BrickFTP
|
|
10
10
|
# BrickFTP::Client.new.list_users
|
11
11
|
#
|
12
12
|
class Client
|
13
|
-
attr_reader :
|
13
|
+
attr_reader :base_url, :api_key, :api_client
|
14
14
|
|
15
|
-
# @param [String]
|
15
|
+
# @param [String] base_url
|
16
|
+
# @param [String] subdomain (deprecated)
|
16
17
|
# @param [String] api_key
|
17
|
-
def initialize(subdomain: nil, api_key: nil)
|
18
|
+
def initialize(base_url: nil, subdomain: nil, api_key: nil)
|
19
|
+
if subdomain
|
20
|
+
warn('DEPRECATION WARNING: The argument `subdomain:` will be deprecated in a future version.' \
|
21
|
+
' Please use `base_url:` instead.')
|
22
|
+
end
|
23
|
+
|
18
24
|
@subdomain = subdomain || ENV['BRICK_FTP_SUBDOMAIN']
|
25
|
+
@base_url = base_url || ENV['BRICK_FTP_BASE_URL']
|
19
26
|
@api_key = api_key || ENV['BRICK_FTP_API_KEY']
|
20
|
-
@api_client = BrickFTP::RESTfulAPI::Client.new(@subdomain, @api_key)
|
27
|
+
@api_client = BrickFTP::RESTfulAPI::Client.new(@base_url || @subdomain, @api_key)
|
28
|
+
end
|
29
|
+
|
30
|
+
def subdomain
|
31
|
+
warn("DEPRECATION WARNING: #{self.class.name}##{__method__} will be deprecated in a future version.")
|
32
|
+
@subdomain
|
21
33
|
end
|
22
34
|
|
23
35
|
private
|
@@ -34,6 +46,7 @@ module BrickFTP
|
|
34
46
|
|
35
47
|
def respond_to_missing?(symbol, include_private)
|
36
48
|
return true if command_class(symbol)
|
49
|
+
|
37
50
|
super
|
38
51
|
end
|
39
52
|
|
@@ -7,10 +7,10 @@ module BrickFTP
|
|
7
7
|
def symbolize_keys
|
8
8
|
each_key.each_with_object({}) do |key, mem|
|
9
9
|
symbolized_key = begin
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
key.to_sym
|
11
|
+
rescue StandardError
|
12
|
+
key
|
13
|
+
end
|
14
14
|
mem[symbolized_key] = self[key]
|
15
15
|
end
|
16
16
|
end
|
@@ -4,7 +4,7 @@ module BrickFTP
|
|
4
4
|
module RESTfulAPI
|
5
5
|
# Add a member
|
6
6
|
#
|
7
|
-
# @see https://developers.
|
7
|
+
# @see https://developers.files.com/#add-a-member Add a member
|
8
8
|
#
|
9
9
|
# ### Params
|
10
10
|
#
|
@@ -37,7 +37,7 @@ module BrickFTP
|
|
37
37
|
def call(group_id, user_id, params)
|
38
38
|
res = client.put("/api/rest/v1/groups/#{group_id}/memberships/#{user_id}.json", membership: params.to_h.compact)
|
39
39
|
|
40
|
-
BrickFTP::Types::GroupMembership.new(res.symbolize_keys)
|
40
|
+
BrickFTP::Types::GroupMembership.new(**res.symbolize_keys)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
@@ -13,7 +13,7 @@ module BrickFTP
|
|
13
13
|
READ_TIMEOUT = 60
|
14
14
|
USER_AGENT = 'BrickFTP Client/1.0 (https://github.com/koshigoe/brick_ftp)'
|
15
15
|
|
16
|
-
# ref. https://developers.
|
16
|
+
# ref. https://developers.files.com/#errors
|
17
17
|
ErrorResponse = Struct.new(
|
18
18
|
'RESTfulAPIErrorResponse',
|
19
19
|
:error,
|
@@ -35,12 +35,13 @@ module BrickFTP
|
|
35
35
|
|
36
36
|
# Initialize REST API client.
|
37
37
|
#
|
38
|
-
# @param [String]
|
38
|
+
# @param [String] base_url
|
39
39
|
# @param [String] api_key
|
40
40
|
#
|
41
|
-
def initialize(
|
42
|
-
@
|
43
|
-
@http
|
41
|
+
def initialize(base_url, api_key)
|
42
|
+
@base_uri = make_base_uri(base_url)
|
43
|
+
@http = Net::HTTP.new(@base_uri.host, @base_uri.port)
|
44
|
+
@http.use_ssl = (@base_uri.scheme == 'https')
|
44
45
|
@http.open_timeout = OPEN_TIMEOUT
|
45
46
|
@http.read_timeout = READ_TIMEOUT
|
46
47
|
@request_headers = {
|
@@ -146,13 +147,26 @@ module BrickFTP
|
|
146
147
|
res = http.start { |session| session.request(req) }
|
147
148
|
|
148
149
|
return io.size if res.is_a?(Net::HTTPSuccess)
|
150
|
+
|
149
151
|
raise Error, parse_error_response(res)
|
150
152
|
end
|
151
153
|
|
152
154
|
private
|
153
155
|
|
156
|
+
DEFAULT_BASE_URL_TEMPLATE = 'https://%{subdomain}.files.com'
|
157
|
+
|
158
|
+
def make_base_uri(url_or_subdomain)
|
159
|
+
unless /[.:]/.match?(url_or_subdomain)
|
160
|
+
url_or_subdomain = format(DEFAULT_BASE_URL_TEMPLATE, subdomain: url_or_subdomain)
|
161
|
+
end
|
162
|
+
|
163
|
+
URI.parse(url_or_subdomain)
|
164
|
+
end
|
165
|
+
|
154
166
|
def handle_response(response)
|
155
167
|
case response
|
168
|
+
when Net::HTTPNoContent
|
169
|
+
nil
|
156
170
|
when Net::HTTPSuccess
|
157
171
|
parse_success_response(response)
|
158
172
|
else
|
@@ -167,10 +181,10 @@ module BrickFTP
|
|
167
181
|
|
168
182
|
def parse_error_response(response)
|
169
183
|
parsed = begin
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
184
|
+
JSON.parse(response.body)
|
185
|
+
rescue StandardError
|
186
|
+
{}
|
187
|
+
end
|
174
188
|
parsed = {} unless parsed.is_a?(Hash)
|
175
189
|
|
176
190
|
ErrorResponse.new(parsed.symbolize_keys).tap do |e|
|
@@ -6,7 +6,7 @@ module BrickFTP
|
|
6
6
|
module RESTfulAPI
|
7
7
|
# Completing an upload
|
8
8
|
#
|
9
|
-
# @see https://developers.
|
9
|
+
# @see https://developers.files.com/#completing-an-upload Completing an upload
|
10
10
|
#
|
11
11
|
# ### Params
|
12
12
|
#
|
@@ -39,7 +39,7 @@ module BrickFTP
|
|
39
39
|
def call(path, params)
|
40
40
|
res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'end'))
|
41
41
|
|
42
|
-
BrickFTP::Types::File.new(res.symbolize_keys)
|
42
|
+
BrickFTP::Types::File.new(**res.symbolize_keys)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -6,7 +6,7 @@ module BrickFTP
|
|
6
6
|
module RESTfulAPI
|
7
7
|
# Requesting additional upload URLs
|
8
8
|
#
|
9
|
-
# @see https://developers.
|
9
|
+
# @see https://developers.files.com/#requesting-additional-upload-urls Requesting additional upload URLs
|
10
10
|
#
|
11
11
|
# ### Params
|
12
12
|
#
|
@@ -43,7 +43,7 @@ module BrickFTP
|
|
43
43
|
def call(path, params)
|
44
44
|
res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'put'))
|
45
45
|
|
46
|
-
BrickFTP::Types::Upload.new(res.symbolize_keys)
|
46
|
+
BrickFTP::Types::Upload.new(**res.symbolize_keys)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -6,8 +6,8 @@ module BrickFTP
|
|
6
6
|
module RESTfulAPI
|
7
7
|
# Count folder contents
|
8
8
|
#
|
9
|
-
# @see https://developers.
|
10
|
-
# @see https://developers.
|
9
|
+
# @see https://developers.files.com/#count-folder-contents-recursively Count folder contents recursively
|
10
|
+
# @see https://developers.files.com/#count-folder-contents-non-recursively Count folder contents non-recursively
|
11
11
|
#
|
12
12
|
class CountFolderContents
|
13
13
|
include Command
|
@@ -29,7 +29,7 @@ module BrickFTP
|
|
29
29
|
if recursive
|
30
30
|
BrickFTP::Types::FolderContentsCount.new(total: res['data']['count'])
|
31
31
|
else
|
32
|
-
BrickFTP::Types::FolderContentsCount.new(res['data']['count'].symbolize_keys)
|
32
|
+
BrickFTP::Types::FolderContentsCount.new(**res['data']['count'].symbolize_keys)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -4,7 +4,7 @@ module BrickFTP
|
|
4
4
|
module RESTfulAPI
|
5
5
|
# Create an API key
|
6
6
|
#
|
7
|
-
# @see https://developers.
|
7
|
+
# @see https://developers.files.com/#create-an-api-key Create an API key
|
8
8
|
#
|
9
9
|
# ### Params
|
10
10
|
#
|
@@ -39,7 +39,7 @@ module BrickFTP
|
|
39
39
|
def call(id, params)
|
40
40
|
res = client.post("/api/rest/v1/users/#{id}/api_keys.json", params.to_h.compact)
|
41
41
|
|
42
|
-
BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
|
42
|
+
BrickFTP::Types::UserAPIKey.new(**res.symbolize_keys)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -4,7 +4,7 @@ module BrickFTP
|
|
4
4
|
module RESTfulAPI
|
5
5
|
# Create a behavior
|
6
6
|
#
|
7
|
-
# @see https://developers.
|
7
|
+
# @see https://developers.files.com/#create-a-behavior Create a behavior
|
8
8
|
#
|
9
9
|
# ### Params
|
10
10
|
#
|
@@ -35,7 +35,7 @@ module BrickFTP
|
|
35
35
|
def call(params)
|
36
36
|
res = client.post('/api/rest/v1/behaviors.json', params.to_h.compact)
|
37
37
|
|
38
|
-
BrickFTP::Types::Behavior.new(res.symbolize_keys)
|
38
|
+
BrickFTP::Types::Behavior.new(**res.symbolize_keys)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -4,7 +4,7 @@ module BrickFTP
|
|
4
4
|
module RESTfulAPI
|
5
5
|
# Create a bundle
|
6
6
|
#
|
7
|
-
# @see https://developers.
|
7
|
+
# @see https://developers.files.com/#create-a-bundle Create a bundle
|
8
8
|
#
|
9
9
|
# ### Params
|
10
10
|
#
|
@@ -33,7 +33,7 @@ module BrickFTP
|
|
33
33
|
def call(params)
|
34
34
|
res = client.post('/api/rest/v1/bundles.json', params.to_h.compact)
|
35
35
|
|
36
|
-
BrickFTP::Types::Bundle.new(res.symbolize_keys)
|
36
|
+
BrickFTP::Types::Bundle.new(**res.symbolize_keys)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|