Skip to content

Storage

Exposes FIO Storage data for users. All storage data requires a FIO API KEY. You will need to have access to the data the user has in FIO in order to access it.

Example:

1
2
3
4
5
6
from fio_wrapper import FIO

fio = FIO(api_key="your_api_key")

# Get users storage data
user_storage = fio.Sites.get(username="PrUn username")

Storage

Bases: AbstractStorage, AbstractEndpoint

get

get(username, timeout=None)

Gets users storage data from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoStorageData

Username has no storage data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Name Type Description
StorageList StorageList

List of storages

Source code in fio_wrapper/endpoints/endpoints_v1/storage.py
@apikey_required
def get(self, username: str, timeout: Optional[float] = None) -> StorageList:
    """Gets users storage data from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoStorageData: Username has no storage data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        StorageList: List of storages
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.storage_get_url(username=username),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return StorageList.model_validate(data)

    elif status == 204:
        raise NoStorageData("Username has no storage data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")

get_specific

get_specific(username, specific, timeout=None)

Gets users specific storage data from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
specific str

StorageId, PlanetId, PlanetNaturalId or PlanetName

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoStorageData

Username has no storage data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Name Type Description
StorageModel Storage

Storage data

Source code in fio_wrapper/endpoints/endpoints_v1/storage.py
@apikey_required
def get_specific(
    self, username: str, specific: str, timeout: Optional[float] = None
) -> StorageModel:
    """Gets users specific storage data from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        specific (str): StorageId, PlanetId, PlanetNaturalId or PlanetName
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoStorageData: Username has no storage data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        StorageModel: Storage data
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.storage_get_specific_url(
            username=username, specific=specific
        ),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return StorageModel.model_validate(data)

    elif status == 204:
        raise NoStorageData("Username has no storage data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")

planets

planets(username, timeout=None)

Returns a list of storages from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoStorageData

Username has no storage data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Type Description
List[str]

List[str]: List of StorageIds

Source code in fio_wrapper/endpoints/endpoints_v1/storage.py
@apikey_required
def planets(self, username: str, timeout: Optional[float] = None) -> List[str]:
    """Returns a list of storages from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoStorageData: Username has no storage data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        List[str]: List of StorageIds
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.storage_planets_get_url(username=username),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return data
    elif status == 204:
        raise NoStorageData("Username has no storage data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")