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:



337
338
339
# File 'lib/brick_ftp/client.rb', line 337

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:



261
262
263
# File 'lib/brick_ftp/client.rb', line 261

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:



211
212
213
# File 'lib/brick_ftp/client.rb', line 211

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:



311
312
313
# File 'lib/brick_ftp/client.rb', line 311

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) ⇒ Boolean

Delete a behavior.

Parameters:

Returns:

  • (Boolean) —

    return true.

See Also:



278
279
280
# File 'lib/brick_ftp/client.rb', line 278

def delete_behavior(behavior)
  behavior.destroy
end

#delete_bundle(bundle) ⇒ Boolean

Delete a bundle.

Parameters:

Returns:

  • (Boolean) —

    return true.

See Also:



219
220
221
# File 'lib/brick_ftp/client.rb', line 219

def delete_bundle(bundle)
  bundle.destroy
end

#delete_file(file) ⇒ Boolean

Delete a file.

Parameters:

Returns:

  • (Boolean) —

    return true.

See Also:



345
346
347
# File 'lib/brick_ftp/client.rb', line 345

def delete_file(file)
  file.destroy
end

#delete_group(group) ⇒ 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)
  group.destroy
end

#delete_notification(notification) ⇒ 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)
  notification.destroy
end

#delete_permission(permission) ⇒ 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)
  permission.destroy
end

#delete_user(user) ⇒ 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)
  user.destroy
end

#list_behaviors ⇒ Array

List all behaviors on the current site.

Returns:

  • (Array) —

    array of BrickFTP::API::Behavior

See Also:



246
247
248
# File 'lib/brick_ftp/client.rb', line 246

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:



229
230
231
# File 'lib/brick_ftp/client.rb', line 229

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:



239
240
241
# File 'lib/brick_ftp/client.rb', line 239

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.

Returns:

  • (Array) —

    array of BrickFTP::API::Bundle

See Also:



196
197
198
# File 'lib/brick_ftp/client.rb', line 196

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:



188
189
190
191
# File 'lib/brick_ftp/client.rb', line 188

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:



285
286
287
# File 'lib/brick_ftp/client.rb', line 285

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:



176
177
178
179
# File 'lib/brick_ftp/client.rb', line 176

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:



299
300
301
302
303
304
305
# File 'lib/brick_ftp/client.rb', line 299

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.

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_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 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(page: nil, per_page: nil, start_at: nil) ⇒ Array

Show all history for a specific user.

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::User

See Also:



164
165
166
167
# File 'lib/brick_ftp/client.rb', line 164

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

#list_users ⇒ Array

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

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

Parameters:

  • path (String)
  • move_destination (String)

Returns:

  • (BrickFTP::API::FileMove)

See Also:



328
329
330
# File 'lib/brick_ftp/client.rb', line 328

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:



254
255
256
# File 'lib/brick_ftp/client.rb', line 254

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:



204
205
206
# File 'lib/brick_ftp/client.rb', line 204

def show_bundle(id)
  BrickFTP::API::Bundle.find(id)
end

#show_file(id) ⇒ BrickFTP::API::File

provides a download URL that will enable you to download a file.

Parameters:

  • id —

    file id.

Returns:

See Also:



319
320
321
# File 'lib/brick_ftp/client.rb', line 319

def show_file(id)
  BrickFTP::API::File.find(id)
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

#update_behavior(behavior, attributes) ⇒ BrickFTP::API::Behavior

Update an existing behavior.

Parameters:

Returns:

See Also:



270
271
272
# File 'lib/brick_ftp/client.rb', line 270

def update_behavior(behavior, attributes)
  behavior.update(attributes)
end

#update_group(group, attributes) ⇒ BrickFTP::API::Group

Update an existing group.

Parameters:

Returns:

See Also:



82
83
84
# File 'lib/brick_ftp/client.rb', line 82

def update_group(group, attributes)
  group.update(attributes)
end

#update_user(user, attributes) ⇒ BrickFTP::API::User

Update an existing user.

Parameters:

Returns:

See Also:



44
45
46
# File 'lib/brick_ftp/client.rb', line 44

def update_user(user, attributes)
  user.update(attributes)
end

#upload_file(path:, source:) ⇒ BrickFTP::API::FileUpload

Upload file.

Parameters:

  • path (String)
  • source (String) —

    path for source file.

Returns:

  • (BrickFTP::API::FileUpload)

See Also:



354
355
356
# File 'lib/brick_ftp/client.rb', line 354

def upload_file(path:, source:)
  BrickFTP::API::FileOperation::Upload.create(path: path, source: source)
end