Skip to content

Overview

Bases: SkahaClient

Overview of the Skaha Server.

Parameters:

Name Type Description Default
SkahaClient Object

Skaha Client.

required
Source code in skaha/overview.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class Overview(SkahaClient):
    """Overview of the Skaha Server.

    Args:
        SkahaClient (Object): Skaha Client.
    """

    @model_validator(mode="after")
    def _update_base_url(self) -> Self:
        """Update base URL for the server.

        Returns:
            Self: The current object.
        """
        # The overview endpoint is not versioned, so need to remove it
        self.client.base_url = f"{self.server}"
        self.asynclient.base_url = f"{self.server}"
        return self

    def availability(self) -> bool:
        """Check if the server backend is available.

        Returns:
            bool: True if the server is available, False otherwise.
        """
        response: Response = self.client.get("availability")  # type: ignore # noqa
        response.raise_for_status()
        # Parse the XML string
        root = ElementTree.fromstring(response.text)  # type: ignore
        available = root.find(
            ".//{http://www.ivoa.net/xml/VOSIAvailability/v1.0}available"
        ).text  # type: ignore
        note = root.find(
            ".//{http://www.ivoa.net/xml/VOSIAvailability/v1.0}note"
        ).text  # type: ignore
        log.info(note)
        if available == "true":
            return True
        return False

_update_base_url()

Update base URL for the server.

Returns:

Name Type Description
Self Self

The current object.

Source code in skaha/overview.py
21
22
23
24
25
26
27
28
29
30
31
@model_validator(mode="after")
def _update_base_url(self) -> Self:
    """Update base URL for the server.

    Returns:
        Self: The current object.
    """
    # The overview endpoint is not versioned, so need to remove it
    self.client.base_url = f"{self.server}"
    self.asynclient.base_url = f"{self.server}"
    return self

availability()

Check if the server backend is available.

Returns:

Name Type Description
bool bool

True if the server is available, False otherwise.

Source code in skaha/overview.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def availability(self) -> bool:
    """Check if the server backend is available.

    Returns:
        bool: True if the server is available, False otherwise.
    """
    response: Response = self.client.get("availability")  # type: ignore # noqa
    response.raise_for_status()
    # Parse the XML string
    root = ElementTree.fromstring(response.text)  # type: ignore
    available = root.find(
        ".//{http://www.ivoa.net/xml/VOSIAvailability/v1.0}available"
    ).text  # type: ignore
    note = root.find(
        ".//{http://www.ivoa.net/xml/VOSIAvailability/v1.0}note"
    ).text  # type: ignore
    log.info(note)
    if available == "true":
        return True
    return False