示例#1
0
 def dnsimple_client(self):
     """creates a dnsimple client object"""
     if self.account_email and self.account_api_token:
         client = Client(sandbox=self.sandbox, email=self.account_email, access_token=self.account_api_token)
     else:
         msg = "Option account_email or account_api_token not provided. " \
               "Dnsimple authentiction with a .dnsimple config file is not " \
               "supported with dnsimple-python>=2.0.0"
         raise DNSimpleException(msg)
     client.identity.whoami()
     self.client = client
示例#2
0
 def setUp(self) -> None:
     self.client = Client(access_token='SomeMagicToken', sandbox=True)
     self.accounts = self.client.accounts
     self.certificates = self.client.certificates
     self.contacts = self.client.contacts
     self.domains = self.client.domains
     self.identity = self.client.identity
     self.oauth = self.client.oauth
     self.registrar = self.client.registrar
     self.services = self.client.services
     self.templates = self.client.templates
     self.tlds = self.client.tlds
     self.vanity_name_servers = self.client.vanity_name_servers
     self.webhooks = self.client.webhooks
     self.zones = self.client.zones
示例#3
0
# This script assumes an account token.
#
# If all you have is a user token you can run this script, by passing email and password when creating the client
# like so:
# `client = Client(sandbox=True, email=<your_email>, password=<your_password>`

import sys

from dnsimple import Client
from auth_token import token
"""
Construct a client instance.

If you want to connect to production omit the sandbox option
"""
client = Client(sandbox=True, access_token=token)
"""
All calls to client pass through a service. In this case, `client.identity` is the identity service

`client.identity.whoami() is the method for retrieving the account details for your
current credentials via the DNSimple API.
"""
response = client.identity.whoami()
"""
The response object returned by any API method includes a `data` attribute.

Underneath that attribute is an attribute for each data object returned.

In this case, `account` provides access to the contained account object.

Here the account id is extracted for use in future calls:
示例#4
0
#!/usr/bin/env python3

# This script assumes an account token.
#
# If all you have is a user token you can run this script, by passing email and password when creating the client
# like so:
# `client = Client(sandbox=True, email=<your_email>, password=<your_password>`

from dnsimple import Client
from auth_token import token
"""
Construct a client instance.

If you want to connect to production omit the sandbox option
"""
client = Client(sandbox=True, access_token=f"{token}")
"""
All calls to client pass through a service. In this case, `client.accounts` is the accounts service

`client.accounts.list_accounts() is the method for retrieving the list of accounts the current authenticated
entity has access to.
"""
response = client.accounts.list_accounts()

account = response.data[0]

print(
    f'Account= id:{account.id}, email:{account.email}, plan_identifier:{account.plan_identifier}'
)
示例#5
0
#!/usr/bin/env python3

# This script assumes an account token.
#
# If all you have is a user token you can run this script, by passing email and password when creating the client
# like so:
# `client = Client(sandbox=True, email=<your_email>, password=<your_password>`

from dnsimple import Client, DNSimpleException
"""
Construct a client instance.

If you want to connect to production omit the sandbox option
"""
client = Client(sandbox=True, access_token='fake')
"""
All calls to client pass through a service. In this case, `client.identity` is the identity service

`client.identity.whoami() is the method for retrieving the account details for your
current credentials via the DNSimple API.

In this case the call will fail and raise an exception.
"""
try:
    whoami = client.identity.whoami()
except DNSimpleException as e:
    print(f'Exception Raised= {e.message}')
示例#6
0
from dnsimple import Client
from dnsimple.struct import ZoneRecordUpdateInput

# Replace with eRezLife API token
token = "TOKENTOKENTOKENTOKEN"

# Replace with US & CA proxy server IPs
ips = ["50.87.234.153"]

# client = Client(sandbox=True, access_token=token)
client = Client(access_token=token)

account_id = client.identity.whoami().data.account.id
zones = client.zones.list_zones(account_id).data

page = 1
records = client.zones.list_records(account_id, zones[0].name).data

while records:
    for record in records:
        if record.type == "A" and record.content in ips:
            print(record.id, record.type, record.name, record.content)
            client.zones.update_record(account_id, zones[0].name, record.id,
                                       ZoneRecordUpdateInput(ttl=300))
    page += 1
    records = client.zones.list_records(account_id, zones[0].name,
                                        page=page).data