Skip to content

OutlineClient

A client for interacting with an Outline VPN server's API.

This class provides access to the server management, metrics, and access keys functionalities of the Outline VPN API. It allows you to manage server settings, retrieve server information, and interact with access keys and metrics.

Attributes:

Name Type Description
server Server

An instance of the Server class for managing server-level settings and configurations.

metrics Metrics

An instance of the Metrics class for monitoring and retrieving server metrics.

access_keys AccessKeys

An instance of the AccessKeys class for managing and retrieving access keys.

Parameters:

Name Type Description Default
management_url str

The management URL used to communicate with the Outline server API. Default is 'https://myoutline.com/SecretPath'.

'https://myoutline.com/SecretPath'
ssl_verify bool

Flag to enable or disable SSL certificate verification for API requests. Default is False. You should set this flag to False if the server's SSL certificate is self-signed or if no certificate is present.

False
Source code in outline_vpn_api_client/client.py
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
class OutlineClient:
    """
    A client for interacting with an Outline VPN server's API.

    This class provides access to the server management, metrics, and access keys functionalities of the Outline VPN API.
    It allows you to manage server settings, retrieve server information, and interact with access keys and metrics.

    Attributes:
        server (Server): An instance of the `Server` class for managing server-level settings and configurations.
        metrics (Metrics): An instance of the `Metrics` class for monitoring and retrieving server metrics.
        access_keys (AccessKeys): An instance of the `AccessKeys` class for managing and retrieving access keys.

    Args:
        management_url (str): The management URL used to communicate with the Outline server API. Default is 'https://myoutline.com/SecretPath'.
        ssl_verify (bool): Flag to enable or disable SSL certificate verification for API requests. Default is `False`. 
                            You should set this flag to `False` if the server's SSL certificate is self-signed or if no certificate is present.
    """
    def __init__(
        self, 
        management_url: str = 'https://myoutline.com/SecretPath',
        ssl_verify: bool = False
    ):
        self.server = Server(management_url, ssl_verify)
        self.metrics = Metrics(management_url, ssl_verify)
        self.access_keys = AccessKeys(management_url, ssl_verify)

    def __str__(self):
        return json.dumps(self.get_information().model_dump(), ensure_ascii=False, indent=4)

    def get_information(self) -> models.Info:
        """
        Retrieves detailed information about the Outline server, including its configuration, metrics, and access keys.

        This method returns a dictionary containing:
            - Information about the server (via the `server.get_information()` method),
            - The status of the metrics (whether they are enabled, checked via the `metrics.check_enabled()` method),
            - A list of all access keys (retrieved using the `access_keys.get_all()` method).

        Returns:
            dict: A dictionary containing:

                - `server`: Information about the server configuration.

                - `metrics`: A dictionary with the status of metrics (e.g., if they are enabled).

                - `access_keys`: A list of all access keys.
        """
        return models.Info.model_validate({
            "server": self.server.get_information(),
            "metrics": {
                "enabled": self.metrics.check_enabled()
            },
            "access_keys": self.access_keys.get_all()
        })

get_information()

Retrieves detailed information about the Outline server, including its configuration, metrics, and access keys.

This method returns a dictionary containing
  • Information about the server (via the server.get_information() method),
  • The status of the metrics (whether they are enabled, checked via the metrics.check_enabled() method),
  • A list of all access keys (retrieved using the access_keys.get_all() method).

Returns:

Name Type Description
dict Info

A dictionary containing:

  • server: Information about the server configuration.

  • metrics: A dictionary with the status of metrics (e.g., if they are enabled).

  • access_keys: A list of all access keys.

Source code in outline_vpn_api_client/client.py
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
def get_information(self) -> models.Info:
    """
    Retrieves detailed information about the Outline server, including its configuration, metrics, and access keys.

    This method returns a dictionary containing:
        - Information about the server (via the `server.get_information()` method),
        - The status of the metrics (whether they are enabled, checked via the `metrics.check_enabled()` method),
        - A list of all access keys (retrieved using the `access_keys.get_all()` method).

    Returns:
        dict: A dictionary containing:

            - `server`: Information about the server configuration.

            - `metrics`: A dictionary with the status of metrics (e.g., if they are enabled).

            - `access_keys`: A list of all access keys.
    """
    return models.Info.model_validate({
        "server": self.server.get_information(),
        "metrics": {
            "enabled": self.metrics.check_enabled()
        },
        "access_keys": self.access_keys.get_all()
    })