Add Resource Distribution Pool support#7
Closed
pavankumar2203 wants to merge 1 commit intoultradns:masterfrom
Closed
Add Resource Distribution Pool support#7pavankumar2203 wants to merge 1 commit intoultradns:masterfrom
pavankumar2203 wants to merge 1 commit intoultradns:masterfrom
Conversation
Contributor
|
First off, I sincerely apologize that this request sat unacknowledged for so long. Your contribution was valuable, and I appreciate you taking the time to submit it. While I’m no longer able to merge this code directly due to the project's changes over the years, I wanted to let you know that I’ve incorporated your feedback and code into the upcoming v2.2.5 release. I’ve extended it a bit to support additional parameters, including a Here’s the updated implementation: def _build_rd_rrset(self, rdata_info, ttl, owner_name, order, description):
"""Builds an RD Pool RRSet.
:param rdata_info: List of record data for the records in the pool.
:param ttl: The TTL value for the RRSet.
:param owner_name: The owner name for the RRSet.
:param order: The order in which rdata is served. Used for RD pools.
:param description: A description for the RD pool. Defaults to owner_name if not provided.
:return: A dictionary representing the RRSet.
"""
profile = {
"@context": "http://schemas.ultradns.com/RDPool.jsonschema",
"order": order,
"description": description if description is not None else owner_name
}
return {"ttl": ttl, "rdata": rdata_info, "profile": profile}
def create_rd_pool(self, zone_name, owner_name, ttl, rdata_info, order="ROUND_ROBIN", ipv6=False, description=None):
"""Creates a new RD Pool.
:param zone_name: The zone that contains the RRSet. The trailing dot is optional.
:param owner_name: The owner name for the RRSet.
If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)
:param ttl: The TTL value for the RRSet.
:param rdata_info: List of record data for the records in the pool.
Values are strings representing either IPv4 or IPv6 addresses.
:param order: (Optional) The order in which rdata is served. Default is ROUND_ROBIN.
Valid options:
- ROUND_ROBIN
- FIXED
- RANDOM
:param ipv6: (Optional) Boolean indicating whether to create an AAAA (True) or A (False) RD pool. Default is False.
:param description: (Optional) A description for the RD pool. Defaults to owner_name if not provided.
:return: API response from the POST request.
"""
rtype = "AAAA" if ipv6 else "A"
rrset = self._build_rd_rrset(rdata_info, ttl, owner_name, order, description)
return self.rest_api_connection.post(
f"/v1/zones/{zone_name}/rrsets/{rtype}/{owner_name}",
json.dumps(rrset)
)
def edit_rd_pool(self, zone_name, owner_name, ttl, rdata_info, order="ROUND_ROBIN", ipv6=False, description=None):
"""Updates an existing RD Pool in the specified zone.
:param zone_name: The zone that contains the RRSet. The trailing dot is optional.
:param owner_name: The owner name for the RRSet.
If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)
:param ttl: The TTL value for the RRSet.
:param rdata_info: List of record data for the records in the pool.
:param order: (Optional) The order in which rdata is served. Default is ROUND_ROBIN.
:param ipv6: (Optional) Boolean indicating whether to create an AAAA (True) or A (False) RD pool. Default is False.
:param description: (Optional) A description for the RD pool. Defaults to owner_name if not provided.
:return: API response from the PUT request.
"""
rtype = "AAAA" if ipv6 else "A"
rrset = self._build_rd_rrset(rdata_info, ttl, owner_name, order, description)
return self.rest_api_connection.put(
f"/v1/zones/{zone_name}/rrsets/{rtype}/{owner_name}",
json.dumps(rrset)
)
def get_rd_pools(self, zone_name):
"""Retrieves an RD Pool in the specified zone.
:param zone_name: The zone that contains the RRSet.
:param owner_name: The owner name for the RRSet.
:return: API response from the GET request.
"""
return self.rest_api_connection.get(
f"/v1/zones/{zone_name}/rrsets?q=kind:RD_POOLS"
)
def delete_rd_pool(self, zone_name, owner_name, ipv6=False):
"""Deletes an RD Pool in the specified zone.
:param zone_name: The zone that contains the RRSet.
:param owner_name: The owner name for the RRSet.
:param ipv6: (Optional) Boolean indicating whether to delete an AAAA (True) or A (False) RD pool. Default is False.
:return: API response from the DELETE request.
"""
rtype = "AAAA" if ipv6 else "A"
return self.rest_api_connection.delete(
f"/v1/zones/{zone_name}/rrsets/{rtype}/{owner_name}"
)Your original PR helped shape these improvements. Thanks again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to get / create /update Resource Distribution Pools on UltraDNS. ( Multiple A Records )