@statsig/pulumi-statsig
Version:
A Pulumi package for creating and managing Statsig resources.
256 lines (247 loc) • 11.5 kB
text/typescript
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "./types/input";
import * as outputs from "./types/output";
import * as utilities from "./utilities";
/**
* This resource allows you to configure metric sources for your Statsig project.
*
* To learn more about metric sources, see [Metric Source Documentation](https://docs.statsig.com/statsig-warehouse-native/configuration/metric-sources)
*
* To learn more about the API powering this resource, see [Metrics API Documentation](https://docs.statsig.com/console-api/metrics)
*
* > Note: This resource is only available for [Warehouse Native](https://docs.statsig.com/statsig-warehouse-native/introduction/) projects
*/
export class MetricSource extends pulumi.CustomResource {
/**
* Get an existing MetricSource resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: MetricSourceState, opts?: pulumi.CustomResourceOptions): MetricSource {
return new MetricSource(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'statsig:index/metricSource:MetricSource';
/**
* Returns true if the given object is an instance of MetricSource. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is MetricSource {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === MetricSource.__pulumiType;
}
/**
* Optional array defining mappings for custom fields using specific formulas.
*/
public readonly customFieldMappings!: pulumi.Output<outputs.MetricSourceCustomFieldMapping[]>;
/**
* An optional description for the metric source, providing context and details about its purpose and usage.
*/
public readonly description!: pulumi.Output<string>;
/**
* Array defining the mapping between Statsig unit IDs and their respective source columns.
*/
public readonly idTypeMappings!: pulumi.Output<outputs.MetricSourceIdTypeMapping[]>;
/**
* Specifies if the source can only be edited via the Console API.
*/
public readonly isReadOnly!: pulumi.Output<boolean>;
/**
* The name of the metric source, serving as its primary identifier.
*/
public readonly name!: pulumi.Output<string>;
/**
* Schema for owner data including ID, type, name. Note that if Entity is created by CONSOLE API, owner will be undefined.
*/
public readonly owner!: pulumi.Output<outputs.MetricSourceOwner>;
/**
* The type of source, indicating whether it is a database table or a custom query.
*/
public readonly sourceType!: pulumi.Output<string>;
/**
* The SQL query or statement used to extract data from the metric source.
*/
public readonly sql!: pulumi.Output<string>;
/**
* The name of the database table if the source type is "table".
*/
public readonly tableName!: pulumi.Output<string>;
/**
* Optional array of tags to categorize the metric source, facilitating easier organization and retrieval.
*/
public readonly tags!: pulumi.Output<string[]>;
/**
* Indicates whether the timestamp should be treated as a day-level granularity.
*/
public readonly timestampAsDay!: pulumi.Output<boolean>;
/**
* The name of the column containing timestamp data for the metric source.
*/
public readonly timestampColumn!: pulumi.Output<string>;
/**
* Create a MetricSource resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: MetricSourceArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: MetricSourceArgs | MetricSourceState, opts?: pulumi.CustomResourceOptions) {
let resourceInputs: pulumi.Inputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState as MetricSourceState | undefined;
resourceInputs["customFieldMappings"] = state ? state.customFieldMappings : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["idTypeMappings"] = state ? state.idTypeMappings : undefined;
resourceInputs["isReadOnly"] = state ? state.isReadOnly : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["owner"] = state ? state.owner : undefined;
resourceInputs["sourceType"] = state ? state.sourceType : undefined;
resourceInputs["sql"] = state ? state.sql : undefined;
resourceInputs["tableName"] = state ? state.tableName : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["timestampAsDay"] = state ? state.timestampAsDay : undefined;
resourceInputs["timestampColumn"] = state ? state.timestampColumn : undefined;
} else {
const args = argsOrState as MetricSourceArgs | undefined;
if ((!args || args.idTypeMappings === undefined) && !opts.urn) {
throw new Error("Missing required property 'idTypeMappings'");
}
if ((!args || args.sql === undefined) && !opts.urn) {
throw new Error("Missing required property 'sql'");
}
if ((!args || args.timestampColumn === undefined) && !opts.urn) {
throw new Error("Missing required property 'timestampColumn'");
}
resourceInputs["customFieldMappings"] = args ? args.customFieldMappings : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["idTypeMappings"] = args ? args.idTypeMappings : undefined;
resourceInputs["isReadOnly"] = args ? args.isReadOnly : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["owner"] = args ? args.owner : undefined;
resourceInputs["sourceType"] = args ? args.sourceType : undefined;
resourceInputs["sql"] = args ? args.sql : undefined;
resourceInputs["tableName"] = args ? args.tableName : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["timestampAsDay"] = args ? args.timestampAsDay : undefined;
resourceInputs["timestampColumn"] = args ? args.timestampColumn : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(MetricSource.__pulumiType, name, resourceInputs, opts);
}
}
/**
* Input properties used for looking up and filtering MetricSource resources.
*/
export interface MetricSourceState {
/**
* Optional array defining mappings for custom fields using specific formulas.
*/
customFieldMappings?: pulumi.Input<pulumi.Input<inputs.MetricSourceCustomFieldMapping>[]>;
/**
* An optional description for the metric source, providing context and details about its purpose and usage.
*/
description?: pulumi.Input<string>;
/**
* Array defining the mapping between Statsig unit IDs and their respective source columns.
*/
idTypeMappings?: pulumi.Input<pulumi.Input<inputs.MetricSourceIdTypeMapping>[]>;
/**
* Specifies if the source can only be edited via the Console API.
*/
isReadOnly?: pulumi.Input<boolean>;
/**
* The name of the metric source, serving as its primary identifier.
*/
name?: pulumi.Input<string>;
/**
* Schema for owner data including ID, type, name. Note that if Entity is created by CONSOLE API, owner will be undefined.
*/
owner?: pulumi.Input<inputs.MetricSourceOwner>;
/**
* The type of source, indicating whether it is a database table or a custom query.
*/
sourceType?: pulumi.Input<string>;
/**
* The SQL query or statement used to extract data from the metric source.
*/
sql?: pulumi.Input<string>;
/**
* The name of the database table if the source type is "table".
*/
tableName?: pulumi.Input<string>;
/**
* Optional array of tags to categorize the metric source, facilitating easier organization and retrieval.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
/**
* Indicates whether the timestamp should be treated as a day-level granularity.
*/
timestampAsDay?: pulumi.Input<boolean>;
/**
* The name of the column containing timestamp data for the metric source.
*/
timestampColumn?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a MetricSource resource.
*/
export interface MetricSourceArgs {
/**
* Optional array defining mappings for custom fields using specific formulas.
*/
customFieldMappings?: pulumi.Input<pulumi.Input<inputs.MetricSourceCustomFieldMapping>[]>;
/**
* An optional description for the metric source, providing context and details about its purpose and usage.
*/
description?: pulumi.Input<string>;
/**
* Array defining the mapping between Statsig unit IDs and their respective source columns.
*/
idTypeMappings: pulumi.Input<pulumi.Input<inputs.MetricSourceIdTypeMapping>[]>;
/**
* Specifies if the source can only be edited via the Console API.
*/
isReadOnly?: pulumi.Input<boolean>;
/**
* The name of the metric source, serving as its primary identifier.
*/
name?: pulumi.Input<string>;
/**
* Schema for owner data including ID, type, name. Note that if Entity is created by CONSOLE API, owner will be undefined.
*/
owner?: pulumi.Input<inputs.MetricSourceOwner>;
/**
* The type of source, indicating whether it is a database table or a custom query.
*/
sourceType?: pulumi.Input<string>;
/**
* The SQL query or statement used to extract data from the metric source.
*/
sql: pulumi.Input<string>;
/**
* The name of the database table if the source type is "table".
*/
tableName?: pulumi.Input<string>;
/**
* Optional array of tags to categorize the metric source, facilitating easier organization and retrieval.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
/**
* Indicates whether the timestamp should be treated as a day-level granularity.
*/
timestampAsDay?: pulumi.Input<boolean>;
/**
* The name of the column containing timestamp data for the metric source.
*/
timestampColumn: pulumi.Input<string>;
}