Skip to content

Commit 4eefb39

Browse files
committed
added functions for domains
1 parent f54ba79 commit 4eefb39

1 file changed

Lines changed: 85 additions & 1 deletion

File tree

vscale.py

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def get_payments(token):
601601

602602
"""
603603
Function consumption performs a GET-request at
604-
https://api.vscale.io/v1/billing/consumption. return all the spendings
604+
https://api.vscale.io/v1/billing/consumption, returns all the spendings
605605
from start date till end date excluding the latter one.
606606
Token has to be provided as a str object.
607607
Start and end date have to be provided as a str object in form YYYY-MM-DD.
@@ -613,3 +613,87 @@ def consumption(token, start, end):
613613
"?start="+str(start)+"&end="+str(end),
614614
headers={"X-Token": token}
615615
)
616+
617+
618+
"""
619+
Function get_domains performs a GET-request at
620+
https://api.vscale.io/v1/domains/, returns list of domains.
621+
Token has to be provided as a str object.
622+
"""
623+
624+
625+
def get_domains(token):
626+
return requests.get("https://api.vscale.io/v1/domains/",
627+
headers={"X-Token": token}
628+
)
629+
630+
631+
"""
632+
Function new_domain performs a POST-request at
633+
https://api.vscale.io/v1/domains/, creates new domain.
634+
Token has to be provided as a str object.
635+
Name has to be provided as a str object.
636+
BIND file has to be provided as a str object.
637+
"""
638+
639+
640+
def new_domain(token, name, bind_file=None):
641+
data = {"name": str(name)}
642+
if bind_file is not None and bind_file != "":
643+
data["bind_zone"] = bind_file
644+
return requests.post("https://api.vscale.io/v1/domains/",
645+
headers={"Content-Type":
646+
"application/json;charset=UTF-8",
647+
"X-Token": token},
648+
data=json.loads(data)
649+
)
650+
651+
652+
"""
653+
Function domain_info performs a GET-request at
654+
https://api.vscale.io/v1/domains/, gets information of the domain with
655+
a given domain id.
656+
Token has to be provided as a str object.
657+
Domain id has to be provided as a str object.
658+
"""
659+
660+
661+
def domain_info(token, domainid):
662+
return requests.get("https://api.vscale.io/v1/domains/"+str(domainid),
663+
headers={"X-Token": token}
664+
)
665+
666+
667+
"""
668+
Function update_domain performs a PATCH-request at
669+
https://api.vscale.io/v1/domains/, updates information of the domain
670+
with a given domain id.
671+
Token has to be provided as a str object.
672+
Domain id has to be provided as a str object.
673+
Tags have to be provided as a list.
674+
"""
675+
676+
677+
def update_domain(token, domainid, tags):
678+
return requests.patch("https://api.vscale.io/v1/domains/"+str(domainid),
679+
headers={"Content-Type":
680+
"application/json;charset=UTF-8",
681+
"X-Token": token},
682+
data=json.loads({"tags": str(tags)})
683+
)
684+
685+
686+
"""
687+
Function delete_domain performs a DELETE-request at
688+
https://api.vscale.io/v1/domains/, deletes the domain with a given domain id.
689+
Token has to be provided as a str object.
690+
Domain id has to be provided as a str object.
691+
"""
692+
693+
694+
def delete_domain(token, domainid):
695+
return requests.delete("https://api.vscale.io/v1/domains/"+str(domainid),
696+
headers={"Content-Type":
697+
"application/json;charset=UTF-8",
698+
"X-Token": token}
699+
)

0 commit comments

Comments
 (0)