mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-10 07:30:26 +00:00
Merge pull request #1154 from jbe-dw/fixBackendContentType
fix: Set Content-Type on backend API calls
This commit is contained in:
commit
bff020443f
@ -208,7 +208,7 @@ class Domain(db.Model):
|
|||||||
Add a domain to power dns
|
Add a domain to power dns
|
||||||
"""
|
"""
|
||||||
|
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
domain_name = domain_name + '.'
|
domain_name = domain_name + '.'
|
||||||
domain_ns = [ns + '.' for ns in domain_ns]
|
domain_ns = [ns + '.' for ns in domain_ns]
|
||||||
@ -311,7 +311,7 @@ class Domain(db.Model):
|
|||||||
if not domain:
|
if not domain:
|
||||||
return {'status': 'error', 'msg': 'Domain does not exist.'}
|
return {'status': 'error', 'msg': 'Domain does not exist.'}
|
||||||
|
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
if soa_edit_api not in ["DEFAULT", "INCREASE", "EPOCH", "OFF"]:
|
if soa_edit_api not in ["DEFAULT", "INCREASE", "EPOCH", "OFF"]:
|
||||||
soa_edit_api = 'DEFAULT'
|
soa_edit_api = 'DEFAULT'
|
||||||
@ -361,7 +361,7 @@ class Domain(db.Model):
|
|||||||
if not domain:
|
if not domain:
|
||||||
return {'status': 'error', 'msg': 'Domain does not exist.'}
|
return {'status': 'error', 'msg': 'Domain does not exist.'}
|
||||||
|
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
post_data = {"kind": kind, "masters": masters}
|
post_data = {"kind": kind, "masters": masters}
|
||||||
|
|
||||||
@ -681,7 +681,7 @@ class Domain(db.Model):
|
|||||||
"""
|
"""
|
||||||
domain = Domain.query.filter(Domain.name == domain_name).first()
|
domain = Domain.query.filter(Domain.name == domain_name).first()
|
||||||
if domain:
|
if domain:
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
try:
|
try:
|
||||||
# Enable API-RECTIFY for domain, BEFORE activating DNSSEC
|
# Enable API-RECTIFY for domain, BEFORE activating DNSSEC
|
||||||
post_data = {"api_rectify": True}
|
post_data = {"api_rectify": True}
|
||||||
@ -747,7 +747,7 @@ class Domain(db.Model):
|
|||||||
"""
|
"""
|
||||||
domain = Domain.query.filter(Domain.name == domain_name).first()
|
domain = Domain.query.filter(Domain.name == domain_name).first()
|
||||||
if domain:
|
if domain:
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
try:
|
try:
|
||||||
# Deactivate DNSSEC
|
# Deactivate DNSSEC
|
||||||
jdata = utils.fetch_json(
|
jdata = utils.fetch_json(
|
||||||
@ -821,7 +821,7 @@ class Domain(db.Model):
|
|||||||
if not domain:
|
if not domain:
|
||||||
return {'status': False, 'msg': 'Domain does not exist'}
|
return {'status': False, 'msg': 'Domain does not exist'}
|
||||||
|
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
account_name = Account().get_name_by_id(account_id)
|
account_name = Account().get_name_by_id(account_id)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class Record(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Continue if the record is ready to be added
|
# Continue if the record is ready to be added
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
jdata = utils.fetch_json(urljoin(
|
jdata = utils.fetch_json(urljoin(
|
||||||
@ -293,7 +293,7 @@ class Record(object):
|
|||||||
return new_rrsets, del_rrsets
|
return new_rrsets, del_rrsets
|
||||||
|
|
||||||
def apply_rrsets(self, domain_name, rrsets):
|
def apply_rrsets(self, domain_name, rrsets):
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
jdata = utils.fetch_json(urljoin(
|
jdata = utils.fetch_json(urljoin(
|
||||||
self.PDNS_STATS_URL, self.API_EXTENDED_URL +
|
self.PDNS_STATS_URL, self.API_EXTENDED_URL +
|
||||||
'/servers/localhost/zones/{0}'.format(domain_name)),
|
'/servers/localhost/zones/{0}'.format(domain_name)),
|
||||||
@ -500,7 +500,7 @@ class Record(object):
|
|||||||
"""
|
"""
|
||||||
Delete a record from domain
|
Delete a record from domain
|
||||||
"""
|
"""
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
data = {
|
data = {
|
||||||
"rrsets": [{
|
"rrsets": [{
|
||||||
"name": self.name.rstrip('.') + '.',
|
"name": self.name.rstrip('.') + '.',
|
||||||
@ -562,7 +562,7 @@ class Record(object):
|
|||||||
"""
|
"""
|
||||||
Update single record
|
Update single record
|
||||||
"""
|
"""
|
||||||
headers = {'X-API-Key': self.PDNS_API_KEY}
|
headers = {'X-API-Key': self.PDNS_API_KEY, 'Content-Type': 'application/json'}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"rrsets": [{
|
"rrsets": [{
|
||||||
|
@ -188,6 +188,7 @@ def api_login_create_zone():
|
|||||||
api_full_uri = api_uri_with_prefix + '/servers/localhost/zones'
|
api_full_uri = api_uri_with_prefix + '/servers/localhost/zones'
|
||||||
headers = {}
|
headers = {}
|
||||||
headers['X-API-Key'] = pdns_api_key
|
headers['X-API-Key'] = pdns_api_key
|
||||||
|
headers['Content-Type'] = 'application/json'
|
||||||
|
|
||||||
msg_str = "Sending request to powerdns API {0}"
|
msg_str = "Sending request to powerdns API {0}"
|
||||||
msg = msg_str.format(request.get_json(force=True))
|
msg = msg_str.format(request.get_json(force=True))
|
||||||
|
Loading…
Reference in New Issue
Block a user