UNPKG

@pulumi/pagerduty

Version:

A Pulumi package for creating and managing pagerduty cloud resources.

166 lines 6.3 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ServiceCustomFieldValue = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * A [service custom field value](https://developer.pagerduty.com/api-reference/6075929031f7d-update-custom-field-values) * allows you to set values for custom fields on a PagerDuty service. These values * provide additional context for services and can be used for filtering, search, * and analytics. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pagerduty from "@pulumi/pagerduty"; * * // First, create a service custom field * const environment = new pagerduty.ServiceCustomField("environment", { * name: "environment", * displayName: "Environment", * dataType: "string", * fieldType: "single_value", * description: "The environment this service runs in", * }); * // Create a service * const example = new pagerduty.Service("example", { * name: "Example Service", * autoResolveTimeout: "14400", * acknowledgementTimeout: "600", * escalationPolicy: examplePagerdutyEscalationPolicy.id, * }); * // Set a custom field value on the service * const exampleServiceCustomFieldValue = new pagerduty.ServiceCustomFieldValue("example", { * serviceId: example.id, * customFields: [{ * name: environment.name, * value: JSON.stringify("production"), * }], * }); * // Set multiple custom field values on a service * const region = new pagerduty.ServiceCustomField("region", { * name: "region", * displayName: "Region", * dataType: "string", * fieldType: "single_value", * description: "The region this service is deployed in", * }); * const multipleExample = new pagerduty.ServiceCustomFieldValue("multiple_example", { * serviceId: example.id, * customFields: [ * { * name: environment.name, * value: JSON.stringify("production"), * }, * { * name: region.name, * value: JSON.stringify("us-east-1"), * }, * ], * }); * // Example with a boolean field * const isCritical = new pagerduty.ServiceCustomField("is_critical", { * name: "is_critical", * displayName: "Is Critical", * dataType: "boolean", * fieldType: "single_value", * description: "Whether this service is critical", * }); * const booleanExample = new pagerduty.ServiceCustomFieldValue("boolean_example", { * serviceId: example.id, * customFields: [{ * name: isCritical.name, * value: JSON.stringify(true), * }], * }); * // Example with a multi-value field * const regions = new pagerduty.ServiceCustomField("regions", { * name: "regions", * displayName: "AWS Regions", * dataType: "string", * fieldType: "multi_value_fixed", * description: "AWS regions where this service is deployed", * fieldOptions: [ * { * value: "us-east-1", * dataType: "string", * }, * { * value: "us-west-1", * dataType: "string", * }, * ], * }); * const multiValueExample = new pagerduty.ServiceCustomFieldValue("multi_value_example", { * serviceId: example.id, * customFields: [{ * name: regions.name, * value: JSON.stringify([ * "us-east-1", * "us-west-1", * ]), * }], * }); * ``` * * ## Import * * Service custom field values can be imported using the service ID, e.g. * * ```sh * $ pulumi import pagerduty:index/serviceCustomFieldValue:ServiceCustomFieldValue example PXYZ123 * ``` */ class ServiceCustomFieldValue extends pulumi.CustomResource { /** * Get an existing ServiceCustomFieldValue 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. */ static get(name, id, state, opts) { return new ServiceCustomFieldValue(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of ServiceCustomFieldValue. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === ServiceCustomFieldValue.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["customFields"] = state ? state.customFields : undefined; resourceInputs["serviceId"] = state ? state.serviceId : undefined; } else { const args = argsOrState; if ((!args || args.customFields === undefined) && !opts.urn) { throw new Error("Missing required property 'customFields'"); } if ((!args || args.serviceId === undefined) && !opts.urn) { throw new Error("Missing required property 'serviceId'"); } resourceInputs["customFields"] = args ? args.customFields : undefined; resourceInputs["serviceId"] = args ? args.serviceId : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ServiceCustomFieldValue.__pulumiType, name, resourceInputs, opts); } } exports.ServiceCustomFieldValue = ServiceCustomFieldValue; /** @internal */ ServiceCustomFieldValue.__pulumiType = 'pagerduty:index/serviceCustomFieldValue:ServiceCustomFieldValue'; //# sourceMappingURL=serviceCustomFieldValue.js.map