@pulumi/pagerduty
Version:
A Pulumi package for creating and managing pagerduty cloud resources.
168 lines • 6.77 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceCustomFieldValue = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(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.
*
* > The API is optimized to receive multiple `customFields` blocks on the same resource when they share `serviceId`, and not for the scenario where there is many resources pointing to the same service. So writing only 1 `pagerduty.ServiceCustomFieldValue` resource per service would result in quicker terraform applies and reduce the risk of encountering errors. See below for an example of the recommended usage pattern.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pagerduty from "@pulumi/pagerduty";
*
* // First, create service custom fields
* const environment = new pagerduty.ServiceCustomField("environment", {
* name: "environment",
* displayName: "Environment",
* dataType: "string",
* fieldType: "single_value",
* description: "The environment this service runs in",
* });
* 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 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-east-2",
* dataType: "string",
* },
* {
* value: "us-west-1",
* dataType: "string",
* },
* ],
* });
* // Create a service
* const example = new pagerduty.Service("example", {
* name: "Example Service",
* autoResolveTimeout: "14400",
* acknowledgementTimeout: "600",
* escalationPolicy: examplePagerdutyEscalationPolicy.id,
* });
* // Set custom field values on the service
* const exampleServiceCustomFieldValue = new pagerduty.ServiceCustomFieldValue("example", {
* serviceId: example.id,
* customFields: [
* {
* name: environment.name,
* value: JSON.stringify("production"),
* },
* {
* name: isCritical.name,
* value: JSON.stringify(true),
* },
* {
* 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, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'pagerduty:index/serviceCustomFieldValue:ServiceCustomFieldValue';
/**
* 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?.customFields;
resourceInputs["serviceId"] = state?.serviceId;
}
else {
const args = argsOrState;
if (args?.customFields === undefined && !opts.urn) {
throw new Error("Missing required property 'customFields'");
}
if (args?.serviceId === undefined && !opts.urn) {
throw new Error("Missing required property 'serviceId'");
}
resourceInputs["customFields"] = args?.customFields;
resourceInputs["serviceId"] = args?.serviceId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ServiceCustomFieldValue.__pulumiType, name, resourceInputs, opts);
}
}
exports.ServiceCustomFieldValue = ServiceCustomFieldValue;
//# sourceMappingURL=serviceCustomFieldValue.js.map