Drupal API Client

Tools to interact with the Druapl REST API

source

DrupalAPIClient

 DrupalAPIClient (origin, username, password)

*A client for interacting with a Drupal JSON:API endpoint, providing functionalities to fetch node IDs (nids) based on UUIDs and to delete nodes.

Attributes: origin (str): The base URL for the Drupal site. auth (HTTPBasicAuth): Authentication credentials for the site. session (requests.Session): A requests session for making API calls.*


source

DrupalAPIClient.__init__

 DrupalAPIClient.__init__ (origin, username, password)

*Initializes the DrupalAPIClient with the necessary credentials and session.

Args: origin (str): The base URL for the Drupal JSON:API. username (str): The username for authentication. password (str): The password for authentication.*


source

DrupalAPIClient.get_nids

 DrupalAPIClient.get_nids (uuids, field_name)

*Retrieves node IDs (nids) for given UUIDs.

Args: uuids (list of str): List of UUIDs to query for. field_name (str): The field name to match UUIDs against.

Returns: dict: A dictionary mapping field item IDs to node IDs.*


source

DrupalAPIClient.delete

 DrupalAPIClient.delete (nid)

*Deletes a node based on its node ID.

Args: nid (int): The node ID of the node to be deleted.

Returns: requests.Response: The response from the API after attempting to delete the node.*


source

DrupalAPIClient.delete_from_nids

 DrupalAPIClient.delete_from_nids (nids)

*Attempts to delete nodes based on a list of node IDs.

Args: nids (dict): A dictionary mapping UUIDs to node IDs.

Returns: list of dict: A list of dictionaries containing error information for each failed deletion.*


source

DrupalAPIClient.load_credentials

 DrupalAPIClient.load_credentials (file_path)

*Loads credentials from a .env file.

Args: file_path (str): The path to the .env file.

Returns: tuple: A tuple containing the URL, username, and password.*