Projects¶
- class pyniryo_nate.components.Projects(http_client: HttpClient, mqtt_client: MqttClient, correlation_id: str)[source]¶
Bases:
BaseAPIComponentProjects component for grouping programs. A program belongs to at most one project, and at most one project is active on the robot.
Methods
Make a project the robot's active project, deactivating the previous one.
Move a program into a project.
closeClose the component and release any resources if needed.
Create a project, with no program in it yet.
Upload a new program inside a project.
Delete a project.
Get a project by its ID.
Get all the projects, each carrying the programs it contains.
Take a program out of its project.
Update the name or the description of a project.
- Parameters:
http_client (HttpClient)
mqtt_client (MqttClient)
correlation_id (str)
- get_all() list[Project][source]¶
Get all the projects, each carrying the programs it contains.
- Returns:
The list of all the projects.
- Return type:
list[Project]
- get(project_id: str) Project[source]¶
Get a project by its ID.
- Parameters:
project_id (str) – The ID of the project.
- Returns:
The corresponding project, with the programs it contains.
- Raises:
ClientError – If no project has this ID.
- Return type:
- create(name: str, description: str | None = None) Project[source]¶
Create a project, with no program in it yet.
- Parameters:
name (str) – The name of the project, unique on the robot. At most 255 bytes, without
/, and not.or...description (str | None) – Free text shown with the project. If None, the project starts with an empty one.
- Returns:
The created project.
- Raises:
ClientError – If the name is invalid, or a project with this name already exists.
- Return type:
- update(project_id: str, name: str, description: str | None = None) Project[source]¶
Update the name or the description of a project.
- Parameters:
project_id (str) – The ID of the project.
name (str) – The new name of the project, same rules as
create().description (str | None) – The new description. If None, the stored one stays.
- Returns:
The updated project.
- Raises:
ClientError – If no project has this ID, the name is invalid, or another project has this name.
- Return type:
- delete(project_id: str) None[source]¶
Delete a project. This also deletes the programs the project contains.
- Parameters:
project_id (str) – The ID of the project.
- Raises:
ClientError – If no project has this ID.
- Return type:
None
- activate(project_id: str) None[source]¶
Make a project the robot’s active project, deactivating the previous one. Activating the project that is already active changes nothing.
- Parameters:
project_id (str) – The ID of the project.
- Raises:
ClientError – If no project has this ID.
- Return type:
None
- create_program(project_id: str, program: IO[bytes], program_type: ProgramType, name: str | None = None) Program[source]¶
Upload a new program inside a project.
- Parameters:
project_id (str) – The ID of the project.
program (IO[bytes]) – A file-like object containing the program content.
program_type (ProgramType) – The type of the program.
name (str | None) – The name of the program. If None, the robot uses the file name.
- Returns:
The created program.
- Raises:
ClientError – If no project has this ID, or the project already contains a program with this name.
- Return type:
- add_program(project_id: str, program_id: str) None[source]¶
Move a program into a project. The program leaves the project it was in, if any. Moving a program into the project it is already in changes nothing.
- Parameters:
project_id (str) – The ID of the project.
program_id (str) – The ID of the program.
- Raises:
ClientError – If no project or no program has this ID, or the project already contains a program with this name.
- Return type:
None
- remove_program(project_id: str, program_id: str) None[source]¶
Take a program out of its project. The program is kept and stays usable outside any project.
- Parameters:
project_id (str) – The ID of the project.
program_id (str) – The ID of the program.
- Raises:
ClientError – If no project or no program has this ID, or the program is not in this project.
- Return type:
None