import * as pulumi from "@pulumi/pulumi";
import * as inputs from "./types/input";
import * as outputs from "./types/output";
/**
* Use this data source to get information about a specific entity in New Relic One that already exists. More information on Terraform's data sources can be found here.
*
* > **IMPORTANT!** Version 2.0.0 of the New Relic Terraform Provider introduces some [additional requirements](https://www.terraform.io/providers/newrelic/newrelic/latest/docs/guides/migration_guide_v2) for configuring the provider.
*
* Before upgrading to version 2.0.0 or later, it is recommended to upgrade to the most recent 1.x version of the provider and ensure that your environment successfully runs `pulumi preview` without unexpected changes.
*
* ### Example: Filter By Account ID
*
* The default behaviour of this data source is to retrieve entities matching the specified parameters (such as `name`, `domain`, `type`) from NerdGraph with the credentials specified in the configuration of the provider (account ID and API Key), filter them by the account ID specified in the configuration of the provider, and return the first match.
*
* This would mean, if no entity with the specified search parameters is found associated with the account ID in the configuration of the provider, i.e. `NEW_RELIC_ACCOUNT_ID`, an error is thrown, stating that no matching entity has been found.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* // The entity returned by this configuration would have to
* // belong to the account_id specified in the provider
* // configuration, i.e. NEW_RELIC_ACCOUNT_ID.
* const app = newrelic.getEntity({
* name: "my-app",
* domain: "APM",
* type: "APPLICATION",
* });
* ```
* However, in order to cater to scenarios in which it could be necessary to retrieve an entity belonging to a subaccount using the account ID and API Key of the parent account (for instance, when entities with identical names are present in both the parent account and subaccounts, since matching entities from subaccounts too are returned by NerdGraph), the `accountId` attribute of this data source may be availed. This ensures that the account ID in the configuration of the provider, used to filter entities returned by the API is now overridden by the `accountId` specified in the configuration; i.e., in the below example, the data source would now return an entity matching the specified `name`, belonging to the account with the ID `accountId`.
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* // The entity returned by this configuration, unlike in
* // the above example, would have to belong to the account_id
* // specified in the configuration below, i.e. 654321.
* const app = newrelic.getEntity({
* name: "my-app",
* accountId: "654321",
* domain: "APM",
* type: "APPLICATION",
* });
* ```
* The following example explains a use case along the lines of the aforementioned; using the `accountId` argument in the data source to allow the filtering criteria to be the `accountId` specified (of the subaccount), and not the account ID in the provider configuration.
*
* In simpler terms, when entities are queried from the parent account, entities with matching names are returned from subaccounts too, hence, specifying the `accountId` of the subaccount in the configuration allows the entity returned to belong to the subaccount with `accountId`.
* ### Query for an OTEL entity
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* const app = newrelic.getEntity({
* name: "my-otel-app",
* domain: "EXT",
* type: "SERVICE",
* tags: [{
* key: "accountID",
* value: "12345",
* }],
* });
* ```
*
* ### Query for an entity by type (AWS Lambda entity in this example)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* const app = newrelic.getEntity({
* name: "my_lambda_trace",
* type: "AWSLAMBDAFUNCTION",
* });
* ```
*
* ### Using the `entityTags` Attribute to Fetch Tags Associated with the Entity
*
* As stated above in the **Attributes Reference** section, while the attribute `entityTags` helps retrieve tags associated with the entity fetched by the data source, the tags are returned as a JSON-encoded string and not a conventional list or a map, owing to a couple of design considerations; which is why one would need to use the Terraform function `jsondecode()`, along with the attribute `entityTags` in order to convert the JSON-encoded string into a map with key-value pairs.
*
* The following is an illustration of the aforementioned scenario. It may be observed that a key-value pair version of the JSON-encoded string exported by `entityTags` is written to the variable `keyValueMaps` , using the `jsondecode()` function.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
* import * as std from "@pulumi/std";
*
* export = async () => {
* const foo = await newrelic.getEntity({
* name: "Sample Searchable Entity",
* domain: "EXT",
* type: "SERVICE_LEVEL",
* });
* const keyValueMap = .reduce((__obj, pair) => ({ ...__obj, [String(pair.key)]: pair.values }), {});
* return {
* keyValueMap: keyValueMap,
* };
* }
* ```
* The value of `local.key_value_map` would look like the following.
*/
export declare function getEntity(args: GetEntityArgs, opts?: pulumi.InvokeOptions): Promise;
/**
* A collection of arguments for invoking getEntity.
*/
export interface GetEntityArgs {
/**
* The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by `accountId` and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the **Example: Filter By Account ID** section above for more details.
*/
accountId?: string;
/**
* The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
*/
domain?: string;
/**
* A JSON-encoded string, comprising tags associated with the entity fetched.
* * See the **Additional Examples** section below, for an illustration depicting the usage of `jsondecode` with the attribute `entityTags`, to get the tags associated with the entity fetched.
*/
entityTags?: string;
/**
* Ignore case of the `name` when searching for the entity. Defaults to false.
*/
ignoreCase?: boolean;
/**
* A boolean argument that, when set to true, prevents an error from being thrown when the queried entity is not found. Instead, a warning is displayed. Defaults to `false`.
*
* > **WARNING:** Setting the `ignoreNotFound` argument to `true` will display an 'entity not found' warning instead of throwing an error. This can lead to downstream errors if the values of attributes exported by this data source are used elsewhere, as all of these values would be null. Please use this argument at your own risk.
*/
ignoreNotFound?: boolean;
/**
* The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
*/
name: string;
/**
* A tag applied to the entity. See Nested tag blocks below for details.
*/
tags?: inputs.GetEntityTag[];
/**
* The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
*/
type?: string;
}
/**
* A collection of values returned by getEntity.
*/
export interface GetEntityResult {
readonly accountId: string;
/**
* The domain-specific application ID of the entity. Only returned for APM and Browser applications.
*/
readonly applicationId: string;
readonly domain: string;
/**
* A JSON-encoded string, comprising tags associated with the entity fetched.
* * See the **Additional Examples** section below, for an illustration depicting the usage of `jsondecode` with the attribute `entityTags`, to get the tags associated with the entity fetched.
*/
readonly entityTags: string;
/**
* The unique GUID of the entity.
*/
readonly guid: string;
/**
* The provider-assigned unique ID for this managed resource.
*/
readonly id: string;
readonly ignoreCase?: boolean;
readonly ignoreNotFound?: boolean;
readonly name: string;
/**
* The browser-specific ID of the backing APM entity. Only returned for Browser applications.
*/
readonly servingApmApplicationId: string;
readonly tags?: outputs.GetEntityTag[];
readonly type: string;
}
/**
* Use this data source to get information about a specific entity in New Relic One that already exists. More information on Terraform's data sources can be found here.
*
* > **IMPORTANT!** Version 2.0.0 of the New Relic Terraform Provider introduces some [additional requirements](https://www.terraform.io/providers/newrelic/newrelic/latest/docs/guides/migration_guide_v2) for configuring the provider.
*
* Before upgrading to version 2.0.0 or later, it is recommended to upgrade to the most recent 1.x version of the provider and ensure that your environment successfully runs `pulumi preview` without unexpected changes.
*
* ### Example: Filter By Account ID
*
* The default behaviour of this data source is to retrieve entities matching the specified parameters (such as `name`, `domain`, `type`) from NerdGraph with the credentials specified in the configuration of the provider (account ID and API Key), filter them by the account ID specified in the configuration of the provider, and return the first match.
*
* This would mean, if no entity with the specified search parameters is found associated with the account ID in the configuration of the provider, i.e. `NEW_RELIC_ACCOUNT_ID`, an error is thrown, stating that no matching entity has been found.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* // The entity returned by this configuration would have to
* // belong to the account_id specified in the provider
* // configuration, i.e. NEW_RELIC_ACCOUNT_ID.
* const app = newrelic.getEntity({
* name: "my-app",
* domain: "APM",
* type: "APPLICATION",
* });
* ```
* However, in order to cater to scenarios in which it could be necessary to retrieve an entity belonging to a subaccount using the account ID and API Key of the parent account (for instance, when entities with identical names are present in both the parent account and subaccounts, since matching entities from subaccounts too are returned by NerdGraph), the `accountId` attribute of this data source may be availed. This ensures that the account ID in the configuration of the provider, used to filter entities returned by the API is now overridden by the `accountId` specified in the configuration; i.e., in the below example, the data source would now return an entity matching the specified `name`, belonging to the account with the ID `accountId`.
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* // The entity returned by this configuration, unlike in
* // the above example, would have to belong to the account_id
* // specified in the configuration below, i.e. 654321.
* const app = newrelic.getEntity({
* name: "my-app",
* accountId: "654321",
* domain: "APM",
* type: "APPLICATION",
* });
* ```
* The following example explains a use case along the lines of the aforementioned; using the `accountId` argument in the data source to allow the filtering criteria to be the `accountId` specified (of the subaccount), and not the account ID in the provider configuration.
*
* In simpler terms, when entities are queried from the parent account, entities with matching names are returned from subaccounts too, hence, specifying the `accountId` of the subaccount in the configuration allows the entity returned to belong to the subaccount with `accountId`.
* ### Query for an OTEL entity
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* const app = newrelic.getEntity({
* name: "my-otel-app",
* domain: "EXT",
* type: "SERVICE",
* tags: [{
* key: "accountID",
* value: "12345",
* }],
* });
* ```
*
* ### Query for an entity by type (AWS Lambda entity in this example)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
*
* const app = newrelic.getEntity({
* name: "my_lambda_trace",
* type: "AWSLAMBDAFUNCTION",
* });
* ```
*
* ### Using the `entityTags` Attribute to Fetch Tags Associated with the Entity
*
* As stated above in the **Attributes Reference** section, while the attribute `entityTags` helps retrieve tags associated with the entity fetched by the data source, the tags are returned as a JSON-encoded string and not a conventional list or a map, owing to a couple of design considerations; which is why one would need to use the Terraform function `jsondecode()`, along with the attribute `entityTags` in order to convert the JSON-encoded string into a map with key-value pairs.
*
* The following is an illustration of the aforementioned scenario. It may be observed that a key-value pair version of the JSON-encoded string exported by `entityTags` is written to the variable `keyValueMaps` , using the `jsondecode()` function.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as newrelic from "@pulumi/newrelic";
* import * as std from "@pulumi/std";
*
* export = async () => {
* const foo = await newrelic.getEntity({
* name: "Sample Searchable Entity",
* domain: "EXT",
* type: "SERVICE_LEVEL",
* });
* const keyValueMap = .reduce((__obj, pair) => ({ ...__obj, [String(pair.key)]: pair.values }), {});
* return {
* keyValueMap: keyValueMap,
* };
* }
* ```
* The value of `local.key_value_map` would look like the following.
*/
export declare function getEntityOutput(args: GetEntityOutputArgs, opts?: pulumi.InvokeOutputOptions): pulumi.Output;
/**
* A collection of arguments for invoking getEntity.
*/
export interface GetEntityOutputArgs {
/**
* The New Relic account ID the entity to be returned would be associated with, i.e. if specified, the data source would filter matching entities received by `accountId` and return the first match. If not, matching entities are filtered by the account ID specified in the configuration of the provider. See the **Example: Filter By Account ID** section above for more details.
*/
accountId?: pulumi.Input;
/**
* The entity's domain. Valid values are APM, BROWSER, INFRA, MOBILE, SYNTH, and EXT. If not specified, all domains are searched.
*/
domain?: pulumi.Input;
/**
* A JSON-encoded string, comprising tags associated with the entity fetched.
* * See the **Additional Examples** section below, for an illustration depicting the usage of `jsondecode` with the attribute `entityTags`, to get the tags associated with the entity fetched.
*/
entityTags?: pulumi.Input;
/**
* Ignore case of the `name` when searching for the entity. Defaults to false.
*/
ignoreCase?: pulumi.Input;
/**
* A boolean argument that, when set to true, prevents an error from being thrown when the queried entity is not found. Instead, a warning is displayed. Defaults to `false`.
*
* > **WARNING:** Setting the `ignoreNotFound` argument to `true` will display an 'entity not found' warning instead of throwing an error. This can lead to downstream errors if the values of attributes exported by this data source are used elsewhere, as all of these values would be null. Please use this argument at your own risk.
*/
ignoreNotFound?: pulumi.Input;
/**
* The name of the entity in New Relic One. The first entity matching this name for the given search parameters will be returned.
*/
name: pulumi.Input;
/**
* A tag applied to the entity. See Nested tag blocks below for details.
*/
tags?: pulumi.Input[] | undefined>;
/**
* The entity's type. Valid values are APPLICATION, DASHBOARD, HOST, MONITOR, WORKLOAD, AWSLAMBDAFUNCTION, SERVICE_LEVEL, and KEY_TRANSACTION. Note: Other entity types may also be queryable as the list of entity types may fluctuate over time.
*/
type?: pulumi.Input;
}
//# sourceMappingURL=getEntity.d.ts.map