## Deprecated Deployment Method

This documentation covers the **legacy Request Manager Agent deployment** that supported ingress. This deployment method has been deprecated.

**New deployments should use the [simplified egress-only Request Manager Agent](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/request-manager-agent/overview)**, which eliminates the need for public internet exposure.

Automate the fulfillment of data subject access, deletion, opt-out, and identifier retrieval requests in Oracle.

## Setup Instructions

In the setup process below, you will create and configure a [Connection](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/legacy-solutions/request-manager-agent-legacy/configuration/environment-variables#connection-schema) object with a Oracle [ConnectorType](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/legacy-solutions/request-manager-agent-legacy/configuration/environment-variables#connectortype) that is used to instantiate a connection. The agent configuration will be updated by placing the connection object into the [DataGrailAgentConfig](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/legacy-solutions/request-manager-agent-legacy/configuration/environment-variables#datagrailagentconfig-schema)`connections` array.

### Example Connection Object

```js
{
  "name": "Contacts DB",
  "uuid": "d4f27472-621d-41f7-bc0f-a6abbffe6c97",
  "capabilities": ["privacy/access", "privacy/delete", "privacy/optout", "privacy/identifiers"],
  "mode": "live",
  "connector_type": "Oracle",
  "queries": {
    "access": ["CALL sp_dsr_access(:email);"] ,
    "delete": ["CALL sp_dsr_delete(:email);"] ,
    "optout": ["CALL sp_dsr_optout(:email);"] ,
    "identifiers": {
      "phone_number": ["CALL sp_dsr_get_phone(:email);"]
    }
  },
  "credentials_location": "arn:aws:secretsmanager:Region:AccountId:secret:datagrail-rm-agent-oracle"
}
```

### Prerequisites

Before performing the steps below, ensure the following:

- Request Manager Agent is [deployed and connected](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/request-manager-agent/quick-start) in DataGrail.
- Network is configured to allow the Agent to connect with the Oracle instance.

### Create Request Logic

In this step, create the request logic to be executed in your system for a specific [request type](https://docs.datagrail.io/docs/request-manager/request-processing/overview#request-lifecycle).

- Access
- Delete
- Opt-Out
- Identifier

When a Data Subject requests to access the personal information that your company maintains on them, they will submit an [Access request](https://docs.datagrail.io/docs/request-manager/request-processing/privacy-right/access).

Your request logic should return all applicable information found in this system.

### Example Access Query

```sql
SELECT * FROM contacts WHERE email = 'subject@domain.com';
```

### Using Stored Procedures

For ease of maintainability and readability, using stored procedures is recommended instead of individual queries. When you need to modify the underlying queries, there will be no need to modify the Agent configuration nor restart the Agent.

### Example Stored Procedure

```sql
CALL sp_dsr_access('subject@domain.com');
```

When a Data Subject wants their personal data removed from your systems, they will submit a [Deletion request](https://docs.datagrail.io/docs/request-manager/request-processing/privacy-right/deletion).
Your request logic should delete or anonymize the Subject's information stored in this system.

### Example Deletion Query

```sql
DELETE FROM contacts WHERE email = 'subject@domain.com';
```

### Using Stored Procedures

### Example Stored Procedure

```sql
CALL sp_dsr_delete('subject@domain.com');
```

When a Data Subject wants to opt out of the Sale of their Personal Information to third parties, they will submit an [Opt-Out request](https://docs.datagrail.io/docs/request-manager/opt-out-requests).
Your request logic should perform the necessary action to honor this request (e.g., setting a flag).

### Example Opt Out Query

```sql
UPDATE contacts SET optout = true WHERE email = 'subject@domain.com';
```

### Using Stored Procedures

### Example Stored Procedure

```sql
CALL sp_dsr_optout('subject@domain.com');
```

Some third-party integrations use identifiers other than an email to process a request (e.g., Phone Number), and the Agent can be used to automate [identifier retrieval](https://docs.datagrail.io/docs/request-manager/settings/multi-id#extracted-identifiers).
Your request logic should return the identifier value stored in this system.

### Example Identifier Retrieval Query

```sql
SELECT phone_number FROM contacts WHERE email = 'subject@domain.com';
```

### Using Stored Procedures

### Example Stored Procedure

```sql
CALL sp_dsr_get_phone('subject@domain.com');
```

### Create and Store Credentials

1. In **Oracle**, create a new user for the agent. Only grant the minimum necessary permissions for executing the request.

2. Configure the following JSON key-value pairs:

```js
{
     "user": "<agent user>",
     "password": "<agent password>",
     "server": "<server domain name or IP address>",
     "port": "<port, e.g. 1521>",
     "database": "<database name>"
}
```

3. Store the JSON value in your vault with an entry name like `datagrail-rm-agent-oracle`.

4. Ensure that the agent is configured to retrieve the value of this vault entry.

### Create Connection Object

To define the interactions between the agent and the internal system, configure the [Connection](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/legacy-solutions/request-manager-agent-legacy/configuration/environment-variables#connection-schema) object.

1. Using the empty connection object below, enter a connection **name** and **uuid** (v4).

```js
{
     "name": "",
     "uuid": "",
     "capabilities": [],
     "mode": "",
     "connector_type": "Oracle",
     "queries": {
       "access": [],
       "delete": [],
       "optout": [],
       "identifiers": {}
     },
     "credentials_location": ""
}
```

2. Set the [**capabilities**](https://docs.datagrail.io/docs/integrations/internal-systems-integrations/legacy-solutions/request-manager-agent-legacy/configuration/environment-variables#capability) that correspond to your request logic.
3. Under **queries**, add your **request logic** as a string to the corresponding request type.
4. The `queries` object allows query strings to be dynamically formatted with identifiers.
Identifiers are passed _individually_ to queries and are bound to the variables in the operation.
Replace any **static** identifier in the request logic using [named parameter formatting](https://peps.python.org/pep-0249/#paramstyle) (e.g., `...WHERE email=:email`).

### Parameter Binding Example

```sql
   -- BEFORE
CALL sp_dsr_access('subject@domain.com');
   -- AFTER
CALL sp_dsr_access(:email);
```

5. Set the **credentials_location** value to the location of the secret created above (e.g., AWS ARN).

### Example Connection Objects

After following the steps above, the resulting connection object should look similar to these examples.

**Example Connection Object with Access Capability**

```js
{
  "name": "Contacts DB",
  "uuid": "d4f27472-621d-41f7-bc0f-a6abbffe6c97",
  "capabilities": ["privacy/access"],
  "mode": "live",
  "connector_type": "Oracle",
  "queries": {
    "access": ["CALL sp_dsr_access(:email);"] ,
    "delete": [],
    "optout": [],
    "identifiers": {}
  },
  "credentials_location": "arn:aws:secretsmanager:Region:AccountId:secret:datagrail-rm-agent-oracle"
}
```

**Example Connection Object with Deletion Capability**

```js
{
  "name": "Contacts DB",
  "uuid": "d4f27472-621d-41f7-bc0f-a6abbffe6c97",
  "capabilities": ["privacy/delete"],
  "mode": "live",
  "connector_type": "Oracle",
  "queries": {
    "access": [],
    "delete": ["CALL sp_dsr_delete(:email);"] ,
    "optout": [],
    "identifiers": {}
  },
  "credentials_location": "arn:aws:secretsmanager:Region:AccountId:secret:datagrail-rm-agent-oracle"
}
```

**Example Connection Object with Opt Out Capability**

```js
{
  "name": "Contacts DB",
  "uuid": "d4f27472-621d-41f7-bc0f-a6abbffe6c97",
  "capabilities": ["privacy/optout"],
  "mode": "live",
  "connector_type": "Oracle",
  "queries": {
    "access": [],
    "delete": [],
    "optout": ["CALL sp_dsr_optout(:email);"] ,
    "identifiers": {}
  },
  "credentials_location": "arn:aws:secretsmanager:Region:AccountId:secret:datagrail-rm-agent-oracle"
}
```

**Example Connection Object with Identifiers Retrieval Capability**

```js
{
  "name": "Contacts DB",
  "uuid": "d4f27472-621d-41f7-bc0f-a6abbffe6c97",
  "capabilities": ["privacy/identifiers"],
  "mode": "live",
  "connector_type": "Oracle",
  "queries": {
    "access": [],
    "delete": [],
    "optout": [],
    "identifiers": {
      "phone_number": ["CALL sp_dsr_get_phone(:email);"]
    }
  },
  "credentials_location": "arn:aws:secretsmanager:Region:AccountId:secret:datagrail-rm-agent-oracle"
}
```

**Example Connection with Multiple Capabilities**

### Update and Restart Agent

In this section, you will integrate the internal system with DataGrail by updating the agent environment variable and restarting the agent to apply the changes.

1. In the `DATAGRAIL_AGENT_CONFIG` environment variable, add the new connection object to the `connections` array.
2. **Save** the environment variable, and **restart** the agent service to apply the changes.
3. After the restart, confirm that the agent service is healthy, and the logs contain no errors.
4. In DataGrail, update the integration by navigating to **Integrations** and select the agent integration.
5. Select **Edit Integration**, enter the **Client Secret**, and then select **Save Changes**.
6. To view the new connection, navigate back to **Integrations** and locate it in the list.

### Processing Your First Request

Now that you've successfully added this connection to DataGrail, try it out by [submitting](https://docs.datagrail.io/docs/request-manager/request-intake/privacy-request-center) and [processing](https://docs.datagrail.io/docs/request-manager/request-processing/overview) a request.

### Need help?

If you have any questions, please reach out to your dedicated Account Manager or contact us at [support@datagrail.io](mailto:support@datagrail.io).

*Disclaimer: The information contained in this message does not constitute as legal advice. We would advise seeking professional counsel before acting on or interpreting any material.*
