create / get zone subscription

This commit is contained in:
zandercymatics 2024-12-05 10:24:28 -07:00
parent 470a5e4904
commit cf0f81ffae
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -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