onlydns-sdk 1.0.3__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.
- onlydns_sdk-1.0.3/PKG-INFO +310 -0
- onlydns_sdk-1.0.3/README.md +287 -0
- onlydns_sdk-1.0.3/onlydns/__init__.py +81 -0
- onlydns_sdk-1.0.3/onlydns/__main__.py +7 -0
- onlydns_sdk-1.0.3/onlydns/cli.py +925 -0
- onlydns_sdk-1.0.3/onlydns/client.py +618 -0
- onlydns_sdk-1.0.3/onlydns/config.py +118 -0
- onlydns_sdk-1.0.3/onlydns/exceptions.py +42 -0
- onlydns_sdk-1.0.3/onlydns/models.py +752 -0
- onlydns_sdk-1.0.3/onlydns_sdk.egg-info/PKG-INFO +310 -0
- onlydns_sdk-1.0.3/onlydns_sdk.egg-info/SOURCES.txt +16 -0
- onlydns_sdk-1.0.3/onlydns_sdk.egg-info/dependency_links.txt +1 -0
- onlydns_sdk-1.0.3/onlydns_sdk.egg-info/entry_points.txt +2 -0
- onlydns_sdk-1.0.3/onlydns_sdk.egg-info/top_level.txt +1 -0
- onlydns_sdk-1.0.3/pyproject.toml +36 -0
- onlydns_sdk-1.0.3/setup.cfg +4 -0
- onlydns_sdk-1.0.3/tests/test_cli.py +494 -0
- onlydns_sdk-1.0.3/tests/test_client.py +353 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: onlydns-sdk
|
|
3
|
+
Version: 1.0.3
|
|
4
|
+
Summary: Official Python SDK for the OnlyDNS System API (onlydns.com)
|
|
5
|
+
Author-email: OnlyDNS <support@onlydns.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://www.onlydns.com
|
|
8
|
+
Project-URL: Documentation, https://api-docs.onlydns.com/
|
|
9
|
+
Project-URL: Repository, https://github.com/onlydns/onlydns-sdk-python
|
|
10
|
+
Keywords: onlydns,dns,sdk,ai-agents,networking
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# OnlyDNS Python SDK
|
|
25
|
+
|
|
26
|
+
Official Python SDK and CLI for [OnlyDNS](https://www.onlydns.com) to programmatically manage authoritative Anycast DNS zones, records, 1-click DNSSEC, and RFC 2136 TSIG keys. Learn more in the [OnlyDNS Technical How-To Guides](https://www.onlydns.com/howto/).
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install onlydns-sdk
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Authentication Environment Variable:** `ONLYDNS_API_TOKEN`.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- **Full OpenAPI Coverage**: Direct mapping to all DNS zones, records, and TSIG key operations.
|
|
37
|
+
- **High-Level Atomic Helpers**: Convenient `add_record`, `remove_record`, `update_record`, and `find_records` methods that simplify record manipulation for human developers and autonomous AI agents.
|
|
38
|
+
- **Strong Typing**: Comprehensive type hints and dataclasses for reliable IDE autocompletion and runtime validation.
|
|
39
|
+
- **Zero Heavy Dependencies**: Built on standard library `urllib` for lightweight execution across all Python environments.
|
|
40
|
+
- **Environment Aware**: Automatically resolves authentication from `ONLYDNS_API_TOKEN`.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
### From Local Source (development / testing)
|
|
45
|
+
|
|
46
|
+
When installing from the local repository directory:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Navigate to the python SDK directory
|
|
50
|
+
cd onlydns-sdk/python
|
|
51
|
+
|
|
52
|
+
# Install the CLI application globally into an isolated environment using pipx
|
|
53
|
+
pipx install .
|
|
54
|
+
|
|
55
|
+
# Or for editable development mode
|
|
56
|
+
pipx install --editable .
|
|
57
|
+
|
|
58
|
+
# Alternatively, using standard pip
|
|
59
|
+
pip install .
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Direct install from Github
|
|
63
|
+
```bash
|
|
64
|
+
pipx install git+https://github.com/Onlydns/onlydns-sdk-python
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### From PyPI (once published)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install onlydns-sdk
|
|
71
|
+
# or via pipx for CLI usage
|
|
72
|
+
pipx install onlydns-sdk
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Command Line Interface (CLI)
|
|
76
|
+
|
|
77
|
+
The Python SDK includes a built-in CLI tool (`onlydns` or `python -m onlydns`) for testing and daily DNS record management.
|
|
78
|
+
|
|
79
|
+
### 1. Authentication & Configuration
|
|
80
|
+
|
|
81
|
+
The CLI resolves API tokens from the `ONLYDNS_API_TOKEN` environment variable, or from stored credentials in `~/.config/onlydns/config.json`.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Save your API key to ~/.config/onlydns/config.json
|
|
85
|
+
onlydns login your_api_bearer_token
|
|
86
|
+
# or
|
|
87
|
+
onlydns config set-key your_api_bearer_token
|
|
88
|
+
|
|
89
|
+
# Check current configuration status
|
|
90
|
+
onlydns config get-key
|
|
91
|
+
|
|
92
|
+
# Check config file path
|
|
93
|
+
onlydns config path
|
|
94
|
+
|
|
95
|
+
# Clear saved credentials
|
|
96
|
+
onlydns config clear
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Alternatively, use an environment variable or the `-k` / `--api-key` flag:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
export ONLYDNS_API_TOKEN="your_api_bearer_token"
|
|
103
|
+
# or
|
|
104
|
+
onlydns -k your_api_bearer_token domains list
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 2. Managing Domains
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# List all domains
|
|
111
|
+
onlydns domains list
|
|
112
|
+
|
|
113
|
+
# Create a new domain
|
|
114
|
+
onlydns domains create mydomain.com
|
|
115
|
+
|
|
116
|
+
# Output JSON
|
|
117
|
+
onlydns --json domains list
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 3. Managing DNS Records
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# List all records in a domain
|
|
124
|
+
onlydns records list example.com
|
|
125
|
+
|
|
126
|
+
# Add a record (or append values)
|
|
127
|
+
onlydns records add example.com --name api --type A --value 192.0.2.1 --ttl 300
|
|
128
|
+
|
|
129
|
+
# Update / replace all values for a record
|
|
130
|
+
onlydns records update example.com --name www --type CNAME --value example.com --ttl 600
|
|
131
|
+
|
|
132
|
+
# Remove a specific value or the entire record
|
|
133
|
+
onlydns records remove example.com --name api --type A --value 192.0.2.1
|
|
134
|
+
onlydns records remove example.com --name api --type A
|
|
135
|
+
|
|
136
|
+
# Find records matching name, type, and/or target value
|
|
137
|
+
onlydns records find example.com --name api
|
|
138
|
+
onlydns records find example.com --type A
|
|
139
|
+
onlydns records find example.com --value 192.0.2.1
|
|
140
|
+
onlydns records find example.com --name api --type A --value 192.0.2.1
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 4. DNSSEC Management
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Get DNSSEC status and DS keys
|
|
147
|
+
onlydns dnssec status example.com
|
|
148
|
+
|
|
149
|
+
# Enable DNSSEC
|
|
150
|
+
onlydns dnssec enable example.com
|
|
151
|
+
|
|
152
|
+
# Disable DNSSEC
|
|
153
|
+
onlydns dnssec disable example.com
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### 5. TSIG Key Management
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# List TSIG keys
|
|
160
|
+
onlydns tsig list
|
|
161
|
+
|
|
162
|
+
# Create a new TSIG key (key name is generated automatically)
|
|
163
|
+
onlydns tsig create --algo hmac-sha256
|
|
164
|
+
|
|
165
|
+
# Get TSIG key details
|
|
166
|
+
onlydns tsig get <key_name>
|
|
167
|
+
|
|
168
|
+
# View TSIG keys and permissions configured on a domain
|
|
169
|
+
onlydns tsig get-domain example.com
|
|
170
|
+
|
|
171
|
+
# Set domain TSIG permissions for whole zone
|
|
172
|
+
onlydns tsig set-permissions example.com <key_name> --transfer --update
|
|
173
|
+
|
|
174
|
+
# Restrict Dynamic DNS Updates to specific subdomain(s) (e.g. ACME DNS-01 challenges)
|
|
175
|
+
onlydns tsig set-permissions example.com <key_name> --update --subdomain _acme-challenge
|
|
176
|
+
onlydns tsig set-permissions example.com <key_name> -s _acme-challenge -s staging
|
|
177
|
+
|
|
178
|
+
# Clear domain TSIG keys
|
|
179
|
+
onlydns tsig clear example.com
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Quick Start (Python SDK)
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from onlydns import OnlyDNSClient, RecordType
|
|
186
|
+
|
|
187
|
+
# Initialize client (uses ONLYDNS_API_TOKEN from environment if not provided)
|
|
188
|
+
client = OnlyDNSClient(api_token="your_api_bearer_token")
|
|
189
|
+
|
|
190
|
+
# 1. List Domains
|
|
191
|
+
domains = client.list_domains()
|
|
192
|
+
print(f"Managed Domains: {domains}")
|
|
193
|
+
|
|
194
|
+
# 2. Get DNS Records
|
|
195
|
+
records = client.get_records("example.com")
|
|
196
|
+
for record in records:
|
|
197
|
+
print(f"{record.name} ({record.type}): {record.records} [TTL {record.ttl}]")
|
|
198
|
+
|
|
199
|
+
# 3. High-Level Helper: Add an A Record
|
|
200
|
+
client.add_record(
|
|
201
|
+
domain_name="example.com",
|
|
202
|
+
name="api",
|
|
203
|
+
type=RecordType.A,
|
|
204
|
+
records=["192.0.2.1"],
|
|
205
|
+
ttl=300
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
# 4. High-Level Helper: Update / Upsert Records
|
|
209
|
+
client.update_record(
|
|
210
|
+
domain_name="example.com",
|
|
211
|
+
name="www",
|
|
212
|
+
type=RecordType.CNAME,
|
|
213
|
+
records=["example.com"],
|
|
214
|
+
ttl=600
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
# 5. High-Level Helper: Remove Specific Value or Record
|
|
218
|
+
client.remove_record(
|
|
219
|
+
domain_name="example.com",
|
|
220
|
+
name="api",
|
|
221
|
+
type=RecordType.A
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
# 6. High-Level Helper: Find / Filter Records
|
|
225
|
+
matches = client.find_records(
|
|
226
|
+
domain_name="example.com",
|
|
227
|
+
name="api",
|
|
228
|
+
type=RecordType.A,
|
|
229
|
+
value="192.0.2.1"
|
|
230
|
+
)
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## TSIG Key Management
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
from onlydns import OnlyDNSClient, TsigAlgorithm
|
|
237
|
+
|
|
238
|
+
client = OnlyDNSClient()
|
|
239
|
+
|
|
240
|
+
# List TSIG keys
|
|
241
|
+
keys = client.get_tsig_keys()
|
|
242
|
+
|
|
243
|
+
# Create a new TSIG key
|
|
244
|
+
new_key = client.create_tsig_key(algorithm=TsigAlgorithm.HMAC_SHA256)
|
|
245
|
+
print(f"Created TSIG key: {new_key.name}")
|
|
246
|
+
|
|
247
|
+
# Inspect TSIG permissions on a domain
|
|
248
|
+
domain_tsig = client.get_domain_tsig("example.com")
|
|
249
|
+
print(f"Configured TSIG keys for domain: {domain_tsig}")
|
|
250
|
+
|
|
251
|
+
# Configure domain TSIG permissions across zone
|
|
252
|
+
client.update_domain_tsig(
|
|
253
|
+
domain_name="example.com",
|
|
254
|
+
key_name=new_key.name,
|
|
255
|
+
allow_axfr=True,
|
|
256
|
+
allow_dns_update=True
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
# Restrict Dynamic DNS Updates to specific subdomains
|
|
260
|
+
client.update_domain_tsig(
|
|
261
|
+
domain_name="example.com",
|
|
262
|
+
key_name=new_key.name,
|
|
263
|
+
allow_axfr=False,
|
|
264
|
+
allow_dns_update=True,
|
|
265
|
+
subdomains=["_acme-challenge", "staging"]
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
# Delete domain TSIG keys
|
|
269
|
+
client.delete_domain_tsig("example.com")
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## DNSSEC & Domain Creation
|
|
273
|
+
|
|
274
|
+
```python
|
|
275
|
+
# Create a new domain
|
|
276
|
+
client.create_domain("my-new-domain.com")
|
|
277
|
+
|
|
278
|
+
# Get DNSSEC status & DS keys
|
|
279
|
+
dnssec = client.get_dnssec_status("my-new-domain.com")
|
|
280
|
+
print(f"DNSSEC Enabled: {dnssec.enabled}")
|
|
281
|
+
for key in dnssec.keys:
|
|
282
|
+
print(f"KeyTag: {key.key_tag}, Digest: {key.digest}")
|
|
283
|
+
|
|
284
|
+
# Enable DNSSEC
|
|
285
|
+
client.enable_dnssec("my-new-domain.com")
|
|
286
|
+
|
|
287
|
+
# Disable DNSSEC
|
|
288
|
+
client.disable_dnssec("my-new-domain.com")
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## AI Agent Integration Example
|
|
292
|
+
|
|
293
|
+
```python
|
|
294
|
+
# Example tool function definition for LLM tool calling (OpenAI / LangChain / CrewAI)
|
|
295
|
+
def set_dns_endpoint(subdomain: str, ip_address: str, domain: str = "example.com") -> str:
|
|
296
|
+
"""Creates or updates a DNS A record for the specified subdomain."""
|
|
297
|
+
client = OnlyDNSClient()
|
|
298
|
+
client.add_record(
|
|
299
|
+
domain_name=domain,
|
|
300
|
+
name=subdomain,
|
|
301
|
+
type="A",
|
|
302
|
+
records=[ip_address],
|
|
303
|
+
ttl=300
|
|
304
|
+
)
|
|
305
|
+
return f"Successfully configured {subdomain}.{domain} -> {ip_address}"
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## License
|
|
309
|
+
|
|
310
|
+
MIT License.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# OnlyDNS Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK and CLI for [OnlyDNS](https://www.onlydns.com) to programmatically manage authoritative Anycast DNS zones, records, 1-click DNSSEC, and RFC 2136 TSIG keys. Learn more in the [OnlyDNS Technical How-To Guides](https://www.onlydns.com/howto/).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install onlydns-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
**Authentication Environment Variable:** `ONLYDNS_API_TOKEN`.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Full OpenAPI Coverage**: Direct mapping to all DNS zones, records, and TSIG key operations.
|
|
14
|
+
- **High-Level Atomic Helpers**: Convenient `add_record`, `remove_record`, `update_record`, and `find_records` methods that simplify record manipulation for human developers and autonomous AI agents.
|
|
15
|
+
- **Strong Typing**: Comprehensive type hints and dataclasses for reliable IDE autocompletion and runtime validation.
|
|
16
|
+
- **Zero Heavy Dependencies**: Built on standard library `urllib` for lightweight execution across all Python environments.
|
|
17
|
+
- **Environment Aware**: Automatically resolves authentication from `ONLYDNS_API_TOKEN`.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### From Local Source (development / testing)
|
|
22
|
+
|
|
23
|
+
When installing from the local repository directory:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Navigate to the python SDK directory
|
|
27
|
+
cd onlydns-sdk/python
|
|
28
|
+
|
|
29
|
+
# Install the CLI application globally into an isolated environment using pipx
|
|
30
|
+
pipx install .
|
|
31
|
+
|
|
32
|
+
# Or for editable development mode
|
|
33
|
+
pipx install --editable .
|
|
34
|
+
|
|
35
|
+
# Alternatively, using standard pip
|
|
36
|
+
pip install .
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Direct install from Github
|
|
40
|
+
```bash
|
|
41
|
+
pipx install git+https://github.com/Onlydns/onlydns-sdk-python
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### From PyPI (once published)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install onlydns-sdk
|
|
48
|
+
# or via pipx for CLI usage
|
|
49
|
+
pipx install onlydns-sdk
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Command Line Interface (CLI)
|
|
53
|
+
|
|
54
|
+
The Python SDK includes a built-in CLI tool (`onlydns` or `python -m onlydns`) for testing and daily DNS record management.
|
|
55
|
+
|
|
56
|
+
### 1. Authentication & Configuration
|
|
57
|
+
|
|
58
|
+
The CLI resolves API tokens from the `ONLYDNS_API_TOKEN` environment variable, or from stored credentials in `~/.config/onlydns/config.json`.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Save your API key to ~/.config/onlydns/config.json
|
|
62
|
+
onlydns login your_api_bearer_token
|
|
63
|
+
# or
|
|
64
|
+
onlydns config set-key your_api_bearer_token
|
|
65
|
+
|
|
66
|
+
# Check current configuration status
|
|
67
|
+
onlydns config get-key
|
|
68
|
+
|
|
69
|
+
# Check config file path
|
|
70
|
+
onlydns config path
|
|
71
|
+
|
|
72
|
+
# Clear saved credentials
|
|
73
|
+
onlydns config clear
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Alternatively, use an environment variable or the `-k` / `--api-key` flag:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
export ONLYDNS_API_TOKEN="your_api_bearer_token"
|
|
80
|
+
# or
|
|
81
|
+
onlydns -k your_api_bearer_token domains list
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Managing Domains
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# List all domains
|
|
88
|
+
onlydns domains list
|
|
89
|
+
|
|
90
|
+
# Create a new domain
|
|
91
|
+
onlydns domains create mydomain.com
|
|
92
|
+
|
|
93
|
+
# Output JSON
|
|
94
|
+
onlydns --json domains list
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 3. Managing DNS Records
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# List all records in a domain
|
|
101
|
+
onlydns records list example.com
|
|
102
|
+
|
|
103
|
+
# Add a record (or append values)
|
|
104
|
+
onlydns records add example.com --name api --type A --value 192.0.2.1 --ttl 300
|
|
105
|
+
|
|
106
|
+
# Update / replace all values for a record
|
|
107
|
+
onlydns records update example.com --name www --type CNAME --value example.com --ttl 600
|
|
108
|
+
|
|
109
|
+
# Remove a specific value or the entire record
|
|
110
|
+
onlydns records remove example.com --name api --type A --value 192.0.2.1
|
|
111
|
+
onlydns records remove example.com --name api --type A
|
|
112
|
+
|
|
113
|
+
# Find records matching name, type, and/or target value
|
|
114
|
+
onlydns records find example.com --name api
|
|
115
|
+
onlydns records find example.com --type A
|
|
116
|
+
onlydns records find example.com --value 192.0.2.1
|
|
117
|
+
onlydns records find example.com --name api --type A --value 192.0.2.1
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### 4. DNSSEC Management
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Get DNSSEC status and DS keys
|
|
124
|
+
onlydns dnssec status example.com
|
|
125
|
+
|
|
126
|
+
# Enable DNSSEC
|
|
127
|
+
onlydns dnssec enable example.com
|
|
128
|
+
|
|
129
|
+
# Disable DNSSEC
|
|
130
|
+
onlydns dnssec disable example.com
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 5. TSIG Key Management
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# List TSIG keys
|
|
137
|
+
onlydns tsig list
|
|
138
|
+
|
|
139
|
+
# Create a new TSIG key (key name is generated automatically)
|
|
140
|
+
onlydns tsig create --algo hmac-sha256
|
|
141
|
+
|
|
142
|
+
# Get TSIG key details
|
|
143
|
+
onlydns tsig get <key_name>
|
|
144
|
+
|
|
145
|
+
# View TSIG keys and permissions configured on a domain
|
|
146
|
+
onlydns tsig get-domain example.com
|
|
147
|
+
|
|
148
|
+
# Set domain TSIG permissions for whole zone
|
|
149
|
+
onlydns tsig set-permissions example.com <key_name> --transfer --update
|
|
150
|
+
|
|
151
|
+
# Restrict Dynamic DNS Updates to specific subdomain(s) (e.g. ACME DNS-01 challenges)
|
|
152
|
+
onlydns tsig set-permissions example.com <key_name> --update --subdomain _acme-challenge
|
|
153
|
+
onlydns tsig set-permissions example.com <key_name> -s _acme-challenge -s staging
|
|
154
|
+
|
|
155
|
+
# Clear domain TSIG keys
|
|
156
|
+
onlydns tsig clear example.com
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Quick Start (Python SDK)
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from onlydns import OnlyDNSClient, RecordType
|
|
163
|
+
|
|
164
|
+
# Initialize client (uses ONLYDNS_API_TOKEN from environment if not provided)
|
|
165
|
+
client = OnlyDNSClient(api_token="your_api_bearer_token")
|
|
166
|
+
|
|
167
|
+
# 1. List Domains
|
|
168
|
+
domains = client.list_domains()
|
|
169
|
+
print(f"Managed Domains: {domains}")
|
|
170
|
+
|
|
171
|
+
# 2. Get DNS Records
|
|
172
|
+
records = client.get_records("example.com")
|
|
173
|
+
for record in records:
|
|
174
|
+
print(f"{record.name} ({record.type}): {record.records} [TTL {record.ttl}]")
|
|
175
|
+
|
|
176
|
+
# 3. High-Level Helper: Add an A Record
|
|
177
|
+
client.add_record(
|
|
178
|
+
domain_name="example.com",
|
|
179
|
+
name="api",
|
|
180
|
+
type=RecordType.A,
|
|
181
|
+
records=["192.0.2.1"],
|
|
182
|
+
ttl=300
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
# 4. High-Level Helper: Update / Upsert Records
|
|
186
|
+
client.update_record(
|
|
187
|
+
domain_name="example.com",
|
|
188
|
+
name="www",
|
|
189
|
+
type=RecordType.CNAME,
|
|
190
|
+
records=["example.com"],
|
|
191
|
+
ttl=600
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# 5. High-Level Helper: Remove Specific Value or Record
|
|
195
|
+
client.remove_record(
|
|
196
|
+
domain_name="example.com",
|
|
197
|
+
name="api",
|
|
198
|
+
type=RecordType.A
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
# 6. High-Level Helper: Find / Filter Records
|
|
202
|
+
matches = client.find_records(
|
|
203
|
+
domain_name="example.com",
|
|
204
|
+
name="api",
|
|
205
|
+
type=RecordType.A,
|
|
206
|
+
value="192.0.2.1"
|
|
207
|
+
)
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## TSIG Key Management
|
|
211
|
+
|
|
212
|
+
```python
|
|
213
|
+
from onlydns import OnlyDNSClient, TsigAlgorithm
|
|
214
|
+
|
|
215
|
+
client = OnlyDNSClient()
|
|
216
|
+
|
|
217
|
+
# List TSIG keys
|
|
218
|
+
keys = client.get_tsig_keys()
|
|
219
|
+
|
|
220
|
+
# Create a new TSIG key
|
|
221
|
+
new_key = client.create_tsig_key(algorithm=TsigAlgorithm.HMAC_SHA256)
|
|
222
|
+
print(f"Created TSIG key: {new_key.name}")
|
|
223
|
+
|
|
224
|
+
# Inspect TSIG permissions on a domain
|
|
225
|
+
domain_tsig = client.get_domain_tsig("example.com")
|
|
226
|
+
print(f"Configured TSIG keys for domain: {domain_tsig}")
|
|
227
|
+
|
|
228
|
+
# Configure domain TSIG permissions across zone
|
|
229
|
+
client.update_domain_tsig(
|
|
230
|
+
domain_name="example.com",
|
|
231
|
+
key_name=new_key.name,
|
|
232
|
+
allow_axfr=True,
|
|
233
|
+
allow_dns_update=True
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# Restrict Dynamic DNS Updates to specific subdomains
|
|
237
|
+
client.update_domain_tsig(
|
|
238
|
+
domain_name="example.com",
|
|
239
|
+
key_name=new_key.name,
|
|
240
|
+
allow_axfr=False,
|
|
241
|
+
allow_dns_update=True,
|
|
242
|
+
subdomains=["_acme-challenge", "staging"]
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
# Delete domain TSIG keys
|
|
246
|
+
client.delete_domain_tsig("example.com")
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## DNSSEC & Domain Creation
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
# Create a new domain
|
|
253
|
+
client.create_domain("my-new-domain.com")
|
|
254
|
+
|
|
255
|
+
# Get DNSSEC status & DS keys
|
|
256
|
+
dnssec = client.get_dnssec_status("my-new-domain.com")
|
|
257
|
+
print(f"DNSSEC Enabled: {dnssec.enabled}")
|
|
258
|
+
for key in dnssec.keys:
|
|
259
|
+
print(f"KeyTag: {key.key_tag}, Digest: {key.digest}")
|
|
260
|
+
|
|
261
|
+
# Enable DNSSEC
|
|
262
|
+
client.enable_dnssec("my-new-domain.com")
|
|
263
|
+
|
|
264
|
+
# Disable DNSSEC
|
|
265
|
+
client.disable_dnssec("my-new-domain.com")
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## AI Agent Integration Example
|
|
269
|
+
|
|
270
|
+
```python
|
|
271
|
+
# Example tool function definition for LLM tool calling (OpenAI / LangChain / CrewAI)
|
|
272
|
+
def set_dns_endpoint(subdomain: str, ip_address: str, domain: str = "example.com") -> str:
|
|
273
|
+
"""Creates or updates a DNS A record for the specified subdomain."""
|
|
274
|
+
client = OnlyDNSClient()
|
|
275
|
+
client.add_record(
|
|
276
|
+
domain_name=domain,
|
|
277
|
+
name=subdomain,
|
|
278
|
+
type="A",
|
|
279
|
+
records=[ip_address],
|
|
280
|
+
ttl=300
|
|
281
|
+
)
|
|
282
|
+
return f"Successfully configured {subdomain}.{domain} -> {ip_address}"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
MIT License.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""OnlyDNS Python SDK.
|
|
2
|
+
|
|
3
|
+
Official Python SDK for managing DNS zones and records with onlydns.com.
|
|
4
|
+
Designed for high developer utility and seamless AI agent tool-calling integration.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .client import OnlyDNSClient
|
|
8
|
+
from .config import (
|
|
9
|
+
clear_config,
|
|
10
|
+
get_api_key,
|
|
11
|
+
get_config_dir,
|
|
12
|
+
get_config_file_path,
|
|
13
|
+
load_config,
|
|
14
|
+
save_config,
|
|
15
|
+
set_api_key,
|
|
16
|
+
)
|
|
17
|
+
from .exceptions import (
|
|
18
|
+
OnlyDNSError,
|
|
19
|
+
AuthenticationError,
|
|
20
|
+
NotFoundError,
|
|
21
|
+
APIError,
|
|
22
|
+
ValidationError,
|
|
23
|
+
)
|
|
24
|
+
from .models import (
|
|
25
|
+
DNSRecord,
|
|
26
|
+
RecordType,
|
|
27
|
+
TsigKey,
|
|
28
|
+
TsigAlgorithm,
|
|
29
|
+
TsigKeyCreateResponse,
|
|
30
|
+
DomainTsigPermissions,
|
|
31
|
+
DNSSECKeyAlgorithm,
|
|
32
|
+
DNSSECKeyDigestType,
|
|
33
|
+
DNSSECDsKey,
|
|
34
|
+
DNSSECStatus,
|
|
35
|
+
DNSDnssecStatusResponse,
|
|
36
|
+
ErrorResponse,
|
|
37
|
+
AccountPostalAddress,
|
|
38
|
+
BillingPackageFeatures,
|
|
39
|
+
BillingPackage,
|
|
40
|
+
AccountInfo,
|
|
41
|
+
AccountOidcNonCompliantUser,
|
|
42
|
+
AccountOidcConfig,
|
|
43
|
+
AccountOidcTestResponse,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"OnlyDNSClient",
|
|
48
|
+
"clear_config",
|
|
49
|
+
"get_api_key",
|
|
50
|
+
"get_config_dir",
|
|
51
|
+
"get_config_file_path",
|
|
52
|
+
"load_config",
|
|
53
|
+
"save_config",
|
|
54
|
+
"set_api_key",
|
|
55
|
+
"OnlyDNSError",
|
|
56
|
+
"AuthenticationError",
|
|
57
|
+
"NotFoundError",
|
|
58
|
+
"APIError",
|
|
59
|
+
"ValidationError",
|
|
60
|
+
"DNSRecord",
|
|
61
|
+
"RecordType",
|
|
62
|
+
"TsigKey",
|
|
63
|
+
"TsigAlgorithm",
|
|
64
|
+
"TsigKeyCreateResponse",
|
|
65
|
+
"DomainTsigPermissions",
|
|
66
|
+
"DNSSECKeyAlgorithm",
|
|
67
|
+
"DNSSECKeyDigestType",
|
|
68
|
+
"DNSSECDsKey",
|
|
69
|
+
"DNSSECStatus",
|
|
70
|
+
"DNSDnssecStatusResponse",
|
|
71
|
+
"ErrorResponse",
|
|
72
|
+
"AccountPostalAddress",
|
|
73
|
+
"BillingPackageFeatures",
|
|
74
|
+
"BillingPackage",
|
|
75
|
+
"AccountInfo",
|
|
76
|
+
"AccountOidcNonCompliantUser",
|
|
77
|
+
"AccountOidcConfig",
|
|
78
|
+
"AccountOidcTestResponse",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
__version__ = "1.0.3"
|