How to use the dnsimple.Client function in dnsimple

To help you get started, we’ve selected a few dnsimple examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dnsimple / dnsimple-api-examples / python / auth.py View on Github external
#!/usr/bin/env python3

# This script assumes a client token. It will work with an account token but the information is not really useful.
# If all you have is a client token, you can run this script, note the account id, and hard code that into
# other scripts where it is supplying an account id from the whoami endpoint.
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()
"""
Note:
    data.user property will be None if an account token was supplied
    data.account property will be None if a user token was supplied
"""
account = response.data.account

print(f'Account= id:{account.id}, email:{account.email}, plan_identifier:{account.plan_identifier}')
github dnsimple / dnsimple-api-examples / python / tld_extended_attributes.py View on Github external
#!/usr/bin/env python3

# This script assumes a client token. It will work with an account token but the information is not really useful.
# If all you have is a client token, you can run this script, note the account id, and hard code that into
# other scripts where it is supplying an account id from the whoami endpoint.
import sys

from auth_token import token
from dnsimple import Client

"""
Construct a client instance.

If you want to connect to production omit the sandbox option
"""
client = Client(sandbox=True, access_token=token)

"""
dnsimple.client.tlds.get_tld_extended_attributes is the method to retrieve the extended attributes
for a particular TLD.
"""
response = client.tlds.get_tld_extended_attributes(str(sys.argv[1]))

for attribute in response.data:
    print(f'- {attribute.name} ({attribute.description}): required? {attribute.required}')
github dnsimple / dnsimple-api-examples / python / create_contact.py View on Github external
parser.add_argument("phone", help="The contact phone number")
parser.add_argument("--label", help="The label to represent the contact")
parser.add_argument("--organization_name", help="The company name. If the organization_name is specified, then you must also include job_title.")
parser.add_argument("--job_title", help="The contact's job title")
parser.add_argument("--address2", help="Apartment or suite number")
parser.add_argument("--fax", help="The contact fax number")
parser.set_defaults(label="", organization_name="", job_title="", address2="", fax="")

args = parser.parse_args()

"""
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.
github dnsimple / dnsimple-api-examples / python / bad_auth.py View on Github external
#!/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=, 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}')
github dnsimple / dnsimple-api-examples / python / zone_records.py View on Github external
#
# 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=, password=`

import sys

from auth_token import token
from dnsimple import Client

"""
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.
github dnsimple / dnsimple-api-examples / python / domains.py View on Github external
#!/usr/bin/env python3

# This script assumes a client token. It will work with an account token but the information is not really useful.
# If all you have is a client token, you can run this script, note the account id, and hard code that into
# other scripts where it is supplying an account id from the whoami endpoint.

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.
github dnsimple / dnsimple-api-examples / python / check.py View on Github external
#!/usr/bin/env python3

# This script assumes a client token. It will work with an account token but the information is not really useful.
# If all you have is a client token, you can run this script, note the account id, and hard code that into
# other scripts where it is supplying an account id from the whoami endpoint.
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.
github dnsimple / dnsimple-api-examples / python / account_list.py View on Github external
# 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=, 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}')
github dnsimple / dnsimple-api-examples / python / create_domain.py View on Github external
#!/usr/bin/env python3

# This script assumes a client token. It will work with an account token but the information is not really useful.
# If all you have is a client token, you can run this script, note the account id, and hard code that into
# other scripts where it is supplying an account id from the whoami endpoint.
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.