UNPKG

@pulumiverse/grafana

Version:

A Pulumi package for creating and managing grafana.

332 lines (331 loc) 11.7 kB
import * as pulumi from "@pulumi/pulumi"; /** * * [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 }}" * ``` */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: OnCallShiftState, opts?: pulumi.CustomResourceOptions): OnCallShift; /** * 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: any): obj is OnCallShift; /** * This parameter takes a list of days in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ readonly byDays: pulumi.Output<string[] | undefined>; /** * This parameter takes a list of days of the month. Valid values are 1 to 31 or -31 to -1 */ readonly byMonthdays: pulumi.Output<number[] | undefined>; /** * This parameter takes a list of months. Valid values are 1 to 12 */ readonly byMonths: pulumi.Output<number[] | undefined>; /** * The duration of the event. */ readonly duration: pulumi.Output<number>; /** * The frequency of the event. Can be hourly, daily, weekly, monthly */ readonly frequency: pulumi.Output<string | undefined>; /** * The positive integer representing at which intervals the recurrence rule repeats. */ readonly interval: pulumi.Output<number | undefined>; /** * The priority level. The higher the value, the higher the priority. */ readonly level: pulumi.Output<number | undefined>; /** * The shift's name. */ readonly name: pulumi.Output<string>; /** * The list of lists with on-call users (for rollingUsers event type) */ readonly rollingUsers: pulumi.Output<string[][] | undefined>; /** * The start time of the on-call shift. This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ readonly start: pulumi.Output<string>; /** * The index of the list of users in rolling_users, from which on-call rotation starts. */ readonly startRotationFromUserIndex: pulumi.Output<number | undefined>; /** * The ID of the OnCall team (using the `grafana.onCall.getTeam` datasource). */ readonly teamId: pulumi.Output<string | undefined>; /** * The shift's timezone. Overrides schedule's timezone. */ readonly timeZone: pulumi.Output<string | undefined>; /** * The shift's type. Can be rolling*users, recurrent*event, single_event */ readonly type: pulumi.Output<string>; /** * The end time of recurrent on-call shifts (endless if null). This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ readonly until: pulumi.Output<string | undefined>; /** * The list of on-call users (for single*event and recurrent*event event type). */ readonly users: pulumi.Output<string[] | undefined>; /** * Start day of the week in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ readonly weekStart: pulumi.Output<string | undefined>; /** * Create a OnCallShift 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: OnCallShiftArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering OnCallShift resources. */ export interface OnCallShiftState { /** * This parameter takes a list of days in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ byDays?: pulumi.Input<pulumi.Input<string>[]>; /** * This parameter takes a list of days of the month. Valid values are 1 to 31 or -31 to -1 */ byMonthdays?: pulumi.Input<pulumi.Input<number>[]>; /** * This parameter takes a list of months. Valid values are 1 to 12 */ byMonths?: pulumi.Input<pulumi.Input<number>[]>; /** * The duration of the event. */ duration?: pulumi.Input<number>; /** * The frequency of the event. Can be hourly, daily, weekly, monthly */ frequency?: pulumi.Input<string>; /** * The positive integer representing at which intervals the recurrence rule repeats. */ interval?: pulumi.Input<number>; /** * The priority level. The higher the value, the higher the priority. */ level?: pulumi.Input<number>; /** * The shift's name. */ name?: pulumi.Input<string>; /** * The list of lists with on-call users (for rollingUsers event type) */ rollingUsers?: pulumi.Input<pulumi.Input<pulumi.Input<string>[]>[]>; /** * The start time of the on-call shift. This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ start?: pulumi.Input<string>; /** * The index of the list of users in rolling_users, from which on-call rotation starts. */ startRotationFromUserIndex?: pulumi.Input<number>; /** * The ID of the OnCall team (using the `grafana.onCall.getTeam` datasource). */ teamId?: pulumi.Input<string>; /** * The shift's timezone. Overrides schedule's timezone. */ timeZone?: pulumi.Input<string>; /** * The shift's type. Can be rolling*users, recurrent*event, single_event */ type?: pulumi.Input<string>; /** * The end time of recurrent on-call shifts (endless if null). This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ until?: pulumi.Input<string>; /** * The list of on-call users (for single*event and recurrent*event event type). */ users?: pulumi.Input<pulumi.Input<string>[]>; /** * Start day of the week in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ weekStart?: pulumi.Input<string>; } /** * The set of arguments for constructing a OnCallShift resource. */ export interface OnCallShiftArgs { /** * This parameter takes a list of days in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ byDays?: pulumi.Input<pulumi.Input<string>[]>; /** * This parameter takes a list of days of the month. Valid values are 1 to 31 or -31 to -1 */ byMonthdays?: pulumi.Input<pulumi.Input<number>[]>; /** * This parameter takes a list of months. Valid values are 1 to 12 */ byMonths?: pulumi.Input<pulumi.Input<number>[]>; /** * The duration of the event. */ duration: pulumi.Input<number>; /** * The frequency of the event. Can be hourly, daily, weekly, monthly */ frequency?: pulumi.Input<string>; /** * The positive integer representing at which intervals the recurrence rule repeats. */ interval?: pulumi.Input<number>; /** * The priority level. The higher the value, the higher the priority. */ level?: pulumi.Input<number>; /** * The shift's name. */ name?: pulumi.Input<string>; /** * The list of lists with on-call users (for rollingUsers event type) */ rollingUsers?: pulumi.Input<pulumi.Input<pulumi.Input<string>[]>[]>; /** * The start time of the on-call shift. This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ start: pulumi.Input<string>; /** * The index of the list of users in rolling_users, from which on-call rotation starts. */ startRotationFromUserIndex?: pulumi.Input<number>; /** * The ID of the OnCall team (using the `grafana.onCall.getTeam` datasource). */ teamId?: pulumi.Input<string>; /** * The shift's timezone. Overrides schedule's timezone. */ timeZone?: pulumi.Input<string>; /** * The shift's type. Can be rolling*users, recurrent*event, single_event */ type: pulumi.Input<string>; /** * The end time of recurrent on-call shifts (endless if null). This parameter takes a date format as yyyy-MM-dd'T'HH:mm:ss (for example "2020-09-05T08:00:00") */ until?: pulumi.Input<string>; /** * The list of on-call users (for single*event and recurrent*event event type). */ users?: pulumi.Input<pulumi.Input<string>[]>; /** * Start day of the week in iCal format. Can be MO, TU, WE, TH, FR, SA, SU */ weekStart?: pulumi.Input<string>; }