Files
arvan-cli/README.md
2026-02-13 22:52:32 +03:30

185 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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}
```