cterasdk.core.files.browser module

cterasdk.core.files.browser module#

class cterasdk.core.files.browser.Backups(core)

Bases: FileBrowser

Backup management API.

device_config(device, destination=None)

Download a device configuration file.

Parameters:
  • device (str) – Device name.

  • destination (str, optional) – File destination. If a directory is provided, original filename is preserved. Defaults to default downloads directory.

Returns:

Path to local file.

Return type:

str

Raises:

cterasdk.exceptions.io.core.OpenError – Raised on error obtaining file handle.

class cterasdk.core.files.browser.CloudDrive(core)

Bases: FileBrowser

CloudDrive extends FileBrowser with upload and share functionality.

add_share_recipients(path, recipients)

Add share recipients.

Parameters:
Returns:

Current list of share members.

Return type:

list[cterasdk.core.types.Collaborator]

delete(*paths, wait=True)

Delete one or more files or folders.

Parameters:
  • paths (list[str]) – Paths to delete.

  • wait (bool, optional) – Wait for task completion. Defaults to True.

Returns:

Task status object, or awaitable task.

Return type:

cterasdk.common.object.Object or cterasdk.lib.tasks.AwaitablePortalTask

Raises:

cterasdk.exceptions.io.core.DeleteError – Raised on error deleting resources.

get_share_info(path)

Get share settings and recipients.

Parameters:

path (str) – Path.

Returns:

Share metadata.

Return type:

object

Raises:

cterasdk.exceptions.io.core.GetShareMetadataError – Raised on error obtaining share metadata.

makedirs(path)

Recursively create a directory.

Parameters:

path (str) – Directory path.

Returns:

Remote directory path.

Return type:

str

Raises:

cterasdk.exceptions.io.core.CreateDirectoryError – Raised on error creating directory.

mkdir(path)

Create a directory.

Parameters:

path (str) – Directory path.

Returns:

Remote directory path.

Return type:

str

Raises:

cterasdk.exceptions.io.core.CreateDirectoryError – Raised on error creating directory.

move(*paths, destination=None, resolver=None, cursor=None, wait=True)

Move one or more files or folders.

Parameters:
Returns:

Task status object, or awaitable task.

Return type:

cterasdk.common.object.Object or cterasdk.lib.tasks.AwaitablePortalTask

Raises:

cterasdk.exceptions.io.core.MoveError – Raised on error moving resources.

remove_share_recipients(path, accounts)

Remove share recipients.

Parameters:
Returns:

Current list of share members.

Return type:

list[cterasdk.core.types.Collaborator]

rename(path, name, *, resolver=None, wait=True)

Rename a file or folder.

Parameters:
  • path (str) – Path of the file or directory.

  • name (str) – New name.

  • resolver (cterasdk.core.types.ConflictResolver, optional) – Conflict resolver. Defaults None.

  • wait (bool, optional) – Wait for task completion. Defaults to True.

Returns:

Task status object, or awaitable task.

Return type:

cterasdk.common.object.Object or cterasdk.lib.tasks.AwaitablePortalTask

Raises:

cterasdk.exceptions.io.core.RenameError – Raised on error renaming object.

share(path, recipients, as_project=True, allow_reshare=True, allow_sync=True)

Share a file or folder.

Parameters:
  • path (str) – Path of the file or folder to share.

  • recipients (list[cterasdk.core.types.Collaborator]) – Share recipients.

  • as_project (bool, optional) – Share as a team project. Defaults True if cloud folder.

  • allow_reshare (bool, optional) – Allow re-share. Defaults True.

  • allow_sync (bool, optional) – Allow sync. Defaults True if cloud folder.

Returns:

Current list of share members.

Return type:

list[cterasdk.core.types.Collaborator]

undelete(*paths, wait=True)

Recover one or more files or folders.

Parameters:
  • paths (list[str]) – Paths to recover.

  • wait (bool, optional) – Wait for task completion. Defaults to True.

Returns:

Task status object, or awaitable task.

Return type:

cterasdk.common.object.Object or cterasdk.lib.tasks.AwaitablePortalTask

Raises:

cterasdk.exceptions.io.core.RecoverError – Raised on error recovering resources.

