Environment Variables#
- class saagieapi.env_vars.EnvVars(saagie_api)#
Bases:
object
- bulk_create_for_pipeline(pipeline_id: str, env_vars: Dict) Dict #
Delete all existing env vars and create new ones for the pipeline
- Parameters:
pipeline_id (str) – Pipeline ID
env_vars (Dict) – Dict that contains all the variables for the pipeline
- Returns:
Dict of created environment variables for pipeline
- Return type:
Examples
>>> saagie_api.env_vars.bulk_create_for_pipeline( ... pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1", ... env_vars={ ... "BULK1": "HELLO", ... "BULK2": "WORLD" ... } ... ) { "replaceEnvironmentVariablesByRawForScope": [ { "id": "750c5366-caea-4d1f-ad38-fa6089ea2015", "scope": "PIPELINE", "name": "BULK1", "value": "HELLO" }, { "id": "ce5f098e-4750-40b1-8c10-11b118ebc23a", "scope": "PIPELINE", "name": "BULK2", "value": "WORLD" } ] }
- create(scope: str, name: str, value: str = 'DEFAULT_VALUE', description: str = '', is_password: bool = False, project_id: str = None, pipeline_id: str = None) Dict #
Create an environment variable in a given scope
- Parameters:
scope (str) – Scope of the environment variable to create. Must be one of GLOBAL, PROJECT or PIPELINE
name (str) – Name of the environment variable to create
value (str) – Value of the environment variable to create
description (str, optional) – Description of the environment variable to create
is_password (bool, optional) – Weather the environment variable to create is a password or not
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
- Returns:
Dict of created environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create( ... name="TEST_PASSWORD", ... value="test", ... description="This is a password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
- create_for_pipeline(pipeline_id: str, name: str, value: str = 'DEFAULT_VALUE', description: str = '', is_password: bool = False) Dict #
Create an environment variable in a given pipeline
- Parameters:
pipeline_id (str) – UUID of your pipeline (see README on how to find it)
name (str) – Name of the environment variable to create
value (str) – Value of the environment variable to create
description (str, optional) – Description of the environment variable to create
is_password (bool, optional) – Weather the environment variable to create is a password or not
- Returns:
Dict of created environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_for_pipeline( ... pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1", ... name="TEST_PASSWORD", ... value="test", ... description="This is a password", ... is_password=True, ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create()
instead.
- create_for_project(project_id: str, name: str, value: str = 'DEFAULT_VALUE', description: str = '', is_password: bool = False) Dict #
Create an environment variable in a given project
- Parameters:
project_id (str) – UUID of your project (see README on how to find it)
name (str) – Name of the environment variable to create
value (str) – Value of the environment variable to create
description (str, optional) – Description of the environment variable to create
is_password (bool, optional) – Weather the environment variable to create is a password or not
- Returns:
Dict of created environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_for_project( ... name="TEST_PASSWORD", ... value="test", ... description="This is a password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create()
instead.
- create_global(name: str, value: str = 'DEFAULT_VALUE', description: str = '', is_password: bool = False) Dict #
Create a global environment variable
- Parameters:
- Returns:
Dict of created environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_global( ... name="TEST_PASSWORD", ... value="test", ... description="This is a password", ... is_password=True ... ) { "saveEnvironmentVariable": { "id": "069f3bf2-da1a-4106-acb4-3c7cc37367a3" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create()
instead.
- create_or_update(scope: str, name: str, value: str = None, description: str = None, is_password: bool = None, project_id: str = None, pipeline_id: str = None) Dict #
Create a new environment variable or update it if it already exists
- Parameters:
scope (str) – Scope of the environment variable to create. Must be one of GLOBAL, PROJECT or PIPELINE
name (str) – Unique name of the environment variable to create or modify
value (str) – Value of the environment variable to create or modify
description (str, optional) – Description of the variable
is_password (boolean, optional) – Weather the variable is a password or not (default: False)
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
- Returns:
Dict of created or updated environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_or_update( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
- create_or_update_for_pipeline(pipeline_id: str, name: str, value: str = None, description: str = None, is_password: bool = None) Dict #
Create a new pipeline environment variable or update it if it already exists
- Parameters:
pipeline_id (str) – UUID of your pipeline (see README on how to find it)
name (str) – Unique name of the environment variable to create or modify
value (str) – Value of the environment variable to create or modify
description (str, optional) – Description of the variable
is_password (boolean, optional) – Weather the variable is a password or not (default: False)
- Returns:
Dict of created or updated environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_or_update_for_pipeline( ... pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1", ... name="TEST_PASSWORD", ... value="test", ... description="This is a password", ... is_password=True, ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create_or_update()
instead.
- create_or_update_for_project(project_id: str, name: str, value: str = None, description: str = None, is_password: bool = None) Dict #
Create a new project environment variable or update it if it already exists
- Parameters:
project_id (str) – UUID of your project (see README on how to find it)
name (str) – Unique name of the environment variable to create or modify
value (str) – Value of the environment variable to create or modify
description (str, optional) – Description of the variable
is_password (boolean, optional) – Weather the variable is a password or not (default: False)
- Returns:
Dict of created or updated environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_or_update_for_project( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create_or_update()
instead.
- create_or_update_global(name: str, value: str = None, description: str = None, is_password: bool = None) Dict #
Create a new global environnement variable or update it if it already exists
- Parameters:
- Returns:
Dict of created or updated environment variable
- Return type:
Examples
>>> saagieapi.env_vars.create_or_update_global( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True ... ) { "saveEnvironmentVariable": { "id": "069f3bf2-da1a-4106-acb4-3c7cc37367a3" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
create_or_update()
instead.
- delete(scope: str, name: str, project_id: str = None, pipeline_id: str = None) Dict #
Delete a given environment variable inside a given scope
- Parameters:
scope (str) – Scope of the environment variable to delete. Must be one of GLOBAL, PROJECT or PIPELINE
name (str) – Name of the environment variable to delete inside the given scope
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
- Returns:
Dict of deleted environment variable
- Return type:
- Raises:
ValueError – When the given name doesn’t correspond to an existing environment variable inside the given scope
Examples
>>> saagieapi.env_vars.delete(name="TEST_PASSWORD") { "deleteEnvironmentVariable": True }
- delete_for_pipeline(pipeline_id: str, name: str) Dict #
Delete a given environment variable inside a given pipeline
- Parameters:
- Returns:
Dict of deleted environment variable
- Return type:
- Raises:
ValueError – When the given name doesn’t correspond to an existing environment variable inside the given pipeline
Examples
>>> saagieapi.env_vars.delete_for_pipeline( ... pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1", ... name="TEST_PASSWORD", ... ) { "deleteEnvironmentVariable": True }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
delete()
instead.
- delete_for_project(project_id: str, name: str) Dict #
Delete a given environment variable inside a given project
- Parameters:
- Returns:
Dict of deleted environment variable
- Return type:
- Raises:
ValueError – When the given name doesn’t correspond to an existing environment variable inside the given project
Examples
>>> saagieapi.env_vars.delete_for_project( ... name="TEST_PASSWORD", ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "deleteEnvironmentVariable": True }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
delete()
instead.
- delete_global(name: str) Dict #
Delete the given global environment variable
- Parameters:
name (str) – Name of the environment variable to delete
- Returns:
Dict of deleted environment variable
- Return type:
- Raises:
ValueError – When the given name doesn’t correspond to an existing environment variable
Examples
>>> saagieapi.env_vars.delete_global(name="TEST_PASSWORD") { "deleteEnvironmentVariable": True }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
delete()
instead.
- export(project_id, output_folder: str, error_folder: str | None = '', project_only: bool = False) bool #
Export the environment variables of scope GLOBAL or PROJECT in a folder To export PIPELINE variables, use the pipelines.export function
- Parameters:
project_id (str) – Project ID
output_folder (str) – Path to store the exported environment variables
project_only (boolean, optional) – True if only project environment variable should be exported False otherwise
error_folder (str, optional) – Path to store the project ID in case of error. If not set, project ID is not write
- Returns:
True if environment variables are exported False otherwise
- Return type:
Examples
>>> saagieapi.env_vars.export( ... project_id="50033e21-83c2-4431-a723-d54c2693b964", ... output_folder="./output/env_vars/", ... error_folder="./output/error/", ... project_only=True ... ) True
- get(scope: str, name: str, project_id: str = None, pipeline_id: str = None, scope_only: bool = False, pprint_result: bool | None = None) Dict #
Get environment variable information NB: You can only get environment variable information if you have at least the viewer role on the project
- Parameters:
scope (str) – Scope of the environment variable to get. Must be one of GLOBAL, PROJECT or PIPELINE
name (str) – Name of the environment variable to get
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
scope_only (bool, optional) – Whether to return only the environment variables of the given scope
pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global
- Returns:
Dict of environment variable
- Return type:
dict (or None if not found)
Examples
>>> saagie_api.env_vars.get(scope="GLOBAL", name="TEST_GLOBAL_ENV_VARS") { 'id': 'ef1aecd1-8cb0-4a09-8b1c-dff72ca97c1f', 'name': 'TEST_GLOBAL_ENV_VARS', 'scope': 'GLOBAL', 'value': 'DEFAULT_VALUE', 'description': '', 'isPassword': False, 'isValid': True, 'invalidReasons': None }
- import_from_json(json_file: str, project_id: str = None) bool #
Import environment variables from JSON format of scope GLOBAL or PROJECT To import PIPELINE variables, use the pipelines.import_from_json function
- Parameters:
- Returns:
True if environment variables are imported False otherwise
- Return type:
Examples
>>> saagieapi.env_vars.import_from_json( ... json_file="/path/to/the/json/file.json", ... project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771" ... ) True
- list(scope: str, project_id: str = None, pipeline_id: str = None, scope_only: bool = False, pprint_result: bool | None = None) Dict #
Get environment variables NB: You can only list environment variables if you have at least the viewer role on the project
- Parameters:
scope (str) – Scope of the environment variable to list. Must be one of GLOBAL, PROJECT or PIPELINE
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
scope_only (bool, optional) – Whether to return only the environment variables of the given scope
pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global
- Returns:
Dict of environment variables
- Return type:
Examples
>>> saagieapi.env_vars.list(scope="GLOBAL") [ { "id": "334c2e0e-e8ea-4639-911e-757bf36bc91b", "name": "TEST_PASSWORD", "scope": "GLOBAL", "value": None, "description": "This is a password", "isPassword": True, "isValid": True, "overriddenValues": [], "invalidReasons": None }, { "id": "eb430066-551a-47f3-97c6-e56a9272fbd0", "name": "PORT_WEBHDFS", "scope": "GLOBAL", "value": "50070", "description": "", "isPassword": False, "isValid": True, "overriddenValues": [], "invalidReasons": None } ]
- list_for_pipeline(pipeline_id: str, pprint_result: bool | None = None) Dict #
Get pipeline environment variables NB: You can only list environment variables if you have at least the viewer role on the project
- Parameters:
- Returns:
Dict of pipeline environment variables
- Return type:
Examples
>>> saagieapi.env_vars.list_for_pipeline(pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1") { "pipelineEnvironmentVariables": [ { "id": "40a7dd59-538f-4c55-a983-8a554525b060", "scope": "GLOBAL", "name": "TEST_GLOBAL", "value": "TEST_GLOBAL", "description": "", "isPassword": False, "isValid": True, "overriddenValues": [], "invalidReasons": None }, { "id": "3f4a8d8f-6f45-480f-8907-2f66ddf26e01", "scope": "PROJECT", "name": "TEST_PROJECT", "value": "TEST_PROJECT", "description": "", "isPassword": False, "isValid": True, "overriddenValues": [], "invalidReasons": None }, { "id": "750c5366-caea-4d1f-ad38-fa6089ea2015", "scope": "PIPELINE", "name": "BLK1", "value": None, "description": "This is a new password", "isPassword": True, "isValid": True, "overriddenValues": [], "invalidReasons": None } ] }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
list()
instead.
- list_for_project(project_id: str, pprint_result: bool | None = None) Dict #
Get project environment variables NB: You can only list environment variables if you have at least the viewer role on the project
- Parameters:
- Returns:
Dict of project environment variables
- Return type:
Examples
>>> saagieapi.env_vars.list_for_project(project_id="50033e21-83c2-4431-a723-d54c2693b964") { "projectEnvironmentVariables": [ { "id": "334c2e0e-e8ea-4639-911e-757bf36bc91b", "name": "TEST_PASSWORD", "scope": "GLOBAL", "value": None, "description": "This is a password", "isPassword": True, "isValid": True, "overriddenValues": [], "invalidReasons": None }, { "id": "eb430066-551a-47f3-97c6-e56a9272fbd0", "name": "RSTUDIO_ADMIN_USER", "scope": "PROJECT", "value": "rstudio", "description": "", "isPassword": False "isValid": True, "overriddenValues": [], "invalidReasons": None } ] }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
list()
instead.
- list_globals(pprint_result: bool | None = None) Dict #
Get global environment variables
NB: You can only list environment variables if you have at least the viewer role on the platform
- Parameters:
pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global
- Returns:
Dict of global environment variable on the platform
- Return type:
Examples
>>> saagie_api.env_vars.list_globals() { "globalEnvironmentVariables": [ { "id": "334c2e0e-e8ea-4639-911e-757bf36bc91b", "name": "TEST_PASSWORD", "scope": "GLOBAL", "value": None, "description": "This is a password", "isPassword": True, "isValid": True, "overriddenValues": [], "invalidReasons": None }, { "id": "eb430066-551a-47f3-97c6-e56a9272fbd0", "name": "PORT_WEBHDFS", "scope": "GLOBAL", "value": "50070", "description": "", "isPassword": False, "isValid": True, "overriddenValues": [], "invalidReasons": None } ] }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
list()
instead.
- update(scope: str, name: str, new_name: str = None, value: str = None, description: str = None, is_password: bool = None, project_id: str = None, pipeline_id: str = None) Dict #
Update environment variable with provided function variables if it exists
- Parameters:
scope (str) – Scope of the environment variable to update. Must be one of GLOBAL, PROJECT or PIPELINE
name (str) – Name of the environment variable to upgrade
new_name (str, optional) – New name of the environment variable. If none provided, keep the actual one
value (str, optional) – New value of the environment variable. If none provided, keep the actual one
description (str, optional) – New description of the environment variable. If none provided, keep the actual one
is_password (boolean, optional) – New password boolean status. If none provided, keep the actual one
project_id (str, optional) – UUID of your project (see README on how to find it)
pipeline_id (str, optional) – UUID of your pipeline (see README on how to find it)
- Returns:
Dict containing the id of the updated environment variable
- Return type:
- Raises:
ValueError – When the variable doesn’t already exist
Examples
>>> saagieapi.env_vars.update( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
- update_for_pipeline(pipeline_id: str, name: str, new_name: str = None, value: str = None, description: str = None, is_password: bool = None) Dict #
Update environment variable with provided function variables if it exists
- Parameters:
pipeline_id (str) – ID of the project
name (str) – Name of the environment variable to upgrade
new_name (str, optional) – New name of the environment variable. If none provided, keep the actual one
value (str, optional) – New value of the environment variable. If none provided, keep the actual one
description (str, optional) – New description of the environment variable. If none provided, keep the actual one
is_password (boolean, optional) – New password boolean status. If none provided, keep the actual one
- Returns:
Dict containing the id of the updated environment variable
- Return type:
- Raises:
ValueError – When the variable doesn’t already exist
Examples
>>> saagie_api.env_vars.update_for_pipeline( ... pipeline_id="5a064fe8-8de3-4dc7-9a69-40b079deaeb1", ... name="TEST_PASSWORD", ... new_name="TEST_PWD", ... value="new value", ... description="This is a new password", ... is_password=True, ... ) { "saveEnvironmentVariable": { "id": "750c5366-caea-4d1f-ad38-fa6089ea2015" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
update()
instead.
- update_for_project(project_id: str, name: str, new_name: str = None, value: str = None, description: str = None, is_password: bool = None) Dict #
Update environment variable with provided function variables if it exists
- Parameters:
project_id (str) – ID of the project
name (str) – Name of the environment variable to upgrade
new_name (str, optional) – New name of the environment variable. If none provided, keep the actual one
value (str, optional) – New value of the environment variable. If none provided, keep the actual one
description (str, optional) – New description of the environment variable. If none provided, keep the actual one
is_password (boolean, optional) – New password boolean status. If none provided, keep the actual one
- Returns:
Dict containing the id of the updated environment variable
- Return type:
- Raises:
ValueError – When the variable doesn’t already exist
Examples
>>> saagieapi.env_vars.update_for_project( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True, ... project_id="50033e21-83c2-4431-a723-d54c2693b964" ... ) { "saveEnvironmentVariable": { "id": "8aaee333-a9f4-40f5-807a-44f8efa65a2f" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
update()
instead.
- update_global(name: str, new_name: str = None, value: str = None, description: str = None, is_password: bool = None) Dict #
Update environment variable with provided function variables if it exists
- Parameters:
name (str) – Name of the environment variable to upgrade
new_name (str, optional) – New name of the environment variable. If none provided, keep the actual one
value (str, optional) – New value of the environment variable. If none provided, keep the actual one
description (str, optional) – New description of the environment variable. If none provided, keep the actual one
is_password (boolean, optional) – New password boolean status. If none provided, keep the actual one
- Returns:
Dict containing the id of the updated environment variable
- Return type:
- Raises:
ValueError – When the variable doesn’t already exist
Examples
>>> saagieapi.env_vars.update_global( ... name="TEST_PASSWORD", ... value="new value", ... description="This is a new password", ... is_password=True ... ) { "saveEnvironmentVariable": { "id": "069f3bf2-da1a-4106-acb4-3c7cc37367a3" } }
Deprecated since version 2.8.0: This function is deprecated and will be removed in a future version. Please use
update()
instead.