### Install Dependencies with Poetry Source: https://github.com/dnsimple/dnsimple-python/blob/main/CONTRIBUTING.md Install project dependencies using Poetry. Ensure Poetry is installed and the project is initialized. ```shell poetry install ``` -------------------------------- ### Install Latest DNSimple Python Client Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Installs the most recent version of the DNSimple Python client using pip. ```shell pip install dnsimple ``` -------------------------------- ### List, Create, and Get Domains Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Demonstrates how to list all domains, create a new domain, and retrieve details for a specific domain. ```python account_id = client.identity.whoami().data.account.id # List domains domains = client.domains.list_domains(account_id).data # Create domain new_domain = client.domains.create_domain( account_id, 'newdomain.com' ).data # Get domain domain = client.domains.get_domain(account_id, 'example.com').data ``` -------------------------------- ### Direct HTTP Method Calls Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Provides examples for making direct HTTP requests (GET, POST, PUT, PATCH, DELETE) to the DNSimple API, including how to pass parameters, data, and construct versioned URLs. ```python # GET response = client.get('/whoami') # GET with parameters response = client.get( '/123/domains', sort='name:asc', filter={'name_like': 'example'}, page=1, per_page=50 ) # POST import json response = client.post( '/123/domains', data=json.dumps({'name': 'example.com'}) ) # PUT response = client.put('/123/zones/example.com/activation') # PATCH response = client.patch( '/123/domains/example.com', data=json.dumps({'auto_renew': True}) ) # DELETE response = client.delete('/123/domains/example.com') # Versioned URL url = client.versioned('/whoami') ``` -------------------------------- ### Install Specific Version of DNSimple Python Client Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Installs a particular version of the DNSimple Python client using pip. ```shell pip install dnsimple==2.0.1 ``` -------------------------------- ### Make a GET Request Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Execute a direct HTTP GET request to a specified API endpoint. Requires initializing the client with an access token. ```python client = Client(access_token='token') # GET request response = client.get('/whoami') ``` -------------------------------- ### Start Poetry Shell Source: https://github.com/dnsimple/dnsimple-python/blob/main/CONTRIBUTING.md Enter the virtual environment created by Poetry to work on the project. ```shell poetry shell ``` -------------------------------- ### Production with Basic Auth Configuration Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Example of configuring the client for production using email and password with a custom user agent. Suitable for administrative consoles. ```python from dnsimple import Client # Configure with email and password client = Client( email='admin@example.com', password='secure_password', user_agent='admin-console/1.0.0' ) ``` -------------------------------- ### Example of Constructing a Versioned URL Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Demonstrates how to use the `versioned` method to create a full API URL, including the version prefix. ```python url = client.versioned('/whoami') # Returns: 'https://api.dnsimple.com/v2/whoami' ``` -------------------------------- ### Production with Token Configuration Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Example of configuring the client for production using an access token and a custom user agent. Used for executing production operations. ```python from dnsimple import Client # Configure for production client = Client( access_token='DNSimple_production_token_here', user_agent='my-production-app/1.0.0' ) # Execute production operations account_id = client.identity.whoami().data.account.id domains = client.domains.list_domains(account_id) ``` -------------------------------- ### Get Domain Registration Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets details of an existing domain registration. Requires account ID, domain name, and domain registration ID. ```python def get_domain_registration(self, account_id, domain, domain_registration) ``` -------------------------------- ### Development with Sandbox Configuration Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Example of configuring the client for sandbox testing with a custom user agent. Allows testing operations without affecting production. ```python from dnsimple import Client # Configure for sandbox testing client = Client( sandbox=True, access_token='DNSimple_sandbox_token_here', user_agent='dev-test/0.1.0' ) # Test operations without affecting production whoami = client.identity.whoami().data print(f"Testing with account: {whoami.account.name}") ``` -------------------------------- ### Initialize DNSimple Client Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/INDEX.md Instantiate the DNSimple client using an access token. Refer to the Configuration Guide for more details. ```python from dnsimple import Client client = Client(access_token='api_token') ``` -------------------------------- ### Get Template Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific template. ```python # Get template = client.templates.get_template(account_id, template_id).data ``` -------------------------------- ### Get Service Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific service. ```python # Get service service = client.services.get_service(service_id).data ``` -------------------------------- ### Basic DNSimple Client Usage Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Demonstrates initializing the DNSimple client with an access token, retrieving authenticated user information, listing domains, and getting zone records for a specific domain. ```python from dnsimple import Client # Initialize client client = Client(access_token='your_api_token') # Get authenticated user information whoami = client.identity.whoami().data # List domains account_id = whoami.account.id domains = client.domains.list_domains(account_id).data # Get zone records zone = client.zones.get_zone(account_id, 'example.com').data ``` -------------------------------- ### Get TLD Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific TLD. ```python # Get tld = client.tlds.get_tld('com').data ``` -------------------------------- ### Get Certificate Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific certificate. ```python # Get cert = client.certificates.get_certificate( account_id, 'example.com', cert_id ).data ``` -------------------------------- ### Transfer a Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Starts the process of transferring an existing domain to DNSimple. Requires an authorization code and registrant information. ```python # Transfer from dnsimple.struct import DomainTransferRequest request = DomainTransferRequest( auth_code='auth_code_from_registrar', registrant_id=contact_id ) transfer = client.registrar.transfer_domain( account_id, 'example.com', request ).data ``` -------------------------------- ### Secure Token Usage with Environment Variable Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md This example demonstrates how to securely load an API token from an environment variable for client authentication. Ensure the DNSIMPLE_API_TOKEN environment variable is set before running. ```python import os from dnsimple import Client # Load token from environment variable api_token = os.environ.get('DNSIMPLE_API_TOKEN') if not api_token: raise ValueError('DNSIMPLE_API_TOKEN environment variable not set') client = Client(access_token=api_token) ``` -------------------------------- ### Direct HTTP Method Calls Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Shows how to make direct HTTP requests (GET, POST, PUT, PATCH, DELETE) using the client, including versioned URLs. ```APIDOC ## Direct HTTP Methods ### Description Allows making raw HTTP requests to the DNSimple API using convenience methods on the client. ### Methods - **client.get(path, **kwargs)**: Performs a GET request. - **client.post(path, data, **kwargs)**: Performs a POST request. - **client.put(path, data, **kwargs)**: Performs a PUT request. - **client.patch(path, data, **kwargs)**: Performs a PATCH request. - **client.delete(path, **kwargs)**: Performs a DELETE request. ### Parameters - **path**: The API endpoint path. - **data**: The request body for POST, PUT, and PATCH requests (should be JSON string). - **kwargs**: Additional parameters like `sort`, `filter`, `page`, `per_page` for GET requests. ### Versioned URL - **client.versioned(path)**: Prepends the API version to the given path. ``` -------------------------------- ### transfer_domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Starts the transfer of a domain to DNSimple. Requires the account ID, domain name, and transfer details. ```APIDOC ## transfer_domain ### Description Starts the transfer of a domain to DNSimple. ### Method `transfer_domain` ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **domain** (str) - Yes - The domain name - **request** (DomainTransferRequest) - Yes - Transfer details with auth_code and optional registrant_id, auto_renew, whois_privacy ### Response #### Success Response Returns a `Response` object containing a `DomainTransfer` object. ### Example ```python from dnsimple.struct import DomainTransferRequest request = DomainTransferRequest( auth_code='auth_code_from_registrar', registrant_id=123, whois_privacy=True ) transfer = client.registrar.transfer_domain( account_id, 'example.com', request ).data ``` ``` -------------------------------- ### Initialize Client with OAuth Token Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Shows how to create a DNSimple client instance using an OAuth 2.0 access token. Recommended for production applications. ```python from dnsimple import Client client = Client(access_token='oauth_token') ``` -------------------------------- ### Get TLD Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Retrieves specific details for a given TLD. Requires the TLD name as a parameter. ```python tld = client.tlds.get_tld('com').data print(f"Whois Privacy: ${tld.whois_privacy_price}") ``` -------------------------------- ### Example 404 Not Found Response JSON Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/errors.md Presents the JSON structure for a 404 Not Found error response, typically containing only a general message indicating the resource was not found. ```json { "message": "Not found" } ``` -------------------------------- ### GET Request Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Sends a GET request to the DNSimple API. This method is used for retrieving data from the API. ```APIDOC ## GET Request ### Description Sends a GET request to the DNSimple API. This method is used for retrieving data from the API. ### Method GET ### Endpoint `/{path}` ### Parameters #### Path Parameters - **path** (str) - Required - Relative path to the API endpoint #### Query Parameters - **sort** (str) - Optional - Sort criteria for list responses - **filter** (dict) - Optional - Filter criteria for list responses - **params** (dict) - Optional - Additional query parameters - **page** (int) - Optional - Page number for pagination - **per_page** (int) - Optional - Number of results per page ### Returns `requests.Response` - Raw HTTP response object ### Request Example ```python client = Client(access_token='token') response = client.get('/whoami') # Use response.status_code, response.json(), etc. ``` ``` -------------------------------- ### Initialize Client with Basic Authentication Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Use this method for basic authentication with your DNSimple account email and password. ```python client = Client(email='user@example.com', password='password') ``` -------------------------------- ### Client Constructor Options Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Initializes the DNSimple Client with various configuration parameters. ```python from dnsimple import Client client = Client( email=None, password=None, access_token=None, base_url=None, sandbox=False, user_agent=None ) ``` -------------------------------- ### Get Certificate Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/certificates-service.md Retrieves detailed information about a specific certificate using its ID. Requires account, domain, and certificate IDs. ```python cert = client.certificates.get_certificate( account_id, 'example.com', cert_id ).data print(f"State: {cert.state}") ``` -------------------------------- ### get_domain_registration Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets details of an existing domain registration. Requires account ID, domain name, and domain registration ID. ```APIDOC ## get_domain_registration ### Description Gets details of an existing domain registration. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/registrations/{domain_registration} ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **domain** (str) - Yes - The domain name - **domain_registration** (int) - Yes - The domain registration ID ### Response #### Success Response (200) - **DomainRegistration** (object) - Details of the domain registration ``` -------------------------------- ### Get Zone File Content Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/zones-service.md Retrieves the zone file content in BIND format for a specified zone. Requires account ID and zone name. ```python zone_file = client.zones.get_zone_file(account_id, 'example.com').data print(zone_file.content) # BIND format zone file ``` -------------------------------- ### Initialize DNSimple Client Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Demonstrates various ways to initialize the DNSimple client, including token authentication (recommended), basic authentication, sandbox environment usage, and custom user agent configuration. ```python from dnsimple import Client # Token authentication (recommended) client = Client(access_token='api_token') # Basic authentication client = Client(email='user@example.com', password='password') # Sandbox environment client = Client(sandbox=True, access_token='token') # Custom user agent client = Client(access_token='token', user_agent='myapp/1.0') ``` -------------------------------- ### Get Domain Pricing Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Retrieves the current registration and renewal prices for a given domain. Useful for understanding costs before proceeding with registration or renewal. ```python prices = client.registrar.get_domain_prices(account_id, 'example.com').data print(f"Registration: ${prices.registration_price}") print(f"Renewal: ${prices.renewal_price}") ``` -------------------------------- ### Get Domain Transfer Lock Status Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets the transfer lock status of a domain. Requires account ID and domain name or ID. ```python def get_domain_transfer_lock(self, account_id, domain) ``` -------------------------------- ### Get Domain WHOIS Privacy Status Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets the WHOIS privacy status of a domain. Requires account ID and domain name or ID. ```python def get_whois_privacy(self, account_id, domain) ``` -------------------------------- ### Configure Client for Sandbox Environment (sandbox=True) Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Initializes the DNSimple client to use the sandbox environment by setting the 'sandbox' option to True. This requires a sandbox-specific access token. ```python from dnsimple import Client client = Client(sandbox=True, access_token='a1b2c3') ``` -------------------------------- ### Send GET Request Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Sends a GET request to a specified API path. Useful for retrieving data. The response object can be used to access status codes and JSON data. ```python client = Client(access_token='token') response = client.get('/whoami') # Use response.status_code, response.json(), etc. ``` -------------------------------- ### Get Webhook Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific webhook. ```python # Get webhook = client.webhooks.get_webhook(account_id, webhook_id).data ``` -------------------------------- ### Initialize Client for Production Environment Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Configures the client to use the production API endpoint (https://api.dnsimple.com). ```python client = Client(access_token='production_token') # Uses: https://api.dnsimple.com ``` -------------------------------- ### Get Account and User Information Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieves current user and account details using the identity service. The returned data includes account ID and user email. ```python whoami = client.identity.whoami().data # Returns: Whoami(account=Account, user=User) account_id = whoami.account.id user_email = whoami.user.email ``` -------------------------------- ### Initialize Client for Sandbox Environment Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Configures the client to use the sandbox API endpoint (https://api.sandbox.dnsimple.com). Requires a separate sandbox token. ```python client = Client(sandbox=True, access_token='sandbox_token') # Uses: https://api.sandbox.dnsimple.com ``` -------------------------------- ### Get Contact Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve details for a specific contact. ```python # Get contact = client.contacts.get_contact(account_id, contact_id).data ``` -------------------------------- ### Initialize Client with OAuth Token Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Use this method for token-based authentication, which is the recommended approach. Ensure you have a valid OAuth 2.0 access token. ```python client = Client(access_token='your_oauth_token') ``` -------------------------------- ### Get Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Retrieves details for a specific domain. ```APIDOC ## Get Domain ### Description Retrieves details for a specific domain. ### Method GET ### Endpoint `/v2/domains/{domain_identifier}` ### Parameters #### Path Parameters - **domain_identifier** (string) - Required - The name or ID of the domain. #### Query Parameters - **account_id** (integer) - Required - The ID of the account. ### Response #### Success Response (200) - **data** (object) - The Domain object. ### Response Example ```json { "data": { "id": 1, "name": "example.com", "unicode_name": "example.com", "bronze_order_id": null, "premium_price_starts_at": null, "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } } ``` ``` -------------------------------- ### DNSimple Client Authentication Methods Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Shows how to initialize the DNSimple client using different authentication methods: token authentication (recommended), basic authentication (email/password), and for the sandbox environment. ```python # Token authentication (recommended) client = Client(access_token='api_token_here') # Basic authentication client = Client(email='user@example.com', password='password') # Sandbox environment sandbox_client = Client(sandbox=True, access_token='sandbox_token') ``` -------------------------------- ### Configure Client for Sandbox Environment (base_url) Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Initializes the DNSimple client to use the sandbox environment by specifying the sandbox API host URL. Ensure you use a sandbox-specific access token. ```python from dnsimple import Client client = Client(base_url='https://api.sandbox.dnsimple.com', access_token="a1b2c3") ``` -------------------------------- ### get_dnssec Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/domains-service.md Gets the current DNSSEC status of the domain. ```APIDOC ## get_dnssec ### Description Gets the current DNSSEC status of the domain. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/dnssec ### Parameters #### Path Parameters - **account_id** (int) - Required - The account ID - **domain** (int or str) - Required - Domain name or ID ### Response #### Success Response (200) - **data** (object) - Dnssec object ``` -------------------------------- ### Use Access Token for API Calls Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/other-services.md Demonstrates how to use the obtained access token to create a new client instance for making authenticated API calls. ```python api_client = Client(access_token=access_token) whoami = api_client.identity.whoami().data ``` -------------------------------- ### Services Get Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/other-services.md Retrieves a specific one-click service by its ID. ```APIDOC ## Get Service ### Description Gets a service by ID. ### Method GET (assumed, based on retrieval operation) ### Endpoint `/services/{service_id}` (assumed structure) ### Parameters #### Path Parameters - **service_id** (int) - Required - The service ID ### Request Example ```python service = client.services.get_service(1).data print(f"Service: {service.name}") ``` ### Response #### Success Response (200) - **data** (object) - Service object - **id** (int) - The service ID - **name** (str) - The service name - **description** (str) - The service description #### Response Example ```json { "data": { "id": 1, "name": "Google Apps", "description": "One-click setup for Google Apps" } } ``` ``` -------------------------------- ### Get a Specific Zone Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieves details for a single zone by its name. ```python # Get zone = client.zones.get_zone(account_id, 'example.com').data ``` -------------------------------- ### Get a Specific Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieves details for a single domain by its name. ```python # Get domain = client.domains.get_domain(account_id, 'example.com').data ``` -------------------------------- ### Basic Authentication Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Configure the client using email and password for authentication. Token authentication is recommended for security. ```python client = Client(email='user@example.com', password='password') ``` ```python client = Client(email='user@example.com', password='mypassword') ``` -------------------------------- ### Basic DNSimple Client Initialization Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Initializes the DNSimple client for production or sandbox environments using an access token. Custom API URLs can also be specified. ```python from dnsimple import Client # Production environment with token client = Client(access_token='your_token') # Sandbox environment client = Client(sandbox=True, access_token='sandbox_token') # Custom API URL client = Client(base_url='https://api.custom.dnsimple.com', access_token='token') ``` -------------------------------- ### Get Domain Prices Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Retrieves pricing information for a domain name. ```APIDOC ## Get Domain Prices ### Description Retrieves pricing information for a domain name. ### Method GET ### Endpoint `/v2/registrar/domains/{domain_name}/prices` ### Parameters #### Path Parameters - **domain_name** (string) - Required - The domain name to get prices for. #### Query Parameters - **account_id** (integer) - Required - The ID of the account. ### Response #### Success Response (200) - **data** (object) - Pricing details for the domain. ### Response Example ```json { "data": { "currency": "USD", "price": 10.00, "premium_price": null, "idn_price": null, "idn_premium_price": null } } ``` ``` -------------------------------- ### Get Webhook Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Retrieves a specific webhook by its ID for a given account. ```APIDOC ## get_webhook ### Description Gets a webhook from the account. ### Method GET ### Endpoint /v2/accounts/{account_id}/webhooks/{webhook_id} ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **webhook** (int or str) - Yes - The webhook ID ### Response #### Success Response (200) - **data** (Webhook) - The Webhook object ### Request Example ```python webhook = client.webhooks.get_webhook(account_id, webhook_id).data ``` ``` -------------------------------- ### Initialize DNSimple Client and Fetch User Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Initializes the DNSimple client with an access token and fetches the authenticated user's details. The data can be extracted directly or in a single line. ```python from dnsimple import Client client = Client(access_token='a1b2c3') # Fetch your details response = client.identity.whoami() # execute the call data = response.data # extract the relevant data from the response or account = client.identity.whoami().data.account # execute the call and get the data in one line ``` -------------------------------- ### Certificate Management Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Illustrates listing certificates, purchasing and issuing a Let's Encrypt certificate, and downloading the certificate bundle. ```python # List certificates certs = client.certificates.list_certificates( account_id, 'example.com' ).data # Purchase Let's Encrypt certificate from dnsimple.struct import LetsencryptCertificateInput cert_input = LetsencryptCertificateInput(auto_renew=True) purchase = client.certificates.purchase_letsencrypt_certificate( account_id, 'example.com', cert_input ).data # Issue certificate cert = client.certificates.issue_letsencrypt_certificate( account_id, 'example.com', purchase.certificate_id ).data # Download certificate bundle = client.certificates.download_certificate( account_id, 'example.com', cert.id ).data ``` -------------------------------- ### Get TLD Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Retrieves details of a specific Top-Level Domain (TLD). ```APIDOC ## get_tld ### Description Gets details of a specific TLD. ### Method GET ### Endpoint /v2/tlds/{tld} ### Parameters #### Path Parameters - **tld** (str) - Yes - The TLD name (e.g., 'com') ### Response #### Success Response (200) - **data** (Tld) - Tld object ### Request Example ```python tld = client.tlds.get_tld('com').data print(f"Whois Privacy: ${tld.whois_privacy_price}") ``` ``` -------------------------------- ### Complete Let's Encrypt Certificate Workflow Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/certificates-service.md Demonstrates the complete process for obtaining a Let's Encrypt certificate: purchase, issue, and download. ```python # Step 1: Purchase purchase = client.certificates.purchase_letsencrypt_certificate( account_id, 'example.com' ).data # Step 2: Issue cert = client.certificates.issue_letsencrypt_certificate( account_id, 'example.com', purchase.certificate_id ).data # Step 3: Download bundle = client.certificates.download_certificate( account_id, 'example.com', cert.id ).data ``` -------------------------------- ### Get TLD Extended Attributes Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve extended attributes for a specific TLD. ```python # Extended attributes attrs = client.tlds.get_tld_extended_attributes('us').data ``` -------------------------------- ### Handling 404 Not Found for Nonexistent Resources Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/errors.md Illustrates handling a 404 Not Found error when attempting to retrieve a resource that does not exist, such as a domain that has been deleted or never existed. ```python try: response = client.domains.get_domain( account_id, 'nonexistent-domain-12345.com' ) except DNSimpleException as e: assert e.status == 404 print(f"Domain not found: {e.message}") ``` -------------------------------- ### Manage WHOIS Privacy Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Get, enable, or disable WHOIS privacy for a domain. ```python whois = client.registrar.get_whois_privacy(account_id, 'example.com').data whois = client.registrar.enable_whois_privacy(account_id, 'example.com').data whois = client.registrar.disable_whois_privacy(account_id, 'example.com').data ``` -------------------------------- ### Get Domain Renewal Status Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieve the renewal status for a specific domain. ```python renewal = client.registrar.get_domain_renewal( account_id, 'example.com', renewal_id ).data ``` -------------------------------- ### Manage Domain Transfer Lock Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Get, enable, or disable the transfer lock for a domain. ```python lock = client.registrar.get_domain_transfer_lock( account_id, 'example.com' ).data lock = client.registrar.enable_domain_transfer_lock( account_id, 'example.com' ).data lock = client.registrar.disable_domain_transfer_lock( account_id, 'example.com' ).data ``` -------------------------------- ### Run Test Suite Source: https://github.com/dnsimple/dnsimple-python/blob/main/CONTRIBUTING.md Execute the project's test suite locally to verify changes before submitting a pull request. ```shell make test ``` -------------------------------- ### Get Zone File Content Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieves the content of a zone file for a specified domain. ```python # Get zone file zone_file = client.zones.get_zone_file(account_id, 'example.com').data ``` -------------------------------- ### Enable Vanity Name Servers Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/other-services.md Enables vanity name servers for a given account and domain. Requires the account ID and domain name or ID. ```python def enable_vanity_name_servers(self, account_id, domain) ``` ```python name_servers = client.vanity_name_servers.enable_vanity_name_servers( account_id, 'example.com' ).data for ns in name_servers: print(f"Nameserver: {ns.name}") ``` -------------------------------- ### Get Zone Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/zones-service.md Retrieves detailed information for a specific DNS zone within an account. ```APIDOC ## GET /zones/{zone_id} ### Description Retrieves details of a zone. ### Method GET ### Endpoint /zones/{zone_id} ### Parameters #### Path Parameters - **account_id** (int) - Required - The account ID - **zone** (str) - Required - The zone name ### Response #### Success Response (200) - **data** (object) - Zone object ``` -------------------------------- ### Download Certificate Bundle Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Download the certificate bundle, including server, root, chain, and private key. ```python # Download bundle = client.certificates.download_certificate( account_id, 'example.com', cert_id ).data # bundle.server, bundle.root, bundle.chain, bundle.private_key ``` -------------------------------- ### List Available One-Click Services Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/other-services.md Lists all available one-click services that can be applied to domains. Supports sorting and pagination. ```python services = client.services.list_services() for service in services.data: print(f"{service.name}: {service.description}") ``` -------------------------------- ### get_domain_prices Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets registration and renewal prices for a domain. Requires the account ID and the domain name. ```APIDOC ## get_domain_prices ### Description Gets registration and renewal prices for a domain. ### Method `get_domain_prices` ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **domain** (str) - Yes - The domain name ### Response #### Success Response Returns a `Response` object containing a `DomainPrice` object. ### Example ```python prices = client.registrar.get_domain_prices(account_id, 'example.com').data print(f"Registration: ${prices.registration_price}") print(f"Renewal: ${prices.renewal_price}") ``` ``` -------------------------------- ### Define Account ID from Whoami Response Source: https://github.com/dnsimple/dnsimple-python/blob/main/README.md Initializes the DNSimple client and defines the account ID by fetching it from the 'whoami' response. This requires authentication with an Account access token. ```python from dnsimple import Client client = Client(access_token='a1b2c3') account_id = 1010 # You can also fetch it from the whoami response # as long as you authenticate with an Account access token whoami = client.identity.whoami().data account_id = whoami.account.id ``` -------------------------------- ### Get Zone File Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/zones-service.md Retrieves the zone file content in BIND format for a specific zone. ```APIDOC ## GET /zones/{zone_id}/zone_file ### Description Retrieves the zone file (BIND format) for a zone. ### Method GET ### Endpoint /zones/{zone_id}/zone_file ### Parameters #### Path Parameters - **account_id** (int) - Required - The account ID - **zone** (str) - Required - The zone name ### Response #### Success Response (200) - **data** (object) - ZoneFile object containing zone content ``` -------------------------------- ### Accessing DNSimple Services Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md Shows how to access various DNSimple services like identity, domains, and zones after client initialization. This involves retrieving data such as account information and zone details. ```python client = Client(access_token='token') # Get whoami information whoami = client.identity.whoami() account_id = whoami.data.account.id # List domains domains = client.domains.list_domains(account_id) # Get zone details zone = client.zones.get_zone(account_id, 'example.com') ``` -------------------------------- ### Get TLD Extended Attributes Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Retrieves the extended attributes or special requirements for a given TLD. ```APIDOC ## get_tld_extended_attributes ### Description Gets the extended attributes (special requirements) for a TLD. ### Method GET ### Endpoint /v2/tlds/{tld}/extended_attributes ### Parameters #### Path Parameters - **tld** (str) - Yes - The TLD name ### Response #### Success Response (200) - **data** (list[TldExtendedAttribute]) - List of TldExtendedAttribute objects ### Request Example ```python attrs = client.tlds.get_tld_extended_attributes('us') for attr in attrs.data: print(f"{attr.name}: {attr.description}") ``` ``` -------------------------------- ### get_domain_transfer_lock Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets the transfer lock status of a domain. Requires account ID and domain name or ID. ```APIDOC ## get_domain_transfer_lock ### Description Gets the transfer lock status of a domain. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/transfer_lock ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **domain** (int or str) - Yes - Domain name or ID ### Response #### Success Response (200) - **DomainTransferLock** (object) - Transfer lock status ``` -------------------------------- ### Sandbox vs Production Environment Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Configure the client to use the sandbox environment for testing or a custom API base URL. Production is the default. ```python # Production (default) client = Client(access_token='prod_token') ``` ```python # Sandbox client = Client(sandbox=True, access_token='sandbox_token') ``` ```python # Custom URL client = Client(base_url='https://api.custom.example.com', access_token='token') ``` ```python # Use sandbox environment sandbox_client = Client( sandbox=True, access_token='sandbox_token_from_sandbox_account' ) ``` ```python # Override to custom environment custom_client = Client( base_url='https://internal-api.example.com', access_token='internal_token' ) ``` -------------------------------- ### get_whois_privacy Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Gets the WHOIS privacy status of a domain. Requires account ID and domain name or ID. ```APIDOC ## get_whois_privacy ### Description Gets the WHOIS privacy status of a domain. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/whois_privacy ### Parameters #### Path Parameters - **account_id** (int) - Yes - The account ID - **domain** (int or str) - Yes - Domain name or ID ### Response #### Success Response (200) - **WhoisPrivacy** (object) - WHOIS privacy status ``` -------------------------------- ### Client Initialization Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/client.md The Client class is the main entry point for the DNSimple Python client. It handles authentication and request routing. You can initialize it using either an access token or email/password credentials. ```APIDOC ## Client Class ### Description The `Client` class provides access to all API services and handles authentication and request routing. ### Constructor ```python Client(email=None, password=None, access_token=None, base_url=None, sandbox=False, user_agent=None) ``` ### Constructor Parameters #### Parameters - **email** (str) - Optional - DNSimple account email address for basic authentication - **password** (str) - Optional - DNSimple account password for basic authentication - **access_token** (str) - Optional - OAuth 2.0 access token for token-based authentication - **base_url** (str) - Optional - Custom API base URL; overrides sandbox setting - **sandbox** (bool) - Optional - Set to True to use the sandbox environment - **user_agent** (str) - Optional - Custom User-Agent string to append to requests ### Authentication Methods #### Token Authentication (Recommended) ```python client = Client(access_token='your_oauth_token') ``` #### Basic Authentication ```python client = Client(email='user@example.com', password='password') ``` ### Properties #### Accounts - **accounts** (Accounts) - Service for account operations #### Billing - **billing** (Billing) - Service for billing operations #### Certificates - **certificates** (Certificates) - Service for certificate operations #### Contacts - **contacts** (Contacts) - Service for contact operations #### DnsAnalytics - **dns_analytics** (DnsAnalytics) - Service for DNS analytics queries #### Domains - **domains** (Domains) - Service for domain operations #### Identity - **identity** (Identity) - Service for identity operations #### Oauth - **oauth** (Oauth) - Service for OAuth operations #### Registrar - **registrar** (Registrar) - Service for domain registration and transfer #### Services - **services** (Services) - Service for domain services #### Templates - **templates** (Templates) - Service for DNS template operations #### Tlds - **tlds** (Tlds) - Service for TLD information #### VanityNameServers - **vanity_name_servers** (VanityNameServers) - Service for vanity name servers #### Webhooks - **webhooks** (Webhooks) - Service for webhook management #### Zones - **zones** (Zones) - Service for DNS zone operations #### base_url - **base_url** (str) - The base URL for API requests #### api_version - **api_version** (str) - The current API version (v2) #### user_agent - **user_agent** (str) - The User-Agent header string #### headers - **headers** (dict) - HTTP headers for requests ``` -------------------------------- ### Get Email Forward Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/domains-service.md Retrieves a specific email forward rule by its ID for a given domain and account. ```python def get_email_forward(self, account_id, domain, email_forward_id) ``` -------------------------------- ### Register a New Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Initiates the registration process for a new domain, specifying registrant details and options like auto-renewal and WHOIS privacy. ```python # Register from dnsimple.struct import DomainRegistrationRequest request = DomainRegistrationRequest( registrant_id=contact_id, auto_renew=True, whois_privacy=True ) registration = client.registrar.register_domain( account_id, 'example.com', request ).data ``` -------------------------------- ### Register Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/INDEX.md Initiate the process of registering a new domain name. This operation requires the account ID, domain name, and specific request parameters. ```python registration = client.registrar.register_domain( account_id, 'example.com', request ).data ``` -------------------------------- ### Create Template Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Create a new template. Requires a `Template` object with name and SID. ```python # Create from dnsimple.struct import Template template = Template({'name': 'My Template', 'sid': 'mytemplate'}) created = client.templates.create_template(account_id, template).data ``` -------------------------------- ### Get a Specific Zone Record Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Retrieves details for a single DNS record within a zone using its ID. ```python # Records - Get record = client.zones.get_record( account_id, 'example.com', record_id ).data ``` -------------------------------- ### get_certificate_private_key Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/certificates-service.md Gets the PEM-encoded certificate private key. This method specifically retrieves the private key associated with a certificate. ```APIDOC ## get_certificate_private_key ### Description Gets the PEM-encoded certificate private key. This method specifically retrieves the private key associated with a certificate. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/certificates/{certificate_id}/private_key ### Parameters #### Path Parameters - **account_id** (int) - Required - The account ID - **domain** (int or str) - Required - Domain name or ID - **certificate_id** (int) - Required - The certificate ID ### Response #### Success Response (200) - **data** (object) - CertificateBundle object containing private key - **private_key** (str) - PEM-encoded private key ### Response Example { "data": { "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" } } ``` -------------------------------- ### Get Contact Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/accounts-billing-contacts.md Retrieves a specific contact by its ID from a given account. Use this to fetch details of an existing contact. ```python contact = client.contacts.get_contact(account_id, contact_id).data ``` -------------------------------- ### Create Domain Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Creates a new domain in the DNSimple account. ```APIDOC ## Create Domain ### Description Creates a new domain in the DNSimple account. ### Method POST ### Endpoint `/v2/domains` ### Parameters #### Query Parameters - **account_id** (integer) - Required - The ID of the account. #### Request Body - **domain** (object) - Required - The domain object containing the name. - **name** (string) - Required - The name of the domain to create (e.g., 'newdomain.com'). ### Response #### Success Response (201) - **data** (object) - The newly created Domain object. ### Request Example ```json { "domain": { "name": "newdomain.com" } } ``` ### Response Example ```json { "data": { "id": 2, "name": "newdomain.com", "unicode_name": "newdomain.com", "bronze_order_id": null, "premium_price_starts_at": null, "created_at": "2023-01-02T12:00:00Z", "updated_at": "2023-01-02T12:00:00Z" } } ``` ``` -------------------------------- ### Environment Selection: Sandbox Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Configures the client to use the sandbox DNSimple API endpoint for testing. ```APIDOC ### Sandbox #### Description Configures the client to use the sandbox DNSimple API endpoint for testing. #### Usage Initialize the `Client` with `sandbox=True` and your sandbox access token. #### Example ```python from dnsimple import Client client = Client(sandbox=True, access_token='YOUR_SANDBOX_TOKEN') # Uses: https://api.sandbox.dnsimple.com ``` **Important:** Sandbox and production tokens are different. Create separate accounts for testing. ``` -------------------------------- ### List DNSimple Templates Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Lists all available DNS templates within a specified account. Supports sorting and pagination. ```python templates = client.templates.list_templates(account_id) for template in templates.data: print(f"{template.name}: {template.sid}") ``` -------------------------------- ### List Webhooks Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/templates-tlds-webhooks.md Lists all configured webhooks for a given account. The account ID is required, and sorting is optional. ```python webhooks = client.webhooks.list_webhooks(account_id) for webhook in webhooks.data: print(f"URL: {webhook.url}") ``` -------------------------------- ### Get Delegation Signer Record Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/domains-service.md Retrieves a specific delegation signer (DS) record by its ID for a given domain and account. ```python def get_delegation_signer_record(self, account_id, domain, ds_record_id) ``` -------------------------------- ### Get Versioned API URL Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Construct a URL for a specific API version. This is useful for ensuring compatibility with different API versions. ```python client = Client(access_token='token') # Versioned URL url = client.versioned('/whoami') # https://api.dnsimple.com/v2/whoami ``` -------------------------------- ### Create Signed Git Tag Source: https://github.com/dnsimple/dnsimple-python/blob/main/RELEASING.md Create a GPG-signed tag for the release version and push it to the remote repository. ```shell git tag -a v$VERSION -s -m "Release $VERSION" git push origin --tags ``` -------------------------------- ### Clone Repository Source: https://github.com/dnsimple/dnsimple-python/blob/main/CONTRIBUTING.md Clone the DNSimple Python library repository and navigate into the project directory. ```shell git clone git@github.com:dnsimple/dnsimple-python.git cd dnsimple-python ``` -------------------------------- ### Get Zone Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/zones-service.md Retrieves detailed information about a specific zone, including its records. Requires account ID and zone name. ```python zone = client.zones.get_zone(account_id, 'example.com').data print(f"Zone {zone.name} has {len(zone.records)} records") ``` -------------------------------- ### Enable and Disable Vanity Name Servers Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/quick-reference.md Manage vanity name servers for a domain. Enable to set them up, and disable to revert to default. ```python # Enable nameservers = client.vanity_name_servers.enable_vanity_name_servers( account_id, 'example.com' ).data ``` ```python # Disable client.vanity_name_servers.disable_vanity_name_servers( account_id, 'example.com' ) ``` -------------------------------- ### Handle DNSimple Exceptions Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Demonstrates how to catch and handle exceptions raised by the DNSimple client. ```APIDOC ## Error Handling ### Description Demonstrates how to catch and handle exceptions raised by the DNSimple client. ### Usage Wrap API calls in a `try...except DNSimpleException` block to gracefully handle errors. ### Example ```python from dnsimple import Client, DNSimpleException # Assuming 'client' is an initialized DNSimple client instance # and 'account_id' is a valid account ID try: domain = client.domains.get_domain(account_id, 'example.com').data except DNSimpleException as e: print(f"Error {e.status}: {e.message}") if e.attribute_errors: for field, errors in e.attribute_errors.items(): print(f" {field}: {errors}") ``` ### Exception Attributes - **status** (integer): The HTTP status code of the error. - **message** (string): A human-readable error message. - **attribute_errors** (dict): A dictionary containing specific field validation errors, if any. ``` -------------------------------- ### get_certificate Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/certificates-service.md Gets details of a specific certificate. This method retrieves detailed information about a single certificate identified by its ID, for a given domain and account. ```APIDOC ## get_certificate ### Description Gets details of a specific certificate. This method retrieves detailed information about a single certificate identified by its ID, for a given domain and account. ### Method GET ### Endpoint /accounts/{account_id}/domains/{domain}/certificates/{certificate_id} ### Parameters #### Path Parameters - **account_id** (int) - Required - The account ID - **domain** (int or str) - Required - Domain name or ID - **certificate_id** (int) - Required - The certificate ID ### Response #### Success Response (200) - **data** (object) - Certificate object ### Response Example { "data": { "id": 123, "account_id": 1, "domain_id": 1, "common_name": "example.com", "state": "issued", "expires_on": "2023-12-31", "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } } ``` -------------------------------- ### Python Identity Class Constructor Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/identity-service.md Initializes the Identity service with a DNSimple API client instance. ```python class Identity(object): def __init__(self, client) ``` -------------------------------- ### Get Zone Record Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/zones-service.md Retrieves a specific zone record using its ID. Requires account ID, zone name, and the record ID. ```python record = client.zones.get_record(account_id, 'example.com', 12345).data ``` -------------------------------- ### Token Authentication Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/configuration.md Configure the client using an OAuth 2.0 access token. This is the recommended authentication method. ```python client = Client(access_token='your_oauth_token') ``` ```python client = Client(access_token='a1b2c3d4e5f6') ``` -------------------------------- ### Get Domain Renewal Details Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/api-reference/registrar-service.md Retrieves details of an existing domain renewal. Requires account ID, domain name, and domain renewal ID. ```python def get_domain_renewal(self, account_id, domain, domain_renewal) ``` -------------------------------- ### Environment Selection: Production Source: https://github.com/dnsimple/dnsimple-python/blob/main/_autodocs/README.md Configures the client to use the production DNSimple API endpoint. ```APIDOC ## Environment Selection ### Production #### Description Configures the client to use the production DNSimple API endpoint. #### Usage Initialize the `Client` with your production access token. The client defaults to the production environment. #### Example ```python from dnsimple import Client client = Client(access_token='YOUR_PRODUCTION_TOKEN') # Uses: https://api.dnsimple.com ``` ```