brick_ftp 0.8.4 → 1.0.0.beta
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 +0 -5
- data/.rubocop.yml +2 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +16 -12
- data/Gemfile +2 -0
- data/README.md +24 -43
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/brick_ftp.gemspec +10 -9
- data/exe/brick_ftp +1 -0
- data/lib/brick_ftp.rb +5 -78
- data/lib/brick_ftp/client.rb +35 -411
- data/lib/brick_ftp/core_ext.rb +8 -0
- data/lib/brick_ftp/core_ext/hash.rb +13 -0
- data/lib/brick_ftp/core_ext/hash/compact.rb +13 -0
- data/lib/brick_ftp/core_ext/struct.rb +13 -0
- data/lib/brick_ftp/core_ext/struct/new.rb +16 -0
- data/lib/brick_ftp/restful_api.rb +82 -0
- data/lib/brick_ftp/restful_api/add_group_member.rb +44 -0
- data/lib/brick_ftp/restful_api/client.rb +179 -0
- data/lib/brick_ftp/restful_api/command.rb +21 -0
- data/lib/brick_ftp/restful_api/complete_upload.rb +46 -0
- data/lib/brick_ftp/restful_api/continue_upload.rb +50 -0
- data/lib/brick_ftp/restful_api/copy_folder.rb +46 -0
- data/lib/brick_ftp/restful_api/count_folder_contents.rb +36 -0
- data/lib/brick_ftp/restful_api/count_users.rb +22 -0
- data/lib/brick_ftp/restful_api/create_api_key.rb +46 -0
- data/lib/brick_ftp/restful_api/create_behavior.rb +42 -0
- data/lib/brick_ftp/restful_api/create_bundle.rb +40 -0
- data/lib/brick_ftp/restful_api/create_folder.rb +25 -0
- data/lib/brick_ftp/restful_api/create_group.rb +42 -0
- data/lib/brick_ftp/restful_api/create_notification.rb +44 -0
- data/lib/brick_ftp/restful_api/create_permission.rb +48 -0
- data/lib/brick_ftp/restful_api/create_public_key.rb +42 -0
- data/lib/brick_ftp/restful_api/create_user.rb +90 -0
- data/lib/brick_ftp/restful_api/create_user_in_group.rb +60 -0
- data/lib/brick_ftp/restful_api/delete_api_key.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_behavior.rb +22 -0
- data/lib/brick_ftp/restful_api/delete_bundle.rb +22 -0
- data/lib/brick_ftp/restful_api/delete_folder.rb +32 -0
- data/lib/brick_ftp/restful_api/delete_group.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_notification.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_permission.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_public_key.rb +23 -0
- data/lib/brick_ftp/restful_api/delete_user.rb +25 -0
- data/lib/brick_ftp/restful_api/download_file.rb +44 -0
- data/lib/brick_ftp/restful_api/get_api_key.rb +25 -0
- data/lib/brick_ftp/restful_api/get_behavior.rb +25 -0
- data/lib/brick_ftp/restful_api/get_bundle.rb +25 -0
- data/lib/brick_ftp/restful_api/get_bundle_zip.rb +48 -0
- data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +49 -0
- data/lib/brick_ftp/restful_api/get_folder_size.rb +25 -0
- data/lib/brick_ftp/restful_api/get_group.rb +26 -0
- data/lib/brick_ftp/restful_api/get_public_key.rb +25 -0
- data/lib/brick_ftp/restful_api/get_site_usage.rb +19 -0
- data/lib/brick_ftp/restful_api/get_user.rb +26 -0
- data/lib/brick_ftp/restful_api/list_api_keys.rb +25 -0
- data/lib/brick_ftp/restful_api/list_behaviors.rb +23 -0
- data/lib/brick_ftp/restful_api/list_bundle_contents.rb +58 -0
- data/lib/brick_ftp/restful_api/list_bundles.rb +23 -0
- data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +39 -0
- data/lib/brick_ftp/restful_api/list_folders.rb +108 -0
- data/lib/brick_ftp/restful_api/list_groups.rb +23 -0
- data/lib/brick_ftp/restful_api/list_notifications.rb +23 -0
- data/lib/brick_ftp/restful_api/list_permissions.rb +41 -0
- data/lib/brick_ftp/restful_api/list_public_keys.rb +25 -0
- data/lib/brick_ftp/restful_api/list_users.rb +60 -0
- data/lib/brick_ftp/restful_api/move_folder.rb +41 -0
- data/lib/brick_ftp/restful_api/remove_group_member.rb +23 -0
- data/lib/brick_ftp/restful_api/retrieve_file_history.rb +41 -0
- data/lib/brick_ftp/restful_api/retrieve_folder_history.rb +41 -0
- data/lib/brick_ftp/restful_api/retrieve_history.rb +54 -0
- data/lib/brick_ftp/restful_api/retrieve_login_history.rb +38 -0
- data/lib/brick_ftp/restful_api/retrieve_site_history.rb +38 -0
- data/lib/brick_ftp/restful_api/retrieve_user_history.rb +40 -0
- data/lib/brick_ftp/restful_api/search_user.rb +28 -0
- data/lib/brick_ftp/restful_api/start_upload.rb +27 -0
- data/lib/brick_ftp/restful_api/unlock_user.rb +25 -0
- data/lib/brick_ftp/restful_api/update_behavior.rb +39 -0
- data/lib/brick_ftp/restful_api/update_group.rb +44 -0
- data/lib/brick_ftp/restful_api/update_group_member.rb +40 -0
- data/lib/brick_ftp/restful_api/update_user.rb +101 -0
- data/lib/brick_ftp/restful_api/upload_file.rb +65 -0
- data/lib/brick_ftp/types.rb +23 -0
- data/lib/brick_ftp/types/behavior.rb +27 -0
- data/lib/brick_ftp/types/bundle.rb +34 -0
- data/lib/brick_ftp/types/bundle_content.rb +25 -0
- data/lib/brick_ftp/types/bundle_zip.rb +19 -0
- data/lib/brick_ftp/types/file.rb +45 -0
- data/lib/brick_ftp/types/file_in_bundle.rb +25 -0
- data/lib/brick_ftp/types/folder_contents_count.rb +24 -0
- data/lib/brick_ftp/types/group.rb +31 -0
- data/lib/brick_ftp/types/group_membership.rb +27 -0
- data/lib/brick_ftp/types/history.rb +43 -0
- data/lib/brick_ftp/types/notification.rb +31 -0
- data/lib/brick_ftp/types/permission.rb +35 -0
- data/lib/brick_ftp/types/site_usage.rb +23 -0
- data/lib/brick_ftp/types/upload.rb +45 -0
- data/lib/brick_ftp/types/user.rb +79 -0
- data/lib/brick_ftp/types/user_api_key.rb +33 -0
- data/lib/brick_ftp/types/user_public_key.rb +28 -0
- data/lib/brick_ftp/utils.rb +2 -0
- data/lib/brick_ftp/utils/chunk_io.rb +5 -4
- data/lib/brick_ftp/version.rb +3 -1
- metadata +123 -86
- data/lib/brick_ftp/api.rb +0 -9
- data/lib/brick_ftp/api/authentication.rb +0 -28
- data/lib/brick_ftp/api/authentication/session.rb +0 -25
- data/lib/brick_ftp/api/base.rb +0 -119
- data/lib/brick_ftp/api/behavior.rb +0 -19
- data/lib/brick_ftp/api/bundle.rb +0 -17
- data/lib/brick_ftp/api/bundle_content.rb +0 -18
- data/lib/brick_ftp/api/bundle_download.rb +0 -18
- data/lib/brick_ftp/api/file.rb +0 -20
- data/lib/brick_ftp/api/file_operation.rb +0 -6
- data/lib/brick_ftp/api/file_operation/copy.rb +0 -10
- data/lib/brick_ftp/api/file_operation/move.rb +0 -10
- data/lib/brick_ftp/api/file_operation/upload.rb +0 -66
- data/lib/brick_ftp/api/file_operation/uploading_result.rb +0 -22
- data/lib/brick_ftp/api/file_operation/uploading_session.rb +0 -95
- data/lib/brick_ftp/api/folder.rb +0 -22
- data/lib/brick_ftp/api/folder_behavior.rb +0 -12
- data/lib/brick_ftp/api/group.rb +0 -16
- data/lib/brick_ftp/api/history.rb +0 -6
- data/lib/brick_ftp/api/history/file.rb +0 -23
- data/lib/brick_ftp/api/history/folder.rb +0 -23
- data/lib/brick_ftp/api/history/login.rb +0 -23
- data/lib/brick_ftp/api/history/site.rb +0 -23
- data/lib/brick_ftp/api/history/user.rb +0 -23
- data/lib/brick_ftp/api/notification.rb +0 -14
- data/lib/brick_ftp/api/permission.rb +0 -17
- data/lib/brick_ftp/api/public_key.rb +0 -15
- data/lib/brick_ftp/api/site_usage.rb +0 -21
- data/lib/brick_ftp/api/user.rb +0 -36
- data/lib/brick_ftp/api_component.rb +0 -81
- data/lib/brick_ftp/api_definition.rb +0 -65
- data/lib/brick_ftp/cli.rb +0 -7
- data/lib/brick_ftp/cli/config.rb +0 -20
- data/lib/brick_ftp/cli/main.rb +0 -26
- data/lib/brick_ftp/cli/site.rb +0 -10
- data/lib/brick_ftp/configuration.rb +0 -121
- data/lib/brick_ftp/http_client.rb +0 -130
- data/lib/brick_ftp/log_formatter.rb +0 -15
- data/lib/brick_ftp/webhook.rb +0 -4
- data/lib/brick_ftp/webhook/request.rb +0 -28
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show an API key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-an-api-key Show an API key
|
8
|
+
#
|
9
|
+
class GetAPIKey
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single API key.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each user API key.
|
15
|
+
# Each user API key is given an ID automatically upon creation.
|
16
|
+
# @return [BrickFTP::Types::UserAPIKey] User's API key
|
17
|
+
#
|
18
|
+
def call(id)
|
19
|
+
res = client.get("/api/rest/v1/api_keys/#{id}.json")
|
20
|
+
|
21
|
+
BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show a behavior
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-a-behavior Show a behavior
|
8
|
+
#
|
9
|
+
class GetBehavior
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single behavior.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each behavior.
|
15
|
+
# @return [BrickFTP::Types::Behavior, nil] found Behavior or nil
|
16
|
+
#
|
17
|
+
def call(id)
|
18
|
+
res = client.get("/api/rest/v1/behaviors/#{id}.json")
|
19
|
+
return nil if !res || res.empty?
|
20
|
+
|
21
|
+
BrickFTP::Types::Behavior.new(res.symbolize_keys)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show a bundle
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-a-bundle Show a bundle
|
8
|
+
#
|
9
|
+
class GetBundle
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single bundle.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each bundle.
|
15
|
+
# @return [BrickFTP::Types::Bundle] Bundle
|
16
|
+
#
|
17
|
+
def call(id)
|
18
|
+
res = client.get("/api/rest/v1/bundles/#{id}.json")
|
19
|
+
return nil if !res || res.empty?
|
20
|
+
|
21
|
+
BrickFTP::Types::Bundle.new(res.symbolize_keys)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Download entire bundle as ZIP
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#download-entire-bundle-as-zip Download entire bundle as ZIP
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | ------ | -----------
|
13
|
+
# code, | string | Unique code string identifier for the bundle.
|
14
|
+
# password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
|
15
|
+
#
|
16
|
+
class GetBundleZip
|
17
|
+
include Command
|
18
|
+
using BrickFTP::CoreExt::Struct
|
19
|
+
using BrickFTP::CoreExt::Hash
|
20
|
+
|
21
|
+
Params = Struct.new(
|
22
|
+
'GetBundleZipParams',
|
23
|
+
:code,
|
24
|
+
:password,
|
25
|
+
keyword_init: true
|
26
|
+
)
|
27
|
+
|
28
|
+
# Provides a download URL that will enable you to download all the files in a bundle as a single ZIP.
|
29
|
+
#
|
30
|
+
# The download URLs can be downloaded using an HTTP GET to the same hostname providing the download_uri
|
31
|
+
# as the URL path. This will be routed by our frontend proxies to our ZIP server that will stream the ZIP.
|
32
|
+
# The ZIP download link is valid for 3 minutes.
|
33
|
+
#
|
34
|
+
# The password parameter is required only for bundles that are password-protected.
|
35
|
+
# If a bundle is password-protected and the password is missing or incorrect, an error message will
|
36
|
+
# specify that the correct password is required.
|
37
|
+
#
|
38
|
+
# @param [BrickFTP::RESTfulAPI::GetFileInBundle::Params] params parameters
|
39
|
+
# @return [BrickFTP::Types::BundleZip] BundleZip
|
40
|
+
#
|
41
|
+
def call(params)
|
42
|
+
res = client.post('/api/rest/v1/bundles/zip.json', params.to_h.compact)
|
43
|
+
|
44
|
+
BrickFTP::Types::BundleZip.new(res.symbolize_keys)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Download one file in a bundle
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#download-one-file-in-a-bundle Download one file in a bundle
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | ------ | -----------
|
13
|
+
# code | string | Unique code string identifier for the bundle.
|
14
|
+
# path | string |
|
15
|
+
# password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
|
16
|
+
#
|
17
|
+
class GetFileInBundle
|
18
|
+
include Command
|
19
|
+
using BrickFTP::CoreExt::Struct
|
20
|
+
using BrickFTP::CoreExt::Hash
|
21
|
+
|
22
|
+
Params = Struct.new(
|
23
|
+
'GetFileInBundleParams',
|
24
|
+
:code,
|
25
|
+
:path,
|
26
|
+
:password,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# Provides a download URL to download a single file in the bundle.
|
31
|
+
#
|
32
|
+
# The download URL is a direct URL to Amazon S3 that has been signed by BrickFTP to provide temporary access to the
|
33
|
+
# file. The download links are valid for 3 minutes. For details on the attributes in the response body from this
|
34
|
+
# endpoint, please see The file object.
|
35
|
+
#
|
36
|
+
# The password parameter is required only for bundles that are password-protected. If a bundle is password-protected
|
37
|
+
# and the password is missing or incorrect, an error message will specify that the correct password is required.
|
38
|
+
#
|
39
|
+
# @param [BrickFTP::RESTfulAPI::GetFileInBundle::Params] params parameters
|
40
|
+
# @return [BrickFTP::Types::FileInBundle] FileInBundle
|
41
|
+
#
|
42
|
+
def call(params)
|
43
|
+
res = client.post('/api/rest/v1/bundles/download.json', params.to_h.compact)
|
44
|
+
|
45
|
+
BrickFTP::Types::FileInBundle.new(res.symbolize_keys)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Get folder size
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#get-folder-size Get folder size
|
10
|
+
#
|
11
|
+
class GetFolderSize
|
12
|
+
include Command
|
13
|
+
|
14
|
+
# Returns the size (in bytes) of the specified folder, recursively.
|
15
|
+
#
|
16
|
+
# @param [String] path
|
17
|
+
# @return [Integer]
|
18
|
+
#
|
19
|
+
def call(path)
|
20
|
+
res = client.get("/api/rest/v1/folders/#{ERB::Util.url_encode(path)}?action=size")
|
21
|
+
res['data']['size']
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show a group
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-a-group Show a group
|
8
|
+
#
|
9
|
+
class GetGroup
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single group.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each group.
|
15
|
+
# Each group is given an ID automatically upon creation.
|
16
|
+
# @return [BrickFTP::Types::Group, nil] found Group or nil
|
17
|
+
#
|
18
|
+
def call(id)
|
19
|
+
res = client.get("/api/rest/v1/groups/#{id}.json")
|
20
|
+
return nil if !res || res.empty?
|
21
|
+
|
22
|
+
BrickFTP::Types::Group.new(res.symbolize_keys)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show a public key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-a-public-key Show a public key
|
8
|
+
#
|
9
|
+
class GetPublicKey
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single public key.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each public key.
|
15
|
+
# Each public key is given an ID automatically upon creation.
|
16
|
+
# @return [BrickFTP::Types::UserPublicKey] User's Public key
|
17
|
+
#
|
18
|
+
def call(id)
|
19
|
+
res = client.get("/api/rest/v1/public_keys/#{id}.json")
|
20
|
+
|
21
|
+
BrickFTP::Types::UserPublicKey.new(res.symbolize_keys)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
class GetSiteUsage
|
6
|
+
include Command
|
7
|
+
|
8
|
+
# Returns site usage
|
9
|
+
#
|
10
|
+
# @return [BrickFTP::Types::SiteUsage] site usage
|
11
|
+
#
|
12
|
+
def call
|
13
|
+
res = client.get('/api/rest/v1/site/usage.json')
|
14
|
+
|
15
|
+
BrickFTP::Types::SiteUsage.new(res.symbolize_keys)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Show a user
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#show-a-user Show a user
|
8
|
+
#
|
9
|
+
class GetUser
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a single user.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each user.
|
15
|
+
# Each user is given an ID automatically upon creation.
|
16
|
+
# @return [BrickFTP::Types::User, nil] found User or nil
|
17
|
+
#
|
18
|
+
def call(id)
|
19
|
+
res = client.get("/api/rest/v1/users/#{id}.json")
|
20
|
+
return nil if !res || res.empty?
|
21
|
+
|
22
|
+
BrickFTP::Types::User.new(res.symbolize_keys)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# List API keys
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#list-api-keys List API keys
|
8
|
+
#
|
9
|
+
class ListAPIKeys
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a list of all API keys for a user on the current site.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each user.
|
15
|
+
# Each user is given an ID automatically upon creation.
|
16
|
+
# @return [Array<BrickFTP::Types::UserAPIKey>] User's API keys
|
17
|
+
#
|
18
|
+
def call(id)
|
19
|
+
res = client.get("/api/rest/v1/users/#{id}/api_keys.json")
|
20
|
+
|
21
|
+
res.map { |i| BrickFTP::Types::UserAPIKey.new(i.symbolize_keys) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# List all behaviors
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#list-all-behaviors List all behaviors
|
8
|
+
#
|
9
|
+
class ListBehaviors
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a list of all behaviors on the current site.
|
13
|
+
#
|
14
|
+
# @return [Array<BrickFTP::Types::Behavior>] Behaviors
|
15
|
+
#
|
16
|
+
def call
|
17
|
+
res = client.get('/api/rest/v1/behaviors.json')
|
18
|
+
|
19
|
+
res.map { |i| BrickFTP::Types::Behavior.new(i.symbolize_keys) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# List bundle contents
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#list-bundle-contents List bundle contents
|
10
|
+
#
|
11
|
+
# ### Params
|
12
|
+
#
|
13
|
+
# PARAMETER | TYPE | DESCRIPTION
|
14
|
+
# --------- | ------ | -----------
|
15
|
+
# code | string | Unique code string identifier for the bundle.
|
16
|
+
# password | string | Optional password to password-protect the bundle. This property is write-only. It cannot be retrieved via the API.
|
17
|
+
#
|
18
|
+
class ListBundleContents
|
19
|
+
include Command
|
20
|
+
using BrickFTP::CoreExt::Struct
|
21
|
+
using BrickFTP::CoreExt::Hash
|
22
|
+
|
23
|
+
Params = Struct.new(
|
24
|
+
'ListBundleContentsParams',
|
25
|
+
:code,
|
26
|
+
:password,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# This unauthenticated (public) endpoint lists the contents of a bundle.
|
31
|
+
#
|
32
|
+
# When no path is specified, the contents of the root of the bundle will be listed. The contents of a subfolder
|
33
|
+
# can be listed by providing its path in the URL after /contents, for example: /bundles/contents/cloud/images.
|
34
|
+
# Alternatively, you can provide path as a parameter in the request body instead of in the URL.
|
35
|
+
#
|
36
|
+
# This endpoint only reveals the public part of the file paths (i.e. relative to the root of the bundle).
|
37
|
+
# To view the full path of included files, use the authenticated Show Bundle endpoint above.
|
38
|
+
#
|
39
|
+
# The password parameter is required only for bundles that are password-protected. If a bundle is password-protected
|
40
|
+
# and the password is missing or incorrect, an error message will specify that the correct password is required.
|
41
|
+
#
|
42
|
+
# @param [String, nil] path
|
43
|
+
# @param [BrickFTP::RESTfulAPI::ListBundleContents::Params] params parameters
|
44
|
+
# @return [Array<BrickFTP::Types::BundleContent>] BundleContent
|
45
|
+
#
|
46
|
+
def call(params, path: nil)
|
47
|
+
endpoint = if path
|
48
|
+
"/api/rest/v1/bundles/contents/#{ERB::Util.url_encode(path)}"
|
49
|
+
else
|
50
|
+
'/api/rest/v1/bundles/contents.json'
|
51
|
+
end
|
52
|
+
res = client.post(endpoint, params.to_h.compact)
|
53
|
+
|
54
|
+
res.map { |i| BrickFTP::Types::BundleContent.new(i.symbolize_keys) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# List all bundles
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#list-all-bundles List all bundles
|
8
|
+
#
|
9
|
+
class ListBundles
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a list of all bundles on the current site.
|
13
|
+
#
|
14
|
+
# @return [Array<BrickFTP::Types::Bundle>] Bundle
|
15
|
+
#
|
16
|
+
def call
|
17
|
+
res = client.get('/api/rest/v1/bundles.json')
|
18
|
+
|
19
|
+
res.map { |i| BrickFTP::Types::Bundle.new(i.symbolize_keys) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|