collaboration.project module¶
Class representing a remote project |
- class Project(handle)[source]¶
Bases:
object
Class representing a remote project
- can_user_view(username: str) bool [source]¶
Determine if a user is in any of the view/edit/admin groups
- create_file(filename: str, contents: bytes, name: str, description: str, parent_folder: ~binaryninja.collaboration.folder.Folder | None = None, progress: ~typing.Callable[[int, int], bool] = <function nop>) File [source]¶
Create a new file on the remote (and pull it)
- Parameters:
- Returns:
Reference to the created file
- Raises:
RuntimeError if there was an error
- Return type:
- create_folder(name: str, description: str, parent: ~binaryninja.collaboration.folder.Folder | None = None, progress: ~typing.Callable[[int, int], bool] = <function nop>) Folder [source]¶
Create a new folder on the remote (and pull it)
- Parameters:
- Returns:
Reference to the created folder
- Raises:
RuntimeError if there was an error pulling folders
- Return type:
- create_group_permission(group_id: int, level: ~binaryninja.collaboration.enums.PermissionLevel, progress: ~typing.Callable[[int, int], bool] = <function nop>) Permission [source]¶
Create a new group permission on the remote (and pull it)
- Parameters:
- Returns:
Reference to the created permission
- Raises:
RuntimeError if there was an error pulling permissions
- Return type:
- create_user_permission(user_id: str, level: ~binaryninja.collaboration.enums.PermissionLevel, progress: ~typing.Callable[[int, int], bool] = <function nop>) Permission [source]¶
Create a new user permission on the remote (and pull it)
- Parameters:
- Returns:
Reference to the created permission
- Raises:
RuntimeError if there was an error pulling permissions
- Return type:
- delete_file(file: File)[source]¶
Delete a file from the remote
- Parameters:
file (File) – File to delete
- Raises:
RuntimeError if there was an error
- delete_folder(folder: Folder)[source]¶
Delete a folder from the remote
- Parameters:
folder (Folder) – Folder to delete
- Raises:
RuntimeError if there was an error
- delete_permission(permission: Permission)[source]¶
Delete a permission from the remote
- Parameters:
permission (Permission) – Permission to delete
- Raises:
RuntimeError if there was an error
- get_file_by_id(id: str) File | None [source]¶
Get a specific File in the Project by its id
Note
If files have not been pulled, they will be pulled upon calling this.
- get_file_by_name(name: str) File | None [source]¶
Get a specific File in the Project by its name
Note
If files have not been pulled, they will be pulled upon calling this.
- get_folder_by_id(id: str) Folder | None [source]¶
Get a specific Folder in the Project by its id
Note
If folders have not been pulled, they will be pulled upon calling this.
- static get_for_bv(bv: BinaryView) Project | None [source]¶
Get the Remote Project for a BinaryView
- Parameters:
bv (BinaryView) – BinaryView, potentially with collaboration metadata
- Returns:
Remote project from one of the connected remotes, or None if not found or if projects are not pulled
- Raises:
RuntimeError – If there was an error
- Return type:
Project | None
- static get_for_local_database(database: Database) Project | None [source]¶
Get the Remote Project for a Database
- Parameters:
database (Database) – BN database, potentially with collaboration metadata
- Returns:
Remote project from one of the connected remotes, or None if not found or if projects are not pulled
- Raises:
RuntimeError – If there was an error
- Return type:
Project | None
- get_permission_by_id(id: str) Permission | None [source]¶
Get a specific permission in the Project by its id
Note
If group or user permissions have not been pulled, they will be pulled upon calling this.
- Parameters:
id (str) – Id of Permission
- Returns:
Permission object, if one with that id exists. Else, None
- Raises:
RuntimeError if there was an error pulling permissions
- Return type:
Permission | None
- pull_files(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]¶
Pull the list of files from the Remote.
Note
If folders have not been pulled, they will be pulled upon calling this.
- pull_folders(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]¶
Pull the list of folders from the Remote.
- pull_group_permissions(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]¶
Pull the list of group permissions from the Remote.
- pull_user_permissions(progress: ~typing.Callable[[int, int], bool] = <function nop>)[source]¶
Pull the list of user permissions from the Remote.
- push_file(file: File, extra_fields: Dict[str, str] | None = None)[source]¶
Push an updated File object to the Remote
- push_folder(folder: Folder, extra_fields: Dict[str, str] | None = None)[source]¶
Push an updated Folder object to the Remote
- push_permission(permission: Permission, extra_fields: Dict[str, str] | None = None)[source]¶
Push project permissions to the remote
- Parameters:
permission (Permission) – Permission object which has been updated
extra_fields (Dict[str, str] | None) – Extra HTTP fields to send with the update
- Raises:
RuntimeError if there was an error
- upload_new_file(target: str | ~os.PathLike | ~binaryninja.binaryview.BinaryView | ~binaryninja.filemetadata.FileMetadata, parent_folder: ~binaryninja.collaboration.folder.Folder | None = None, progress: ~typing.Callable[[int, int], bool] = <function nop>, open_view_options=None) File [source]¶
Upload a file to the project, creating a new File and pulling it
- Parameters:
target (str | PathLike | BinaryView | FileMetadata) – Path to file on disk or BinaryView/FileMetadata object of already-opened file
parent_folder (Folder | None) – Parent folder to place the uploaded file in
progress (Callable[[int, int], bool]) – Function to call for progress updates
- Returns:
Created File object
- Raises:
RuntimeError if there was an error
- Return type:
- property default_path: str¶
Get the default directory path for a remote Project. This is based off the Setting for collaboration.directory, the project’s id, and the project’s remote’s id.
- Returns:
Default project path
- Return type:
- property description¶
Description of the project
- Returns:
Description string
- property files: List[File]¶
Get the list of files in this project.
Note
If folders have not been pulled, they will be pulled upon calling this.
Note
If files have not been pulled, they will be pulled upon calling this.
- Returns:
List of File objects
- Raises:
RuntimeError if there was an error pulling files
- property folders: List[Folder]¶
Get the list of folders in this project.
Note
If folders have not been pulled, they will be pulled upon calling this.
- Returns:
List of Folder objects
- Raises:
RuntimeError if there was an error pulling folders
- property group_permissions: List[Permission]¶
Get the list of group permissions in this project.
Note
If group permissions have not been pulled, they will be pulled upon calling this.
- Returns:
List of Permission objects
- Raises:
RuntimeError if there was an error pulling group permissions
- property has_pulled_files¶
If the project has pulled the files yet
- Returns:
True if they have been pulled
- property has_pulled_folders¶
If the project has pulled the folders yet
- Returns:
True if they have been pulled
- property has_pulled_group_permissions¶
If the project has pulled the group permissions yet
- Returns:
True if they have been pulled
- property has_pulled_user_permissions¶
If the project has pulled the user permissions yet
- Returns:
True if they have been pulled
- property id¶
Unique id
- Returns:
Id string
- property is_admin¶
If the currently logged in user is an administrator of the project (and can edit permissions and such for the project).
- Returns:
True if the user is an admin
- property name¶
Displayed name of project
- Returns:
Name string
- property url¶
Web api endpoint URL
- Returns:
URL string
- property user_permissions: List[Permission]¶
Get the list of user permissions in this project.
Note
If user permissions have not been pulled, they will be pulled upon calling this.
- Returns:
List of Permission objects
- Raises:
RuntimeError if there was an error pulling user permissions