Storages

class saagieapi.storages.Storages(saagie_api)

Bases: object

create(project_id: str, storage_name: str, storage_size: int, storage_description: str | None = None) Dict

Create a storage

Note

Each optional parameter can be set to change the value of the corresponding field.

Parameters:
  • project_id (str) – UUID of your project

  • storage_name (str) – Storage name

  • storage_size (int, optional) – Size of the storage

  • storage_description (str, optional) – Description of storage if not filled, the storage will have no description

Returns:

Dict of storage information

Return type:

dict

Examples

>>> saagieapi.storages.create(
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     storage_name="storage name",
...     storage_size="128 MB",
...     storage_description="storage description"
... )
{
    "createVolume":{
        "id":"fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
        "name":"storage name",
        "size":"128 MB",
        "description":"storage description",
        "creationDate":"2022-09-12T13:52:19.523Z",
        "creator":"user.name",
        "linkedApp":"None"
    }
}
delete(storage_id: str, project_id: str) Dict

Delete a given storage (not currently used)

Parameters:
  • storage_id (str) – UUID of your storage

  • project_id (str) – UUID of your storage project

Returns:

Dict of deleted storage

Return type:

dict

Raises:

ValueError – When the storage is currently used

Examples

>>> saagieapi.storages.delete(
...     storage_id="fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771"
... )
{
    "deleteVolume":{
        "id":"fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
        "name":"storage new name",
    }
}
edit(storage_id: str, storage_name: str = None, description: str = None) Dict

Edit a storage

Note

Each optional parameter can be set to change the value of the corresponding field.

Parameters:
  • storage_id (str) – UUID of your storage

  • storage_name (str, optional) – Storage name If not filled, defaults to current value, else it will change the storage’s name

  • description (str, optional) – Description of storage if not filled, defaults to current value, else it will change the description of the storage

Returns:

Dict of storage information

Return type:

dict

Examples

>>> saagieapi.storages.edit(
...     storage_id="fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
...     storage_name="storage new name",
...     storage_description="storage new description"
... )
{
    "editVolume":{
        "id":"fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
        "name":"storage new name",
    }
}
get_info(project_id: str, storage_id: str) Dict

Get storage information.

Note

You can only get storage information if you have at least the viewer role on the project.

Parameters:
  • project_id (str) – UUID of your project

  • storage_id (str) – UUID of your storage

Returns:

Dict of storage information

Return type:

dict

Examples

>>> saagieapi.storages.get_info(
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     job_id="f5fce22d-2152-4a01-8c6a-4c2eb4808b6d"
... )
{
    "id":"89bf5f86-3fc3-4bf6-879b-7ca8eafe6c4f",
    "name":"storage Jupyter Notebook (0)",
    "size":"64 MB",
    "description":"Autogenerated storage from app installation for "/notebooks-dir" path in "Jupyter Notebook" app.",
    "creationDate":"2022-08-26T13:12:05.363Z",
    "creator":"user.name",
    "linkedApp":{
        "id":"6871e9a2-2c06-45fe-bf8d-6356090f1d1d",
        "name":"Jupyter Notebook",
        "versions":[
            {
                "number":1,
                "volumesWithPath":[
                    {
                        "path":"/notebooks-dir",
                        "volume":{
                            "id":"89bf5f86-3fc3-4bf6-879b-7ca8eafe6c4f"
                        }
                    }
                ]
            }
        ],
        "currentVersion":{
            "number":1,
            "volumesWithPath":[]
        }
    }
}
list_for_project(project_id: str, minimal: bool | None = False, pprint_result: bool | None = None) Dict

List storages of project.

Note

You can only list storage if you have at least the viewer role on the project.

Parameters:
  • project_id (str) – UUID of your project (see README on how to find it)

  • minimal (bool, optional) – Whether to only return the storage’s name and id, default to False

  • pprint_result (bool, optional) – Whether to pretty print the result of the query, default to saagie_api.pprint_global

Returns:

Dict of storage information

Return type:

dict

Examples

>>> saagieapi.storages.list_for_project(
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771",
...     minimal=False
... )
{
    "volumes":[
        {
            "id":"89bf5f86-3fc3-4bf6-879b-7ca8eafe6c4f",
            "name":"storage Jupyter Notebook (0)",
            "size":"64 MB",
            "description":"Autogenerated storage from app installation for "/notebooks-dir" path in "Jupyter Notebook" app.",
            "creationDate":"2022-08-26T13:12:05.363Z",
            "creator":"guillaume.prevost",
            "linkedApp":{
                "id":"6871e9a2-2c06-45fe-bf8d-6356090f1d1d",
                "name":"Jupyter Notebook",
                "versions":[
                    {
                        "number":1,
                        "volumesWithPath":[
                            {
                                "path":"/notebooks-dir",
                                "volume":{
                                    "id":"89bf5f86-3fc3-4bf6-879b-7ca8eafe6c4f"
                                }
                            }
                        ]
                    }
                ],
                "currentVersion":{
                    "number":1,
                    "volumesWithPath":[]
                }
            }
        },
        {
            "id":"905d8441-8955-444f-a333-19d7c6fe6274",
            "name":"test",
            "size":"128 MB",
            "description":"test description",
            "creationDate":"2022-08-29T08:02:11.811Z",
            "creator":"user.name",
            "linkedApp":{
                "id":"c7b2b5ea-834a-4e0e-bfa4-f3303477b9e5",
                "name":"test_app",
                "versions":[
                    {
                        "number":5,
                        "volumesWithPath":[
                            {
                                "path":"/data",
                                "volume":{
                                    "id":"905d8441-8955-444f-a333-19d7c6fe6274"
                                }
                            }
                        ]
                    }
                ],
                "currentVersion":{
                    "number":1,
                    "volumesWithPath":[
                        {
                            "path":"/data",
                            "volume":{
                                "id":"905d8441-8955-444f-a333-19d7c6fe6274"
                            }
                        }
                    ]
                }
            }
        }
    ]
}

Unlink a given storage (not currently used) to the associated app

Parameters:
  • storage_id (str) – UUID of your storage

  • project_id (str) – UUID of your storage project

Returns:

Dict of unlink storage

Return type:

dict

Raises:

ValueError – When the storage is currently used

Examples

>>> saagieapi.storages.unlink(
...     storage_id="fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
...     project_id="860b8dc8-e634-4c98-b2e7-f9ec32ab4771"
... )
{
    "unlinkVolume":{
        "id":"fdb43a11-ccec-4b10-9690-2b83fbd7eb93",
        "name":"storage new name",
    }
}