|
50 | 50 | - [Update single DNS entry](#update-single-dns-entry)
|
51 | 51 | - [Update all DNS entries for a domain](#update-all-dns-entries-for-a-domain)
|
52 | 52 | - [Remove a DNS entry from a domain](#remove-a-dns-entry-from-a-domain)
|
| 53 | + - [Nameservers](#nameserver) |
| 54 | + - [The **Nameserver** class](#the-nameserver-class) |
| 55 | + - [List nameservers for a domain](#list-nameservers-for-a-domain) |
| 56 | + - [Update nameservers for a domain](#update-nameservers-for-a-domain) |
53 | 57 | - [VPS](#vps)
|
54 | 58 | - [HA-IP](#ha-ip)
|
55 | 59 | - [Colocation](#colocation)
|
@@ -641,6 +645,61 @@ domain.dns.delete(dns_entry_data)
|
641 | 645 |
|
642 | 646 | The **transip.v6.objects.DnsEntry** class also provides a **delete()** method to delete a **DnsEntry** object from an instance.
|
643 | 647 |
|
| 648 | +### Nameservers |
| 649 | +Manage the nameserver of a domain. |
| 650 | +#### The **Nameserver** class |
| 651 | + |
| 652 | +When listing all nameservers of a **transip.v6.objects.Domain** object, a list of **transip.v6.objects.Nameserver** objects is returned. |
| 653 | + |
| 654 | +**_class_ Nameserver** |
| 655 | + |
| 656 | +The **Nameserver** class makes the following attributes available: |
| 657 | + |
| 658 | +- **hostname**: The hostname of this nameserver. |
| 659 | +- **ipv4**: The optional ipv4 glue record for this nameserver. |
| 660 | +- **ipv6**: The optional ipv6 glue record for this nameserver |
| 661 | + |
| 662 | +#### List nameservers for a domain |
| 663 | +Retrieve the nameserver of a single domain registered in your TransIP account by calling **nameserver.list()** on a **transip.v6.objects.Domain** object. This will return a list of **transip.v6.objects.Nameserver** objects. |
| 664 | + |
| 665 | +For example: |
| 666 | +```python |
| 667 | +import transip |
| 668 | +# Initialize a client using the TransIP demo token. |
| 669 | +client = transip.TransIP(access_token=transip.v6.DEMO_TOKEN) |
| 670 | + |
| 671 | +# Retrieve a domain by its name. |
| 672 | +domain = client.domains.get('transipdemonstratie.nl') |
| 673 | +# Retrieve the nameservers of a single domain. |
| 674 | +nameservers = domain.nameservers.list() |
| 675 | +# Show the nameserver information on the screen. |
| 676 | +for nameserver in nameservers: |
| 677 | + print(f"Nameserver: {nameserver.hostname}") |
| 678 | +``` |
| 679 | + |
| 680 | +#### Update nameservers for a domain |
| 681 | +Update all the nameservers of a single domain registered in your TransIP account at once by calling **nameservers.replace()** on a **transip.v6.objects.Domain** object. |
| 682 | + |
| 683 | +**Note:** This will wipe all nameservers previously configured on the domain. |
| 684 | + |
| 685 | +For example: |
| 686 | +```python |
| 687 | +import transip |
| 688 | +# Initialize a client using the TransIP demo token. |
| 689 | +client = transip.TransIP(access_token=transip.v6.DEMO_TOKEN) |
| 690 | + |
| 691 | +# Retrieve a domain by its name. |
| 692 | +domain = client.domains.get('transipdemonstratie.nl') |
| 693 | +# Retrieve the nameservers of the domain. |
| 694 | +nameservers = domain.nameservers.list() |
| 695 | + |
| 696 | +# Update the ipv4 glue record of the first nameserver. |
| 697 | +nameserver[0].ipv4 = '195.135.195.195' |
| 698 | + |
| 699 | +# Replace all the records with the updated ones |
| 700 | +domain.nameservers.replace(nameservers) |
| 701 | +``` |
| 702 | + |
644 | 703 | ## VPS
|
645 | 704 | The documentation for managing **VPSs** and related resources has not yet been documented. Feel free to file an [issue](https://github.com/roaldnefs/python-transip/issues/new/choose) for adding the missing section(s) in the documentation.
|
646 | 705 |
|
|
0 commit comments