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,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a public key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-public-key Create a public key
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# ---------- | ------- | -----------
|
13
|
+
# title | string | Title to identify the public key. For your reference. Maximum of 50 characters.
|
14
|
+
# public_key | string | The public key itself. This property is write-only. It cannot be retrieved via the API.
|
15
|
+
#
|
16
|
+
class CreatePublicKey
|
17
|
+
include Command
|
18
|
+
using BrickFTP::CoreExt::Struct
|
19
|
+
using BrickFTP::CoreExt::Hash
|
20
|
+
|
21
|
+
Params = Struct.new(
|
22
|
+
'CreatePublicKeyParams',
|
23
|
+
:title,
|
24
|
+
:public_key,
|
25
|
+
keyword_init: true
|
26
|
+
)
|
27
|
+
|
28
|
+
# Creates a new public key for a user on the current site.
|
29
|
+
#
|
30
|
+
# @param [Integer] id Globally unique identifier of each user.
|
31
|
+
# Each user is given an ID automatically upon creation.
|
32
|
+
# @param [BrickFTP::RESTfulAPI::CreatePublicKey::Params] params parameters for creating an Public key
|
33
|
+
# @return [BrickFTP::Types::UserPublicKey] User's Public key
|
34
|
+
#
|
35
|
+
def call(id, params)
|
36
|
+
res = client.post("/api/rest/v1/users/#{id}/public_keys.json", params.to_h.compact)
|
37
|
+
|
38
|
+
BrickFTP::Types::UserPublicKey.new(res.symbolize_keys)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a user
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-user Create a user
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# ----------------------- | ------------------------ | -----------
|
13
|
+
# username | string | Username for the user. This is how the user will be displayed on the site. Maximum of 50 characters.
|
14
|
+
# authentication_method | enum | Authentication method for this user. Can be one of the following: password, ldap, or oauth_google. Default is password.
|
15
|
+
# password | string | Password for the user. This property is write-only. It cannot be retrieved via the API.
|
16
|
+
# password_confirmation | string | Confirms the new password provided in the password field. This field is optional but will be validated if provided.
|
17
|
+
# authenticate_until | datetime | If set, the user will be blocked from logging in after this date.
|
18
|
+
# name | string | Real name of the user. For your reference. Maximum of 50 characters.
|
19
|
+
# email | string | E-Mail address of the user. Maximum of 50 characters.
|
20
|
+
# notes | text | You may use this property to store any additional information you require. There are no restrictions on its formatting.
|
21
|
+
# group_ids | comma-separated integers | IDs of the Groups that this user is in.
|
22
|
+
# ftp_permission | boolean | Allow user access via FTP/FTPS (port 21 or 990) interface. Default is true.
|
23
|
+
# sftp_permission | boolean | Allow user access via SFTP (port 22) interface. Default is true.
|
24
|
+
# dav_permission | boolean | Allow user access via WebDAV (port 443) interface. Default is true.
|
25
|
+
# restapi_permission | boolean | Allow user access the REST API, via HTTP/HTTPS (port 80 or 443), and the desktop application. Default is true.
|
26
|
+
# attachments_permission | boolean | Allow user to use Sharing tab in web interface to share files with anonymous users via a unique URL. Default is false.
|
27
|
+
# self_managed | boolean | Allow user to change their password and user information via the web interface. Default is true.
|
28
|
+
# require_password_change | boolean | Require user to change their password at their next login. Note: requires restapi_permission to be true, as password changes can only occur via the web interface. Default is false.
|
29
|
+
# allowed_ips | text | List allowed IPs, one per line. You may specify a range in CIDR format, such as 192.168.1.0/27. Leave blank to allow all IPs. If you are also restricting IP addresses on the Site tab, users matching in either place will be allowed to log in.
|
30
|
+
# user_root | string | Folder to show as the root when this user logs in via the FTP interface. Make sure this folder exists, as it will not be automatically created. Does not apply to the web interface! This should not contain a leading slash, but must contain a trailing slash. Example: Users/jenny/. Limit of 250 characters.
|
31
|
+
# time_zone | string | File modification times will be displayed in this time zone. Default is Eastern Time (US & Canada).
|
32
|
+
# language | string | The language that BrickFTP will be displayed in, if the translation is available. Leave as default (null) to auto-detect or use the site setting.
|
33
|
+
# grant_permission | enum | Value must be set to full, read, write, preview, read+write, or preview+write. The user will be granted that permission on their FTP root folder as defined by the user_root. This property is write-only. It cannot be retrieved via the User resource of the REST API, though may be obtained with the Permissions resource of the REST API.
|
34
|
+
# ssl_required | enum | Whether or not SSL encryption is required on all connections for this user. Can be one of the following: use_system_setting, always_require, or never_require. Default is use_system_setting.
|
35
|
+
# site_admin | boolean | If set to true, this user will be treated as a site-wide administrator. Default is false.
|
36
|
+
# receive_admin_alerts | boolean | Enable this user to receive alerts sent to site administrators. This property will only be accepted/returned if site_admin is true. Default is false.
|
37
|
+
# subscribe_to_newsletter | boolean | Add this user to the BrickFTP newsletter and our mailing list for notices about product updates. This property will only be accepted/returned if site_admin is true. Default is false.
|
38
|
+
# can_create_new_users | boolean | If true, this user will be able to create other users within groups where they have administrator privileges. Default is false.
|
39
|
+
# admin_group_ids | comma-separated integers | IDs of the Groups that this user is an administrator of.
|
40
|
+
#
|
41
|
+
class CreateUser
|
42
|
+
include Command
|
43
|
+
using BrickFTP::CoreExt::Struct
|
44
|
+
using BrickFTP::CoreExt::Hash
|
45
|
+
|
46
|
+
Params = Struct.new(
|
47
|
+
'CreateUserParams',
|
48
|
+
:username,
|
49
|
+
:authentication_method,
|
50
|
+
:password,
|
51
|
+
:password_confirmation,
|
52
|
+
:authenticate_until,
|
53
|
+
:name,
|
54
|
+
:email,
|
55
|
+
:notes,
|
56
|
+
:group_ids,
|
57
|
+
:ftp_permission,
|
58
|
+
:sftp_permission,
|
59
|
+
:dav_permission,
|
60
|
+
:restapi_permission,
|
61
|
+
:attachments_permission,
|
62
|
+
:self_managed,
|
63
|
+
:require_password_change,
|
64
|
+
:allowed_ips,
|
65
|
+
:user_root,
|
66
|
+
:time_zone,
|
67
|
+
:language,
|
68
|
+
:grant_permission,
|
69
|
+
:ssl_required,
|
70
|
+
:site_admin,
|
71
|
+
:receive_admin_alerts,
|
72
|
+
:subscribe_to_newsletter,
|
73
|
+
:can_create_new_users,
|
74
|
+
:admin_group_ids,
|
75
|
+
keyword_init: true
|
76
|
+
)
|
77
|
+
|
78
|
+
# Creates a new user on the current site.
|
79
|
+
#
|
80
|
+
# @param [BrickFTP::RESTfulAPI::CreateUser::Params] params parameters for create a user
|
81
|
+
# @return [BrickFTP::Types::User] create User
|
82
|
+
#
|
83
|
+
def call(params)
|
84
|
+
res = client.post('/api/rest/v1/users.json', params.to_h.compact)
|
85
|
+
|
86
|
+
BrickFTP::Types::User.new(res.symbolize_keys)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a user in a group
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-user-in-a-groupCreate a user in a group
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# ----------------------- | ------------------------ | -----------
|
13
|
+
# username | string | Username for the user. This is how the user will be displayed on the site. Maximum of 50 characters.
|
14
|
+
# password | string | Password for the user. This property is write-only. It cannot be retrieved via the API.
|
15
|
+
# authenticate_until | datetime | If set, the user will be blocked from logging in after this date.
|
16
|
+
# name | string | Real name of the user. For your reference. Maximum of 50 characters.
|
17
|
+
# email | string | E-Mail address of the user. Maximum of 50 characters.
|
18
|
+
# notes | text | You may use this property to store any additional information you require. There are no restrictions on its formatting.
|
19
|
+
# group_ids | comma-separated integers | IDs of the Groups that this user is in.
|
20
|
+
# require_password_change | boolean | Require user to change their password at their next login. Note: requires restapi_permission to be true, as password changes can only occur via the web interface. Default is false.
|
21
|
+
# user_root | string | Folder to show as the root when this user logs in via the FTP interface. Make sure this folder exists, as it will not be automatically created. Does not apply to the web interface! This should not contain a leading slash, but must contain a trailing slash. Example: Users/jenny/. Limit of 250 characters.
|
22
|
+
# time_zone | string | File modification times will be displayed in this time zone. Default is Eastern Time (US & Canada).
|
23
|
+
# language | string | The language that BrickFTP will be displayed in, if the translation is available. Leave as default (null) to auto-detect or use the site setting.
|
24
|
+
#
|
25
|
+
class CreateUserInGroup
|
26
|
+
include Command
|
27
|
+
using BrickFTP::CoreExt::Struct
|
28
|
+
using BrickFTP::CoreExt::Hash
|
29
|
+
|
30
|
+
Params = Struct.new(
|
31
|
+
'CreateUserInGroupParams',
|
32
|
+
:username,
|
33
|
+
:password,
|
34
|
+
:authenticate_until,
|
35
|
+
:name,
|
36
|
+
:email,
|
37
|
+
:notes,
|
38
|
+
:group_ids,
|
39
|
+
:require_password_change,
|
40
|
+
:user_root,
|
41
|
+
:time_zone,
|
42
|
+
:language,
|
43
|
+
keyword_init: true
|
44
|
+
)
|
45
|
+
|
46
|
+
# Creates a new user within a specified group.
|
47
|
+
#
|
48
|
+
# @param [Integer] id Globally unique identifier of each group.
|
49
|
+
# Each group is given an ID automatically upon creation.
|
50
|
+
# @param [BrickFTP::RESTfulAPI::CreateUserInGroup::Params] params parameters
|
51
|
+
# @return [BrickFTP::Types::User] created User
|
52
|
+
#
|
53
|
+
def call(id, params)
|
54
|
+
res = client.post("/api/rest/v1/groups/#{id}/users.json", user: params.to_h.compact)
|
55
|
+
|
56
|
+
BrickFTP::Types::User.new(res.symbolize_keys)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete an API key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-an-api-key Delete an API key
|
8
|
+
#
|
9
|
+
class DeleteAPIKey
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified 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
|
+
#
|
17
|
+
def call(id)
|
18
|
+
client.delete("/api/rest/v1/api_keys/#{id}.json")
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a behavior
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-behavior Delete a behavior
|
8
|
+
#
|
9
|
+
class DeleteBehavior
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes a behavior.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each behavior.
|
15
|
+
#
|
16
|
+
def call(id)
|
17
|
+
client.delete("/api/rest/v1/behaviors/#{id}.json")
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a bundle
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-bundle Delete a bundle
|
8
|
+
#
|
9
|
+
class DeleteBundle
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified bundle.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each bundle.
|
15
|
+
#
|
16
|
+
def call(id)
|
17
|
+
client.delete("/api/rest/v1/bundles/#{id}.json")
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Delete a file or folder
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#delete-a-file-or-folder Delete a file or folder
|
10
|
+
#
|
11
|
+
class DeleteFolder
|
12
|
+
include Command
|
13
|
+
|
14
|
+
# Deletes a file or folder.
|
15
|
+
#
|
16
|
+
# Note that this operation works for both files and folders, but normally it will only work on empty folders.
|
17
|
+
# If you want to recursively delete a folder and all its contents, send the request with a `Depth` header
|
18
|
+
# with the value set to `infinity`.
|
19
|
+
#
|
20
|
+
# @param [String] path Full path of the file or folder. Maximum of 550 characters.
|
21
|
+
# @param [Boolean] recursive
|
22
|
+
#
|
23
|
+
def call(path, recursive: false)
|
24
|
+
headers = {}
|
25
|
+
headers = { 'Depth' => 'infinity' } if recursive
|
26
|
+
|
27
|
+
client.delete("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", headers)
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a group
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-group Delete a group
|
8
|
+
#
|
9
|
+
class DeleteGroup
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified group.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each group.
|
15
|
+
# Each group is given an ID automatically upon creation.
|
16
|
+
#
|
17
|
+
def call(id)
|
18
|
+
client.delete("/api/rest/v1/groups/#{id}.json")
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a notification
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-notification Delete a notification
|
8
|
+
#
|
9
|
+
class DeleteNotification
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified notification.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each notification.
|
15
|
+
# Each notification is given an ID automatically upon creation.
|
16
|
+
#
|
17
|
+
def call(id)
|
18
|
+
client.delete("/api/rest/v1/notifications/#{id}.json")
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a permission
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-permission Delete a permission
|
8
|
+
#
|
9
|
+
class DeletePermission
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified group.
|
13
|
+
#
|
14
|
+
# @param [Integer] id Globally unique identifier of each permission.
|
15
|
+
# Each permission is given an ID automatically upon creation.
|
16
|
+
#
|
17
|
+
def call(id)
|
18
|
+
client.delete("/api/rest/v1/permissions/#{id}.json")
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a public key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-public-key Delete a public key
|
8
|
+
#
|
9
|
+
class DeletePublicKey
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified 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
|
+
#
|
17
|
+
def call(id)
|
18
|
+
client.delete("/api/rest/v1/public_keys/#{id}.json")
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Delete a user
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#delete-a-user Delete a user
|
8
|
+
#
|
9
|
+
class DeleteUser
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Deletes the specified user.
|
13
|
+
#
|
14
|
+
# For additional security, this method requires reauthentication when updating a password unless an API key is used.
|
15
|
+
#
|
16
|
+
# @param [Integer] id Globally unique identifier of each user.
|
17
|
+
# Each user is given an ID automatically upon creation.
|
18
|
+
#
|
19
|
+
def call(id)
|
20
|
+
client.delete("/api/rest/v1/users/#{id}.json")
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Download a file
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#download-a-file Download a file
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | -------- | -----------
|
13
|
+
# action | string | Optionally set to `stat` to have the `download_uri` field omitted in the response and no download action logged.
|
14
|
+
#
|
15
|
+
class DownloadFile
|
16
|
+
include Command
|
17
|
+
|
18
|
+
# Provides a download URL that will enable you to download a file.
|
19
|
+
#
|
20
|
+
# The download URL is a direct URL to Amazon S3 that has been signed by BrickFTP to provide temporary
|
21
|
+
# access to the file. The download links are valid for 3 minutes.
|
22
|
+
#
|
23
|
+
# By default this request assumes that the file will be downloaded, and therefore a download action is
|
24
|
+
# logged for the user that is logged into the REST API session. If downloading the file is not desired,
|
25
|
+
# but rather one is just looking at the information associated with the file such as the MD5 checksum or
|
26
|
+
# file size, then the action query parameter can be passed in on the URL with the value of stat.
|
27
|
+
# This causes the download_uri field to be omitted in the response and no download action to be logged.
|
28
|
+
#
|
29
|
+
# @param [String] path Full path of the file or folder. Maximum of 550 characters.
|
30
|
+
# @param [Boolean] stat Optionally set to stat to have the `download_uri` field
|
31
|
+
# omitted in the response and no download action logged.
|
32
|
+
# @return [BrickFTP::Types::File] File
|
33
|
+
#
|
34
|
+
def call(path, stat: false)
|
35
|
+
endpoint = "/api/rest/v1/files/#{ERB::Util.url_encode(path)}"
|
36
|
+
endpoint = "#{endpoint}?action=stat" if stat
|
37
|
+
res = client.get(endpoint)
|
38
|
+
return nil if !res || res.empty?
|
39
|
+
|
40
|
+
BrickFTP::Types::File.new(res.symbolize_keys)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|