interface TemplateApply {
    actions?: (
        | { action?: "skipKind"; properties?: { kind: TemplateKind } }
        | {
            action?: "skipResource";
            properties?: { kind: TemplateKind; resourceTemplateName: string };
        }
    )[];
    dryRun?: boolean;
    envRefs?: any;
    orgID?: string;
    remotes?: { contentType?: string; url: string }[];
    secrets?: any;
    stackID?: string;
    template?: {
        contents?: Template;
        contentType?: string;
        sources?: string[];
    };
    templates?: {
        contents?: Template;
        contentType?: string;
        sources?: string[];
    }[];
}

Properties

actions?: (
    | { action?: "skipKind"; properties?: { kind: TemplateKind } }
    | {
        action?: "skipResource";
        properties?: { kind: TemplateKind; resourceTemplateName: string };
    }
)[]

A list of action objects. Actions let you customize how InfluxDB applies templates in the request.

You can use the following actions to prevent creating or updating resources:

  • A skipKind action skips template resources of a specified kind.
  • A skipResource action skips template resources with a specified metadata.name and kind.
dryRun?: boolean

Only applies a dry run of the templates passed in the request.

  • Validates the template and generates a resource diff and summary.
  • Doesn't install templates or make changes to the InfluxDB instance.
envRefs?: any

An object with key-value pairs that map to environment references in templates.

Environment references in templates are envRef objects with an envRef.key property. To substitute a custom environment reference value when applying templates, pass envRefs with the envRef.key and the value.

When you apply a template, InfluxDB replaces envRef objects in the template with the values that you provide in the envRefs parameter. For more examples, see how to define environment references.

The following template fields may use environment references:

  • metadata.name
  • spec.endpointName
  • spec.associations.name

For more information about including environment references in template fields, see how to include user-definable resource names.

orgID?: string

Organization ID. InfluxDB applies templates to this organization. The organization owns all resources created by the template.

To find your organization, see how to view organizations.

remotes?: { contentType?: string; url: string }[]

A list of URLs for template files.

To apply a template manifest file located at a URL, pass remotes with an array that contains the URL.

secrets?: any

An object with key-value pairs that map to secrets in queries.

Queries may reference secrets stored in InfluxDB--for example, the following Flux script retrieves POSTGRES_USERNAME and POSTGRES_PASSWORD secrets and then uses them to connect to a PostgreSQL database:

import "sql"
import "influxdata/influxdb/secrets"

username = secrets.get(key: "POSTGRES_USERNAME")
password = secrets.get(key: "POSTGRES_PASSWORD")

sql.from(
driverName: "postgres",
dataSourceName: "postgresql://${username}:${password}@localhost:5432",
query: "SELECT * FROM example_table",
)

To define secret values in your /api/v2/templates/apply request, pass the secrets parameter with key-value pairs--for example:

{
...
"secrets": {
"POSTGRES_USERNAME": "pguser",
"POSTGRES_PASSWORD": "foo"
}
...
}

InfluxDB stores the key-value pairs as secrets that you can access with secrets.get(). Once stored, you can't view secret values in InfluxDB.

stackID?: string

ID of the stack to update.

To apply templates to an existing stack in the organization, use the stackID parameter. If you apply templates without providing a stack ID, InfluxDB initializes a new stack with all new resources.

To find a stack ID, use the InfluxDB /api/v2/stacks API endpoint to list stacks.

template?: { contents?: Template; contentType?: string; sources?: string[] }

A template object to apply. A template object has a contents property with an array of InfluxDB resource configurations.

Pass template to apply only one template object. If you use template, you can't use the templates parameter. If you want to apply multiple template objects, use templates instead.

templates?: { contents?: Template; contentType?: string; sources?: string[] }[]

A list of template objects to apply. A template object has a contents property with an array of InfluxDB resource configurations.

Use the templates parameter to apply multiple template objects. If you use templates, you can't use the template parameter.

MMNEPVFCICPMFPCPTTAAATR