### GET /zonefiles/list Source: https://github.com/mdiez/pyczds/blob/main/README.md Retrieves a list of download URLs for all zone files accessible under the authenticated account. ```APIDOC ## GET /zonefiles/list ### Description This endpoint retrieves the download links for all zone files that the authenticated account is authorized to access. It returns a list of URLs. ### Method GET ### Endpoint `/zonefiles/list` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python zonefile_urls = c.get_zonefiles_list() print(zonefile_urls) ``` ### Response #### Success Response (200) - **list**: A list of strings, where each string is a URL to a zone file. #### Response Example ```json [ "https://czds-download-api.icann.org/czds/downloads/net.zone", "https://czds-download-api.icann.org/czds/downloads/com.zone" ] ``` ``` -------------------------------- ### GET /zonefiles/download/{zonefile_url} Source: https://github.com/mdiez/pyczds/blob/main/README.md Downloads a specified zone file. The file is saved to the current directory with a `.gz` extension. ```APIDOC ## GET /zonefiles/download/{zonefile_url} ### Description This endpoint downloads a specified zone file. The file is saved to the current directory, typically with a `.gz` extension. ### Method GET ### Endpoint `/zonefiles/download/{zonefile_url}` ### Parameters #### Path Parameters - **zonefile_url** (string) - Required - The URL of the zone file to download. #### Query Parameters None #### Request Body None ### Request Example ```python c.get_zonefile('https://czds-download-api.icann.org/czds/downloads/com.zone') # This will download the file to the current directory as 'com.txt.gz' ``` ### Response #### Success Response (200) - **file**: The downloaded zone file content. #### Response Example None (the response is saved directly to a file). ``` -------------------------------- ### Download Zone File with pyczds Source: https://github.com/mdiez/pyczds/blob/main/README.md Shows how to download a specified zone file using the `get_zonefile` method. Optional parameters allow specifying the download directory and filename. ```python c.get_zonefile('https://czds-download-api.icann.org/czds/downloads/vision.zone', download_dir='zonefiles/', filename='vision_zonefile') ``` -------------------------------- ### User Authentication and Client Instantiation Source: https://github.com/mdiez/pyczds/blob/main/README.md This section details how to instantiate the CZDSClient, which handles authentication with the CZDS API. The client automatically manages authentication tokens and renews them upon expiration. ```APIDOC ## Instantiate a client ### Description Use the following code to create a new `CZDSClient` object. The client handles authentication with the API transparently, retaining the acquired token for subsequent requests and automatically renewing it when it expires. ### Method `CZDSClient(username, password)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from pyczds.client import CZDSClient # replace username and password with actual credentials c = CZDSClient(username, password) ``` ### Response #### Success Response (200) - **CZDSClient object**: An authenticated client instance. #### Response Example None (client instantiation does not return a value, but an object is created). ``` -------------------------------- ### Compare Zone File Headers with Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Demonstrates how to compare 'last-modified' timestamps of zone files to determine if an update has occurred. It assumes parsed header information is available. ```python headers_old['parsed']['last-modified'] < headers_new['parsed']['last_modified'] # True ``` -------------------------------- ### Set Credentials for pyczds Tests Source: https://github.com/mdiez/pyczds/blob/main/README.md Provides a code snippet from the test suite that shows where to input CZDS website username and password for running the tests. It highlights that these tests do not modify any data. ```python class TestPyCZDS(unittest.TestCase): def setUp(self): # In order to run these tests, enter your valid username and password for the CZDS website here. # Please note that these tests do not change any data. # TODO PASTE USERNAME AND PASSWORD HERE username = '' password = '' # END TODO ``` -------------------------------- ### Instantiate CZDS Client in Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Creates a new CZDSClient object to interact with the CZDS API. Replace 'username' and 'password' with actual user credentials. This client handles API authentication transparently, including token renewal. ```python from pyczds.client import CZDSClient # replace username and password with actual credentials c = CZDSClient(username, password) ``` -------------------------------- ### Increase Logging Level for Troubleshooting Source: https://github.com/mdiez/pyczds/blob/main/README.md Illustrates how to set the logging level to 'DEBUG' to aid in troubleshooting issues with the pyczds client. This involves importing the `logging` module and configuring the logger. ```python import logging from pyczds import client logger = logging.getLogger() logger.setLevel(logging.DEBUG) # Run the problematic command c = client.CZDSClient(username, password) ``` -------------------------------- ### HEAD /zonefiles/download/{zonefile_url} Source: https://github.com/mdiez/pyczds/blob/main/README.md Retrieves the headers for a specified zone file, including metadata like last modified timestamp and file size. ```APIDOC ## HEAD /zonefiles/download/{zonefile_url} ### Description This endpoint retrieves the headers for a specified zone file. The headers contain metadata such as the last modified timestamp and the file's size. It returns a dictionary-like object. ### Method HEAD ### Endpoint `/zonefiles/download/{zonefile_url}` ### Parameters #### Path Parameters - **zonefile_url** (string) - Required - The URL of the zone file to retrieve headers for. #### Query Parameters None #### Request Body None ### Request Example ```python com_zonefile_headers = c.head_zonefile('https://czds-download-api.icann.org/czds/downloads/com.zone') print(com_zonefile_headers) ``` ### Response #### Success Response (200) - **CaseInsensitiveDict**: A dictionary containing HTTP headers, including a `parsed` sub-dictionary with type-parsed metadata. #### Response Example ```json { "Date": "Fri, 16 Dec 2022 19:42:58 GMT", "Last-Modified": "Fri, 16 Dec 2022 01:29:08 GMT", "Content-Disposition": "attachment;filename=com.txt.gz", "Content-Length": "1234567", "parsed": { "last-modified": "2022-12-16T01:29:08+00:00", "content-length": 1234567, "filename": "com.txt.gz" } } ``` ``` -------------------------------- ### Retrieve Zone File URLs in Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Fetches a list of download URLs for all zone files that the authenticated account is authorized to access. The function returns a list of strings, where each string is a URL. ```python zonefile_urls = c.get_zonefiles_list() print(zonefile_urls) ``` -------------------------------- ### Select Specific Zone File URL in Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Iterates through a list of zone file URLs to find and select the URL for a specific zone file, such as '.com.zone'. It uses a generator expression with `next()` to efficiently find the first matching URL or return `None` if not found. ```python com_zonefile_url = next((url for url in zonefile_urls if "com.zone" in url), None) ``` -------------------------------- ### Download Zone File in Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Downloads a specified zone file from its URL. The downloaded file is saved in the current directory with a name derived from the URL, typically ending in '.txt.gz'. This function implicitly handles the HTTP request and file saving. ```python c.get_zonefile(com_zonefile_url) ``` -------------------------------- ### Inspect Zone File Headers in Python Source: https://github.com/mdiez/pyczds/blob/main/README.md Retrieves the headers for a specified zone file URL. The headers contain metadata like the last modified timestamp and file size. It returns a dictionary, including a 'parsed' sub-dictionary with commonly used headers converted to appropriate data types. ```python from datetime import datetime, timezone com_zonefile_headers = c.head_zonefile(com_zonefile_url) # Example: Check if the zonefile was last modified today if com_zonefile_headers and 'parsed' in com_zonefile_headers and 'last-modified' in com_zonefile_headers['parsed']: is_modified_today = com_zonefile_headers['parsed']['last-modified'].date() == datetime.now(timezone.utc).date() print(f"Zone file modified today: {is_modified_today}") else: print("Could not retrieve or parse headers.") # Example: Print raw headers # print(c.head_zonefile('https://czds-download-api.icann.org/czds/downloads/vision.zone')) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.