mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 10:46:06 +02:00
create / get zone subscription
This commit is contained in:
parent
470a5e4904
commit
cf0f81ffae
1 changed files with 25 additions and 12 deletions
|
@ -614,18 +614,31 @@ class PrototypeDomainDNSRecordView(DomainFormBaseView):
|
||||||
zone_id = zone_response_json["result"]["id"]
|
zone_id = zone_response_json["result"]["id"]
|
||||||
zone_response.raise_for_status()
|
zone_response.raise_for_status()
|
||||||
|
|
||||||
# # 4. Add zone subscription
|
# 4. Add or get a zone subscription
|
||||||
# subscription_response = requests.post(
|
|
||||||
# f"{base_url}/zones/{zone_id}/subscription",
|
# See if one already exists
|
||||||
# headers=headers,
|
subscription_response = requests.get(f"{base_url}/zones/{zone_id}/subscription", headers=headers)
|
||||||
# json={
|
subscription_response_json = subscription_response.json()
|
||||||
# "rate_plan": {"id": "PARTNERS_ENT"},
|
logger.debug(f"get subscription: {subscription_response_json}")
|
||||||
# "frequency": "annual"
|
|
||||||
# }
|
# Create a subscription if one doesn't exist already.
|
||||||
# )
|
# If it doesn't, we get this error message (code 1207):
|
||||||
# subscription_response.raise_for_status()
|
# Add a core subscription first and try again. The zone does not have an active core subscription.
|
||||||
# subscription_response_json = subscription_response.json()
|
# Note that status code and error code are different here.
|
||||||
# logger.info(f"Created subscription: {subscription_response_json}")
|
if subscription_response.status_code == 404:
|
||||||
|
subscription_response = requests.post(
|
||||||
|
f"{base_url}/zones/{zone_id}/subscription",
|
||||||
|
headers=headers,
|
||||||
|
json={
|
||||||
|
"rate_plan": {"id": "PARTNERS_ENT"},
|
||||||
|
"frequency": "annual"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
subscription_response.raise_for_status()
|
||||||
|
subscription_response_json = subscription_response.json()
|
||||||
|
logger.info(f"Created subscription: {subscription_response_json}")
|
||||||
|
else:
|
||||||
|
subscription_response.raise_for_status()
|
||||||
|
|
||||||
|
|
||||||
# # 5. Create DNS record
|
# # 5. Create DNS record
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue