Skip to content

AsyncServer

Bases: AsyncBaseRoute

A class for managing the Outline VPN server's settings and configurations asynchronously.

Provides methods to interact with and configure server-level settings such as renaming the server, changing the hostname, adjusting port settings, and setting or removing data transfer limits.

Parameters:

Name Type Description Default
management_url str

The management URL used to communicate with the Outline server API.

required
ssl_verify bool

Flag to enable or disable SSL certificate verification. Default is False.

False
Source code in outline_vpn_api_client/async_client.py
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
class AsyncServer(AsyncBaseRoute):
    """
    A class for managing the Outline VPN server's settings and configurations asynchronously.

    Provides methods to interact with and configure server-level settings such as renaming the server,
    changing the hostname, adjusting port settings, and setting or removing data transfer limits.

    Args:
        management_url (str): The management URL used to communicate with the Outline server API.
        ssl_verify (bool, optional): Flag to enable or disable SSL certificate verification. Default is False.
    """

    async def get_information(self) -> models.Server:
        """
        Returns information about the server.

        Returns:
            models.Server: Server configuration and state.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.get(f"{self.base_url}/server")
            response_json = response.json()
            _check_response(response, response_json)
        return models.Server.model_validate(response_json)

    async def change_hostname(self, hostname: str) -> bool:
        """
        Changes the hostname for access keys.

        Updates the hostname or IP address used for access keys on the Outline VPN server.
        If a hostname is provided, DNS must be configured independently of this API.

        Args:
            hostname (str): The new hostname or IP address to use for access keys.

        Returns:
            bool: True if the hostname was successfully changed.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        data = {"hostname": hostname}
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.put(f"{self.base_url}/server/hostname-for-access-keys", json=data)
            _check_response(response)
        return True

    async def rename(self, name: str) -> bool:
        """
        Renames the server.

        Args:
            name (str): The new name for the server.

        Returns:
            bool: True if the server was successfully renamed.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        data = {"name": name}
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.put(f"{self.base_url}/name", json=data)
            _check_response(response)
        return True

    async def change_default_port_for_new_keys(self, port: int) -> bool:
        """
        Changes the default port for newly created access keys.

        The specified port can be one already in use by other access keys.

        Args:
            port (int): The new default port to be used for newly created access keys.

        Returns:
            bool: True if the default port was successfully changed.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        data = {"port": port}
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.put(f"{self.base_url}/server/port-for-new-access-keys", json=data)
            _check_response(response)
        return True

    async def set_server_default_limits(self, limit: int) -> bool:
        """
        Sets a data transfer limit for all access keys.

        Args:
            limit (int): The data transfer limit in bytes to set for all access keys.

        Returns:
            bool: True if the default data transfer limit was successfully set.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        data = {"limit": {"bytes": limit}}
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.put(f"{self.base_url}/server/access-key-data-limit", json=data)
            _check_response(response)
        return True

    async def remove_server_default_limits(self) -> bool:
        """
        Removes the access key data limit, lifting data transfer restrictions on all access keys.

        Returns:
            bool: True if the data transfer limit was successfully removed.

        Raises:
            ResponseNotOkException: If the server response indicates an error (status code >= 300).
        """
        async with httpx.AsyncClient(verify=self.ssl_verify) as client:
            response = await client.delete(f"{self.base_url}/server/access-key-data-limit")
            _check_response(response)
        return True

    def __str__(self):
        return json.dumps({"info": "AsyncServer object for managing server settings"}, ensure_ascii=False)

change_default_port_for_new_keys(port) async

Changes the default port for newly created access keys.

The specified port can be one already in use by other access keys.

Parameters:

Name Type Description Default
port int

The new default port to be used for newly created access keys.

required

Returns:

Name Type Description
bool bool

True if the default port was successfully changed.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
async def change_default_port_for_new_keys(self, port: int) -> bool:
    """
    Changes the default port for newly created access keys.

    The specified port can be one already in use by other access keys.

    Args:
        port (int): The new default port to be used for newly created access keys.

    Returns:
        bool: True if the default port was successfully changed.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    data = {"port": port}
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.put(f"{self.base_url}/server/port-for-new-access-keys", json=data)
        _check_response(response)
    return True

change_hostname(hostname) async

Changes the hostname for access keys.

Updates the hostname or IP address used for access keys on the Outline VPN server. If a hostname is provided, DNS must be configured independently of this API.

Parameters:

Name Type Description Default
hostname str

The new hostname or IP address to use for access keys.

required

Returns:

Name Type Description
bool bool

True if the hostname was successfully changed.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
async def change_hostname(self, hostname: str) -> bool:
    """
    Changes the hostname for access keys.

    Updates the hostname or IP address used for access keys on the Outline VPN server.
    If a hostname is provided, DNS must be configured independently of this API.

    Args:
        hostname (str): The new hostname or IP address to use for access keys.

    Returns:
        bool: True if the hostname was successfully changed.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    data = {"hostname": hostname}
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.put(f"{self.base_url}/server/hostname-for-access-keys", json=data)
        _check_response(response)
    return True

get_information() async

Returns information about the server.

Returns:

Type Description
Server

models.Server: Server configuration and state.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
async def get_information(self) -> models.Server:
    """
    Returns information about the server.

    Returns:
        models.Server: Server configuration and state.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.get(f"{self.base_url}/server")
        response_json = response.json()
        _check_response(response, response_json)
    return models.Server.model_validate(response_json)

remove_server_default_limits() async

Removes the access key data limit, lifting data transfer restrictions on all access keys.

Returns:

Name Type Description
bool bool

True if the data transfer limit was successfully removed.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
async def remove_server_default_limits(self) -> bool:
    """
    Removes the access key data limit, lifting data transfer restrictions on all access keys.

    Returns:
        bool: True if the data transfer limit was successfully removed.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.delete(f"{self.base_url}/server/access-key-data-limit")
        _check_response(response)
    return True

rename(name) async

Renames the server.

Parameters:

Name Type Description Default
name str

The new name for the server.

required

Returns:

Name Type Description
bool bool

True if the server was successfully renamed.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
async def rename(self, name: str) -> bool:
    """
    Renames the server.

    Args:
        name (str): The new name for the server.

    Returns:
        bool: True if the server was successfully renamed.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    data = {"name": name}
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.put(f"{self.base_url}/name", json=data)
        _check_response(response)
    return True

set_server_default_limits(limit) async

Sets a data transfer limit for all access keys.

Parameters:

Name Type Description Default
limit int

The data transfer limit in bytes to set for all access keys.

required

Returns:

Name Type Description
bool bool

True if the default data transfer limit was successfully set.

Raises:

Type Description
ResponseNotOkException

If the server response indicates an error (status code >= 300).

Source code in outline_vpn_api_client/async_client.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
async def set_server_default_limits(self, limit: int) -> bool:
    """
    Sets a data transfer limit for all access keys.

    Args:
        limit (int): The data transfer limit in bytes to set for all access keys.

    Returns:
        bool: True if the default data transfer limit was successfully set.

    Raises:
        ResponseNotOkException: If the server response indicates an error (status code >= 300).
    """
    data = {"limit": {"bytes": limit}}
    async with httpx.AsyncClient(verify=self.ssl_verify) as client:
        response = await client.put(f"{self.base_url}/server/access-key-data-limit", json=data)
        _check_response(response)
    return True