# Structure of a generator assignment

In the Tonic Structural API, a generator assignment is referred to as a replacement.

A group of replacements makes up the message body for the response to get generator configuration details, and a request to update generator configuration details.

For details and examples of replacements for each Structural generator, go to [generator-api-reference](https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/generator-api-reference "mention").

## Replacement structure <a href="#tonic-api-generator-replacement-structure" id="tonic-api-generator-replacement-structure"></a>

At a very high level, the structure of a replacement object is:

<figure><img src="https://3378426797-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSQCLFQ4bslJ-HYc8c3%2Fuploads%2FGlVR9GygRygPiq92EFez%2FReplacementStructure.png?alt=media&#x26;token=a7c76c14-9370-4eb6-a425-f5470b255a05" alt=""><figcaption><p>Diagram that shows the overall outline of the replacement structure</p></figcaption></figure>

Each [`Replacement`](https://app.tonic.ai/apidocs/index.html#/models/Replacement) object contains:

* The name of the replacement.
* The schema and table where the configured columns are located.
* Link objects for generator and sub-generator configurations.
* Columns to use for partitioning.

## Link object structure

Within a replacement, each [link](https://app.tonic.ai/apidocs/index.html#/models/Link) object contains the generator or sub-generator configuration for a single column.

For `fallBackLinks`, the link object contains the generator configuration for the fallback generator.

{% code overflow="wrap" %}

```json
{
  "schema": "string",
  "table": "string",
  "column": "string",
  "path": "string",  //JSON fields only
  "dataType": "string", //MongoDB, Amazon DynamoDB, and JSON fields only
  "metadata": {
    "presetId": "string",
    "generatorId": "string",
    "isConsistent": boolean,
    "consistencyColumn": "string",
    "isDifferentiallyPrivate": boolean,
    //Other generator configuration fields
    "encryptionProcessor": "x-on", //To use configured Structural data encryption
    "customValueProcessor": "string", //If custom value processor applied
    "pathExpression": "string", //Path expression for a composite generator
    "subGeneratorMetadata": {
      "presetId": "string",
      "generatorId": "string",
      "customValueProcessor": "string" //If custom value processor applied to the sub-generator
      //Other generator configuration fields for the sub-generator
    }
  }
}
```

{% endcode %}

## Column identification

In the link object, to identify the column, you always provide the schema name, table name, and column name.

The `schema` and `table` values in the link object must match the `schema` and `table` values for the replacement.

Note that even if there isn't a schema (for example, for the Databricks data connector), you must still provide an empty value for `schema`.

### Identifying MongoDB and Amazon DynamoDB fields <a href="#fields-mongodb-dynamodb" id="fields-mongodb-dynamodb"></a>

For MongoDB and Amazon DynamoDB fields, in addition to the schema, table, and column, you use the `dataType` field to provide the data type.

### Identifying a field in a JSON column <a href="#fields-json" id="fields-json"></a>

For a JSON column, in the Structural application, you can [use **Document View** to assign a generator to individual JSON fields](https://docs.tonic.ai/app/generation/working-with-document-based-data/json-document-view).

To use the API to assign a generator to a JSON field, in addition to the schema, table, and column:

* You use the `path` field to provide the path to the field.
* You use the `dataType` field to provide the field data type.

## Metadata <a href="#generator-link-metadata" id="generator-link-metadata"></a>

In the link object, the `metadata` object identifies the generator and generator preset, and provides the generator configuration.

### Generator and preset identification

In the `metadata` object, `presetId` identifies the applied [generator preset](https://docs.tonic.ai/app/generation/generators-assign-config/generator-presets) configuration. `generatorId` identifies the type of generator. `generatorId` must match the generator type for `presetId`.

Generator presets require an Enterprise license. For Basic and Professional licenses, only `generatorId` is provided.

For the built-in preset for a generator, `presetId` and `generatorId` are the same. If during configuration the generator preset specified by `presetId` is not available - for example, if the generator preset was deleted - then the baseline version of the generator specified by `generatorId` is applied.

### Generator configuration

For the generator configuration, `metadata` contains fields from [`BaseMetadata`](https://app.tonic.ai/apidocs/index.html#/models/BaseMetadata), which provides the fields to configure consistency and differential privacy.

`metadata` can also contain additional objects and fields from generator-specific metadata objects.

### Structural data encryption

In the `metadata` object, if [Structural data encryption](https://docs.tonic.ai/app/generation/generators-assign-config/generators-data-encryption-config) is enabled for the instance, then to indicate to use the configured data encryption, set `encryptionProcessor` to `x-on`.

### Custom value processors

In the `metadata` object, you can specify a [custom value processor](https://docs.tonic.ai/app/generation/generators-assign-config/custom-value-processors) to apply to the generator (`customValueProcessor`).

### Sub-generator configuration <a href="#link-metadata-subgeneratormetadata" id="link-metadata-subgeneratormetadata"></a>

In the `metadata` object, for composite generators other than Array Regex, Regex, or Conditional, `pathExpression` identifies the value within the column to apply a sub-generator to.

The `subGeneratorMetadata` object then identifies and configures the generator to apply to that value:

```json
"pathExpression": "string",
"subGeneratorMetadata": {
  "presetId": "string",
  "generatorId": "string",
  "customValueProcessor": "string"
   //Other generator configuration fields for the sub-generator
}
```

Within `subGeneratorMetadata`:

* `presetId` identifies the generator preset to apply.
* `generatorId` identifies the type of generator.
* `customValueProcessor` identifies the custom value processor to apply.

`subGeneratorMetadata` also contains any other fields used to configure the selected sub-generator.&#x20;

## Partition column list <a href="#tonic-api-generator-partition-column-list" id="tonic-api-generator-partition-column-list"></a>

The Continuous and Event Timestamps generators allow [partitioning](https://docs.tonic.ai/app/generation/generators/generator-characteristics/partitioning).

In the replacement object, the `partitions` field contains a comma-separated list of columns to partition by.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/api/quick-start-guide/tonic-api-generator-assignment/tonic-api-generator-assignment-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