unshare(path)

Unshare a file or folder.

Parameters:

path (str) – Path of file/folder.

upload(destination, handle, name=None, size=None)

Upload from file handle.

Parameters:
  • destination (str) – Remote path.

  • handle (object) – File-like handle.

  • size (str, optional) – File size. Defaults to content length.

  • name (str, optional) – Filename to use if it cannot be derived from destination

Returns:

Remote file path.

Return type:

str

Raises:

cterasdk.exceptions.io.core.UploadError – Raised on upload failure.

upload_file(path, destination)

Upload a file.

Parameters:
  • path (str) – Local path.

  • destination (str) – Remote path.

Returns:

Remote file path.

Return type:

str

Raises:

cterasdk.exceptions.io.core.UploadError – Raised on upload failure.

class cterasdk.core.files.browser.FileBrowser(core)

Bases: BaseCommand

CTERA Portal File Browser API.

copy(*paths, destination=None, resolver=None, cursor=None, wait=True)

Copy one or more files or folders.

Parameters:
Returns:

Task status object, or awaitable task.

Return type:

cterasdk.common.object.Object or cterasdk.lib.tasks.AwaitablePortalTask

Raises:

cterasdk.exceptions.io.core.CopyError – Raised on failure to copy resources.

download(path, objects=None, destination=None)

Download a file.

Parameters:
  • path (str) – Path.

  • objects (list[str],optional) – List of files and / or directory names to download.

  • destination (str, optional) – File destination. If a directory is provided, the original filename is preserved. Defaults to the default download directory.

Returns:

Path to the local file.

Return type:

str

Raises:
exists(path)

Check whether an item exists.

Parameters:

path (str) – Path.

Returns:

True if the item exists, False otherwise.

Return type:

bool

handle(path, objects=None)

Get a file handle.

Parameters:
  • path (str) – Path to a file.

  • objects (list[str],optional) – Files and folders to include.

Returns:

File handle.

Return type:

object

Raises:
listdir(path=None, include_deleted=False)

List directory contents.

Parameters:
  • path (str, optional) – Path. Defaults to the Cloud Drive root.

  • include_deleted (bool, optional) – Include deleted files. Defaults to False.

Returns:

Directory contents.

Return type:

list[cterasdk.cio.core.types.PortalResource]

Raises:
permalink(path)

Get permalink for a path.

Parameters:

path (str) – Path.

Returns:

Permalink.

Return type:

str

Raises:

cterasdk.exceptions.io.core.GetMetadataError – Raised on error retrieving object metadata.

properties(path)

Get object properties.

Parameters:

path (str) – Path.

Returns:

Object properties.

Return type:

cterasdk.cio.core.types.PortalResource

Raises:

cterasdk.exceptions.io.core.GetMetadataError – Raised on error retrieving object metadata.

public_link(path, access='RO', expire_in=30)

Create a public link to a file or folder.

Parameters:
  • path (str) – Path of the file or folder.

  • access (str, optional) – Access policy of the link. Defaults to ‘RO’.

  • expire_in (int, optional) – Days until link expires. Defaults to 30.

Returns:

Public link.

Return type:

str

Raises:

cterasdk.exceptions.io.core.CreateLinkError – Raised on failure to generate public link.

versions(path)

List snapshots of a file or directory.

Parameters:

path (str) – Path.

Returns:

List of versions.

Return type:

list[cterasdk.cio.core.types.PreviousVersion]

Raises:

cterasdk.exceptions.io.core.GetVersionsError – Raised on error retrieving versions.

walk(path=None, include_deleted=False)

Walk directory contents.

Parameters:
  • path (str, optional) – Path to walk. Defaults to the root directory.

  • include_deleted (bool, optional) – Include deleted files. Defaults to False.

Returns:

A generator of file-system objects.

Return type:

Iterator[cterasdk.cio.core.types.PortalResource]

Raises:
class cterasdk.core.files.browser.InvitationBrowser(core)

Bases: object

details()
download(path, objects=None, destination=None)
exists(path)
listdir(path=None)
makedirs(path)
mkdir(path)
properties(path)
upload(destination, handle, name=None, size=None)
upload_file(path, destination)
walk(path=None)