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:) ⇒ 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.
341 342 343 |
# File 'lib/brick_ftp/client.rb', line 341 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.
262 263 264 |
# File 'lib/brick_ftp/client.rb', line 262 def create_behavior(attributes) BrickFTP::API::Behavior.create(attributes) end |
#create_bundle(attributes) ⇒ Object
Create a new bundle on the current site.
212 213 214 |
# File 'lib/brick_ftp/client.rb', line 212 def create_bundle(attributes) BrickFTP::API::Bundle.create(attributes) end |
#create_folder(path:) ⇒ BrickFTP::API::Folder
Create a folder.
312 313 314 |
# File 'lib/brick_ftp/client.rb', line 312 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.
279 280 281 |
# File 'lib/brick_ftp/client.rb', line 279 def delete_behavior(behavior_or_id) instantize_behavior(behavior_or_id).destroy end |
#delete_bundle(bundle_or_id) ⇒ Boolean
Delete a bundle.
220 221 222 |
# File 'lib/brick_ftp/client.rb', line 220 def delete_bundle(bundle_or_id) instantize_bundle(bundle_or_id).destroy end |
#delete_file(file_or_path, recursive: false) ⇒ Boolean
Delete a file.
350 351 352 |
# File 'lib/brick_ftp/client.rb', line 350 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.
247 248 249 |
# File 'lib/brick_ftp/client.rb', line 247 def list_behaviors BrickFTP::API::Behavior.all end |
#list_bundle_contents(path: nil, code:, host:) ⇒ Array
List the contents of a bundle.
230 231 232 |
# File 'lib/brick_ftp/client.rb', line 230 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.
240 241 242 |
# File 'lib/brick_ftp/client.rb', line 240 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.
197 198 199 |
# File 'lib/brick_ftp/client.rb', line 197 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.
189 190 191 192 |
# File 'lib/brick_ftp/client.rb', line 189 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.
286 287 288 |
# File 'lib/brick_ftp/client.rb', line 286 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.
177 178 179 180 |
# File 'lib/brick_ftp/client.rb', line 177 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.
300 301 302 303 304 305 306 |
# File 'lib/brick_ftp/client.rb', line 300 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) 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.
153 154 155 156 |
# File 'lib/brick_ftp/client.rb', line 153 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.
142 143 144 145 |
# File 'lib/brick_ftp/client.rb', line 142 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.
165 166 167 168 |
# File 'lib/brick_ftp/client.rb', line 165 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.
332 333 334 |
# File 'lib/brick_ftp/client.rb', line 332 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.
255 256 257 |
# File 'lib/brick_ftp/client.rb', line 255 def show_behavior(id) BrickFTP::API::Behavior.find(id) end |
#show_bundle(id) ⇒ BrickFTP::API::Bundle
Show a single bundle.
205 206 207 |
# File 'lib/brick_ftp/client.rb', line 205 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.
321 322 323 324 325 |
# File 'lib/brick_ftp/client.rb', line 321 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.
365 366 367 |
# File 'lib/brick_ftp/client.rb', line 365 def site_usage BrickFTP::API::SiteUsage.find end |
#update_behavior(behavior_or_id, attributes) ⇒ BrickFTP::API::Behavior
Update an existing behavior.
271 272 273 |
# File 'lib/brick_ftp/client.rb', line 271 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:) ⇒ BrickFTP::API::FileUpload
Upload file.
359 360 361 |
# File 'lib/brick_ftp/client.rb', line 359 def upload_file(path:, source:) BrickFTP::API::FileOperation::Upload.create(path: path, source: source) end |