InfluxDB 2.0 JavaScript client
Home > @influxdata/influxdb-client-apis > TemplateApply
Signature:
interface TemplateApply
| Property | Modifiers | Type | Description |
| — | — | — | — |
| actions? | | Array<{ action?: ‘skipKind’; properties?: { kind: TemplateKind; }; } | { action?: ‘skipResource’; properties?: { kind: TemplateKind; resourceTemplateName: string; }; }> | <p>(Optional) A list of action
objects. Actions let you customize how InfluxDB applies templates in the request.</p><p>You can use the following actions to prevent creating or updating resources:</p><p>- A skipKind
action skips template resources of a specified kind
. - A skipResource
action skips template resources with a specified metadata.name
and kind
.</p> |
| dryRun? | | boolean | <p>(Optional) Only applies a dry run of the templates passed in the request.</p><p>- Validates the template and generates a resource diff and summary. - Doesn’t install templates or make changes to the InfluxDB instance.</p> |
| envRefs? | | any | <p>(Optional) An object with key-value pairs that map to **environment references** in templates.</p><p>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.</p><p>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.</p><p>The following template fields may use environment references:</p><p>- metadata.name
- spec.endpointName
- spec.associations.name
</p><p>For more information about including environment references in template fields, see how to include user-definable resource names.</p> |
| orgID? | | string | <p>(Optional) Organization ID. InfluxDB applies templates to this organization. The organization owns all resources created by the template.</p><p>To find your organization, see how to view organizations.</p> |
| remotes? | | Array<{ url: string; contentType?: string; }> | <p>(Optional) A list of URLs for template files.</p><p>To apply a template manifest file located at a URL, pass remotes
with an array that contains the URL.</p> |
| secrets? | | any | <p>(Optional) An object with key-value pairs that map to **secrets** in queries.</p><p>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:</p>
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.
\#\#\#\# Related guides
- [How to pass secrets when installing a template](https://docs.influxdata.com/influxdb/v2.3/influxdb-templates/use/#pass-secrets-when-installing-a-template)
|
| stackID? | | string | <p>(Optional) ID of the stack to update.</p><p>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.</p><p>To find a stack ID, use the InfluxDB to list stacks.</p><p>#### Related guides</p><p>- Stacks - View stacks</p> |
| template? | | { contentType?: string; sources?: string[]; contents?: Template; } | <p>(Optional) A template object to apply. A template object has a contents
property with an array of InfluxDB resource configurations.</p><p>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.</p> |
| templates? | | Array<{ contentType?: string; sources?: string[]; contents?: Template; }> | <p>(Optional) A list of template objects to apply. A template object has a contents
property with an array of InfluxDB resource configurations.</p><p>Use the templates
parameter to apply multiple template objects. If you use templates
, you can’t use the template
parameter.</p> |