Installing the Protegrity Anonymization Python SDK

Complete the steps provided in this section to install the Protegrity Anonymization Python SDK in your environment. Protegrity Anonymization communicates with the Protegrity Anonymization REST API to anonymize data.

Prerequisites for deploying Protegrity Anonymization

Protegrity Anonymization Python SDK is provided as a wheel file that may be installed using pip. Additionally, ensure that the following prerequisites are met:

  • Python 3.12 is installed.

  • Protegrity Anonymization REST API is installed.

    For more information about the installation steps, refer to the section Installing the Protegrity Anonymization REST API.

    Note: If administrator has not updated the DNS entry for ANON REST API service, then map the hostname with the IP address of Anon Service in the hosts file of the system.

Installing Protegrity Anonymization Python

After having installed Protegrity Anonymization via one of the several installation methods, you may now leverage the provided Python SDK, provided as a wheel file, to interact with the product using Python. Install the Wheel file provided using pip to use the Protegrity Anonymization SDK:

  1. Install Python 3.12 in the environment where you mapped the IP address of Ingress to anon.protegrity.com.

  2. Obtain the whl file via the instructions given on the several installation methods of Protegrity Anonymization.

  3. Instal the whl file via

    pip install anonsdk_dir-1.3.0-py3-none-any.whl
    
  4. You can now import and use the Protegrity Anonymization SDK using Python in your environment.

  5. Refer to the Sample Requests for Protegrity Anonymization section for code snippets.

Optional - Enabling custom certificates from SDK

Protegrity Anonymization SDK uses certificates for secure communication with the client. You can use the certificates provided by Protegrity or use your own certificates. Complete the configurations provided in this section to use your custom certificates with the SDK.

Ensure that the certificates and keys are in the .pem format.

Note: If you want to use the default Protegrity certificates for the Protegrity Anonymization SDK, then skip the steps to set up the certificates provided in this section.

  1. Complete the configuration on the machine where the Protegrity Anonymization SDK SDK will be used.

    1. Create a directory that is named .pty_anon in the directory from where the SDK will run.

    2. Create certs in the .pty_anon directory.

    3. Create generated-certs in the certs directory.

    4. Create ca-cert in the generated-certs directory.

    5. Create cert in the generated-certs directory.

    6. Create key in the generated-certs directory.

    7. Copy the client certificates and key to the respective directories in the .pty_anon/certs/generated-certs directory.

      The directory structure will be as follows:

      .pty_anon/certs/generated-certs/ca-cert/CA-xyz-cert.pem
      .pty_anon/certs/generated-certs/key/xyz-key.pem
      .pty_anon/certs/generated-certs/cert/xyz-cert.pem
      

      Make sure that you are using valid certificates.

    8. Create a config.yaml file in the .pty_anon directory with the following Ingress Endpoint defined under CLUSTER_ENDPOINT. The BUCKET_NAME, ACCESS_KEY, and SECRET_KEY are the default details that are used to communicate with the MinIO container for reading and writing files from SDK.

      STORAGE:
        CLUSTER_ENDPOINT: https://**anon.protegrity.com**/
        BUCKET_NAME: 'anonstorage'
        ACCESS_KEY: 'anonuser'
        SECRET_KEY: 'protegrity'
      

      Note: Ensure that you replace anon.protegrity.com with your host name specified in values.yaml. Also, ensure that you update the default credentials if you have used your own secret.

  2. Updating the hosts file.

    1. Log in to the machine where Protegrity Anonymization SDK will be used.

    2. Update the hosts file with the following code according to your setup.

      For Kubernetes:

      <LB-IP of Ingress> <host defined for ingress in values.yaml>
      

      For Docker:

      <LB-IP of Ingress> <server_name defined in nginx.conf>
      

      For example,

      XX.XX.XX.XX anon.protegrity.com
      

The URL can now be used while creating the Connection Object in the SDK, such as, conn = anonsdk.Connection("https://anon.protegrity.com/").


Last modified : June 27, 2025