1. Packages
  2. Pagerduty Provider
  3. API Docs
  4. getUserContactMethod
PagerDuty v4.17.0 published on Wednesday, Nov 20, 2024 by Pulumi

pagerduty.getUserContactMethod

Explore with Pulumi AI

pagerduty logo
PagerDuty v4.17.0 published on Wednesday, Nov 20, 2024 by Pulumi

    Use this data source to get information about a specific contact method of a PagerDuty user that you can use for other PagerDuty resources.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as pagerduty from "@pulumi/pagerduty";
    
    const me = pagerduty.getUser({
        email: "me@example.com",
    });
    const phonePush = me.then(me => pagerduty.getUserContactMethod({
        userId: me.id,
        type: "push_notification_contact_method",
        label: "iPhone (John)",
    }));
    const lowUrgencySms = new pagerduty.UserNotificationRule("low_urgency_sms", {
        userId: me.then(me => me.id),
        startDelayInMinutes: 5,
        urgency: "high",
        contactMethod: {
            type: "push_notification_contact_method",
            id: phonePush.then(phonePush => phonePush.id),
        },
    });
    
    import pulumi
    import pulumi_pagerduty as pagerduty
    
    me = pagerduty.get_user(email="me@example.com")
    phone_push = pagerduty.get_user_contact_method(user_id=me.id,
        type="push_notification_contact_method",
        label="iPhone (John)")
    low_urgency_sms = pagerduty.UserNotificationRule("low_urgency_sms",
        user_id=me.id,
        start_delay_in_minutes=5,
        urgency="high",
        contact_method={
            "type": "push_notification_contact_method",
            "id": phone_push.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 {
    		me, err := pagerduty.LookupUser(ctx, &pagerduty.LookupUserArgs{
    			Email: "me@example.com",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		phonePush, err := pagerduty.LookupUserContactMethod(ctx, &pagerduty.LookupUserContactMethodArgs{
    			UserId: me.Id,
    			Type:   "push_notification_contact_method",
    			Label:  "iPhone (John)",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = pagerduty.NewUserNotificationRule(ctx, "low_urgency_sms", &pagerduty.UserNotificationRuleArgs{
    			UserId:              pulumi.String(me.Id),
    			StartDelayInMinutes: pulumi.Int(5),
    			Urgency:             pulumi.String("high"),
    			ContactMethod: pulumi.StringMap{
    				"type": pulumi.String("push_notification_contact_method"),
    				"id":   pulumi.String(phonePush.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 me = Pagerduty.GetUser.Invoke(new()
        {
            Email = "me@example.com",
        });
    
        var phonePush = Pagerduty.GetUserContactMethod.Invoke(new()
        {
            UserId = me.Apply(getUserResult => getUserResult.Id),
            Type = "push_notification_contact_method",
            Label = "iPhone (John)",
        });
    
        var lowUrgencySms = new Pagerduty.UserNotificationRule("low_urgency_sms", new()
        {
            UserId = me.Apply(getUserResult => getUserResult.Id),
            StartDelayInMinutes = 5,
            Urgency = "high",
            ContactMethod = 
            {
                { "type", "push_notification_contact_method" },
                { "id", phonePush.Apply(getUserContactMethodResult => getUserContactMethodResult.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.GetUserArgs;
    import com.pulumi.pagerduty.inputs.GetUserContactMethodArgs;
    import com.pulumi.pagerduty.UserNotificationRule;
    import com.pulumi.pagerduty.UserNotificationRuleArgs;
    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 me = PagerdutyFunctions.getUser(GetUserArgs.builder()
                .email("me@example.com")
                .build());
    
            final var phonePush = PagerdutyFunctions.getUserContactMethod(GetUserContactMethodArgs.builder()
                .userId(me.applyValue(getUserResult -> getUserResult.id()))
                .type("push_notification_contact_method")
                .label("iPhone (John)")
                .build());
    
            var lowUrgencySms = new UserNotificationRule("lowUrgencySms", UserNotificationRuleArgs.builder()
                .userId(me.applyValue(getUserResult -> getUserResult.id()))
                .startDelayInMinutes(5)
                .urgency("high")
                .contactMethod(Map.ofEntries(
                    Map.entry("type", "push_notification_contact_method"),
                    Map.entry("id", phonePush.applyValue(getUserContactMethodResult -> getUserContactMethodResult.id()))
                ))
                .build());
    
        }
    }
    
    resources:
      lowUrgencySms:
        type: pagerduty:UserNotificationRule
        name: low_urgency_sms
        properties:
          userId: ${me.id}
          startDelayInMinutes: 5
          urgency: high
          contactMethod:
            type: push_notification_contact_method
            id: ${phonePush.id}
    variables:
      me:
        fn::invoke:
          Function: pagerduty:getUser
          Arguments:
            email: me@example.com
      phonePush:
        fn::invoke:
          Function: pagerduty:getUserContactMethod
          Arguments:
            userId: ${me.id}
            type: push_notification_contact_method
            label: iPhone (John)
    

    Using getUserContactMethod

    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 getUserContactMethod(args: GetUserContactMethodArgs, opts?: InvokeOptions): Promise<GetUserContactMethodResult>
    function getUserContactMethodOutput(args: GetUserContactMethodOutputArgs, opts?: InvokeOptions): Output<GetUserContactMethodResult>
    def get_user_contact_method(label: Optional[str] = None,
                                type: Optional[str] = None,
                                user_id: Optional[str] = None,
                                opts: Optional[InvokeOptions] = None) -> GetUserContactMethodResult
    def get_user_contact_method_output(label: Optional[pulumi.Input[str]] = None,
                                type: Optional[pulumi.Input[str]] = None,
                                user_id: Optional[pulumi.Input[str]] = None,
                                opts: Optional[InvokeOptions] = None) -> Output[GetUserContactMethodResult]
    func LookupUserContactMethod(ctx *Context, args *LookupUserContactMethodArgs, opts ...InvokeOption) (*LookupUserContactMethodResult, error)
    func LookupUserContactMethodOutput(ctx *Context, args *LookupUserContactMethodOutputArgs, opts ...InvokeOption) LookupUserContactMethodResultOutput

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

    public static class GetUserContactMethod 
    {
        public static Task<GetUserContactMethodResult> InvokeAsync(GetUserContactMethodArgs args, InvokeOptions? opts = null)
        public static Output<GetUserContactMethodResult> Invoke(GetUserContactMethodInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetUserContactMethodResult> getUserContactMethod(GetUserContactMethodArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: pagerduty:index/getUserContactMethod:getUserContactMethod
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    Type string
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    UserId string
    The ID of the user.
    Label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    Type string
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    UserId string
    The ID of the user.
    label String
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    type String
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId String
    The ID of the user.
    label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    type string
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId string
    The ID of the user.
    label str
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    type str
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    user_id str
    The ID of the user.
    label String
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    type String
    The contact method type. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId String
    The ID of the user.

    getUserContactMethod Result

    The following output properties are available:

    Address string
    The "address" to deliver to: email, phone number, etc., depending on the type.
    Blacklisted bool
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    CountryCode int
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    DeviceType string
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    Enabled bool
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    Id string
    The provider-assigned unique ID for this managed resource.
    Label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    SendShortEmail bool
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    Type string
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    UserId string
    Address string
    The "address" to deliver to: email, phone number, etc., depending on the type.
    Blacklisted bool
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    CountryCode int
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    DeviceType string
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    Enabled bool
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    Id string
    The provider-assigned unique ID for this managed resource.
    Label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    SendShortEmail bool
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    Type string
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    UserId string
    address String
    The "address" to deliver to: email, phone number, etc., depending on the type.
    blacklisted Boolean
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    countryCode Integer
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    deviceType String
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    enabled Boolean
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    id String
    The provider-assigned unique ID for this managed resource.
    label String
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    sendShortEmail Boolean
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    type String
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId String
    address string
    The "address" to deliver to: email, phone number, etc., depending on the type.
    blacklisted boolean
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    countryCode number
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    deviceType string
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    enabled boolean
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    id string
    The provider-assigned unique ID for this managed resource.
    label string
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    sendShortEmail boolean
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    type string
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId string
    address str
    The "address" to deliver to: email, phone number, etc., depending on the type.
    blacklisted bool
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    country_code int
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    device_type str
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    enabled bool
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    id str
    The provider-assigned unique ID for this managed resource.
    label str
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    send_short_email bool
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    type str
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    user_id str
    address String
    The "address" to deliver to: email, phone number, etc., depending on the type.
    blacklisted Boolean
    If true, this phone has been blacklisted by PagerDuty and no messages will be sent to it. (Phone and SMS contact methods only.)
    countryCode Number
    The 1-to-3 digit country calling code. (Phone and SMS contact methods only.)
    deviceType String
    Either ios or android, depending on the type of the device receiving notifications. (Push notification contact method only.)
    enabled Boolean
    If true, this phone is capable of receiving SMS messages. (Phone and SMS contact methods only.)
    id String
    The provider-assigned unique ID for this managed resource.
    label String
    The label (e.g., "Work", "Mobile", "Ashley's iPhone", etc.).
    sendShortEmail Boolean
    Send an abbreviated email message instead of the standard email output. (Email contact method only.)
    type String
    The type of the found contact method. May be (email_contact_method, phone_contact_method, sms_contact_method, push_notification_contact_method).
    userId String

    Package Details

    Repository
    PagerDuty pulumi/pulumi-pagerduty
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the pagerduty Terraform Provider.
    pagerduty logo
    PagerDuty v4.17.0 published on Wednesday, Nov 20, 2024 by Pulumi