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.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +0 -5
  3. data/.rubocop.yml +2 -1
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +16 -12
  6. data/Gemfile +2 -0
  7. data/README.md +24 -43
  8. data/Rakefile +2 -0
  9. data/bin/console +1 -0
  10. data/brick_ftp.gemspec +10 -9
  11. data/exe/brick_ftp +1 -0
  12. data/lib/brick_ftp.rb +5 -78
  13. data/lib/brick_ftp/client.rb +35 -411
  14. data/lib/brick_ftp/core_ext.rb +8 -0
  15. data/lib/brick_ftp/core_ext/hash.rb +13 -0
  16. data/lib/brick_ftp/core_ext/hash/compact.rb +13 -0
  17. data/lib/brick_ftp/core_ext/struct.rb +13 -0
  18. data/lib/brick_ftp/core_ext/struct/new.rb +16 -0
  19. data/lib/brick_ftp/restful_api.rb +82 -0
  20. data/lib/brick_ftp/restful_api/add_group_member.rb +44 -0
  21. data/lib/brick_ftp/restful_api/client.rb +179 -0
  22. data/lib/brick_ftp/restful_api/command.rb +21 -0
  23. data/lib/brick_ftp/restful_api/complete_upload.rb +46 -0
  24. data/lib/brick_ftp/restful_api/continue_upload.rb +50 -0
  25. data/lib/brick_ftp/restful_api/copy_folder.rb +46 -0
  26. data/lib/brick_ftp/restful_api/count_folder_contents.rb +36 -0
  27. data/lib/brick_ftp/restful_api/count_users.rb +22 -0
  28. data/lib/brick_ftp/restful_api/create_api_key.rb +46 -0
  29. data/lib/brick_ftp/restful_api/create_behavior.rb +42 -0
  30. data/lib/brick_ftp/restful_api/create_bundle.rb +40 -0
  31. data/lib/brick_ftp/restful_api/create_folder.rb +25 -0
  32. data/lib/brick_ftp/restful_api/create_group.rb +42 -0
  33. data/lib/brick_ftp/restful_api/create_notification.rb +44 -0
  34. data/lib/brick_ftp/restful_api/create_permission.rb +48 -0
  35. data/lib/brick_ftp/restful_api/create_public_key.rb +42 -0
  36. data/lib/brick_ftp/restful_api/create_user.rb +90 -0
  37. data/lib/brick_ftp/restful_api/create_user_in_group.rb +60 -0
  38. data/lib/brick_ftp/restful_api/delete_api_key.rb +23 -0
  39. data/lib/brick_ftp/restful_api/delete_behavior.rb +22 -0
  40. data/lib/brick_ftp/restful_api/delete_bundle.rb +22 -0
  41. data/lib/brick_ftp/restful_api/delete_folder.rb +32 -0
  42. data/lib/brick_ftp/restful_api/delete_group.rb +23 -0
  43. data/lib/brick_ftp/restful_api/delete_notification.rb +23 -0
  44. data/lib/brick_ftp/restful_api/delete_permission.rb +23 -0
  45. data/lib/brick_ftp/restful_api/delete_public_key.rb +23 -0
  46. data/lib/brick_ftp/restful_api/delete_user.rb +25 -0
  47. data/lib/brick_ftp/restful_api/download_file.rb +44 -0
  48. data/lib/brick_ftp/restful_api/get_api_key.rb +25 -0
  49. data/lib/brick_ftp/restful_api/get_behavior.rb +25 -0
  50. data/lib/brick_ftp/restful_api/get_bundle.rb +25 -0
  51. data/lib/brick_ftp/restful_api/get_bundle_zip.rb +48 -0
  52. data/lib/brick_ftp/restful_api/get_file_in_bundle.rb +49 -0
  53. data/lib/brick_ftp/restful_api/get_folder_size.rb +25 -0
  54. data/lib/brick_ftp/restful_api/get_group.rb +26 -0
  55. data/lib/brick_ftp/restful_api/get_public_key.rb +25 -0
  56. data/lib/brick_ftp/restful_api/get_site_usage.rb +19 -0
  57. data/lib/brick_ftp/restful_api/get_user.rb +26 -0
  58. data/lib/brick_ftp/restful_api/list_api_keys.rb +25 -0
  59. data/lib/brick_ftp/restful_api/list_behaviors.rb +23 -0
  60. data/lib/brick_ftp/restful_api/list_bundle_contents.rb +58 -0
  61. data/lib/brick_ftp/restful_api/list_bundles.rb +23 -0
  62. data/lib/brick_ftp/restful_api/list_folder_behaviors.rb +39 -0
  63. data/lib/brick_ftp/restful_api/list_folders.rb +108 -0
  64. data/lib/brick_ftp/restful_api/list_groups.rb +23 -0
  65. data/lib/brick_ftp/restful_api/list_notifications.rb +23 -0
  66. data/lib/brick_ftp/restful_api/list_permissions.rb +41 -0
  67. data/lib/brick_ftp/restful_api/list_public_keys.rb +25 -0
  68. data/lib/brick_ftp/restful_api/list_users.rb +60 -0
  69. data/lib/brick_ftp/restful_api/move_folder.rb +41 -0
  70. data/lib/brick_ftp/restful_api/remove_group_member.rb +23 -0
  71. data/lib/brick_ftp/restful_api/retrieve_file_history.rb +41 -0
  72. data/lib/brick_ftp/restful_api/retrieve_folder_history.rb +41 -0
  73. data/lib/brick_ftp/restful_api/retrieve_history.rb +54 -0
  74. data/lib/brick_ftp/restful_api/retrieve_login_history.rb +38 -0
  75. data/lib/brick_ftp/restful_api/retrieve_site_history.rb +38 -0
  76. data/lib/brick_ftp/restful_api/retrieve_user_history.rb +40 -0
  77. data/lib/brick_ftp/restful_api/search_user.rb +28 -0
  78. data/lib/brick_ftp/restful_api/start_upload.rb +27 -0
  79. data/lib/brick_ftp/restful_api/unlock_user.rb +25 -0
  80. data/lib/brick_ftp/restful_api/update_behavior.rb +39 -0
  81. data/lib/brick_ftp/restful_api/update_group.rb +44 -0
  82. data/lib/brick_ftp/restful_api/update_group_member.rb +40 -0
  83. data/lib/brick_ftp/restful_api/update_user.rb +101 -0
  84. data/lib/brick_ftp/restful_api/upload_file.rb +65 -0
  85. data/lib/brick_ftp/types.rb +23 -0
  86. data/lib/brick_ftp/types/behavior.rb +27 -0
  87. data/lib/brick_ftp/types/bundle.rb +34 -0
  88. data/lib/brick_ftp/types/bundle_content.rb +25 -0
  89. data/lib/brick_ftp/types/bundle_zip.rb +19 -0
  90. data/lib/brick_ftp/types/file.rb +45 -0
  91. data/lib/brick_ftp/types/file_in_bundle.rb +25 -0
  92. data/lib/brick_ftp/types/folder_contents_count.rb +24 -0
  93. data/lib/brick_ftp/types/group.rb +31 -0
  94. data/lib/brick_ftp/types/group_membership.rb +27 -0
  95. data/lib/brick_ftp/types/history.rb +43 -0
  96. data/lib/brick_ftp/types/notification.rb +31 -0
  97. data/lib/brick_ftp/types/permission.rb +35 -0
  98. data/lib/brick_ftp/types/site_usage.rb +23 -0
  99. data/lib/brick_ftp/types/upload.rb +45 -0
  100. data/lib/brick_ftp/types/user.rb +79 -0
  101. data/lib/brick_ftp/types/user_api_key.rb +33 -0
  102. data/lib/brick_ftp/types/user_public_key.rb +28 -0
  103. data/lib/brick_ftp/utils.rb +2 -0
  104. data/lib/brick_ftp/utils/chunk_io.rb +5 -4
  105. data/lib/brick_ftp/version.rb +3 -1
  106. metadata +123 -86
  107. data/lib/brick_ftp/api.rb +0 -9
  108. data/lib/brick_ftp/api/authentication.rb +0 -28
  109. data/lib/brick_ftp/api/authentication/session.rb +0 -25
  110. data/lib/brick_ftp/api/base.rb +0 -119
  111. data/lib/brick_ftp/api/behavior.rb +0 -19
  112. data/lib/brick_ftp/api/bundle.rb +0 -17
  113. data/lib/brick_ftp/api/bundle_content.rb +0 -18
  114. data/lib/brick_ftp/api/bundle_download.rb +0 -18
  115. data/lib/brick_ftp/api/file.rb +0 -20
  116. data/lib/brick_ftp/api/file_operation.rb +0 -6
  117. data/lib/brick_ftp/api/file_operation/copy.rb +0 -10
  118. data/lib/brick_ftp/api/file_operation/move.rb +0 -10
  119. data/lib/brick_ftp/api/file_operation/upload.rb +0 -66
  120. data/lib/brick_ftp/api/file_operation/uploading_result.rb +0 -22
  121. data/lib/brick_ftp/api/file_operation/uploading_session.rb +0 -95
  122. data/lib/brick_ftp/api/folder.rb +0 -22
  123. data/lib/brick_ftp/api/folder_behavior.rb +0 -12
  124. data/lib/brick_ftp/api/group.rb +0 -16
  125. data/lib/brick_ftp/api/history.rb +0 -6
  126. data/lib/brick_ftp/api/history/file.rb +0 -23
  127. data/lib/brick_ftp/api/history/folder.rb +0 -23
  128. data/lib/brick_ftp/api/history/login.rb +0 -23
  129. data/lib/brick_ftp/api/history/site.rb +0 -23
  130. data/lib/brick_ftp/api/history/user.rb +0 -23
  131. data/lib/brick_ftp/api/notification.rb +0 -14
  132. data/lib/brick_ftp/api/permission.rb +0 -17
  133. data/lib/brick_ftp/api/public_key.rb +0 -15
  134. data/lib/brick_ftp/api/site_usage.rb +0 -21
  135. data/lib/brick_ftp/api/user.rb +0 -36
  136. data/lib/brick_ftp/api_component.rb +0 -81
  137. data/lib/brick_ftp/api_definition.rb +0 -65
  138. data/lib/brick_ftp/cli.rb +0 -7
  139. data/lib/brick_ftp/cli/config.rb +0 -20
  140. data/lib/brick_ftp/cli/main.rb +0 -26
  141. data/lib/brick_ftp/cli/site.rb +0 -10
  142. data/lib/brick_ftp/configuration.rb +0 -121
  143. data/lib/brick_ftp/http_client.rb +0 -130
  144. data/lib/brick_ftp/log_formatter.rb +0 -15
  145. data/lib/brick_ftp/webhook.rb +0 -4
  146. data/lib/brick_ftp/webhook/request.rb +0 -28
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # List behaviors for a folder
8
+ #
9
+ # @see https://developers.brickftp.com/#list-behaviors-for-a-folder List behaviors for a folder
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # --------- | -------- | -----------
15
+ # recursive | integer | Optionally set to 1 to have response include behaviors inherited from parent folders.
16
+ #
17
+ class ListFolderBehaviors
18
+ include Command
19
+
20
+ # Returns the behaviors that apply to the given path.
21
+ #
22
+ # By default, only behaviors applied directly on the the given path will be returned.
23
+ # If you would also like behaviors that are inherited from parent folders to be returned,
24
+ # the recursive query parameter can be passed in on the URL with the value of 1.
25
+ #
26
+ # @param [String] path
27
+ # @param [Boolean] recursive
28
+ # @return [Array<BrickFTP::Types::Behavior>] Behaviors
29
+ #
30
+ def call(path, recursive: false)
31
+ endpoint = "/api/rest/v1/behaviors/folders/#{ERB::Util.url_encode(path)}"
32
+ endpoint = "#{endpoint}?recursive=1" if recursive
33
+ res = client.get(endpoint)
34
+
35
+ res.map { |i| BrickFTP::Types::Behavior.new(i.symbolize_keys) }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # List folder contents
8
+ #
9
+ # @see https://developers.brickftp.com/#list-folder-contents List folder contents
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # ----------------------------- | -------- | -----------
15
+ # page | integer | Page number of items to return in this request.
16
+ # per_page | integer | Requested number of items returned per request. Maximum: `5000`, leave blank for default (strongly recommended).
17
+ # search | string | Only return items matching the given search text.
18
+ # sort_by[path] | enum | Sort by file name, and value is either `asc` or `desc` to indicate normal or reverse sort. (Note that `sort_by[path] = asc` is the default.)
19
+ # sort_by[size] | enum | Sort by file size, and value is either `asc` or `desc` to indicate smaller files first or larger files first, respectively.
20
+ # sort_by[modified_at_datetime] | enum | Sort by modification time, and value is either `asc` or `desc` to indicate older files first or newer files first, respectively.
21
+ #
22
+ class ListFolders
23
+ include Command
24
+ using BrickFTP::CoreExt::Struct
25
+ using BrickFTP::CoreExt::Hash
26
+
27
+ Params = Struct.new(
28
+ 'ListFoldersParams',
29
+ :page,
30
+ :per_page,
31
+ :search,
32
+ :'sort_by[path]',
33
+ :'sort_by[size]',
34
+ :'sort_by[modified_at_datetime]',
35
+ keyword_init: true
36
+ )
37
+
38
+ # Lists the contents of the folder provided in the URL.
39
+ #
40
+ # Remember that a blank URL refers to the root folder. So for example, you can list the contents of the root folder
41
+ # using the REST API by sending a GET request to /folders. Another folder can be listed by inserting its complete
42
+ # path in that URL after /folders, for example: /folders/employee/engineering.
43
+ #
44
+ # There is a maximum number of entries in the folder that will be listed with a single request
45
+ # (default 1000 or whatever value you provide as the per_page parameter).
46
+ # So if exactly that many entries are returned you will need to increment the value of the page parameter in
47
+ # subsequent queries to continue listing the folder.
48
+ #
49
+ # @param [String] path Full path of the file or folder. Maximum of 550 characters.
50
+ # @param [BrickFTP::RESTfulAPI::ListFolders::Params, nil] params parameters
51
+ # @return [Array<BrickFTP::Types::File>] Files
52
+ #
53
+ def call(path, params = nil)
54
+ validate_params!(params)
55
+
56
+ query = build_query(params)
57
+ endpoint = "/api/rest/v1/folders/#{ERB::Util.url_encode(path)}"
58
+ endpoint = "#{endpoint}?#{query}" unless query.empty?
59
+
60
+ res = client.get(endpoint)
61
+
62
+ res.map { |i| BrickFTP::Types::File.new(i.symbolize_keys) }
63
+ end
64
+
65
+ private
66
+
67
+ def build_query(params)
68
+ return '' if params.nil?
69
+
70
+ params.to_h.compact.map { |k, v| "#{k}=#{ERB::Util.url_encode(v.to_s)}" }.join('&')
71
+ end
72
+
73
+ def validate_params!(params)
74
+ return if params.nil?
75
+
76
+ validate_page!(params[:page])
77
+ validate_per_page!(params[:per_page])
78
+ validate_sort_by!(params[:'sort_by[path]'])
79
+ validate_sort_by!(params[:'sort_by[size]'])
80
+ validate_sort_by!(params[:'sort_by[modified_at_datetime]'])
81
+ end
82
+
83
+ def validate_page!(page)
84
+ return if page.nil?
85
+ return if page.is_a?(Integer) && page.positive?
86
+
87
+ raise ArgumentError, 'page must be greater than 0.'
88
+ end
89
+
90
+ MAX_PER_PAGE = 5_000
91
+
92
+ def validate_per_page!(per_page)
93
+ return if per_page.nil?
94
+ return if per_page.is_a?(Integer) && per_page.positive? && per_page <= MAX_PER_PAGE
95
+
96
+ raise ArgumentError, "per_page must be greater than 0 and less than equal #{MAX_PER_PAGE}."
97
+ end
98
+
99
+ VALID_SORT = %w[asc desc].freeze
100
+
101
+ def validate_sort_by!(value)
102
+ return if value.nil? || VALID_SORT.include?(value)
103
+
104
+ raise ArgumentError, 'sort_by[*] must be `asc` or `desc`.'
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List all groups
6
+ #
7
+ # @see https://developers.brickftp.com/#list-all-groups List all groups
8
+ #
9
+ class ListGroups
10
+ include Command
11
+
12
+ # Returns a list of all groups on the current site.
13
+ #
14
+ # @return [Array<BrickFTP::Types::Group>] Groups
15
+ #
16
+ def call
17
+ res = client.get('/api/rest/v1/groups.json')
18
+
19
+ res.map { |i| BrickFTP::Types::Group.new(i.symbolize_keys) }
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
+ # List all notifications
6
+ #
7
+ # @see https://developers.brickftp.com/#list-all-notifications List all notifications
8
+ #
9
+ class ListNotifications
10
+ include Command
11
+
12
+ # Returns a list of all notifications on the current site.
13
+ #
14
+ # @return [Array<BrickFTP::Types::Notification>] Notifications
15
+ #
16
+ def call
17
+ res = client.get('/api/rest/v1/notifications.json')
18
+
19
+ res.map { |i| BrickFTP::Types::Notification.new(i.symbolize_keys) }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # List permissions
8
+ #
9
+ # @see https://developers.brickftp.com/#list-permissions List permissions
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # --------- | ------ | -----------
15
+ # path | string | Optional path to focus the result set on.
16
+ #
17
+ class ListPermissions
18
+ include Command
19
+
20
+ # Returns a list of permissions on the current site.
21
+ #
22
+ # - By default all permissions for the entire site are returned.
23
+ # - When given a path parameter, then only permissions immediately relevant to the given path are returned.
24
+ # - When using a path parameter, the result will include permissions on the current path and recursive
25
+ # permissions that are inherited from parent paths, except that lesser permissions will be excluded
26
+ # if a greater permission applies on the given path for a particular user or group.
27
+ #
28
+ # @param [String] path Folder path for the permission to apply to. This must be slash-delimited,
29
+ # but it must neither start nor end with a slash. Maximum of 5000 characters.
30
+ # @return [Array<BrickFTP::Types::Permission>] Permissions
31
+ #
32
+ def call(path: nil)
33
+ endpoint = '/api/rest/v1/permissions.json'
34
+ endpoint = "#{endpoint}?path=#{ERB::Util.url_encode(path)}" unless path.nil?
35
+ res = client.get(endpoint)
36
+
37
+ res.map { |i| BrickFTP::Types::Permission.new(i.symbolize_keys) }
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List public keys
6
+ #
7
+ # @see https://developers.brickftp.com/#list-public-keys List public keys
8
+ #
9
+ class ListPublicKeys
10
+ include Command
11
+
12
+ # Returns a list of all public 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::UserPublicKey>] User's Public keys
17
+ #
18
+ def call(id)
19
+ res = client.get("/api/rest/v1/users/#{id}/public_keys.json")
20
+
21
+ res.map { |i| BrickFTP::Types::UserPublicKey.new(i.symbolize_keys) }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # List users
6
+ #
7
+ # @see https://developers.brickftp.com/#list-users List users
8
+ #
9
+ # ### Params
10
+ #
11
+ # PARAMETER | TYPE | DESCRIPTION
12
+ # --------- | ------- | -----------
13
+ # page | integer | Optional page number of items to return in this request. Default: 1.
14
+ # per_page | integer | Optional requested number of items returned per request. Default: 1000. Leave blank for default (strongly recommended).
15
+ #
16
+ class ListUsers
17
+ include Command
18
+
19
+ # Returns a list of users on the current site.
20
+ #
21
+ # @param [Integer] page Optional page number of items to return in this request.
22
+ # Default: 1.
23
+ # @param [Integer] per_page Optional requested number of items returned per request.
24
+ # Default: 1000. Leave blank for default (strongly recommended).
25
+ # @return [Array<BrickFTP::Types::User>] Users
26
+ #
27
+ def call(page: nil, per_page: nil)
28
+ validate_page!(page)
29
+ validate_per_page!(per_page)
30
+
31
+ params = {}
32
+ params[:page] = page if page
33
+ params[:per_page] = per_page if per_page
34
+ query = params.map { |k, v| "#{k}=#{v}" }.join('&')
35
+
36
+ endpoint = '/api/rest/v1/users.json'
37
+ endpoint = "#{endpoint}?#{query}" unless query.empty?
38
+ res = client.get(endpoint)
39
+
40
+ res.map { |i| BrickFTP::Types::User.new(i.symbolize_keys) }
41
+ end
42
+
43
+ private
44
+
45
+ def validate_page!(page)
46
+ return if page.nil?
47
+ return if page.is_a?(Integer) && page.positive?
48
+
49
+ raise ArgumentError, 'page must be greater than 0.'
50
+ end
51
+
52
+ def validate_per_page!(per_page)
53
+ return if per_page.nil?
54
+ return if per_page.is_a?(Integer) && per_page.positive?
55
+
56
+ raise ArgumentError, 'per_page must be greater than 0.'
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # Move or rename a file or folder
8
+ #
9
+ # @see https://developers.brickftp.com/#move-or-rename-a-file-or-folder Move or rename a file or folder
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # ---------------- | ------ | -----------
15
+ # move-destination | string | Full path of the file or folder. Maximum of 550 characters.
16
+ #
17
+ class MoveFolder
18
+ include Command
19
+ using BrickFTP::CoreExt::Struct
20
+ using BrickFTP::CoreExt::Hash
21
+
22
+ Params = Struct.new(
23
+ 'MoveFolderParams',
24
+ :'move-destination',
25
+ keyword_init: true
26
+ )
27
+
28
+ # Moves or renames a file or folder to the destination provided in
29
+ # the `move-destination` parameter in the request body.
30
+ # Note that a move/rename will fail if the destination already exists.
31
+ #
32
+ # @param [String] path Full path of the file or folder. Maximum of 550 characters.
33
+ # @param [BrickFTP::RESTfulAPI::MoveFolder::Params] params parameters
34
+ #
35
+ def call(path, params)
36
+ client.post("/api/rest/v1/files/#{ERB::Util.url_encode(path)}", params.to_h.compact)
37
+ true
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BrickFTP
4
+ module RESTfulAPI
5
+ # Remove a member
6
+ #
7
+ # @see https://developers.brickftp.com/#remove-a-member Remove a member
8
+ #
9
+ class RemoveGroupMember
10
+ include Command
11
+
12
+ # Removes a user from a group. No action will be taken if the user is not already in the group.
13
+ #
14
+ # @param [Integer] group_id ID of the group the membership is associated with.
15
+ # @param [Integer] user_id ID of the user the membership is associated with.
16
+ #
17
+ def call(group_id, user_id)
18
+ client.delete("/api/rest/v1/groups/#{group_id}/memberships/#{user_id}.json")
19
+ true
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # Retrieve file history
8
+ #
9
+ # @see https://developers.brickftp.com/#retrieve-file-history Retrieve file history
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # --------- | -------- | -----------
15
+ # page | integer | Optional page number of items to return in this request.
16
+ # per_page | integer | Optional requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
17
+ # start_at | datetime | Optional date and time in the history to start from.
18
+ #
19
+ class RetrieveFileHistory
20
+ include Command
21
+ include RetrieveHistory
22
+
23
+ # Returns all history for a specific file.
24
+ #
25
+ # - The history starts with the most recent entries and proceeds back in time.
26
+ # - There is a maximum number of records that will be returned with a single request
27
+ # (default 1000 or whatever value you provide as the per_page parameter, up to a maximum of 10,000).
28
+ #
29
+ # @param [String] path Path of the file or folder associated with the history entry.
30
+ # @param [Integer] page Optional page number of items to return in this request.
31
+ # @param [Integer] per_page Optional requested number of items returned per request.
32
+ # Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
33
+ # @param [Time] start_at Optional date and time in the history to start from.
34
+ # @return [Array<BrickFTP::Types::History>] History
35
+ #
36
+ def call(path, page: nil, per_page: nil, start_at: nil)
37
+ retrieve("/api/rest/v1/history/files/#{ERB::Util.url_encode(path)}", page, per_page, start_at)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erb'
4
+
5
+ module BrickFTP
6
+ module RESTfulAPI
7
+ # Retrieve folder history
8
+ #
9
+ # @see https://developers.brickftp.com/#retrieve-folder-history Retrieve folder history
10
+ #
11
+ # ### Params
12
+ #
13
+ # PARAMETER | TYPE | DESCRIPTION
14
+ # --------- | -------- | -----------
15
+ # page | integer | Optional page number of items to return in this request.
16
+ # per_page | integer | Optional requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
17
+ # start_at | datetime | Optional date and time in the history to start from.
18
+ #
19
+ class RetrieveFolderHistory
20
+ include Command
21
+ include RetrieveHistory
22
+
23
+ # Returns all history for a specific folder.
24
+ #
25
+ # - The history starts with the most recent entries and proceeds back in time.
26
+ # - There is a maximum number of records that will be returned with a single request
27
+ # (default 1000 or whatever value you provide as the per_page parameter, up to a maximum of 10,000).
28
+ #
29
+ # @param [String] path Path of the file or folder associated with the history entry.
30
+ # @param [Integer] page Optional page number of items to return in this request.
31
+ # @param [Integer] per_page Optional requested number of items returned per request.
32
+ # Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).
33
+ # @param [Time] start_at Optional date and time in the history to start from.
34
+ # @return [Array<BrickFTP::Types::History>] History
35
+ #
36
+ def call(path, page: nil, per_page: nil, start_at: nil)
37
+ retrieve("/api/rest/v1/history/folders/#{ERB::Util.url_encode(path)}", page, per_page, start_at)
38
+ end
39
+ end
40
+ end
41
+ end