Added README
This commit is contained in:
184
README.md
Normal file
184
README.md
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
# ArvanCloud CDN CLI Tool
|
||||||
|
|
||||||
|
A lightweight Python CLI utility for managing DNS records and domains on **ArvanCloud CDN** via its public API.
|
||||||
|
|
||||||
|
Designed for **DevOps engineers**, SREs, and system administrators who need fast DNS automation directly from Linux CLI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📦 Requirements
|
||||||
|
|
||||||
|
* Python 3.7+
|
||||||
|
* `requests` library
|
||||||
|
|
||||||
|
Install dependency:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install requests
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📁 Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── arvan_cdn_cli.py
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 🖥 How to Use as a Default Linux Command
|
||||||
|
|
||||||
|
Instead of running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python arvan_cdn_cli.py ...
|
||||||
|
```
|
||||||
|
|
||||||
|
You can make it a global Linux command.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 1 — Make Script Executable
|
||||||
|
|
||||||
|
Ensure the shebang exists at the top (already included):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#!/bin/python3
|
||||||
|
```
|
||||||
|
|
||||||
|
Make it executable:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
chmod +x arvan_cdn_cli.py
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Step 2 — Move to System Path
|
||||||
|
|
||||||
|
Move the file to `/usr/local/bin`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo mv arvan_cdn_cli.py /usr/local/bin/arvanctl
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can run it globally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn domains
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Optional: Verify PATH
|
||||||
|
|
||||||
|
Check if `/usr/local/bin` exists in PATH:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo $PATH
|
||||||
|
```
|
||||||
|
|
||||||
|
If not, add it to `~/.bashrc`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PATH=$PATH:/usr/local/bin
|
||||||
|
```
|
||||||
|
|
||||||
|
Then reload:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source ~/.bashrc
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 📌 Usage
|
||||||
|
|
||||||
|
General syntax:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn <resource> <action> [options]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 🔹 Commands
|
||||||
|
|
||||||
|
## 1️⃣ List All Domains
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn domains
|
||||||
|
```
|
||||||
|
|
||||||
|
Example Output:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"example.com": {
|
||||||
|
"name": "example.com",
|
||||||
|
"status": "active"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2️⃣ Create DNS Record
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn records create \
|
||||||
|
--domain example.com \
|
||||||
|
--name api \
|
||||||
|
--ip 192.168.1.10 \
|
||||||
|
--ttl 120 \
|
||||||
|
--cloud
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
| Parameter | Required | Default | Description |
|
||||||
|
| --------- | -------- | ------- | ------------------ |
|
||||||
|
| --domain | ✅ | - | Target domain |
|
||||||
|
| --name | ✅ | - | Record name |
|
||||||
|
| --type | ❌ | a | Record type |
|
||||||
|
| --ttl | ❌ | 120 | TTL value |
|
||||||
|
| --ip | ✅ | - | IP address |
|
||||||
|
| --cloud | ❌ | False | Enable Arvan proxy |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3️⃣ Remove DNS Record
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn records remove \
|
||||||
|
--domain example.com \
|
||||||
|
--name api
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4️⃣ Update DNS Record
|
||||||
|
|
||||||
|
```bash
|
||||||
|
arvanctl cdn records update \
|
||||||
|
--domain example.com \
|
||||||
|
--name api \
|
||||||
|
--ip 192.168.1.20
|
||||||
|
```
|
||||||
|
|
||||||
|
> ⚠️ Update logic is partially implemented in current version.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 🌐 API Endpoints Used
|
||||||
|
|
||||||
|
```
|
||||||
|
GET /cdn/4.0/domains
|
||||||
|
GET /cdn/4.0/domains/{domain}/dns-records
|
||||||
|
POST /cdn/4.0/domains/{domain}/dns-records
|
||||||
|
DELETE /cdn/4.0/domains/{domain}/dns-records/{id}
|
||||||
|
```
|
||||||
|
|
||||||
Reference in New Issue
Block a user