Skip to content

Commit

Permalink
fix: solved pre-commit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxd committed Jan 21, 2025
1 parent f2fd6e9 commit efeb6d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions powerdns_api_proxy/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

from powerdns_api_proxy.config import (
check_pdns_search_allowed,
check_pdns_tsigkeys_allowed,
check_pdns_zone_admin,
check_pdns_zone_allowed,
check_pdns_tsigkeys_allowed,
dependency_check_token_defined,
dependency_metrics_proxy_enabled,
ensure_rrsets_request_allowed,
Expand Down Expand Up @@ -444,9 +444,7 @@ async def search_data(


@router_pdns.get('/servers/{server_id}/tsigkeys')
async def list_tsigkeys(
response: Response, server_id: str, X_API_Key: str = Header()
):
async def list_tsigkeys(response: Response, server_id: str, X_API_Key: str = Header()):
'''
Get all TSIGKeys on the server, except the actual key.
Expand Down Expand Up @@ -488,23 +486,30 @@ async def create_tsigkey(
'''
Add a TSIG key.
This methods add a new TSIGKey. The actual key can be generated by the server or be provided by the client.
This methods add a new TSIGKey. The actual key can be generated by the server or
be provided by the client.
<https://doc.powerdns.com/authoritative/http-api/tsigkey.html#post--servers-server_id-tsigkeys>
'''
environment = get_environment_for_token(config, X_API_Key)
if not check_pdns_tsigkeys_allowed(environment):
logger.info(f'TSIGKeys not allowed for environment {environment.name}')
raise ZoneNotAllowedException()
resp = await pdns.post(f'/api/v1/servers/{server_id}/tsigkeys', payload=await request.json())
resp = await pdns.post(
f'/api/v1/servers/{server_id}/tsigkeys', payload=await request.json()
)
response.status_code = resp.status
data = await response_json_or_text(resp)
return data


@router_pdns.put('/servers/{server_id}/tsigkeys/{tsigkey_id}')
async def update_tsigkey(
request: Request, response: Response, server_id: str, tsigkey_id: str, X_API_Key: str = Header()
request: Request,
response: Response,
server_id: str,
tsigkey_id: str,
X_API_Key: str = Header(),
):
'''
The TSIGKey at tsigkey_id can be changed in multiple ways:
Expand All @@ -521,7 +526,10 @@ async def update_tsigkey(
if not check_pdns_tsigkeys_allowed(environment):
logger.info(f'TSIGKeys not allowed for environment {environment.name}')
raise ZoneNotAllowedException()
resp = await pdns.put(f'/api/v1/servers/{server_id}/tsigkeys/{tsigkey_id}', payload=await request.json())
resp = await pdns.put(
f'/api/v1/servers/{server_id}/tsigkeys/{tsigkey_id}',
payload=await request.json(),
)
response.status_code = resp.status
data = await response_json_or_text(resp)
return data
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from powerdns_api_proxy.config import (
check_acme_record_allowed,
check_pdns_search_allowed,
check_pdns_tsigkeys_allowed,
check_pdns_zone_admin,
check_pdns_zone_allowed,
check_pdns_tsigkeys_allowed,
check_rrset_allowed,
check_token_defined,
ensure_rrsets_request_allowed,
Expand Down

0 comments on commit efeb6d1

Please sign in to comment.