proxyrack 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michel Ace
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyrack
3
+ Version: 0.1.1
4
+ Summary: API wrapper and CLI client for the Proxyrack proxy service
5
+ Author: Michel Ace
6
+ Author-email: Michel Ace <divtiply@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Dist: httpx2>=2.17.0
10
+ Requires-Dist: platformdirs>=4.14.9
11
+ Requires-Dist: pydantic>=2.14.4
12
+ Requires-Dist: rich>=15.0.0
13
+ Requires-Dist: tomli-w>=1.2.0
14
+ Requires-Dist: typer>=0.29.3
15
+ Requires-Python: >=3.11
16
+ Description-Content-Type: text/markdown
17
+
18
+ # proxyrack
19
+
20
+ API wrapper and CLI client for the [Proxyrack](https://proxyrack.com) proxy service.
21
+
22
+ Covers both documented API surfaces:
23
+
24
+ - **Proxy-Control API** - commands sent through the proxy tunnel itself (`api.proxyrack.net`): sticky sessions, releases, active connections, thread usage, stats, temporary passwords.
25
+ - **Account API** - direct HTTPS calls to `app.proxyrack.com`: sub-users and shared access.
26
+
27
+ Geo-targeting inventory (through the **Proxy-Control API**):
28
+
29
+ - `proxyrack geo countries` - country codes available in the pool.
30
+ - `proxyrack geo cities US` - cities available in a country.
31
+ - `proxyrack geo isps US` - ISPs available in a country.
32
+ - `proxyrack geo count US` - number of available IPs in a country.
33
+
34
+ List commands accept `--counts` to include the number of currently available IPs per item (e.g. `proxyrack geo cities US --counts`).
35
+
36
+ Plus local helpers for day-to-day use:
37
+
38
+ - `proxyrack proxy-url` - compose ready-to-use proxy URLs with geo-targeting, TTL, session, auto-replace and other parameters. Ports: 10000+ are sticky ports; 9000 is the random port on networks that offer it (one HTTP Keep-Alive connection keeps one exit IP there).
39
+ - `proxyrack networks list` - the built-in registry of proxy networks, probed live for availability (needs credentials; without them the registry is shown unchecked).
40
+ - `proxyrack config` - layered configuration (flags -> environment -> config file).
41
+
42
+ ## Installation
43
+
44
+ Requires Python >= 3.11 and [uv](https://docs.astral.sh/uv/).
45
+
46
+ ```sh
47
+ git clone https://github.com/divtiply/proxyrack
48
+ cd proxyrack
49
+ uv sync
50
+ uv run proxyrack --help
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ Credentials are stored as **profiles** — saved sets of `username` + `api-key` (+ optional default network) for any number of Proxyrack accounts.
56
+
57
+ ```sh
58
+ proxyrack profile add main # asks for username, api-key (hidden)
59
+ proxyrack profile add work --username <u> --api-key <k> --default-network mobile
60
+ proxyrack profile add main --default-network premium --force
61
+ # change the default network; omitted values
62
+ # (username, api-key, network) keep stored ones
63
+ proxyrack profile use main # set the default profile
64
+ proxyrack profile list # names, masked keys, default marker
65
+ proxyrack profile remove work --yes
66
+ ```
67
+
68
+ Profile selection order: `--profile NAME` flag → `PROXYRACK_PROFILE` env var → `default_profile` in the config file → the only profile when exactly one exists. Credentials resolve: `PROXYRACK_USERNAME`/`PROXYRACK_API_KEY` env vars → the selected profile (env wins over the profile, so CI scripts can inject credentials on top).
69
+
70
+ Per-account settings live in the profile (`default_network`); global settings in `proxyrack config` (`timeout`). Config file path: `proxyrack config path` (TOML; override the directory with `PROXYRACK_CONFIG_DIR`).
71
+
72
+ ```toml
73
+ default_profile = "main"
74
+ timeout = 30.0
75
+
76
+ [profiles.main]
77
+ username = "..."
78
+ api_key = "..."
79
+ default_network = "unmetered"
80
+ ```
81
+
82
+ ## Usage
83
+
84
+ ### Proxy-Control API (through the proxy)
85
+
86
+ ```sh
87
+ proxyrack networks list
88
+ proxyrack sessions list --network unmetered
89
+ proxyrack sessions list --wide
90
+ proxyrack sessions show 10001 # sticky session info by port or session name
91
+ proxyrack sessions release --network unmetered --port 10001
92
+ proxyrack sessions release --network unmetered --port 10000 --session mgr
93
+ proxyrack sessions release --network unmetered --all
94
+ proxyrack connections list --network premium
95
+ proxyrack usage threads
96
+ proxyrack usage stats # Request params / Exit IP reflect the proxy serving this request
97
+ proxyrack usage stats --port 10001 # send the stats request through a specific sticky port
98
+ proxyrack usage stats --port 10000 --session mgr # inspect a named session's own binding on that port
99
+ proxyrack geo countries
100
+ proxyrack geo cities US
101
+ proxyrack geo count US
102
+ proxyrack passwords list
103
+ proxyrack passwords create --label ci-job --ttl 300
104
+ proxyrack whitelist add --expire-time 86400 # whitelist your current IP
105
+ proxyrack whitelist add --ip 203.0.113.7 --label office --expire-time 2026-12-31T23:59:59Z
106
+ proxyrack whitelist list
107
+ proxyrack whitelist remove C5Ctf9gOR
108
+ ```
109
+
110
+ ### Account API (direct HTTPS)
111
+
112
+ ```sh
113
+ proxyrack sub-users list
114
+ proxyrack sub-users create --email a@b.c --first-name A --last-name B --password pw
115
+ proxyrack sub-users update bob --email new@b.c
116
+ proxyrack sub-users access add bob --service-id s-... --units 5
117
+ proxyrack sub-users access remove bob --service-id s-...
118
+ proxyrack sub-users delete bob
119
+ ```
120
+
121
+ ### Composing proxy URLs
122
+
123
+ ```sh
124
+ proxyrack proxy-url --network mobile --country us --session s1
125
+ # user;session=s1;country=us:<api-key>@mobile.residential.proxyrack.net:10000
126
+
127
+ # pin a known exit by Proxy ID or Exit IP (both are shown by `proxyrack usage stats`)
128
+ proxyrack proxy-url --network unmetered --proxy-id PD50KM5LD0
129
+ proxyrack proxy-url --network unmetered --proxy-ip 41.43.224.85
130
+
131
+ # multiple geo values are comma-separated (city names without spaces)
132
+ proxyrack proxy-url --network unmetered --country US,CA,FR
133
+ proxyrack proxy-url --network unmetered --country US --city LosAngeles,Denver --isp Verizon,Comcast
134
+
135
+ # a leading minus excludes a value (use the --flag=value form so the minus is not read as a flag)
136
+ proxyrack proxy-url --network unmetered --country=-US
137
+
138
+ # geo matching uses Maxmind by default; switch the geolocation database
139
+ proxyrack proxy-url --network unmetered --country US --geo-db ipinfo
140
+
141
+ proxyrack proxy-url --network unmetered --refresh-minutes 10 --auto-replace strict --format host-port-user-pass
142
+ ```
143
+
144
+ List commands print human-readable tables by default; add `--json` for raw API output. `--verbose` logs each request's method and URL (never credentials).
145
+
146
+ ### API response codes
147
+
148
+ Proxyrack answers with plain HTTP codes plus its own ones (407, 460–467, 560–565). The CLI appends a short hint to any of them:
149
+
150
+ | Code | Meaning |
151
+ | ---- | ------- |
152
+ | 407 | Authentication error — use the API key as the proxy password and connect from an allowed IP |
153
+ | 460 | Geo-targeting is not enabled for the network |
154
+ | 461 | Sticky port limit reached for the subscription |
155
+ | 463 | Malformed request |
156
+ | 464 | Host not allowed |
157
+ | 465 | Port not allowed |
158
+ | 466 | Too many requests — thread limit exceeded |
159
+ | 467 | Hourly release limit exceeded (geo parameter changes count as releases) |
160
+ | 560 | Geo location not found |
161
+ | 561 | Proxy unreachable |
162
+ | 562 | Proxy not found |
163
+ | 563 | Service unavailable |
164
+ | 564 | Proxy not online |
165
+ | 565 | Proxy handshake failed |
166
+
167
+ ## Library use
168
+
169
+ ```python
170
+ from proxyrack import ProxyControlClient, AccountClient
171
+
172
+ with ProxyControlClient(username, api_key, "unmetered.residential.proxyrack.net", 10000) as client:
173
+ sessions = client.list_sessions()
174
+ ```
175
+
176
+ ## Development
177
+
178
+ ```sh
179
+ uv sync
180
+ uv run pytest
181
+ uv run ruff check .
182
+ uv run ruff format .
183
+ uv run ty check src tests
184
+ ```
185
+
186
+ Commits follow [Conventional Commits](https://www.conventionalcommits.org) via [commitizen](https://commitizen-tools.github.io/commitizen/):
187
+
188
+ ```sh
189
+ uv run cz commit # interactive conventional commit helper
190
+ uv run cz check # validate a commit message
191
+ uv run cz bump # bump version (pyproject + uv.lock + package __version__, git tag) and update CHANGELOG.md
192
+ ```
193
+
194
+ PR commit messages are linted in CI (`commit-lint` job). Before the first release, tag the current version so `cz bump` has a base: `git tag v0.1.0`. Run `cz bump` with `--yes` in scripts and agent shells: without a TTY it stops at its prompts (e.g. "Is this the first tag created?" until the first release tag exists).
195
+
196
+ ### Releases
197
+
198
+ A **Package Release** is triggered by pushing a `v*` tag (create it with `cz bump`). The `publish` workflow runs the same checks as CI, verifies the tag matches the package version, builds distributions and publishes them to PyPI via [trusted publishing](https://docs.pypi.org/trusted-publishers/) (OIDC through the `pypi` environment — no `PYPI_TOKEN` secret), then creates a GitHub Release with the CHANGELOG section for that version.
199
+
200
+ One-time setup (repository owner): create the `pypi` GitHub environment restricted to `v*` tags, and register the trusted publisher on pypi.org — owner `divtiply`, repository `proxyrack`, workflow `publish.yaml`, environment `pypi`.
201
+
202
+ ## License
203
+
204
+ MIT
@@ -0,0 +1,187 @@
1
+ # proxyrack
2
+
3
+ API wrapper and CLI client for the [Proxyrack](https://proxyrack.com) proxy service.
4
+
5
+ Covers both documented API surfaces:
6
+
7
+ - **Proxy-Control API** - commands sent through the proxy tunnel itself (`api.proxyrack.net`): sticky sessions, releases, active connections, thread usage, stats, temporary passwords.
8
+ - **Account API** - direct HTTPS calls to `app.proxyrack.com`: sub-users and shared access.
9
+
10
+ Geo-targeting inventory (through the **Proxy-Control API**):
11
+
12
+ - `proxyrack geo countries` - country codes available in the pool.
13
+ - `proxyrack geo cities US` - cities available in a country.
14
+ - `proxyrack geo isps US` - ISPs available in a country.
15
+ - `proxyrack geo count US` - number of available IPs in a country.
16
+
17
+ List commands accept `--counts` to include the number of currently available IPs per item (e.g. `proxyrack geo cities US --counts`).
18
+
19
+ Plus local helpers for day-to-day use:
20
+
21
+ - `proxyrack proxy-url` - compose ready-to-use proxy URLs with geo-targeting, TTL, session, auto-replace and other parameters. Ports: 10000+ are sticky ports; 9000 is the random port on networks that offer it (one HTTP Keep-Alive connection keeps one exit IP there).
22
+ - `proxyrack networks list` - the built-in registry of proxy networks, probed live for availability (needs credentials; without them the registry is shown unchecked).
23
+ - `proxyrack config` - layered configuration (flags -> environment -> config file).
24
+
25
+ ## Installation
26
+
27
+ Requires Python >= 3.11 and [uv](https://docs.astral.sh/uv/).
28
+
29
+ ```sh
30
+ git clone https://github.com/divtiply/proxyrack
31
+ cd proxyrack
32
+ uv sync
33
+ uv run proxyrack --help
34
+ ```
35
+
36
+ ## Configuration
37
+
38
+ Credentials are stored as **profiles** — saved sets of `username` + `api-key` (+ optional default network) for any number of Proxyrack accounts.
39
+
40
+ ```sh
41
+ proxyrack profile add main # asks for username, api-key (hidden)
42
+ proxyrack profile add work --username <u> --api-key <k> --default-network mobile
43
+ proxyrack profile add main --default-network premium --force
44
+ # change the default network; omitted values
45
+ # (username, api-key, network) keep stored ones
46
+ proxyrack profile use main # set the default profile
47
+ proxyrack profile list # names, masked keys, default marker
48
+ proxyrack profile remove work --yes
49
+ ```
50
+
51
+ Profile selection order: `--profile NAME` flag → `PROXYRACK_PROFILE` env var → `default_profile` in the config file → the only profile when exactly one exists. Credentials resolve: `PROXYRACK_USERNAME`/`PROXYRACK_API_KEY` env vars → the selected profile (env wins over the profile, so CI scripts can inject credentials on top).
52
+
53
+ Per-account settings live in the profile (`default_network`); global settings in `proxyrack config` (`timeout`). Config file path: `proxyrack config path` (TOML; override the directory with `PROXYRACK_CONFIG_DIR`).
54
+
55
+ ```toml
56
+ default_profile = "main"
57
+ timeout = 30.0
58
+
59
+ [profiles.main]
60
+ username = "..."
61
+ api_key = "..."
62
+ default_network = "unmetered"
63
+ ```
64
+
65
+ ## Usage
66
+
67
+ ### Proxy-Control API (through the proxy)
68
+
69
+ ```sh
70
+ proxyrack networks list
71
+ proxyrack sessions list --network unmetered
72
+ proxyrack sessions list --wide
73
+ proxyrack sessions show 10001 # sticky session info by port or session name
74
+ proxyrack sessions release --network unmetered --port 10001
75
+ proxyrack sessions release --network unmetered --port 10000 --session mgr
76
+ proxyrack sessions release --network unmetered --all
77
+ proxyrack connections list --network premium
78
+ proxyrack usage threads
79
+ proxyrack usage stats # Request params / Exit IP reflect the proxy serving this request
80
+ proxyrack usage stats --port 10001 # send the stats request through a specific sticky port
81
+ proxyrack usage stats --port 10000 --session mgr # inspect a named session's own binding on that port
82
+ proxyrack geo countries
83
+ proxyrack geo cities US
84
+ proxyrack geo count US
85
+ proxyrack passwords list
86
+ proxyrack passwords create --label ci-job --ttl 300
87
+ proxyrack whitelist add --expire-time 86400 # whitelist your current IP
88
+ proxyrack whitelist add --ip 203.0.113.7 --label office --expire-time 2026-12-31T23:59:59Z
89
+ proxyrack whitelist list
90
+ proxyrack whitelist remove C5Ctf9gOR
91
+ ```
92
+
93
+ ### Account API (direct HTTPS)
94
+
95
+ ```sh
96
+ proxyrack sub-users list
97
+ proxyrack sub-users create --email a@b.c --first-name A --last-name B --password pw
98
+ proxyrack sub-users update bob --email new@b.c
99
+ proxyrack sub-users access add bob --service-id s-... --units 5
100
+ proxyrack sub-users access remove bob --service-id s-...
101
+ proxyrack sub-users delete bob
102
+ ```
103
+
104
+ ### Composing proxy URLs
105
+
106
+ ```sh
107
+ proxyrack proxy-url --network mobile --country us --session s1
108
+ # user;session=s1;country=us:<api-key>@mobile.residential.proxyrack.net:10000
109
+
110
+ # pin a known exit by Proxy ID or Exit IP (both are shown by `proxyrack usage stats`)
111
+ proxyrack proxy-url --network unmetered --proxy-id PD50KM5LD0
112
+ proxyrack proxy-url --network unmetered --proxy-ip 41.43.224.85
113
+
114
+ # multiple geo values are comma-separated (city names without spaces)
115
+ proxyrack proxy-url --network unmetered --country US,CA,FR
116
+ proxyrack proxy-url --network unmetered --country US --city LosAngeles,Denver --isp Verizon,Comcast
117
+
118
+ # a leading minus excludes a value (use the --flag=value form so the minus is not read as a flag)
119
+ proxyrack proxy-url --network unmetered --country=-US
120
+
121
+ # geo matching uses Maxmind by default; switch the geolocation database
122
+ proxyrack proxy-url --network unmetered --country US --geo-db ipinfo
123
+
124
+ proxyrack proxy-url --network unmetered --refresh-minutes 10 --auto-replace strict --format host-port-user-pass
125
+ ```
126
+
127
+ List commands print human-readable tables by default; add `--json` for raw API output. `--verbose` logs each request's method and URL (never credentials).
128
+
129
+ ### API response codes
130
+
131
+ Proxyrack answers with plain HTTP codes plus its own ones (407, 460–467, 560–565). The CLI appends a short hint to any of them:
132
+
133
+ | Code | Meaning |
134
+ | ---- | ------- |
135
+ | 407 | Authentication error — use the API key as the proxy password and connect from an allowed IP |
136
+ | 460 | Geo-targeting is not enabled for the network |
137
+ | 461 | Sticky port limit reached for the subscription |
138
+ | 463 | Malformed request |
139
+ | 464 | Host not allowed |
140
+ | 465 | Port not allowed |
141
+ | 466 | Too many requests — thread limit exceeded |
142
+ | 467 | Hourly release limit exceeded (geo parameter changes count as releases) |
143
+ | 560 | Geo location not found |
144
+ | 561 | Proxy unreachable |
145
+ | 562 | Proxy not found |
146
+ | 563 | Service unavailable |
147
+ | 564 | Proxy not online |
148
+ | 565 | Proxy handshake failed |
149
+
150
+ ## Library use
151
+
152
+ ```python
153
+ from proxyrack import ProxyControlClient, AccountClient
154
+
155
+ with ProxyControlClient(username, api_key, "unmetered.residential.proxyrack.net", 10000) as client:
156
+ sessions = client.list_sessions()
157
+ ```
158
+
159
+ ## Development
160
+
161
+ ```sh
162
+ uv sync
163
+ uv run pytest
164
+ uv run ruff check .
165
+ uv run ruff format .
166
+ uv run ty check src tests
167
+ ```
168
+
169
+ Commits follow [Conventional Commits](https://www.conventionalcommits.org) via [commitizen](https://commitizen-tools.github.io/commitizen/):
170
+
171
+ ```sh
172
+ uv run cz commit # interactive conventional commit helper
173
+ uv run cz check # validate a commit message
174
+ uv run cz bump # bump version (pyproject + uv.lock + package __version__, git tag) and update CHANGELOG.md
175
+ ```
176
+
177
+ PR commit messages are linted in CI (`commit-lint` job). Before the first release, tag the current version so `cz bump` has a base: `git tag v0.1.0`. Run `cz bump` with `--yes` in scripts and agent shells: without a TTY it stops at its prompts (e.g. "Is this the first tag created?" until the first release tag exists).
178
+
179
+ ### Releases
180
+
181
+ A **Package Release** is triggered by pushing a `v*` tag (create it with `cz bump`). The `publish` workflow runs the same checks as CI, verifies the tag matches the package version, builds distributions and publishes them to PyPI via [trusted publishing](https://docs.pypi.org/trusted-publishers/) (OIDC through the `pypi` environment — no `PYPI_TOKEN` secret), then creates a GitHub Release with the CHANGELOG section for that version.
182
+
183
+ One-time setup (repository owner): create the `pypi` GitHub environment restricted to `v*` tags, and register the trusted publisher on pypi.org — owner `divtiply`, repository `proxyrack`, workflow `publish.yaml`, environment `pypi`.
184
+
185
+ ## License
186
+
187
+ MIT
@@ -0,0 +1,52 @@
1
+ [project]
2
+ name = "proxyrack"
3
+ version = "0.1.1"
4
+ description = "API wrapper and CLI client for the Proxyrack proxy service"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.11"
9
+ dependencies = [
10
+ "httpx2>=2.17.0",
11
+ "platformdirs>=4.14.9",
12
+ "pydantic>=2.14.4",
13
+ "rich>=15.0.0",
14
+ "tomli-w>=1.2.0",
15
+ "typer>=0.29.3",
16
+ ]
17
+
18
+ [[project.authors]]
19
+ name = "Michel Ace"
20
+ email = "divtiply@gmail.com"
21
+
22
+ [project.scripts]
23
+ proxyrack = "proxyrack.cli:main"
24
+
25
+ [build-system]
26
+ requires = ["uv_build>=0.13.9,<0.14.0"]
27
+ build-backend = "uv_build"
28
+
29
+ [dependency-groups]
30
+ dev = [
31
+ "commitizen>=4.20.1",
32
+ "pytest>=9.2.0",
33
+ "pytest-httpx2>=1.0.0",
34
+ "ruff>=0.17.6",
35
+ "ty>=0.0.115",
36
+ ]
37
+
38
+ [tool.ruff]
39
+ line-length = 100
40
+ target-version = "py311"
41
+
42
+ [tool.pytest.ini_options]
43
+ testpaths = ["tests"]
44
+
45
+ [tool.commitizen]
46
+ name = "cz_conventional_commits"
47
+ tag_format = "v$version"
48
+ version_scheme = "pep440"
49
+ version_provider = "uv"
50
+ version_files = ["src/proxyrack/__init__.py"]
51
+ update_changelog_on_bump = true
52
+ major_version_zero = true
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "proxyrack"
3
+ version = "0.1.1"
4
+ description = "API wrapper and CLI client for the Proxyrack proxy service"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "Michel Ace", email = "divtiply@gmail.com" }
10
+ ]
11
+ requires-python = ">=3.11"
12
+ dependencies = [
13
+ "httpx2>=2.17.0",
14
+ "platformdirs>=4.14.9",
15
+ "pydantic>=2.14.4",
16
+ "rich>=15.0.0",
17
+ "tomli-w>=1.2.0",
18
+ "typer>=0.29.3",
19
+ ]
20
+
21
+ [project.scripts]
22
+ proxyrack = "proxyrack.cli:main"
23
+
24
+ [build-system]
25
+ requires = ["uv_build>=0.13.9,<0.14.0"]
26
+ build-backend = "uv_build"
27
+
28
+ [dependency-groups]
29
+ dev = [
30
+ "commitizen>=4.20.1",
31
+ "pytest>=9.2.0",
32
+ "pytest-httpx2>=1.0.0",
33
+ "ruff>=0.17.6",
34
+ "ty>=0.0.115",
35
+ ]
36
+
37
+ [tool.ruff]
38
+ line-length = 100
39
+ target-version = "py311"
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+
44
+ [tool.commitizen]
45
+ name = "cz_conventional_commits"
46
+ tag_format = "v$version"
47
+ version_scheme = "pep440"
48
+ version_provider = "uv"
49
+ version_files = ["src/proxyrack/__init__.py"]
50
+ update_changelog_on_bump = true
51
+ major_version_zero = true
@@ -0,0 +1,15 @@
1
+ """Proxyrack API wrapper and CLI client."""
2
+
3
+ from proxyrack.account import AccountClient
4
+ from proxyrack.errors import ApiError, ProxyrackError
5
+ from proxyrack.proxy_control import ProxyControlClient
6
+
7
+ __version__ = "0.1.1"
8
+
9
+ __all__ = [
10
+ "AccountClient",
11
+ "ApiError",
12
+ "ProxyControlClient",
13
+ "ProxyrackError",
14
+ "__version__",
15
+ ]
@@ -0,0 +1,92 @@
1
+ """Client for the Account API at app.proxyrack.com (sub-users and shared access)."""
2
+
3
+ from typing import Any
4
+
5
+ import httpx2
6
+
7
+ from proxyrack.base import BaseClient
8
+
9
+ ACCOUNT_BASE = "https://app.proxyrack.com"
10
+
11
+
12
+ class AccountClient(BaseClient):
13
+ def __init__(
14
+ self,
15
+ username: str,
16
+ api_key: str,
17
+ *,
18
+ base_url: str = ACCOUNT_BASE,
19
+ timeout: float = 30.0,
20
+ verbose: bool = False,
21
+ ):
22
+ self._account_username = username
23
+ self._api_key = api_key
24
+ self._base_url = base_url.rstrip("/")
25
+ super().__init__(timeout=timeout, verbose=verbose)
26
+
27
+ def _build_client(self) -> httpx2.Client:
28
+ return httpx2.Client(
29
+ headers={
30
+ "X-AUTH-USERNAME": self._account_username,
31
+ "X-AUTH-API-KEY": self._api_key,
32
+ }
33
+ )
34
+
35
+ def _url(self, path: str) -> str:
36
+ return f"{self._base_url}{path}"
37
+
38
+ def list_sub_users(self) -> Any:
39
+ return self._request("GET", self._url("/api/u/sub-users"))
40
+
41
+ def create_sub_user(self, *, email: str, first_name: str, last_name: str, password: str) -> Any:
42
+ return self._request(
43
+ "POST",
44
+ self._url("/api/u/sub-users"),
45
+ json={
46
+ "email": email,
47
+ "first_name": first_name,
48
+ "last_name": last_name,
49
+ "password": password,
50
+ },
51
+ )
52
+
53
+ def update_sub_user(
54
+ self,
55
+ username: str,
56
+ *,
57
+ email: str | None = None,
58
+ first_name: str | None = None,
59
+ last_name: str | None = None,
60
+ password: str | None = None,
61
+ ) -> Any:
62
+ payload = {
63
+ key: value
64
+ for key, value in (
65
+ ("email", email),
66
+ ("first_name", first_name),
67
+ ("last_name", last_name),
68
+ ("password", password),
69
+ )
70
+ if value is not None
71
+ }
72
+ return self._request("PATCH", self._url(f"/api/u/sub-users/{username}"), json=payload)
73
+
74
+ def delete_sub_user(self, username: str) -> Any:
75
+ return self._request("DELETE", self._url(f"/api/u/sub-users/{username}"))
76
+
77
+ def add_shared_access(
78
+ self, username: str, *, service_id: str, units: int, speed: int | None = None
79
+ ) -> Any:
80
+ payload: dict[str, Any] = {"service_id": service_id, "units": units}
81
+ if speed is not None:
82
+ payload["speed"] = speed
83
+ return self._request(
84
+ "POST", self._url(f"/api/u/sub-users/{username}/access/add"), json=payload
85
+ )
86
+
87
+ def remove_shared_access(self, username: str, *, service_id: str) -> Any:
88
+ return self._request(
89
+ "POST",
90
+ self._url(f"/api/u/sub-users/{username}/access/delete"),
91
+ json={"service_id": service_id},
92
+ )