API documentation for egnyte package
egnyte.audits module
-
class egnyte.audits.AuditReport(_client, **kwargs)[source]
Bases: egnyte.base.Resource
-
complete_url()[source]
-
download()[source]
-
is_ready()[source]
True if report is ready to be downloaded.
Does a single API request.
-
json()[source]
-
status = u'running'
-
wait(check_time=5.0)[source]
Block until report is ready.
Probably only useful for command line applications.
-
class egnyte.audits.Audits(_client, **kwargs)[source]
Bases: egnyte.base.HasClient
This resource is used to generated various kinds of audit reports.
-
files(format, date_start, date_end, folders=None, file=None, users=None, transaction_type=None)[source]
Generate files report.
Parameters:
- format: ‘csv’ or ‘json’
- date_start: string in ‘YYYY-MM-DD’ format or datetime.date - first day report should cover
- date_end: string in ‘YYYY-MM-DD’ format or datetime.date - last day report should cover
Returns an AuditReport object.
-
get(id)[source]
Get a previously generated report by its id
-
logins(format, date_start, date_end, events, access_points=None, users=None)[source]
Generate login report.
Parameters:
- format: ‘csv’ or ‘json’
- date_start: string in ‘YYYY-MM-DD’ format or datetime.date - first day report should cover
- date_end: string in ‘YYYY-MM-DD’ format or datetime.date - last day report should cover
Returns an AuditReport object.
-
permissions(format, date_start, date_end, folders, assigners, assignee_users, assignee_groups)[source]
Generate permissions report.
Parameters:
- format: ‘csv’ or ‘json’
- date_start: string in ‘YYYY-MM-DD’ format or datetime.date - first day report should cover
- date_end: string in ‘YYYY-MM-DD’ format or datetime.date - last day report should cover
Returns an AuditReport object.
egnyte.base module
-
egnyte.base.DEFAULT_EXCLUDES_RE()
match(string[, pos[, endpos]]) –> match object or None.
Matches zero or more characters at the beginning of the string
-
class egnyte.base.FileDownload(response, file)[source]
Bases: object
Provides the file length and other metadata.
Delegates reads to underlying request’s response.
-
close()[source]
-
iter_content(chunk_size=16384)[source]
-
read(size=None, decode_content=True)[source]
Wrap urllib3 response.
size - How much of the content to read. If specified, caching is skipped because it doesn’t make sense to cache partial content as the full response.
decode_content - If True, will attempt to decode the body based on the ‘content-encoding’ header.
-
save_to(path, progress_callback=None)[source]
Create a new file and save the contents
Optional progress_callback should have the signature of ProgressCallbacks.download_progress
-
write_to(fp, progress_callback=None)[source]
Copy data to a file, then close the source.
Optional progress_callback should have the signature of ProgressCallbacks.download_progress
-
class egnyte.base.HasClient(_client, **kwargs)[source]
Bases: object
Base class for API wrappers and utils
-
class egnyte.base.Resource(_client, **kwargs)[source]
Bases: object
Base wrapper for API resources (singular objects with specific URL)
-
check()[source]
Check if this object exists in the cloud and current user has read permissions on it.
Will raise an exception otherwise.
-
delete()[source]
-
class egnyte.base.ResultList(data, total_count, offset)[source]
Bases: list
List with additional attributes representing a partial list of objects that exist in the cloud.
total_count: Count of all objects that exist.
offset: Starting index of this slice of results.
-
class egnyte.base.Session(config=None)[source]
Bases: object
Provides persistent HTTPS connections to the Egnyte API
-
DELETE(url, **kwargs)[source]
-
GET(url, **kwargs)[source]
-
PATCH(url, json_data=None, **kwargs)[source]
-
POST(url, json_data=None, **kwargs)[source]
-
close()[source]
-
get_url(_path, **kwargs)[source]
-
last_request_time = None
-
time_between_requests = None
-
egnyte.base.date_format(date)[source]
-
egnyte.base.encode_path(path)[source]
-
egnyte.base.filter_none_values(dict)[source]
Return dictionary with values that are None filtered out
-
egnyte.base.generate_paths(roots, excludes=None)[source]
Walk set of paths in local filesystem, and for each file and directory generate a tuple of
(is directory, absolute path, path relative root used to get to that file)
-
egnyte.base.get_access_token(config)[source]
-
egnyte.base.get_file_size(fp)[source]
Get size of the file or length of a bytes object
-
egnyte.base.make_excluded(excludes=None)[source]
-
egnyte.base.split_file_into_chunks(fp, file_size, chunk_size)[source]
Split file-like object into sequence of file-like objects, each of
those with size no greater than chunk_size bytes.
Those are just wrappers to the original file-like objects. They should be fully
read sequentially, and they cannot be used concurrently with
the original object.
egnyte.client module
-
class egnyte.client.EgnyteClient(config=None)[source]
Bases: egnyte.base.Session
Main client objects. This should be the only object you have to manually create in standard API use.
-
audits[source]
API for Audit Reports
-
bulk_download(paths, local_dir, overwrite=False, progress_callbacks=None)[source]
Transfer many files or directories to Cloud File System.
- paths - list of local file paths
- target - Path in CFS to upload to
- progress_callbacks - Callback object (see ProgressCallbacks)
-
bulk_upload(paths, target, exclude=None, progress_callbacks=None)[source]
Transfer many files or directories to Cloud File System.
- paths - list of local file paths
- target - Path in CFS to upload to
- progress_callbacks - Callback object (see ProgressCallbacks)
-
file(path, **kwargs)[source]
Get a File object for the specified path
-
folder(path='/Shared', **kwargs)[source]
Get a Folder object for the specified path
-
get(path)[source]
Check whether a path is a file or a folder and return the right object.
-
groups[source]
API for Group Management
-
impersonate(username)[source]
Start impersonating another user.
- username: either username or full email address of user to impersonate.
-
links[source]
API for Links management
-
notes[source]
API for Notes management
-
settings[source]
Domain settings.
-
stop_impersonating()[source]
Stop impersonating another user.
-
user_info[source]
Information about user associated with this API access token.
-
users[source]
API for User management
-
class egnyte.client.ProgressCallbacks[source]
Bases: object
This object is used for bulk transfers (uploads and downloads)
Inherit this and add override any of the callabcks you’d like to handle.
-
creating_directory(cloud_folder)[source]
Creating a directory.
-
download_finish(cloud_file)[source]
Finished downloading a file.
-
download_progress(cloud_file, size, downloaded)[source]
Some progress in file download.
-
download_start(local_path, cloud_file, size)[source]
Starting to download a file.
-
finished()[source]
Called after all operations.
-
getting_info(cloud_path)[source]
Getting information about an object. Called for directories and unknown paths.
-
got_info(cloud_obj)[source]
Got information about an object.
-
skipped(cloud_obj, reason)[source]
Object has been skipped because of ‘reason’
-
upload_finish(cloud_file)[source]
Finished uploading a file.
-
upload_progress(cloud_file, size, uploaded)[source]
Some progress in file upload.
-
upload_start(local_path, cloud_file, size)[source]
Starting to upload a file.
egnyte.configuration module
-
egnyte.configuration.add_directory(filepath)[source]
Add ‘~/.egnyte’ in a platform independent way to a file path it it’s relative.
-
egnyte.configuration.load(filename=None)[source]
Load configuration from a JSON file.
If filename is None, ~/.egnyte/config.json will be loaded.
If filename is not an absolute path, it will be prefixed with ~/.egnyte/
Returns loaded config as a dictionary on success and {} on failure.
-
egnyte.configuration.save(config, filename=None)[source]
Load configuration from a JSON file.
If filename is not an absolute path, it will be prefixed with ~/.egnyte/
egnyte.resources module
-
class egnyte.resources.File(_client, **kwargs)[source]
Bases: egnyte.resources.FileOrFolder
Wrapper for a file in the cloud.
Does not have to exist - this can represent a new file to be uploaded.
path - file path
-
add_note(message)[source]
Add a note to this file. Returns the created Note object.
-
delete()[source]
Delete this file.
-
download(download_range=None)[source]
Download file contents.
Returns a FileDownload.
Optional range is 2 integer sequence (start offset, end offset) used to download only part of the file.
-
get_notes(**kwargs)[source]
Get notes attached to this file. Returns list of Note objects
-
upload(fp, size=None, progress_callback=None)[source]
Upload file contents.
fp can be any file-like object, but if you don’t specify it’s size in advance it must support tell and seek methods.
Progress callback is optional - if provided, it should match signature of ProgressCallbacks.upload_progress
-
class egnyte.resources.FileOrFolder(_client, **kwargs)[source]
Bases: egnyte.base.Resource
Things that are common to both files and folders.
-
copy(destination)[source]
Copy this to another path. Destination path should have all segments (including the last one).
-
link(accessibility, recipients=None, send_email=None, message=None, copy_me=None, notify=None, link_to_current=None, expiry_date=None, expiry_clicks=None, add_filename=None)[source]
Create a link.
- accessibility: Determines how the link can be accessed (‘Anyone’, ‘Password’, ‘Domain’, ‘Recipients’)
- send_email: If true, Egnyte will send the link by email.
- recipients: List email addresses for people who should receive the link. Only required if send_email is True (List of valid email addresses)
- message: Personal message to be sent in link email. Only applies if send_email is True (plain text)
- copy_me: If True, a copy of the link message will be sent to the link creator. Only applies if send_email is True.
- notify: If True, link creator will be notified via email when link is accessed.
- link_to_current: If True, link will always refer to current version of file. Only applicable for file links.
- expiry_date: The expiry date for the link. If expiry_date is specified, expiry_clicks cannot be set (future date as datetime.date or string in YYYY-MM-DD format)
- expiry_clicks: The number of times the link can be clicked before it stops working. If expiry_clicks is specified, expiry_date cannot be set (value must be between 1 - 10, inclusive)
- add_filename: If True then the filename will be appended to the end of the link. Only applies to file links, not folder links.
Will return sequence of created Links, one for each recipient.
-
move(destination)[source]
Move this to another path. Destination path should have all segments (including the last one).
-
class egnyte.resources.Folder(_client, **kwargs)[source]
Bases: egnyte.resources.FileOrFolder
Wrapper for a folder the cloud.
Does not have to exist - can represent a new folder yet to be created.
-
create(ignore_if_exists=True)[source]
Create a new folder in the Egnyte cloud.
If ignore_if_exists is True, error raised if folder already exists will be ignored.
-
delete()[source]
Delete this folder in the cloud.
-
file(filename, **kwargs)[source]
Return a file in this folder.
-
files = None
-
folder(path, **kwargs)[source]
Return a subfolder of this folder.
-
folders = None
-
get_effective_permissions(username)[source]
Get effective permissions (both direct, and granted by membership in groups) to this folder for a specific user.
username: name of user (string)
Returns one of ‘Owner’, ‘Full’, ‘Editor’, ‘Viewer’
-
get_notes(**kwargs)[source]
Get notes attached to any file in this folder.
-
get_permissions(users=None, groups=None)[source]
Get Permission values for this folder.
-
list()[source]
Gets contents of this folder (in instance attributes ‘folders’ and ‘files’)
-
set_permissions(permission, users=None, groups=None)[source]
Set permission level for some users and/or groups for this folder.
-
class egnyte.resources.Group(_client, **kwargs)[source]
Bases: egnyte.base.Resource
Group of users.
-
delete()[source]
Delete this Group
-
class egnyte.resources.Groups(_client, **kwargs)[source]
Bases: egnyte.base.HasClient
Group Management API
-
by_displayName(displayName)[source]
Get a Group object by displayName. Returns None if Group does not exist
-
create(displayName, members=None)[source]
Create a new Group. Parameters:
- displayName: Name of the group (string). Required
- members: List of members to be added to the new group (user ids or User objects). Optional.
Returns created Group object.
-
get(id)[source]
Get a Group object by id. Does not check if Group exists.
-
list(displayName=None, startIndex=None, count=None)[source]
List existing groups.
Optional filtering parameters:
- displayName: Filter by name of the group. This may contain ‘*’ wildcards at beginning for prefix search or both at beginning and end for contains search.
Returns list of Group objects, with additional attributes total_result and offset
-
class egnyte.resources.Link(_client, **kwargs)[source]
Bases: egnyte.base.Resource
Link to a file or folder
-
delete()[source]
Delete this link
-
class egnyte.resources.Links(_client, **kwargs)[source]
Bases: egnyte.base.HasClient
Link management API
-
create(path, type, accessibility, recipients=None, send_email=None, message=None, copy_me=None, notify=None, link_to_current=None, expiry_date=None, expiry_clicks=None, add_filename=None)[source]
Create links.
- path: The absolute path of the destination file or folder.
- type: This determines what type of link will be created (‘File’ or ‘Folder’)
- accessibility: Determines who a link is accessible by (‘Anyone’, ‘Password’, ‘Domain’, ‘Recipients’)
- send_email: If True, the link will be sent via email by Egnyte.
- recipients: List email addresses of recipients of the link. Only required if send_email is True (List of valid email addresses)
- message: Personal message to be sent in link email. Only applies if send_email is True (plain text)
- copy_me: If True, a copy of the link message will be sent to the link creator. Only applies if send_email is True.
- notify: If True, link creator will be notified via email when link is accessed.
- link_to_current: If True, link will always refer to current version of file. Only applicable for file links.
- expiry_date: The expiry date for the link. If expiry_date is specified, expiry_clicks cannot be set (future date as datetime.date or string in YYYY-MM-DD format)
- expiry_clicks: The number of clicks the link is valid for. If expiry_clicks is specified, expiry_date cannot be set (value must be between 1 - 10, inclusive)
- add_filename: If True then the filename will be appended to the end of the link. Only applies to file links, not folder links.
Will return a sequence of created Links, one for each recipient.
-
get(id)[source]
Get a Link object by it’s id
-
list(path=None, username=None, created_before=None, created_after=None, type=None, accessibility=None, offset=None, count=None)[source]
Search links that match following optional conditions:
- path: List links to this file or folder (Full absolute path of destination file or folder)
- username: List links created by this user (Any username from your Egnyte account)
- created_before: List links created before this date (datetime.date, or string in YYYY-MM-DD format)
- created_after: List links created after this date (datetime.date, or string in YYYY-MM-DD format)
- type: Links of selected type will be shown (‘File’ or ‘Folder’)
- accessibility: Links of selected accessibility will be shown (‘Anyone’, ‘Password’, ‘Domain’, or ‘Recipients’)
- offset: Start at this link, where offset=0 means start with first link.
- count: Send this number of links. If not specified, all links will be sent.
Returns a list of Link objects, with additional total_count and offset attributes.
-
class egnyte.resources.Note(_client, **kwargs)[source]
Bases: egnyte.base.Resource
Note attached to a file or folder.
-
delete()[source]
Delete this Note
-
get_file()[source]
Get the file to which this note is attached.
-
class egnyte.resources.Notes(_client, **kwargs)[source]
Bases: egnyte.base.HasClient
Notes management API
-
create(path, message)[source]
Create a new note.
Parameters:
- path - path to the file the note is about
- message - contents of the note
Returns the created Note object.
-
list(file=None, folder=None, start_time=None, end_time=None)[source]
List existing notes.
Optional filtering parameters:
- start_time: Get notes created after start_time (datetime.date or string in ‘YYYY-MM-DD’ format)
- file: Get only notes attached to a specific file (path).
- folder: Get only notes atatched to files in specific folder (path).
- end_time: Get notes created before end_time (datetime.date or string in ‘YYYY-MM-DD’ format)
Returns list of Note objects, with additional attributes total_result and offset.
-
class egnyte.resources.PermissionSet(json)[source]
Bases: object
Wrapper for a permission set
-
class egnyte.resources.User(_client, **kwargs)[source]
Bases: egnyte.base.Resource
Wrapper for a User.
Warning: attribute names in this class use camelCase instead of underscores.
Name is a dictionary with 2 keys: givenName and lastName.
-
delete()[source]
Delete this user account.
-
get_effective_permissions(path)[source]
-
update(email=None, familyName=None, givenName=None, active=None, sendInvite=None, authType=None, userType=None, idpUserId=None, userPrincipalName=None)[source]
Modify this user account.
Optional parameters (no change if value is None):
- email: The email address of the user. Any valid email address (e.g. admin@acme.com)
- familyName: The last name of the user. Any plain text (e.g. John)
- givenName: The first name of the user. Any plain text (e.g. Smith)
- active: Whether the user is active or inactive. True or False
- sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
- authType: The authentication type for the user. ‘ad’ (AD), ‘sso’ (SAML SSO), ‘egnyte’ (Internal Egnyte)
- userType: The Egnyte role of the user. ‘admin’ (Administrator), ‘power’ (Power User), ‘standard’ (Standard User)
- idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
- userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. jmiller@example.com)
-
class egnyte.resources.Users(_client, **kwargs)[source]
Bases: egnyte.base.HasClient
User management API
-
by_email(email)[source]
Get a User object by email. Returns None if user does not exist
-
by_username(userName)[source]
Get a User object by username. Returns None if user does not exist
-
create(userName, externalId, email, familyName, givenName, active=True, sendInvite=True, authType=u'egnyte', userType=u'power', role=None, idpUserId=None, userPrincipalName=None)[source]
Create a new user account. Parameters:
- userName: The Egnyte username for the user. Username must start with a letter or digit. Special characters are not supported (with the exception of periods, hyphens, and underscores).
- externalId: This is an immutable unique identifier provided by the API consumer. Any plain text (e.g. S-1-5-21-3623811015-3361044348-30300820-1013)
- email: The email address of the user. Any valid email address (e.g. admin@acme.com)
- familyName: The last name of the user. Any plain text (e.g. John)
- givenName: The first name of the user. Any plain text (e.g. Smith)
- active: Whether the user is active or inactive. True or False
- sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
- authType: The authentication type for the user. ‘ad’ (AD), ‘sso’ (SAML SSO), ‘egnyte’ (Internal Egnyte)
- userType: The type of the user. ‘admin’ (Administrator), ‘power’ (Power User), ‘standard’ (Standard User)
- role: The role assigned to the user. Only applicable for Power Users. Default or custom role name
- idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
- userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. jmiller@example.com)
Returns created User object.
-
get(id)[source]
Get a User object by id. Does not check if User exists.
-
list(email=None, externalId=None, userName=None, startIndex=None, count=None)[source]
Search users. Optional search parameters are ‘email’, ‘externalId’ and ‘userName’.
startIndex (starts with 1) and count may be used for pagination
Returns a list of User objects, with additional total_count and offset attributes.