UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

181 lines 7 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.OnCallShift = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * * [HTTP API](https://grafana.com/docs/oncall/latest/oncall-api-reference/on_call_shifts/) * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as grafana from "@pulumiverse/grafana"; * import * as std from "@pulumi/std"; * * const alex = grafana.onCall.getUser({ * username: "alex", * }); * const myTeam = grafana.oss.getTeam({ * name: "my team", * }); * const myTeamGetTeam = myTeam.then(myTeam => grafana.onCall.getTeam({ * name: myTeam.name, * })); * const exampleShift = new grafana.oncall.OnCallShift("example_shift", { * name: "Example Shift", * type: "recurrent_event", * start: "2020-09-07T14:00:00", * duration: 60 * 30, * frequency: "weekly", * interval: 2, * byDays: [ * "MO", * "FR", * ], * weekStart: "MO", * users: [alex.then(alex => alex.id)], * timeZone: "UTC", * teamId: myTeamGetTeam.then(myTeamGetTeam => myTeamGetTeam.id), * }); * //////// * // Advanced example * //////// * const teams = { * emea: [ * "alfa@grafana.com", * "bravo@grafana.com", * "charlie@grafana.com", * "echo@grafana.com", * "delta@grafana.com", * "foxtrot@grafana.com", * "golf@grafana.com", * ], * }; * // Importing users * const allUsers = .reduce((__obj, [__key, __value]) => ({ ...__obj, [__key]: grafana.onCall.getUser({ * username: __key, * }) })); * // oncall API operates with resources ID's, so we convert emails into ID's * const teamsMapOfUserId = Object.entries(teams).reduce((__obj, [teamName, usernameList]) => ({ ...__obj, [teamName]: usernameList.map(username => (std.index.lookup({ * map: allUsers, * key: username, * }).result.id)) })); * const usersMapById = _arg0_; * // A 12 hour shift on week days with the on-call person rotating weekly. * const emeaWeekdayShift = new grafana.oncall.OnCallShift("emea_weekday_shift", { * name: "EMEA Weekday Shift", * type: "rolling_users", * start: "2022-02-28T03:00:00", * duration: 60 * 60 * 12, * frequency: "weekly", * interval: 1, * byDays: [ * "MO", * "TU", * "WE", * "TH", * "FR", * ], * weekStart: "MO", * rollingUsers: .map(k => ([k])), * startRotationFromUserIndex: 0, * teamId: myTeamGetTeam.then(myTeamGetTeam => myTeamGetTeam.id), * }); * export const emeaWeekdayRollingUsers = .map(k => (std.index.lookup({ * map: usersMapById, * key: k, * }).result.username)); * ``` * * ## Import * * ```sh * terraform import grafana_oncall_on_call_shift.name "{{ id }}" * ``` */ class OnCallShift extends pulumi.CustomResource { /** * Get an existing OnCallShift 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 OnCallShift(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of OnCallShift. 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'] === OnCallShift.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["byDays"] = state?.byDays; resourceInputs["byMonthdays"] = state?.byMonthdays; resourceInputs["byMonths"] = state?.byMonths; resourceInputs["duration"] = state?.duration; resourceInputs["frequency"] = state?.frequency; resourceInputs["interval"] = state?.interval; resourceInputs["level"] = state?.level; resourceInputs["name"] = state?.name; resourceInputs["rollingUsers"] = state?.rollingUsers; resourceInputs["start"] = state?.start; resourceInputs["startRotationFromUserIndex"] = state?.startRotationFromUserIndex; resourceInputs["teamId"] = state?.teamId; resourceInputs["timeZone"] = state?.timeZone; resourceInputs["type"] = state?.type; resourceInputs["until"] = state?.until; resourceInputs["users"] = state?.users; resourceInputs["weekStart"] = state?.weekStart; } else { const args = argsOrState; if (args?.duration === undefined && !opts.urn) { throw new Error("Missing required property 'duration'"); } if (args?.start === undefined && !opts.urn) { throw new Error("Missing required property 'start'"); } if (args?.type === undefined && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["byDays"] = args?.byDays; resourceInputs["byMonthdays"] = args?.byMonthdays; resourceInputs["byMonths"] = args?.byMonths; resourceInputs["duration"] = args?.duration; resourceInputs["frequency"] = args?.frequency; resourceInputs["interval"] = args?.interval; resourceInputs["level"] = args?.level; resourceInputs["name"] = args?.name; resourceInputs["rollingUsers"] = args?.rollingUsers; resourceInputs["start"] = args?.start; resourceInputs["startRotationFromUserIndex"] = args?.startRotationFromUserIndex; resourceInputs["teamId"] = args?.teamId; resourceInputs["timeZone"] = args?.timeZone; resourceInputs["type"] = args?.type; resourceInputs["until"] = args?.until; resourceInputs["users"] = args?.users; resourceInputs["weekStart"] = args?.weekStart; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(OnCallShift.__pulumiType, name, resourceInputs, opts); } } exports.OnCallShift = OnCallShift; /** @internal */ OnCallShift.__pulumiType = 'grafana:onCall/onCallShift:OnCallShift'; //# sourceMappingURL=onCallShift.js.map