Class: BrickFTP::Client
- Inherits:
-
Object
- Object
- BrickFTP::Client
- Defined in:
- lib/brick_ftp/client.rb
Instance Method Summary collapse
-
#copy_file(path:, copy_destination:) ⇒ BrickFTP::API::FileCopy
Copy a file or folder to the destination provided in the copy_destination parameter.
-
#create_behavior(attributes) ⇒ Object
Create a new behavior on the current site.
-
#create_bundle(attributes) ⇒ Object
Create a new bundle on the current site.
-
#create_folder(path:) ⇒ BrickFTP::API::Folder
Create a folder.
-
#create_group(attributes) ⇒ Object
Create a new group on the current site.
-
#create_notification(attributes) ⇒ Object
Create a new notification on the current site.
-
#create_permission(attributes) ⇒ Object
Create a new permission on the current site.
-
#create_user(attributes) ⇒ Object
Create a new user on the current site.
-
#delete_behavior(behavior_or_id) ⇒ Boolean
Delete a behavior.
-
#delete_bundle(bundle_or_id) ⇒ Boolean
Delete a bundle.
-
#delete_file(file_or_path, recursive: false) ⇒ Boolean
Delete a file.
-
#delete_group(group_or_id) ⇒ Boolean
Delete a group.
-
#delete_notification(notification_or_id) ⇒ Boolean
Delete a notification.
-
#delete_permission(permission_or_id) ⇒ Boolean
Delete a permission.
-
#delete_user(user_or_id) ⇒ Boolean
Delete a user.
-
#list_behaviors ⇒ Array
List all behaviors on the current site.
-
#list_bundle_contents(path: nil, code:, host:) ⇒ Array
List the contents of a bundle.
-
#list_bundle_downloads(code:, host:, paths: []) ⇒ Array
Provides download URLs that will enable you to download the files in a bundle.
-
#list_bundles ⇒ Array
List all bundles on the current site.
-
#list_file_history(path:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific file.
-
#list_folder_behaviors(path:) ⇒ Array
shows the behaviors that apply to the given path.
-
#list_folder_history(path:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific folder.
-
#list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil) ⇒ Array
Lists the contents of the folder provided in the URL.
-
#list_groups ⇒ Object
List all groups on the current site.
-
#list_login_history(page: nil, per_page: nil, start_at: nil) ⇒ Array
Show login history only.
-
#list_notifications ⇒ Object
List all notifications on the current site.
-
#list_permissions ⇒ Object
List all permissions on the current site.
-
#list_site_history(page: nil, per_page: nil, start_at: nil) ⇒ Array
Show the entire history for the current site.
-
#list_user_history(user_id:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific user.
-
#list_users ⇒ Array
List all users on the current site.
-
#login(username, password) ⇒ Object
Login and store authentication session.
-
#logout ⇒ Object
Logout and discard authentication session.
-
#move_file(path:, move_destination:) ⇒ BrickFTP::API::FileMove
Move or renames a file or folder to the destination provided in the move_destination parameter.
-
#show_behavior(id) ⇒ BrickFTP::API::Behavior
Show a single behavior.
-
#show_bundle(id) ⇒ BrickFTP::API::Bundle
Show a single bundle.
-
#show_file(path, omit_download_uri: false) ⇒ BrickFTP::API::File
provides a download URL that will enable you to download a file.
-
#show_group(id) ⇒ BrickFTP::API::Group
Show a single group.
-
#show_user(id) ⇒ BrickFTP::API::User
Show a single user.
-
#site_usage ⇒ BrickFTP::API::SiteUsage
Get usage of site.
-
#update_behavior(behavior_or_id, attributes) ⇒ BrickFTP::API::Behavior
Update an existing behavior.
-
#update_group(group_or_id, attributes) ⇒ BrickFTP::API::Group
Update an existing group.
-
#update_user(user_or_id, attributes) ⇒ BrickFTP::API::User
Update an existing user.
-
#upload_file(path:, source:, chunk_size: nil) ⇒ BrickFTP::API::FileUpload
Upload file.
Instance Method Details
#copy_file(path:, copy_destination:) ⇒ BrickFTP::API::FileCopy
Copy a file or folder to the destination provided in the copy_destination parameter.
350 351 352 |
# File 'lib/brick_ftp/client.rb', line 350 def copy_file(path:, copy_destination:) BrickFTP::API::FileOperation::Copy.create(path: path, 'copy-destination': copy_destination) end |
#create_behavior(attributes) ⇒ Object
Create a new behavior on the current site.
267 268 269 |
# File 'lib/brick_ftp/client.rb', line 267 def create_behavior(attributes) BrickFTP::API::Behavior.create(attributes) end |
#create_bundle(attributes) ⇒ Object
Create a new bundle on the current site.
217 218 219 |
# File 'lib/brick_ftp/client.rb', line 217 def create_bundle(attributes) BrickFTP::API::Bundle.create(attributes) end |
#create_folder(path:) ⇒ BrickFTP::API::Folder
Create a folder.
321 322 323 |
# File 'lib/brick_ftp/client.rb', line 321 def create_folder(path:) BrickFTP::API::Folder.create(path: path) end |
#create_group(attributes) ⇒ Object
Create a new group on the current site.
73 74 75 |
# File 'lib/brick_ftp/client.rb', line 73 def create_group(attributes) BrickFTP::API::Group.create(attributes) end |
#create_notification(attributes) ⇒ Object
Create a new notification on the current site.
124 125 126 |
# File 'lib/brick_ftp/client.rb', line 124 def create_notification(attributes) BrickFTP::API::Notification.create(attributes) end |
#create_permission(attributes) ⇒ Object
Create a new permission on the current site.
103 104 105 |
# File 'lib/brick_ftp/client.rb', line 103 def (attributes) BrickFTP::API::Permission.create(attributes) end |
#create_user(attributes) ⇒ Object
Create a new user on the current site.
35 36 37 |
# File 'lib/brick_ftp/client.rb', line 35 def create_user(attributes) BrickFTP::API::User.create(attributes) end |
#delete_behavior(behavior_or_id) ⇒ Boolean
Delete a behavior.
284 285 286 |
# File 'lib/brick_ftp/client.rb', line 284 def delete_behavior(behavior_or_id) instantize_behavior(behavior_or_id).destroy end |
#delete_bundle(bundle_or_id) ⇒ Boolean
Delete a bundle.
225 226 227 |
# File 'lib/brick_ftp/client.rb', line 225 def delete_bundle(bundle_or_id) instantize_bundle(bundle_or_id).destroy end |
#delete_file(file_or_path, recursive: false) ⇒ Boolean
Delete a file.
359 360 361 |
# File 'lib/brick_ftp/client.rb', line 359 def delete_file(file_or_path, recursive: false) instantize_file(file_or_path).destroy(recursive: recursive) end |
#delete_group(group_or_id) ⇒ Boolean
Delete a group.
90 91 92 |
# File 'lib/brick_ftp/client.rb', line 90 def delete_group(group_or_id) instantize_group(group_or_id).destroy end |
#delete_notification(notification_or_id) ⇒ Boolean
Delete a notification.
132 133 134 |
# File 'lib/brick_ftp/client.rb', line 132 def delete_notification(notification_or_id) instantize_notification(notification_or_id).destroy end |
#delete_permission(permission_or_id) ⇒ Boolean
Delete a permission.
111 112 113 |
# File 'lib/brick_ftp/client.rb', line 111 def () ().destroy end |
#delete_user(user_or_id) ⇒ Boolean
Delete a user.
52 53 54 |
# File 'lib/brick_ftp/client.rb', line 52 def delete_user(user_or_id) instantize_user(user_or_id).destroy end |
#list_behaviors ⇒ Array
List all behaviors on the current site.
252 253 254 |
# File 'lib/brick_ftp/client.rb', line 252 def list_behaviors BrickFTP::API::Behavior.all end |
#list_bundle_contents(path: nil, code:, host:) ⇒ Array
List the contents of a bundle.
235 236 237 |
# File 'lib/brick_ftp/client.rb', line 235 def list_bundle_contents(path: nil, code:, host:) BrickFTP::API::BundleContent.all(path: path, code: code, host: host) end |
#list_bundle_downloads(code:, host:, paths: []) ⇒ Array
Provides download URLs that will enable you to download the files in a bundle.
245 246 247 |
# File 'lib/brick_ftp/client.rb', line 245 def list_bundle_downloads(code:, host:, paths: []) BrickFTP::API::BundleDownload.all(code: code, host: host, paths: paths) end |
#list_bundles ⇒ Array
List all bundles on the current site.
202 203 204 |
# File 'lib/brick_ftp/client.rb', line 202 def list_bundles BrickFTP::API::Bundle.all end |
#list_file_history(path:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific file.
194 195 196 197 |
# File 'lib/brick_ftp/client.rb', line 194 def list_file_history(path:, page: nil, per_page: nil, start_at: nil) query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? } BrickFTP::API::History::File.all(query) end |
#list_folder_behaviors(path:) ⇒ Array
shows the behaviors that apply to the given path.
291 292 293 |
# File 'lib/brick_ftp/client.rb', line 291 def list_folder_behaviors(path:) BrickFTP::API::FolderBehavior.all(path: path) end |
#list_folder_history(path:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific folder.
181 182 183 184 |
# File 'lib/brick_ftp/client.rb', line 181 def list_folder_history(path:, page: nil, per_page: nil, start_at: nil) query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? } BrickFTP::API::History::Folder.all(query) end |
#list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil) ⇒ Array
Lists the contents of the folder provided in the URL.
309 310 311 312 313 314 315 |
# File 'lib/brick_ftp/client.rb', line 309 def list_folders(path:, page: nil, per_page: nil, search: nil, sort_by_path: nil, sort_by_size: nil, sort_by_modified_at_datetime: nil) # rubocop:disable Metrics/LineLength query = { path: path, page: page, per_page: per_page, search: search }.reject { |_, v| v.nil? } query[:'sort_by[path]'] = sort_by_path if sort_by_path query[:'sort_by[size]'] = sort_by_size if sort_by_size query[:'sort_by[modified_at_datetime]'] = sort_by_modified_at_datetime if sort_by_modified_at_datetime BrickFTP::API::Folder.all(query) end |
#list_groups ⇒ Object
List all groups on the current site.
58 59 60 |
# File 'lib/brick_ftp/client.rb', line 58 def list_groups BrickFTP::API::Group.all end |
#list_login_history(page: nil, per_page: nil, start_at: nil) ⇒ Array
Show login history only.
155 156 157 158 |
# File 'lib/brick_ftp/client.rb', line 155 def list_login_history(page: nil, per_page: nil, start_at: nil) query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? } BrickFTP::API::History::Login.all(query) end |
#list_notifications ⇒ Object
List all notifications on the current site.
117 118 119 |
# File 'lib/brick_ftp/client.rb', line 117 def list_notifications BrickFTP::API::Notification.all end |
#list_permissions ⇒ Object
List all permissions on the current site.
96 97 98 |
# File 'lib/brick_ftp/client.rb', line 96 def BrickFTP::API::Permission.all end |
#list_site_history(page: nil, per_page: nil, start_at: nil) ⇒ Array
Show the entire history for the current site.
143 144 145 146 |
# File 'lib/brick_ftp/client.rb', line 143 def list_site_history(page: nil, per_page: nil, start_at: nil) query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? } BrickFTP::API::History::Site.all(query) end |
#list_user_history(user_id:, page: nil, per_page: nil, start_at: nil) ⇒ Array
Show all history for a specific user.
168 169 170 171 |
# File 'lib/brick_ftp/client.rb', line 168 def list_user_history(user_id:, page: nil, per_page: nil, start_at: nil) query = { user_id: user_id, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? } BrickFTP::API::History::User.all(query) end |
#list_users ⇒ Array
List all users on the current site.
20 21 22 |
# File 'lib/brick_ftp/client.rb', line 20 def list_users BrickFTP::API::User.all end |
#login(username, password) ⇒ Object
Login and store authentication session.
7 8 9 |
# File 'lib/brick_ftp/client.rb', line 7 def login(username, password) BrickFTP::API::Authentication.login(username, password) end |
#logout ⇒ Object
Logout and discard authentication session.
13 14 15 |
# File 'lib/brick_ftp/client.rb', line 13 def logout BrickFTP::API::Authentication.logout end |
#move_file(path:, move_destination:) ⇒ BrickFTP::API::FileMove
Move or renames a file or folder to the destination provided in the move_destination parameter.
341 342 343 |
# File 'lib/brick_ftp/client.rb', line 341 def move_file(path:, move_destination:) BrickFTP::API::FileOperation::Move.create(path: path, 'move-destination': move_destination) end |
#show_behavior(id) ⇒ BrickFTP::API::Behavior
Show a single behavior.
260 261 262 |
# File 'lib/brick_ftp/client.rb', line 260 def show_behavior(id) BrickFTP::API::Behavior.find(id) end |
#show_bundle(id) ⇒ BrickFTP::API::Bundle
Show a single bundle.
210 211 212 |
# File 'lib/brick_ftp/client.rb', line 210 def show_bundle(id) BrickFTP::API::Bundle.find(id) end |
#show_file(path, omit_download_uri: false) ⇒ BrickFTP::API::File
provides a download URL that will enable you to download a file.
330 331 332 333 334 |
# File 'lib/brick_ftp/client.rb', line 330 def show_file(path, omit_download_uri: false) params = {} params[:action] = 'stat' if omit_download_uri BrickFTP::API::File.find(path, params: params) end |
#show_group(id) ⇒ BrickFTP::API::Group
Show a single group.
66 67 68 |
# File 'lib/brick_ftp/client.rb', line 66 def show_group(id) BrickFTP::API::Group.find(id) end |
#show_user(id) ⇒ BrickFTP::API::User
Show a single user.
28 29 30 |
# File 'lib/brick_ftp/client.rb', line 28 def show_user(id) BrickFTP::API::User.find(id) end |
#site_usage ⇒ BrickFTP::API::SiteUsage
Get usage of site.
375 376 377 |
# File 'lib/brick_ftp/client.rb', line 375 def site_usage BrickFTP::API::SiteUsage.find end |
#update_behavior(behavior_or_id, attributes) ⇒ BrickFTP::API::Behavior
Update an existing behavior.
276 277 278 |
# File 'lib/brick_ftp/client.rb', line 276 def update_behavior(behavior_or_id, attributes) instantize_behavior(behavior_or_id).update(attributes) end |
#update_group(group_or_id, attributes) ⇒ BrickFTP::API::Group
Update an existing group.
82 83 84 |
# File 'lib/brick_ftp/client.rb', line 82 def update_group(group_or_id, attributes) instantize_group(group_or_id).update(attributes) end |
#update_user(user_or_id, attributes) ⇒ BrickFTP::API::User
Update an existing user.
44 45 46 |
# File 'lib/brick_ftp/client.rb', line 44 def update_user(user_or_id, attributes) instantize_user(user_or_id).update(attributes) end |
#upload_file(path:, source:, chunk_size: nil) ⇒ BrickFTP::API::FileUpload
Upload file.
369 370 371 |
# File 'lib/brick_ftp/client.rb', line 369 def upload_file(path:, source:, chunk_size: nil) BrickFTP::API::FileOperation::Upload.create(path: path, source: source, chunk_size: chunk_size) end |