Installing the Protegrity Anonymization Python SDK
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:
Install Python 3.12 in the environment where you mapped the IP address of Ingress to anon.protegrity.com.
Obtain the whl file via the instructions given on the several installation methods of Protegrity Anonymization.
Instal the whl file via
pip install anonsdk_dir-1.3.0-py3-none-any.whlYou can now import and use the Protegrity Anonymization SDK using Python in your environment.
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.
Complete the configuration on the machine where the Protegrity Anonymization SDK SDK will be used.
Create a directory that is named .pty_anon in the directory from where the SDK will run.
Create certs in the .pty_anon directory.
Create generated-certs in the certs directory.
Create ca-cert in the generated-certs directory.
Create cert in the generated-certs directory.
Create key in the generated-certs directory.
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.pemMake sure that you are using valid certificates.
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.
Updating the hosts file.
Log in to the machine where Protegrity Anonymization SDK will be used.
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/").
Feedback
Was this page helpful?