All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.gcp.essentialcontacts.kotlin.Contact.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 8.10.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.essentialcontacts.kotlin

import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List

/**
 * Builder for [Contact].
 */
@PulumiTagMarker
public class ContactResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ContactArgs = ContactArgs()

    public var opts: CustomResourceOptions = CustomResourceOptions()

    /**
     * @param name The _unique_ name of the resulting resource.
     */
    public fun name(`value`: String) {
        this.name = value
    }

    /**
     * @param block The arguments to use to populate this resource's properties.
     */
    public suspend fun args(block: suspend ContactArgsBuilder.() -> Unit) {
        val builder = ContactArgsBuilder()
        block(builder)
        this.args = builder.build()
    }

    /**
     * @param block A bag of options that control this resource's behavior.
     */
    public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
        this.opts = com.pulumi.kotlin.options.CustomResourceOptions.opts(block)
    }

    internal fun build(): Contact {
        val builtJavaResource = com.pulumi.gcp.essentialcontacts.Contact(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Contact(builtJavaResource)
    }
}

/**
 * A contact that will receive notifications from Google Cloud.
 * To get more information about Contact, see:
 * * [API documentation](https://cloud.google.com/resource-manager/docs/reference/essentialcontacts/rest/v1/projects.contacts)
 * * How-to Guides
 *     * [Official Documentation](https://cloud.google.com/resource-manager/docs/managing-notification-contacts)
 * > **Warning:** If you are using User ADCs (Application Default Credentials) with this resource,
 * you must specify a `billing_project` and set `user_project_override` to true
 * in the provider configuration. Otherwise the Essential Contacts API will return a 403 error.
 * Your account must have the `serviceusage.services.use` permission on the
 * `billing_project` you defined.
 * ## Example Usage
 * ### Essential Contact
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const project = gcp.organizations.getProject({});
 * const contact = new gcp.essentialcontacts.Contact("contact", {
 *     parent: project.then(project => project.id),
 *     email: "[email protected]",
 *     languageTag: "en-GB",
 *     notificationCategorySubscriptions: ["ALL"],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * project = gcp.organizations.get_project()
 * contact = gcp.essentialcontacts.Contact("contact",
 *     parent=project.id,
 *     email="[email protected]",
 *     language_tag="en-GB",
 *     notification_category_subscriptions=["ALL"])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var project = Gcp.Organizations.GetProject.Invoke();
 *     var contact = new Gcp.EssentialContacts.Contact("contact", new()
 *     {
 *         Parent = project.Apply(getProjectResult => getProjectResult.Id),
 *         Email = "[email protected]",
 *         LanguageTag = "en-GB",
 *         NotificationCategorySubscriptions = new[]
 *         {
 *             "ALL",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/essentialcontacts"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		project, err := organizations.LookupProject(ctx, nil, nil)
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = essentialcontacts.NewContact(ctx, "contact", &essentialcontacts.ContactArgs{
 * 			Parent:      pulumi.String(project.Id),
 * 			Email:       pulumi.String("[email protected]"),
 * 			LanguageTag: pulumi.String("en-GB"),
 * 			NotificationCategorySubscriptions: pulumi.StringArray{
 * 				pulumi.String("ALL"),
 * 			},
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		return nil
 * 	})
 * }
 * ```
 * ```java
 * package generated_program;
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.gcp.organizations.OrganizationsFunctions;
 * import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
 * import com.pulumi.gcp.essentialcontacts.Contact;
 * import com.pulumi.gcp.essentialcontacts.ContactArgs;
 * 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 project = OrganizationsFunctions.getProject();
 *         var contact = new Contact("contact", ContactArgs.builder()
 *             .parent(project.applyValue(getProjectResult -> getProjectResult.id()))
 *             .email("[email protected]")
 *             .languageTag("en-GB")
 *             .notificationCategorySubscriptions("ALL")
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   contact:
 *     type: gcp:essentialcontacts:Contact
 *     properties:
 *       parent: ${project.id}
 *       email: [email protected]
 *       languageTag: en-GB
 *       notificationCategorySubscriptions:
 *         - ALL
 * variables:
 *   project:
 *     fn::invoke:
 *       Function: gcp:organizations:getProject
 *       Arguments: {}
 * ```
 * 
 * ## Import
 * Contact can be imported using any of these accepted formats:
 * * `{{name}}`
 * When using the `pulumi import` command, Contact can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:essentialcontacts/contact:Contact default {{name}}
 * ```
 */
public class Contact internal constructor(
    override val javaResource: com.pulumi.gcp.essentialcontacts.Contact,
) : KotlinCustomResource(javaResource, ContactMapper) {
    /**
     * The email address to send notifications to. This does not need to be a Google account.
     */
    public val email: Output
        get() = javaResource.email().applyValue({ args0 -> args0 })

    /**
     * The preferred language for notifications, as a ISO 639-1 language code. See Supported languages for a list of supported languages.
     */
    public val languageTag: Output
        get() = javaResource.languageTag().applyValue({ args0 -> args0 })

    /**
     * The identifier for the contact. Format: {resourceType}/{resource_id}/contacts/{contact_id}
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The categories of notifications that the contact will receive communications for.
     */
    public val notificationCategorySubscriptions: Output>
        get() = javaResource.notificationCategorySubscriptions().applyValue({ args0 ->
            args0.map({ args0 -> args0 })
        })

    /**
     * The resource to save this contact for. Format: organizations/{organization_id}, folders/{folder_id} or projects/{project_id}
     * - - -
     */
    public val parent: Output
        get() = javaResource.parent().applyValue({ args0 -> args0 })
}

public object ContactMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.essentialcontacts.Contact::class == javaResource::class

    override fun map(javaResource: Resource): Contact = Contact(
        javaResource as
            com.pulumi.gcp.essentialcontacts.Contact,
    )
}

/**
 * @see [Contact].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Contact].
 */
public suspend fun contact(name: String, block: suspend ContactResourceBuilder.() -> Unit): Contact {
    val builder = ContactResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Contact].
 * @param name The _unique_ name of the resulting resource.
 */
public fun contact(name: String): Contact {
    val builder = ContactResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy