@@ -599,6 +599,109 @@ def batch(self, batch_list):
599
599
"""
600
600
return self .rest_api_connection .post ("/v1/batch" , json .dumps (batch_list ))
601
601
602
+ # Create an RD Pool
603
+ # Sample JSON for an RD pool -- see the REST API docs for their descriptions
604
+ # {
605
+ # "ttl": 120,
606
+ # "rdata": [
607
+ # "4.5.6.7", "199.7.167.22", "1.2.3.4", "5.6.7.8"
608
+ # ],
609
+ # "profile": {
610
+ # "@context": "http://schemas.ultradns.com/RDPool.jsonschema",
611
+ # "description": "description",
612
+ # "order": "ROUND_ROBIN"
613
+ # }
614
+ # }
615
+
616
+ def _build_rd_rrset (self , rdata_info , ttl , owner_name , order , description ):
617
+ """Builds an RD Pool RRSet.
618
+
619
+ :param rdata_info: List of record data for the records in the pool.
620
+ :param ttl: The TTL value for the RRSet.
621
+ :param owner_name: The owner name for the RRSet.
622
+ :param order: The order in which rdata is served. Used for RD pools.
623
+ :param description: A description for the RD pool. Defaults to owner_name if not provided.
624
+ :return: A dictionary representing the RRSet.
625
+ """
626
+ profile = {
627
+ "@context" : "http://schemas.ultradns.com/RDPool.jsonschema" ,
628
+ "order" : order ,
629
+ "description" : description if description is not None else owner_name
630
+ }
631
+
632
+ return {"ttl" : ttl , "rdata" : rdata_info , "profile" : profile }
633
+
634
+ def create_rd_pool (self , zone_name , owner_name , ttl , rdata_info , order = "ROUND_ROBIN" , ipv6 = False , description = None ):
635
+ """Creates a new RD Pool.
636
+
637
+ :param zone_name: The zone that contains the RRSet. The trailing dot is optional.
638
+ :param owner_name: The owner name for the RRSet.
639
+ If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
640
+ If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)
641
+ :param ttl: The TTL value for the RRSet.
642
+ :param rdata_info: List of record data for the records in the pool.
643
+ Values are strings representing either IPv4 or IPv6 addresses.
644
+ :param order: (Optional) The order in which rdata is served. Default is ROUND_ROBIN.
645
+ Valid options:
646
+ - ROUND_ROBIN
647
+ - FIXED
648
+ - RANDOM
649
+ :param ipv6: (Optional) Boolean indicating whether to create an AAAA (True) or A (False) RD pool. Default is False.
650
+ :param description: (Optional) A description for the RD pool. Defaults to owner_name if not provided.
651
+ :return: API response from the POST request.
652
+ """
653
+ rtype = "AAAA" if ipv6 else "A"
654
+ rrset = self ._build_rd_rrset (rdata_info , ttl , owner_name , order , description )
655
+ return self .rest_api_connection .post (
656
+ f"/v1/zones/{ zone_name } /rrsets/{ rtype } /{ owner_name } " ,
657
+ json .dumps (rrset )
658
+ )
659
+
660
+ def edit_rd_pool (self , zone_name , owner_name , ttl , rdata_info , order = "ROUND_ROBIN" , ipv6 = False , description = None ):
661
+ """Updates an existing RD Pool in the specified zone.
662
+
663
+ :param zone_name: The zone that contains the RRSet. The trailing dot is optional.
664
+ :param owner_name: The owner name for the RRSet.
665
+ If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
666
+ If a trailing dot is supplied, the owner name is assumed to be absolute (foo.zonename.com.)
667
+ :param ttl: The TTL value for the RRSet.
668
+ :param rdata_info: List of record data for the records in the pool.
669
+ :param order: (Optional) The order in which rdata is served. Default is ROUND_ROBIN.
670
+ :param ipv6: (Optional) Boolean indicating whether to create an AAAA (True) or A (False) RD pool. Default is False.
671
+ :param description: (Optional) A description for the RD pool. Defaults to owner_name if not provided.
672
+ :return: API response from the PUT request.
673
+ """
674
+ rtype = "AAAA" if ipv6 else "A"
675
+ rrset = self ._build_rd_rrset (rdata_info , ttl , owner_name , order , description )
676
+ return self .rest_api_connection .put (
677
+ f"/v1/zones/{ zone_name } /rrsets/{ rtype } /{ owner_name } " ,
678
+ json .dumps (rrset )
679
+ )
680
+
681
+ def get_rd_pools (self , zone_name ):
682
+ """Retrieves an RD Pool in the specified zone.
683
+
684
+ :param zone_name: The zone that contains the RRSet.
685
+ :param owner_name: The owner name for the RRSet.
686
+ :return: API response from the GET request.
687
+ """
688
+ return self .rest_api_connection .get (
689
+ f"/v1/zones/{ zone_name } /rrsets?q=kind:RD_POOLS"
690
+ )
691
+
692
+ def delete_rd_pool (self , zone_name , owner_name , ipv6 = False ):
693
+ """Deletes an RD Pool in the specified zone.
694
+
695
+ :param zone_name: The zone that contains the RRSet.
696
+ :param owner_name: The owner name for the RRSet.
697
+ :param ipv6: (Optional) Boolean indicating whether to delete an AAAA (True) or A (False) RD pool. Default is False.
698
+ :return: API response from the DELETE request.
699
+ """
700
+ rtype = "AAAA" if ipv6 else "A"
701
+ return self .rest_api_connection .delete (
702
+ f"/v1/zones/{ zone_name } /rrsets/{ rtype } /{ owner_name } "
703
+ )
704
+
602
705
# Create an SB Pool
603
706
# Sample JSON for an SB pool -- see the REST API docs for their descriptions
604
707
# {
0 commit comments