Skip to content

Planet

Access planet information from FIO.

Planet

Bases: AbstractPlanet, AbstractEndpoint

Planet endpoint wrapper

get

get(planet, timeout=None)

Gets full planet data from FIO

Parameters:

Name Type Description Default
planet str

PlanetId, PlanetNaturalId or PlanetName

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
PlanetNotFound

Planet not found

Returns:

Name Type Description
PlanetFull PlanetFull

Full planet information

Source code in fio_wrapper/endpoints/endpoints_v1/planet.py
def get(self, planet: str, timeout: Optional[float] = None) -> PlanetFull:
    """Gets full planet data from FIO

    Args:
        planet (str): PlanetId, PlanetNaturalId or PlanetName
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        PlanetNotFound: Planet not found

    Returns:
        PlanetFull: Full planet information
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.planet_get_url(planet=planet),
        err_codes=[204],
        timeout=timeout,
    )

    if status == 200:
        return PlanetFull.model_validate(data)
    elif status == 204:
        raise PlanetNotFound("Planet not found")

all

all(timeout=None)

Gets a list of all Planets with minimal information from FIO

Parameters:

Name Type Description Default
timeout float

Request timeout in seconds. Defaults to None.

None

Returns:

Name Type Description
PlanetList PlanetList

List of Planets as List[Planet]

Source code in fio_wrapper/endpoints/endpoints_v1/planet.py
def all(self, timeout: Optional[float] = None) -> PlanetList:
    """Gets a list of all Planets with minimal information from FIO

    Args:
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Returns:
        PlanetList: List of Planets as List[Planet]
    """
    (_, data) = self.adapter.get(
        endpoint=self.urls.planet_all_url(), timeout=timeout
    )

    return PlanetList.model_validate(data)

full

full(timeout=None)

Gets a list of all planets from FIO with full planet information

Parameters:

Name Type Description Default
timeout float

Request timeout in seconds. Defaults to None.

None

Returns:

Name Type Description
PlanetFullList PlanetFullList

List of Planets with full information as List[PlanetFull]

Source code in fio_wrapper/endpoints/endpoints_v1/planet.py
def full(self, timeout: Optional[float] = None) -> PlanetFullList:
    """Gets a list of all planets from FIO with full planet information

    Args:
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Returns:
        PlanetFullList: List of Planets with full information as List[PlanetFull]
    """
    (_, data) = self.adapter.get(
        endpoint=self.urls.planet_full_url(), timeout=timeout
    )

    return PlanetFullList.model_validate(data)

sites

sites(planet, timeout=None)

Gets a list of sites on the planet from FIO

Parameters:

Name Type Description Default
planet str

PlanetId, PlanetNaturalId or PlanetName

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
PlanetNotFound

Planet not found

Returns:

Name Type Description
PlanetSiteList PlanetSiteList

List of Planet sites as List[PlanetSite]

Source code in fio_wrapper/endpoints/endpoints_v1/planet.py
def sites(self, planet: str, timeout: Optional[float] = None) -> PlanetSiteList:
    """Gets a list of sites on the planet from FIO

    Args:
        planet (str): PlanetId, PlanetNaturalId or PlanetName
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        PlanetNotFound: Planet not found

    Returns:
        PlanetSiteList: List of Planet sites as List[PlanetSite]
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.planet_sites_url(planet=planet),
        err_codes=[204],
        timeout=timeout,
    )

    if status == 200:
        return PlanetSiteList.model_validate(data)
    elif status == 204:
        raise PlanetNotFound("Planet not found")

search

search(
    materials=None,
    include_rocky=False,
    include_gaseous=False,
    include_low_gravity=False,
    include_high_gravity=False,
    include_low_pressure=False,
    include_high_pressure=False,
    include_low_temperature=False,
    include_high_temperature=False,
    must_be_fertile=False,
    must_have_localmarket=False,
    must_have_cogc=False,
    must_have_war=False,
    must_have_adm=False,
    must_have_shy=False,
    distance_checks=None,
    timeout=None,
)

Performs a search request towards FIO to find a planet matching the search parameters

Parameters:

Name Type Description Default
materials List[str]

List of materials to search for, e.g. ["FEO", "LST"].

None
include_rocky bool

Planet can be Rocky.

False
include_gaseous bool

Planet can be Gaseous.

False
include_low_gravity bool

Planet can be low gravity.

False
include_high_gravity bool

Planet can be high gravity.

False
include_low_pressure bool

Planet can be low pressure.

False
include_high_pressure bool

Planet can be high pressure.

False
include_low_temperature bool

Planet can be low temperature.

False
include_high_temperature bool

Planet can be high temperature.

