Groups#
- class saagieapi.groups.Groups(saagie_api)#
Bases:
object
- create(group_name: str, users: List[str], verify_ssl: bool | None = None) bool #
Create a group NB: You can only create group if you have the admin role on the platform
- Parameters:
- Returns:
True if group is exported False otherwise
- Return type:
Examples
>>> saagieapi.groups.create( ... group_name="group_reader", ... users=["user1", "user2"] ... ) True
- delete(group_name: str, verify_ssl: bool | None = None) bool #
Delete a given group
- Parameters:
- Returns:
True if group is deleted Error otherwise
- Return type:
Examples
>>> saagieapi.groups.delete(group_name="test_user") True
- edit_permission(group_name: str, authorizations: List[Dict] | None = None, realm_authorization: Dict | None = None, verify_ssl: bool | None = None) bool #
Create a group NB: You can only create group if you have the admin role on the platform
- Parameters:
group_name (str) – Name of the group
authorizations (Optional[List[Dict]]) – Group’s authorization on the platform if not filled, defaults to current value
realm_authorization (Optional[Dict]) – Dict of authorization to technology catalog and cluster overview if not filled, defaults to current value
verify_ssl (bool, optional) – Enable or disable verification of SSL certification By default, refers to saagie_api.verify_ssl
- Returns:
True if group’s permission successfully edited False otherwise
- Return type:
Examples
>>> saagieapi.groups.edit_permission( ... group_name="group_reader", ... authorizations=[ ... { ... "platformId": 1, ... "platformName": "Dev", ... "permissions": [ ... { ... "artifact": { ... "id": "project_id", ... "type": "PROJECT" ... }, ... "role": "ROLE_PROJECT_VIEWER" ... } ... ] ... } ... ], ... realm_authorization={ ... "permissions": [ ... { ... "artifact": { ... "type": "TECHNOLOGY_CATALOG" ... }, ... "role": "ROLE_ACCESS" ... } ... ] ... } ... ) True
- export(output_folder: str, error_folder: str | None = '', verify_ssl: bool | None = None) bool #
Export groups NB: You can only export group’s information if you have the admin role on the platform
- Parameters:
output_folder (str) – Folder to store the exported groups
error_folder (str) – Path to store the not correctly exported group in case of error. If not set, not correctly exported group is not write
verify_ssl (bool, optional) – Enable or disable verification of SSL certification By default, refers to saagie_api.verify_ssl
- Returns:
True if group is exported False otherwise
- Return type:
Examples
>>> saagieapi.groups.export( ... output_folder="./output/groups/", ... error_folder=""./output/error_folder/" ... ) True
- get_permission(group_name: str, verify_ssl: bool | None = None) Dict #
Get group’s permissions NB: You can only list group’s permission if you have the admin role on the platform
- Parameters:
- Returns:
Dict of group’s permissions
- Return type:
Examples
>>> saagieapi.groups.get_permission(group_name="test_group") { "name": "test_group", "role": "ROLE_READER", "authorizations": [ { "platformId": 1, "platformName": "Dev", "permissions": [ { "artifact": { "type": "PROJECTS_ENVVAR_EDITOR" }, "role": "ROLE_PROJECT_ENVVAR_EDITOR" }, { "artifact": { "id": "87ad5abb-5ee9-4e7d-8c82-5b40378ad931", "type": "PROJECT" }, "role": "ROLE_PROJECT_MANAGER" } ] } ], "protected": False, "realmAuthorization": { "permissions": [ { "artifact": { "type": "TECHNOLOGY_CATALOG" }, "role": "ROLE_ACCESS" } ] } }
- get_users(group_name, verify_ssl: bool | None = None) Dict #
Get group’s users NB: You can only list group’s users if you have the admin role on the platform
- Parameters:
- Returns:
Dict of group’s users
- Return type:
Examples
>>> saagieapi.groups.get_users(group_name="test_group") { "name": "test_group", "users": ["test_user"], "protected": False }
- import_from_json(path_to_folder: str, error_folder: str | None = '', verify_ssl: bool | None = None) bool #
Import groups from JSON format NB: You can only use this function if you have the admin role on the platform
All protected groups (created at platform installation) will not be imported. For the moment, authorizations of groups are not imported, so if you want the same authorization, you have to set up manually.
- Parameters:
path_to_folder (str) – Path to the folder of the groups to import
error_folder (str) – Path to store the failed imported groups in case of error. If not set, failed imported users not write
verify_ssl (bool, optional) – Enable or disable verification of SSL certification By default, refers to saagie_api.verify_ssl
- Returns:
True if groups are imported False otherwise
- Return type:
Examples
>>> saagieapi.groups.import_from_json( ... path_to_folder="/path/to/the/group/folder", ... error_folder="/path/to/the/error/folder" ... ) True
- list(verify_ssl: bool | None = None) List[Dict] #
Get groups NB: You can only list users if you have the admin role on the platform
- Parameters:
verify_ssl (bool, optional) – Enable or disable verification of SSL certification By default, refers to saagie_api.verify_ssl
- Returns:
Dict of groups on the platform
- Return type:
Examples
>>> saagieapi.groups.list() [ { "name": "administrators", "protected": True }, { "name": "test_group", "protected": False } ]