Class: BrickFTP::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/brick_ftp/client.rb

Instance Method Summary collapse

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.

Parameters:

  • path (String)
  • copy_destination (String)

Returns:

  • (BrickFTP::API::FileCopy)

See Also:



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.

Parameters:

  • attributes (Hash)

    Behavior’s attributes.

See Also:



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.

Parameters:

  • attributes (Hash)

    Bundle’s attributes.

See Also:



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.

Parameters:

  • path (String)

Returns:

See Also:



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.

Parameters:

  • attributes (Hash)

    Group’s attributes.

See Also:



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.

Parameters:

  • attributes (Hash)

    Notification’s attributes.

See Also:



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.

Parameters:

  • attributes (Hash)

    Permission’s attributes.

See Also:



103
104
105
# File 'lib/brick_ftp/client.rb', line 103

def create_permission(attributes)
  BrickFTP::API::Permission.create(attributes)
end

#create_user(attributes) ⇒ Object

Create a new user on the current site.

Parameters:

  • attributes (Hash)

    User’s attributes.

See Also:



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.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



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.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



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.

Parameters:

  • file_or_path (BrickFTP::API::File, String)

    file object or file(folder) path.

  • recursive: (Boolean) (defaults to: false)

Returns:

  • (Boolean)

    return true.

See Also:



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.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



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.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



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.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



111
112
113
# File 'lib/brick_ftp/client.rb', line 111

def delete_permission(permission_or_id)
  instantize_permission(permission_or_id).destroy
end

#delete_user(user_or_id) ⇒ Boolean

Delete a user.

Parameters:

Returns:

  • (Boolean)

    return true.

See Also:



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_behaviorsArray

List all behaviors on the current site.

Returns:

  • (Array)

    array of BrickFTP::API::Behavior

See Also:



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.

Parameters:

  • path (String) (defaults to: nil)
  • code (String)
  • host (String)

Returns:

  • (Array)

    array of ‘BrickFTP::API::BundleContent`.

See Also:



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.

Parameters:

  • code (String)
  • host (String)
  • paths (Array) (defaults to: [])

    array of path string.

Returns:

  • (Array)

    array of ‘BrickFTP::API::BundleDownload`.

See Also:



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_bundlesArray

List all bundles on the current site.

Returns:

  • (Array)

    array of BrickFTP::API::Bundle

See Also:



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.

Parameters:

  • path (String)

    path of file.

  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).

  • start_at (String) (defaults to: nil)

    Date and time in the history to start from.

Returns:

  • (Array)

    array of ‘BrickFTP::API::History::File`

See Also:



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.

Returns:

  • (Array)

    array of BrickFTP::API::FolderBehavior

See Also:



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.

Parameters:

  • path (String)

    path of folder.

  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).

  • start_at (String) (defaults to: nil)

    Date and time in the history to start from.

Returns:

  • (Array)

    array of ‘BrickFTP::API::History::Folder`

See Also:



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.

Parameters:

  • path (String)
  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Maximum: 5000, leave blank for default (strongly recommended).

  • search (String) (defaults to: nil)

    Only return items matching the given search text.

  • sort_by_path (String) (defaults to: nil)

    Sort by file name, and value is either asc or desc to indicate normal or reverse sort. (Note that sort_by = asc is the default.)

  • sort_by_size (String) (defaults to: nil)

    Sort by file size, and value is either asc or desc to indicate smaller files first or larger files first, respectively.

  • sort_by_modified_at_datetime (String) (defaults to: nil)

    Sort by modification time, and value is either asc or desc to indicate older files first or newer files first, respectively.

Returns:

  • (Array)

    array of BrickFTP::API::Folder.

See Also:



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_groupsObject

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.

Parameters:

  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).

  • start_at (String) (defaults to: nil)

    Date and time in the history to start from.

Returns:

  • (Array)

    array of ‘BrickFTP::API::History::Login`

See Also:



153
154
155
156
# File 'lib/brick_ftp/client.rb', line 153

def (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::.all(query)
end

#list_notificationsObject

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_permissionsObject

List all permissions on the current site.



96
97
98
# File 'lib/brick_ftp/client.rb', line 96

def list_permissions
  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.

Parameters:

  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).

  • start_at (String) (defaults to: nil)

    Date and time in the history to start from.

Returns:

  • (Array)

    array of ‘BrickFTP::API::History::Site`

See Also:



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.

Parameters:

  • user_id (Integer)

    User ID.

  • page (Integer) (defaults to: nil)

    Page number of items to return in this request.

  • per_page (Integer) (defaults to: nil)

    Requested number of items returned per request. Default: 1000, maximum: 10000. Leave blank for default (strongly recommended).

  • start_at (String) (defaults to: nil)

    Date and time in the history to start from.

Returns:

  • (Array)

    array of ‘BrickFTP::API::History::User`

See Also:



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_usersArray

List all users on the current site.

Returns:

  • (Array)

    array of BrickFTP::API::User

See Also:



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.

Parameters:

  • username (String)

    username of BrickFTP’s user.

  • password (String)

    password of BrickFTP’s user.

See Also:



7
8
9
# File 'lib/brick_ftp/client.rb', line 7

def (username, password)
  BrickFTP::API::Authentication.(username, password)
end

#logoutObject

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.

Parameters:

  • path (String)
  • move_destination (String)

Returns:

  • (BrickFTP::API::FileMove)

See Also:



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.

Parameters:

  • id

    behavior id.

Returns:

See Also:



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.

Parameters:

  • id

    bundle id.

Returns:

See Also:



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.

Parameters:

  • path (String)

    path for file.

  • omit_download_uri (Boolean) (defaults to: false)

    If true, omit download_uri. (Add query ‘action=stat`)

Returns:

See Also:



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.

Parameters:

  • id

    group id.

Returns:

See Also:



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.

Parameters:

  • id

    user id.

Returns:

See Also:



28
29
30
# File 'lib/brick_ftp/client.rb', line 28

def show_user(id)
  BrickFTP::API::User.find(id)
end

#site_usageBrickFTP::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.

Parameters:

  • behavior_or_id (BrickFTP::API::Behavior, Integer)

    behavior object or behavior id.

  • attributes (Hash)

    Behavior’s attributes.

Returns:

See Also:



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.

Parameters:

  • group_or_id (BrickFTP::API::Group, Integer)

    group object or group id.

  • attributes (Hash)

    Group’s attributes.

Returns:

See Also:



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.

Parameters:

  • user_or_id (BrickFTP::API::User, Integer)

    user object or user id.

  • attributes (Hash)

    User’s attributes.

Returns:

See Also:



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.

Parameters:

  • path (String)
  • source (IO)

    source ‘data` (not `path`) to upload

Returns:

  • (BrickFTP::API::FileUpload)

See Also:



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