False
must_be_fertile bool

Planet must be Fertile.

False
must_have_localmarket bool

Planet must have a Local Market.

False
must_have_cogc bool

Planet must have a Chamber of Glboal Commerce.

False
must_have_war bool

Planet must have warehouses.

False
must_have_adm bool

Planet must have a Planetary Administration Center.

False
must_have_shy bool

Planet must have a Shipyard.

False
distance_checks List[str]

List of other planets to check distance to, e.g. ["ANT", "MOR"].

None
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
PlanetSearchMaterialsInvalid

description

PlanetSearchDistanceChecksInvalid

description

PlanetSearchInvalidRequest

description

Returns:

Name Type Description
PlanetFullList PlanetFullList

List of Planets with full information as List[PlanetFull]

Source code in fio_wrapper/endpoints/endpoints_v1/planet.py
def search(
    self,
    materials: List[str] = None,
    include_rocky: bool = False,
    include_gaseous: bool = False,
    include_low_gravity: bool = False,
    include_high_gravity: bool = False,
    include_low_pressure: bool = False,
    include_high_pressure: bool = False,
    include_low_temperature: bool = False,
    include_high_temperature: bool = False,
    must_be_fertile: bool = False,
    must_have_localmarket: bool = False,
    must_have_cogc: bool = False,
    must_have_war: bool = False,
    must_have_adm: bool = False,
    must_have_shy: bool = False,
    distance_checks: List[str] = None,
    timeout: Optional[float] = None,
) -> PlanetFullList:
    """Performs a search request towards FIO to find a planet matching the search parameters

    Args:
        materials (List[str], optional): List of materials to search for, e.g. ["FEO", "LST"].
        include_rocky (bool, optional): Planet can be Rocky.
        include_gaseous (bool, optional): Planet can be Gaseous.
        include_low_gravity (bool, optional): Planet can be low gravity.
        include_high_gravity (bool, optional): Planet can be high gravity.
        include_low_pressure (bool, optional): Planet can be low pressure.
        include_high_pressure (bool, optional): Planet can be high pressure.
        include_low_temperature (bool, optional): Planet can be low temperature.
        include_high_temperature (bool, optional): Planet can be high temperature.
        must_be_fertile (bool, optional): Planet must be Fertile.
        must_have_localmarket (bool, optional): Planet must have a Local Market.
        must_have_cogc (bool, optional): Planet must have a Chamber of Glboal Commerce.
        must_have_war (bool, optional): Planet must have warehouses.
        must_have_adm (bool, optional): Planet must have a Planetary Administration Center.
        must_have_shy (bool, optional): Planet must have a Shipyard.
        distance_checks (List[str], optional): List of other planets to check distance to, e.g. ["ANT", "MOR"].
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        PlanetSearchMaterialsInvalid: _description_
        PlanetSearchDistanceChecksInvalid: _description_
        PlanetSearchInvalidRequest: _description_

    Returns:
        PlanetFullList: List of Planets with full information as List[PlanetFull]
    """

    # accept None as materials, don't include materials in search
    if materials is not None:
        if not validate_planet_search_materials(materials=materials):
            raise PlanetSearchMaterialsInvalid(
                "Invalid materials provided. Can check for up to 4 materials."
            )

    if distance_checks is not None:
        if not validate_planet_search_distance_checks(
            distance_checks=distance_checks
        ):
            raise PlanetSearchDistanceChecksInvalid(
                "Invalid distance checks. Can check for up to 10 distances."
            )

    (status, data) = self.adapter.post(
        endpoint=self.urls.planet_search_url(),
        data={
            "Materials": [] if materials is None else materials,
            "IncludeRocky": include_rocky,
            "IncludeGaseous": include_gaseous,
            "IncludeLowGravity": include_low_gravity,
            "IncludeHighGravity": include_high_gravity,
            "IncludeLowPressure": include_low_pressure,
            "IncludeHighPressure": include_high_pressure,
            "IncludeLowTemperature": include_low_temperature,
            "IncludeHighTemperature": include_high_temperature,
            "MustBeFertile": must_be_fertile,
            "MustHaveLocalMarket": must_have_localmarket,
            "MustHaveChamberOfCommerce": must_have_cogc,
            "MustHaveWarehouse": must_have_war,
            "MustHaveAdministrationCenter": must_have_adm,
            "MustHaveShipyard": must_have_shy,
            "DistanceChecks": [] if distance_checks is None else distance_checks,
        },
        err_codes=[400],
        timeout=timeout,
    )

    if status == 200:
        return PlanetFullList.model_validate(data)
    elif status == 400:
        raise PlanetSearchInvalidRequest("Failed to parse payload")