29 lines
673 B
Python
29 lines
673 B
Python
import requests
|
|
import json
|
|
import os
|
|
|
|
VULTR_API_KEY = os.environ.get("VULTR_API_KEY")
|
|
DOMAIN = "oncloud.my.id"
|
|
|
|
headers = {
|
|
"Authorization": f"Bearer {VULTR_API_KEY}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
print(f"Creating record btlabel.{DOMAIN} -> 103.138.63.186")
|
|
|
|
data = {
|
|
"name": "btlabel",
|
|
"type": "A",
|
|
"data": "103.138.63.186",
|
|
"ttl": 300
|
|
}
|
|
|
|
response = requests.post(f"https://api.vultr.com/v2/domains/{DOMAIN}/records", headers=headers, json=data)
|
|
|
|
if response.status_code == 201:
|
|
print("Record created successfully!")
|
|
print(json.dumps(response.json(), indent=2))
|
|
else:
|
|
print(f"Error ({response.status_code}): {response.text}")
|