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,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Requesting additional upload URLs
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#requesting-additional-upload-urls Requesting additional upload URLs
|
10
|
+
#
|
11
|
+
# ### Params
|
12
|
+
#
|
13
|
+
# PARAMETER | TYPE | DESCRIPTION
|
14
|
+
# --------- | ------- | -----------
|
15
|
+
# ref | string | Unique identifier to reference this file upload. This identifier is needed for subsequent requests to the REST API to complete the upload or request more upload URLs.
|
16
|
+
# part | integer | part number of multi part uploads.
|
17
|
+
#
|
18
|
+
class ContinueUpload
|
19
|
+
include Command
|
20
|
+
using BrickFTP::CoreExt::Struct
|
21
|
+
using BrickFTP::CoreExt::Hash
|
22
|
+
|
23
|
+
Params = Struct.new(
|
24
|
+
'ContinueUploadParams',
|
25
|
+
:ref,
|
26
|
+
:part,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# Once an upload has been opened and before it is completed,
|
31
|
+
# additional upload URLs can be requested from the REST API.
|
32
|
+
#
|
33
|
+
# Send a POST request to `/files/PATH_AND_FILENAME.EXT` with parameter `action` set to `put`, parameter `ref` set to
|
34
|
+
# the reference ID returned at the start of the upload, and parameter `part` set to the part number the upload URL
|
35
|
+
# should refer to. The part number can be the same as one previously used if a new URL is required, either
|
36
|
+
# because the part is to be re-uploaded or because a prior upload attempt failed and the prior URL's signature
|
37
|
+
# has expired.
|
38
|
+
#
|
39
|
+
# @param [String] path Full path of the file or folder. Maximum of 550 characters.
|
40
|
+
# @param [BrickFTP::RESTfulAPI::ContinueUpload::Params] params parameters
|
41
|
+
# @return [BrickFTP::Types::Upload] Upload object
|
42
|
+
#
|
43
|
+
def call(path, params)
|
44
|
+
res = client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact.merge(action: 'put'))
|
45
|
+
|
46
|
+
BrickFTP::Types::Upload.new(res.symbolize_keys)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Copy a file or folder
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#copy-a-file-or-folder Copy a file or folder
|
10
|
+
#
|
11
|
+
# ### Params
|
12
|
+
#
|
13
|
+
# PARAMETER | TYPE | DESCRIPTION
|
14
|
+
# ---------------- | ------ | -----------
|
15
|
+
# copy-destination | string | Full path of the file or folder. Maximum of 550 characters.
|
16
|
+
# structure | any | Optionally, provide the parameter `structure` and set it to any value to only copy the folder structure without copying any files.
|
17
|
+
#
|
18
|
+
class CopyFolder
|
19
|
+
include Command
|
20
|
+
using BrickFTP::CoreExt::Struct
|
21
|
+
using BrickFTP::CoreExt::Hash
|
22
|
+
|
23
|
+
Params = Struct.new(
|
24
|
+
'CopyFolderParams',
|
25
|
+
:'copy-destination',
|
26
|
+
:structure,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# Copies a file or folder to the destination provided in the
|
31
|
+
# `copy-destination` parameter in the request body.
|
32
|
+
# Note that a copy will fail if the destination already exists.
|
33
|
+
#
|
34
|
+
# Optionally, provide the parameter `structure` and set it to any value
|
35
|
+
# to only copy the folder structure without copying any files.
|
36
|
+
#
|
37
|
+
# @param [String] path Full path of the file or folder. Maximum of 550 characters.
|
38
|
+
# @param [BrickFTP::RESTfulAPI::CopyFolder::Params] params parameters
|
39
|
+
#
|
40
|
+
def call(path, params)
|
41
|
+
client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact)
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Count folder contents
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#count-folder-contents-recursively Count folder contents recursively
|
10
|
+
# @see https://developers.brickftp.com/#count-folder-contents-non-recursively Count folder contents non-recursively
|
11
|
+
#
|
12
|
+
class CountFolderContents
|
13
|
+
include Command
|
14
|
+
|
15
|
+
# Returns number of files and folders.
|
16
|
+
#
|
17
|
+
# - Returns the combined total number of files and subfolders in a given folder recursively.
|
18
|
+
# - Returns the number of files and folders, separately, located inside a given folder (non-recursively).
|
19
|
+
#
|
20
|
+
# @param [String] path
|
21
|
+
# @param [Boolean] recursive
|
22
|
+
# @return [BrickFTP::Types::FolderContentsCount] count
|
23
|
+
#
|
24
|
+
def call(path, recursive: false)
|
25
|
+
action = recursive ? 'count' : 'count_nrs'
|
26
|
+
res = client.get("/api/rest/v1/folders/#{ERB::Util.url_encode(path)}?action=#{action}")
|
27
|
+
|
28
|
+
if recursive
|
29
|
+
BrickFTP::Types::FolderContentsCount.new(total: res['data']['count'])
|
30
|
+
else
|
31
|
+
BrickFTP::Types::FolderContentsCount.new(res['data']['count'].symbolize_keys)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Count users
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#count-users Count users
|
8
|
+
#
|
9
|
+
class CountUsers
|
10
|
+
include Command
|
11
|
+
|
12
|
+
# Returns a count of the number of users for the current site.
|
13
|
+
#
|
14
|
+
# @return [Integer] count
|
15
|
+
#
|
16
|
+
def call
|
17
|
+
res = client.get('/api/rest/v1/users.json?action=count')
|
18
|
+
res['data']['count']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create an API key
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-an-api-key Create an API key
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# -------------- | -------- | -----------
|
13
|
+
# name | string | Name to identify the user API key. For your reference. Maximum of 100 characters.
|
14
|
+
# permission_set | string | The permission set for the user API key. Can be desktop_app or full.
|
15
|
+
# platform | string | The platform for the user API key. Can be win32, macos, linux, or none. Applies only to API keys with a permission_set of desktop_app.
|
16
|
+
# expires_at | datetime | The date that this API key is valid through.
|
17
|
+
#
|
18
|
+
class CreateAPIKey
|
19
|
+
include Command
|
20
|
+
using BrickFTP::CoreExt::Struct
|
21
|
+
using BrickFTP::CoreExt::Hash
|
22
|
+
|
23
|
+
Params = Struct.new(
|
24
|
+
'CreateAPIKeyParams',
|
25
|
+
:name,
|
26
|
+
:permission_set,
|
27
|
+
:platform,
|
28
|
+
:expires_at,
|
29
|
+
keyword_init: true
|
30
|
+
)
|
31
|
+
|
32
|
+
# Creates a new API key for a user on the current site.
|
33
|
+
#
|
34
|
+
# @param [Integer] id Globally unique identifier of each user.
|
35
|
+
# Each user is given an ID automatically upon creation.
|
36
|
+
# @param [BrickFTP::RESTfulAPI::CreateAPIKey::Params] params parameters for creating an API key
|
37
|
+
# @return [BrickFTP::Types::UserAPIKey] User's API key
|
38
|
+
#
|
39
|
+
def call(id, params)
|
40
|
+
res = client.post("/api/rest/v1/users/#{id}/api_keys.json", params.to_h.compact)
|
41
|
+
|
42
|
+
BrickFTP::Types::UserAPIKey.new(res.symbolize_keys)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a behavior
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-behavior Create a behavior
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | ------ | -----------
|
13
|
+
# path | string | Folder path for behaviors. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
14
|
+
# behavior | string | The behavior type. Can be one of the following: webhook, file_expiration, auto_encrypt, lock_subfolders.
|
15
|
+
# value | array | Array of values associated with the behavior.
|
16
|
+
#
|
17
|
+
class CreateBehavior
|
18
|
+
include Command
|
19
|
+
using BrickFTP::CoreExt::Struct
|
20
|
+
using BrickFTP::CoreExt::Hash
|
21
|
+
|
22
|
+
Params = Struct.new(
|
23
|
+
'CreateBehaviorParams',
|
24
|
+
:path,
|
25
|
+
:behavior,
|
26
|
+
:value,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# Creates a new behavior.
|
31
|
+
#
|
32
|
+
# @param [BrickFTP::RESTfulAPI::CreateBehavior::Params] params parameters
|
33
|
+
# @return [BrickFTP::Types::Behavior] Behavior
|
34
|
+
#
|
35
|
+
def call(params)
|
36
|
+
res = client.post('/api/rest/v1/behaviors.json', params.to_h.compact)
|
37
|
+
|
38
|
+
BrickFTP::Types::Behavior.new(res.symbolize_keys)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a bundle
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-bundle Create a bundle
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | ------ | -----------
|
13
|
+
# paths | array | List of the paths associated with 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 CreateBundle
|
17
|
+
include Command
|
18
|
+
using BrickFTP::CoreExt::Struct
|
19
|
+
using BrickFTP::CoreExt::Hash
|
20
|
+
|
21
|
+
Params = Struct.new(
|
22
|
+
'CreateBundleParams',
|
23
|
+
:paths,
|
24
|
+
:password,
|
25
|
+
keyword_init: true
|
26
|
+
)
|
27
|
+
|
28
|
+
# Creates a new group on the current site.
|
29
|
+
#
|
30
|
+
# @param [BrickFTP::RESTfulAPI::CreateBundle::Params] params parameters
|
31
|
+
# @return [BrickFTP::Types::Bundle] Bundle
|
32
|
+
#
|
33
|
+
def call(params)
|
34
|
+
res = client.post('/api/rest/v1/bundles.json', params.to_h.compact)
|
35
|
+
|
36
|
+
BrickFTP::Types::Bundle.new(res.symbolize_keys)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'erb'
|
4
|
+
|
5
|
+
module BrickFTP
|
6
|
+
module RESTfulAPI
|
7
|
+
# Create a folder
|
8
|
+
#
|
9
|
+
# @see https://developers.brickftp.com/#create-a-folder Create a folder
|
10
|
+
#
|
11
|
+
class CreateFolder
|
12
|
+
include Command
|
13
|
+
|
14
|
+
# Creates a folder.
|
15
|
+
#
|
16
|
+
# @param [String] path
|
17
|
+
# @return [BrickFTP::Types::Folder] Folders
|
18
|
+
#
|
19
|
+
def call(path)
|
20
|
+
client.post("/api/rest/v1/folders/#{ERB::Util.url_encode(path)}")
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a group
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-group Create a group
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# --------- | ------------------------ | -----------
|
13
|
+
# name | string | Name of the group. This is how the group will be displayed on the site. Maximum of 50 characters.
|
14
|
+
# notes | text | You may use this property to store any additional information you require. There are no restrictions on its formatting.
|
15
|
+
# user_ids | comma-separated integers | IDs of the users that are in this group.
|
16
|
+
#
|
17
|
+
class CreateGroup
|
18
|
+
include Command
|
19
|
+
using BrickFTP::CoreExt::Struct
|
20
|
+
using BrickFTP::CoreExt::Hash
|
21
|
+
|
22
|
+
Params = Struct.new(
|
23
|
+
'CreateGroupParams',
|
24
|
+
:name,
|
25
|
+
:notes,
|
26
|
+
:user_ids,
|
27
|
+
keyword_init: true
|
28
|
+
)
|
29
|
+
|
30
|
+
# Creates a new group on the current site.
|
31
|
+
#
|
32
|
+
# @param [BrickFTP::RESTfulAPI::CreateGroup::Params] params parameters for creating a Group
|
33
|
+
# @return [BrickFTP::Types::Group] created Group
|
34
|
+
#
|
35
|
+
def call(params)
|
36
|
+
res = client.post('/api/rest/v1/groups.json', params.to_h.compact)
|
37
|
+
|
38
|
+
BrickFTP::Types::Group.new(res.symbolize_keys)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a notification
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-notification Create a notification
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# ------------- | ------- | -----------
|
13
|
+
# path | string | Folder path for notifications. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
14
|
+
# user_id | integer | Unique identifier for the user being notified. Each user is given an ID automatically upon creation. You can look up user IDs by using the User resource of this REST API.
|
15
|
+
# username | string | Username for the user given by user_id. If this value is set during creation and user_id is not set, the user_id is looked up from the username and set. Maximum of 50 characters.
|
16
|
+
# send_interval | string | The send interval for notifications. Can be one of the following: five_minutes (default), fifteen_minutes, hourly, daily.
|
17
|
+
#
|
18
|
+
class CreateNotification
|
19
|
+
include Command
|
20
|
+
using BrickFTP::CoreExt::Struct
|
21
|
+
using BrickFTP::CoreExt::Hash
|
22
|
+
|
23
|
+
Params = Struct.new(
|
24
|
+
'CreateNotificationParams',
|
25
|
+
:path,
|
26
|
+
:user_id,
|
27
|
+
:username,
|
28
|
+
:send_interval,
|
29
|
+
keyword_init: true
|
30
|
+
)
|
31
|
+
|
32
|
+
# Creates a new notification on the current site.
|
33
|
+
#
|
34
|
+
# @param [BrickFTP::RESTfulAPI::CreateNotification::Params] params parameters
|
35
|
+
# @return [BrickFTP::Types::Notification] Notification
|
36
|
+
#
|
37
|
+
def call(params)
|
38
|
+
res = client.post('/api/rest/v1/notifications.json', params.to_h.compact)
|
39
|
+
|
40
|
+
BrickFTP::Types::Notification.new(res.symbolize_keys)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BrickFTP
|
4
|
+
module RESTfulAPI
|
5
|
+
# Create a permission
|
6
|
+
#
|
7
|
+
# @see https://developers.brickftp.com/#create-a-permission Create a permission
|
8
|
+
#
|
9
|
+
# ### Params
|
10
|
+
#
|
11
|
+
# PARAMETER | TYPE | DESCRIPTION
|
12
|
+
# ---------- | ------- | -----------
|
13
|
+
# user_id | integer | Unique identifier for the user being granted a permission. Each user is given an ID automatically upon creation. The user_id and group_id fields cannot both be set.
|
14
|
+
# username | string | Username for the user, if user_id is set. If this value is set during creation and user_id is not set, the user_id is looked up from the username and set. Maximum of 50 characters.
|
15
|
+
# group_id | integer | Unique identifier for the group being granted a permission. Each group is given an ID automatically upon creation. The user_id and group_id fields cannot both be set.
|
16
|
+
# path | string | Folder path for the permission to apply to. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
17
|
+
# permission | enum | Value must be set to full, readonly, writeonly, previewonly, or history, depending on the type of access to be granted by the Permission.
|
18
|
+
# recursive | boolean | If set to false, the permission will be non-recursive, and will not apply to subfolders of the folder specified by the path property. Default is true.
|
19
|
+
#
|
20
|
+
class CreatePermission
|
21
|
+
include Command
|
22
|
+
using BrickFTP::CoreExt::Struct
|
23
|
+
using BrickFTP::CoreExt::Hash
|
24
|
+
|
25
|
+
Params = Struct.new(
|
26
|
+
'CreatePermissionParams',
|
27
|
+
:user_id,
|
28
|
+
:username,
|
29
|
+
:group_id,
|
30
|
+
:path,
|
31
|
+
:permission,
|
32
|
+
:recursive,
|
33
|
+
keyword_init: true
|
34
|
+
)
|
35
|
+
|
36
|
+
# Creates a new permission record.
|
37
|
+
#
|
38
|
+
# @param [BrickFTP::RESTfulAPI::CreatePermission::Params] params parameters
|
39
|
+
# @return [BrickFTP::Types::Permission] Permissions
|
40
|
+
#
|
41
|
+
def call(params)
|
42
|
+
res = client.post('/api/rest/v1/permissions.json', params.to_h.compact)
|
43
|
+
|
44
|
+
BrickFTP::Types::Permission.new(res.symbolize_keys)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|