1. Packages
  2. Pagerduty Provider
  3. API Docs
  4. getSchedulev2
Viewing docs for PagerDuty v4.31.1
published on Wednesday, Mar 25, 2026 by Pulumi
pagerduty logo
Viewing docs for PagerDuty v4.31.1
published on Wednesday, Mar 25, 2026 by Pulumi

    Use this data source to look up a specific v3 schedule by name so you can reference its ID in other resources such as escalation policies.

    Note: This data source requires the flexible-schedules-early-access early access flag on your PagerDuty account. The required X-Early-Access header is sent automatically by the provider.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as pagerduty from "@pulumi/pagerduty";
    
    const oncall = pagerduty.getSchedulev2({
        name: "Engineering On-Call",
    });
    const example = new pagerduty.EscalationPolicy("example", {
        name: "Engineering Escalation Policy",
        numLoops: 2,
        rules: [{
            escalationDelayInMinutes: 10,
            targets: [{
                type: "schedule_reference",
                id: oncall.then(oncall => oncall.id),
            }],
        }],
    });
    
    import pulumi
    import pulumi_pagerduty as pagerduty
    
    oncall = pagerduty.get_schedulev2(name="Engineering On-Call")
    example = pagerduty.EscalationPolicy("example",
        name="Engineering Escalation Policy",
        num_loops=2,
        rules=[{
            "escalation_delay_in_minutes": 10,
            "targets": [{
                "type": "schedule_reference",
                "id": oncall.id,
            }],
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-pagerduty/sdk/v4/go/pagerduty"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		oncall, err := pagerduty.LookupSchedulev2(ctx, &pagerduty.LookupSchedulev2Args{
    			Name: "Engineering On-Call",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = pagerduty.NewEscalationPolicy(ctx, "example", &pagerduty.EscalationPolicyArgs{
    			Name:     pulumi.String("Engineering Escalation Policy"),
    			NumLoops: pulumi.Int(2),
    			Rules: pagerduty.EscalationPolicyRuleArray{
    				&pagerduty.EscalationPolicyRuleArgs{
    					EscalationDelayInMinutes: pulumi.Int(10),
    					Targets: pagerduty.EscalationPolicyRuleTargetArray{
    						&pagerduty.EscalationPolicyRuleTargetArgs{
    							Type: pulumi.String("schedule_reference"),
    							Id:   pulumi.String(oncall.Id),
    						},
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Pagerduty = Pulumi.Pagerduty;
    
    return await Deployment.RunAsync(() => 
    {
        var oncall = Pagerduty.GetSchedulev2.Invoke(new()
        {
            Name = "Engineering On-Call",
        });
    
        var example = new Pagerduty.EscalationPolicy("example", new()
        {
            Name = "Engineering Escalation Policy",
            NumLoops = 2,
            Rules = new[]
            {
                new Pagerduty.Inputs.EscalationPolicyRuleArgs
                {
                    EscalationDelayInMinutes = 10,
                    Targets = new[]
                    {
                        new Pagerduty.Inputs.EscalationPolicyRuleTargetArgs
                        {
                            Type = "schedule_reference",
                            Id = oncall.Apply(getSchedulev2Result => getSchedulev2Result.Id),
                        },
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.pagerduty.PagerdutyFunctions;
    import com.pulumi.pagerduty.inputs.GetSchedulev2Args;
    import com.pulumi.pagerduty.EscalationPolicy;
    import com.pulumi.pagerduty.EscalationPolicyArgs;
    import com.pulumi.pagerduty.inputs.EscalationPolicyRuleArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var oncall = PagerdutyFunctions.getSchedulev2(GetSchedulev2Args.builder()
                .name("Engineering On-Call")
                .build());
    
            var example = new EscalationPolicy("example", EscalationPolicyArgs.builder()
                .name("Engineering Escalation Policy")
                .numLoops(2)
                .rules(EscalationPolicyRuleArgs.builder()
                    .escalationDelayInMinutes(10)
                    .targets(EscalationPolicyRuleTargetArgs.builder()
                        .type("schedule_reference")
                        .id(oncall.id())
                        .build())
                    .build())
                .build());
    
        }
    }
    
    resources:
      example:
        type: pagerduty:EscalationPolicy
        properties:
          name: Engineering Escalation Policy
          numLoops: 2
          rules:
            - escalationDelayInMinutes: 10
              targets:
                - type: schedule_reference
                  id: ${oncall.id}
    variables:
      oncall:
        fn::invoke:
          function: pagerduty:getSchedulev2
          arguments:
            name: Engineering On-Call
    

    Using getSchedulev2

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSchedulev2(args: GetSchedulev2Args, opts?: InvokeOptions): Promise<GetSchedulev2Result>
    function getSchedulev2Output(args: GetSchedulev2OutputArgs, opts?: InvokeOptions): Output<GetSchedulev2Result>
    def get_schedulev2(name: Optional[str] = None,
                       opts: Optional[InvokeOptions] = None) -> GetSchedulev2Result
    def get_schedulev2_output(name: Optional[pulumi.Input[str]] = None,
                       opts: Optional[InvokeOptions] = None) -> Output[GetSchedulev2Result]
    func LookupSchedulev2(ctx *Context, args *LookupSchedulev2Args, opts ...InvokeOption) (*LookupSchedulev2Result, error)
    func LookupSchedulev2Output(ctx *Context, args *LookupSchedulev2OutputArgs, opts ...InvokeOption) LookupSchedulev2ResultOutput

    > Note: This function is named LookupSchedulev2 in the Go SDK.

    public static class GetSchedulev2 
    {
        public static Task<GetSchedulev2Result> InvokeAsync(GetSchedulev2Args args, InvokeOptions? opts = null)
        public static Output<GetSchedulev2Result> Invoke(GetSchedulev2InvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSchedulev2Result> getSchedulev2(GetSchedulev2Args args, InvokeOptions options)
    public static Output<GetSchedulev2Result> getSchedulev2(GetSchedulev2Args args, InvokeOptions options)
    
    fn::invoke:
      function: pagerduty:index/getSchedulev2:getSchedulev2
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    The exact name of the v3 schedule to look up.
    Name string
    The exact name of the v3 schedule to look up.
    name String
    The exact name of the v3 schedule to look up.
    name string
    The exact name of the v3 schedule to look up.
    name str
    The exact name of the v3 schedule to look up.
    name String
    The exact name of the v3 schedule to look up.

    getSchedulev2 Result

    The following output properties are available:

    Id string
    The ID of the found schedule.
    Name string
    The name of the found schedule.
    Id string
    The ID of the found schedule.
    Name string
    The name of the found schedule.
    id String
    The ID of the found schedule.
    name String
    The name of the found schedule.
    id string
    The ID of the found schedule.
    name string
    The name of the found schedule.
    id str
    The ID of the found schedule.
    name str
    The name of the found schedule.
    id String
    The ID of the found schedule.
    name String
    The name of the found schedule.

    Package Details

    Repository
    PagerDuty pulumi/pulumi-pagerduty
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the pagerduty Terraform Provider.
    pagerduty logo
    Viewing docs for PagerDuty v4.31.1
    published on Wednesday, Mar 25, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.