mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-18 05:50:31 +00:00
45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
|
from cloudflare import Cloudflare
|
||
|
from cloudflare.types.dns import SRVRecord
|
||
|
from cloudflare.types.dns.record_create_params import SRVRecordData
|
||
|
from typing_extensions import Literal
|
||
|
|
||
|
api_key = ('v1.0-6461a24521b5431608149858-953c8f44c3eca9e9f6c23675e3c0d2'
|
||
|
'0662a5960f87a3c8f8ad1a80a882b480b1d05c9924ec4c342e65783dba4c5742bee5cf665df07b3ac21c448ea5c72f7df'
|
||
|
'a46728dbb37f62845e7')
|
||
|
zone_id = "33ddf3f97d1f4fd9be7b0725b848a0d7"
|
||
|
|
||
|
client = Cloudflare(
|
||
|
api_key="d33db5b942cb5cebd76dabb4f495e14a9033a",
|
||
|
api_email="lemauxcharles@yahoo.com",
|
||
|
)
|
||
|
|
||
|
|
||
|
def add_cloudflare_dns(subdomain: str, port: str) -> SRVRecord:
|
||
|
record: Literal["SRV"] = "SRV"
|
||
|
data: SRVRecordData = {
|
||
|
'weight': 5,
|
||
|
'port': int(port),
|
||
|
'priority': 5,
|
||
|
'target': "servii.fr",
|
||
|
port: int(port),
|
||
|
zone_id: zone_id,
|
||
|
}
|
||
|
return client.dns.records.create(
|
||
|
type=record,
|
||
|
name=f'_minecraft._tcp.{subdomain}',
|
||
|
zone_id=zone_id,
|
||
|
priority=5,
|
||
|
data=data,
|
||
|
)
|
||
|
|
||
|
|
||
|
def delete_cloudflare_dns(dns_record_id: str) -> None:
|
||
|
client.dns.records.delete(
|
||
|
dns_record_id=dns_record_id,
|
||
|
zone_id=zone_id,
|
||
|
)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
pass
|