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

com.pulumi.gcp.projects.kotlin.ApiKey.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.projects.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.projects.kotlin.outputs.ApiKeyRestrictions
import com.pulumi.gcp.projects.kotlin.outputs.ApiKeyRestrictions.Companion.toKotlin
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

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

    public var args: ApiKeyArgs = ApiKeyArgs()

    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 ApiKeyArgsBuilder.() -> Unit) {
        val builder = ApiKeyArgsBuilder()
        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(): ApiKey {
        val builtJavaResource = com.pulumi.gcp.projects.ApiKey(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return ApiKey(builtJavaResource)
    }
}

/**
 * The Apikeys Key resource
 * ## Example Usage
 * ### Android_key
 * A basic example of a android api keys key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.organizations.Project("basic", {
 *     projectId: "app",
 *     name: "app",
 *     orgId: "123456789",
 * });
 * const primary = new gcp.projects.ApiKey("primary", {
 *     name: "key",
 *     displayName: "sample-key",
 *     project: basic.name,
 *     restrictions: {
 *         androidKeyRestrictions: {
 *             allowedApplications: [{
 *                 packageName: "com.example.app123",
 *                 sha1Fingerprint: "1699466a142d4682a5f91b50fdf400f2358e2b0b",
 *             }],
 *         },
 *         apiTargets: [{
 *             service: "translate.googleapis.com",
 *             methods: ["GET*"],
 *         }],
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.organizations.Project("basic",
 *     project_id="app",
 *     name="app",
 *     org_id="123456789")
 * primary = gcp.projects.ApiKey("primary",
 *     name="key",
 *     display_name="sample-key",
 *     project=basic.name,
 *     restrictions=gcp.projects.ApiKeyRestrictionsArgs(
 *         android_key_restrictions=gcp.projects.ApiKeyRestrictionsAndroidKeyRestrictionsArgs(
 *             allowed_applications=[gcp.projects.ApiKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationArgs(
 *                 package_name="com.example.app123",
 *                 sha1_fingerprint="1699466a142d4682a5f91b50fdf400f2358e2b0b",
 *             )],
 *         ),
 *         api_targets=[gcp.projects.ApiKeyRestrictionsApiTargetArgs(
 *             service="translate.googleapis.com",
 *             methods=["GET*"],
 *         )],
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Organizations.Project("basic", new()
 *     {
 *         ProjectId = "app",
 *         Name = "app",
 *         OrgId = "123456789",
 *     });
 *     var primary = new Gcp.Projects.ApiKey("primary", new()
 *     {
 *         Name = "key",
 *         DisplayName = "sample-key",
 *         Project = basic.Name,
 *         Restrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsArgs
 *         {
 *             AndroidKeyRestrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsAndroidKeyRestrictionsArgs
 *             {
 *                 AllowedApplications = new[]
 *                 {
 *                     new Gcp.Projects.Inputs.ApiKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationArgs
 *                     {
 *                         PackageName = "com.example.app123",
 *                         Sha1Fingerprint = "1699466a142d4682a5f91b50fdf400f2358e2b0b",
 *                     },
 *                 },
 *             },
 *             ApiTargets = new[]
 *             {
 *                 new Gcp.Projects.Inputs.ApiKeyRestrictionsApiTargetArgs
 *                 {
 *                     Service = "translate.googleapis.com",
 *                     Methods = new[]
 *                     {
 *                         "GET*",
 *                     },
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("app"),
 * 			Name:      pulumi.String("app"),
 * 			OrgId:     pulumi.String("123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewApiKey(ctx, "primary", &projects.ApiKeyArgs{
 * 			Name:        pulumi.String("key"),
 * 			DisplayName: pulumi.String("sample-key"),
 * 			Project:     basic.Name,
 * 			Restrictions: &projects.ApiKeyRestrictionsArgs{
 * 				AndroidKeyRestrictions: &projects.ApiKeyRestrictionsAndroidKeyRestrictionsArgs{
 * 					AllowedApplications: projects.ApiKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationArray{
 * 						&projects.ApiKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationArgs{
 * 							PackageName:     pulumi.String("com.example.app123"),
 * 							Sha1Fingerprint: pulumi.String("1699466a142d4682a5f91b50fdf400f2358e2b0b"),
 * 						},
 * 					},
 * 				},
 * 				ApiTargets: projects.ApiKeyRestrictionsApiTargetArray{
 * 					&projects.ApiKeyRestrictionsApiTargetArgs{
 * 						Service: pulumi.String("translate.googleapis.com"),
 * 						Methods: pulumi.StringArray{
 * 							pulumi.String("GET*"),
 * 						},
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.projects.ApiKey;
 * import com.pulumi.gcp.projects.ApiKeyArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsAndroidKeyRestrictionsArgs;
 * 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) {
 *         var basic = new Project("basic", ProjectArgs.builder()
 *             .projectId("app")
 *             .name("app")
 *             .orgId("123456789")
 *             .build());
 *         var primary = new ApiKey("primary", ApiKeyArgs.builder()
 *             .name("key")
 *             .displayName("sample-key")
 *             .project(basic.name())
 *             .restrictions(ApiKeyRestrictionsArgs.builder()
 *                 .androidKeyRestrictions(ApiKeyRestrictionsAndroidKeyRestrictionsArgs.builder()
 *                     .allowedApplications(ApiKeyRestrictionsAndroidKeyRestrictionsAllowedApplicationArgs.builder()
 *                         .packageName("com.example.app123")
 *                         .sha1Fingerprint("1699466a142d4682a5f91b50fdf400f2358e2b0b")
 *                         .build())
 *                     .build())
 *                 .apiTargets(ApiKeyRestrictionsApiTargetArgs.builder()
 *                     .service("translate.googleapis.com")
 *                     .methods("GET*")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:projects:ApiKey
 *     properties:
 *       name: key
 *       displayName: sample-key
 *       project: ${basic.name}
 *       restrictions:
 *         androidKeyRestrictions:
 *           allowedApplications:
 *             - packageName: com.example.app123
 *               sha1Fingerprint: 1699466a142d4682a5f91b50fdf400f2358e2b0b
 *         apiTargets:
 *           - service: translate.googleapis.com
 *             methods:
 *               - GET*
 *   basic:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: app
 *       name: app
 *       orgId: '123456789'
 * ```
 * 
 * ### Basic_key
 * A basic example of a api keys key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.organizations.Project("basic", {
 *     projectId: "app",
 *     name: "app",
 *     orgId: "123456789",
 * });
 * const primary = new gcp.projects.ApiKey("primary", {
 *     name: "key",
 *     displayName: "sample-key",
 *     project: basic.name,
 *     restrictions: {
 *         apiTargets: [{
 *             service: "translate.googleapis.com",
 *             methods: ["GET*"],
 *         }],
 *         browserKeyRestrictions: {
 *             allowedReferrers: [".*"],
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.organizations.Project("basic",
 *     project_id="app",
 *     name="app",
 *     org_id="123456789")
 * primary = gcp.projects.ApiKey("primary",
 *     name="key",
 *     display_name="sample-key",
 *     project=basic.name,
 *     restrictions=gcp.projects.ApiKeyRestrictionsArgs(
 *         api_targets=[gcp.projects.ApiKeyRestrictionsApiTargetArgs(
 *             service="translate.googleapis.com",
 *             methods=["GET*"],
 *         )],
 *         browser_key_restrictions=gcp.projects.ApiKeyRestrictionsBrowserKeyRestrictionsArgs(
 *             allowed_referrers=[".*"],
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Organizations.Project("basic", new()
 *     {
 *         ProjectId = "app",
 *         Name = "app",
 *         OrgId = "123456789",
 *     });
 *     var primary = new Gcp.Projects.ApiKey("primary", new()
 *     {
 *         Name = "key",
 *         DisplayName = "sample-key",
 *         Project = basic.Name,
 *         Restrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsArgs
 *         {
 *             ApiTargets = new[]
 *             {
 *                 new Gcp.Projects.Inputs.ApiKeyRestrictionsApiTargetArgs
 *                 {
 *                     Service = "translate.googleapis.com",
 *                     Methods = new[]
 *                     {
 *                         "GET*",
 *                     },
 *                 },
 *             },
 *             BrowserKeyRestrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsBrowserKeyRestrictionsArgs
 *             {
 *                 AllowedReferrers = new[]
 *                 {
 *                     ".*",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("app"),
 * 			Name:      pulumi.String("app"),
 * 			OrgId:     pulumi.String("123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewApiKey(ctx, "primary", &projects.ApiKeyArgs{
 * 			Name:        pulumi.String("key"),
 * 			DisplayName: pulumi.String("sample-key"),
 * 			Project:     basic.Name,
 * 			Restrictions: &projects.ApiKeyRestrictionsArgs{
 * 				ApiTargets: projects.ApiKeyRestrictionsApiTargetArray{
 * 					&projects.ApiKeyRestrictionsApiTargetArgs{
 * 						Service: pulumi.String("translate.googleapis.com"),
 * 						Methods: pulumi.StringArray{
 * 							pulumi.String("GET*"),
 * 						},
 * 					},
 * 				},
 * 				BrowserKeyRestrictions: &projects.ApiKeyRestrictionsBrowserKeyRestrictionsArgs{
 * 					AllowedReferrers: pulumi.StringArray{
 * 						pulumi.String(".*"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.projects.ApiKey;
 * import com.pulumi.gcp.projects.ApiKeyArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsBrowserKeyRestrictionsArgs;
 * 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) {
 *         var basic = new Project("basic", ProjectArgs.builder()
 *             .projectId("app")
 *             .name("app")
 *             .orgId("123456789")
 *             .build());
 *         var primary = new ApiKey("primary", ApiKeyArgs.builder()
 *             .name("key")
 *             .displayName("sample-key")
 *             .project(basic.name())
 *             .restrictions(ApiKeyRestrictionsArgs.builder()
 *                 .apiTargets(ApiKeyRestrictionsApiTargetArgs.builder()
 *                     .service("translate.googleapis.com")
 *                     .methods("GET*")
 *                     .build())
 *                 .browserKeyRestrictions(ApiKeyRestrictionsBrowserKeyRestrictionsArgs.builder()
 *                     .allowedReferrers(".*")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:projects:ApiKey
 *     properties:
 *       name: key
 *       displayName: sample-key
 *       project: ${basic.name}
 *       restrictions:
 *         apiTargets:
 *           - service: translate.googleapis.com
 *             methods:
 *               - GET*
 *         browserKeyRestrictions:
 *           allowedReferrers:
 *             - .*
 *   basic:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: app
 *       name: app
 *       orgId: '123456789'
 * ```
 * 
 * ### Ios_key
 * A basic example of a ios api keys key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.organizations.Project("basic", {
 *     projectId: "app",
 *     name: "app",
 *     orgId: "123456789",
 * });
 * const primary = new gcp.projects.ApiKey("primary", {
 *     name: "key",
 *     displayName: "sample-key",
 *     project: basic.name,
 *     restrictions: {
 *         apiTargets: [{
 *             service: "translate.googleapis.com",
 *             methods: ["GET*"],
 *         }],
 *         iosKeyRestrictions: {
 *             allowedBundleIds: ["com.google.app.macos"],
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.organizations.Project("basic",
 *     project_id="app",
 *     name="app",
 *     org_id="123456789")
 * primary = gcp.projects.ApiKey("primary",
 *     name="key",
 *     display_name="sample-key",
 *     project=basic.name,
 *     restrictions=gcp.projects.ApiKeyRestrictionsArgs(
 *         api_targets=[gcp.projects.ApiKeyRestrictionsApiTargetArgs(
 *             service="translate.googleapis.com",
 *             methods=["GET*"],
 *         )],
 *         ios_key_restrictions=gcp.projects.ApiKeyRestrictionsIosKeyRestrictionsArgs(
 *             allowed_bundle_ids=["com.google.app.macos"],
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Organizations.Project("basic", new()
 *     {
 *         ProjectId = "app",
 *         Name = "app",
 *         OrgId = "123456789",
 *     });
 *     var primary = new Gcp.Projects.ApiKey("primary", new()
 *     {
 *         Name = "key",
 *         DisplayName = "sample-key",
 *         Project = basic.Name,
 *         Restrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsArgs
 *         {
 *             ApiTargets = new[]
 *             {
 *                 new Gcp.Projects.Inputs.ApiKeyRestrictionsApiTargetArgs
 *                 {
 *                     Service = "translate.googleapis.com",
 *                     Methods = new[]
 *                     {
 *                         "GET*",
 *                     },
 *                 },
 *             },
 *             IosKeyRestrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsIosKeyRestrictionsArgs
 *             {
 *                 AllowedBundleIds = new[]
 *                 {
 *                     "com.google.app.macos",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("app"),
 * 			Name:      pulumi.String("app"),
 * 			OrgId:     pulumi.String("123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewApiKey(ctx, "primary", &projects.ApiKeyArgs{
 * 			Name:        pulumi.String("key"),
 * 			DisplayName: pulumi.String("sample-key"),
 * 			Project:     basic.Name,
 * 			Restrictions: &projects.ApiKeyRestrictionsArgs{
 * 				ApiTargets: projects.ApiKeyRestrictionsApiTargetArray{
 * 					&projects.ApiKeyRestrictionsApiTargetArgs{
 * 						Service: pulumi.String("translate.googleapis.com"),
 * 						Methods: pulumi.StringArray{
 * 							pulumi.String("GET*"),
 * 						},
 * 					},
 * 				},
 * 				IosKeyRestrictions: &projects.ApiKeyRestrictionsIosKeyRestrictionsArgs{
 * 					AllowedBundleIds: pulumi.StringArray{
 * 						pulumi.String("com.google.app.macos"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.projects.ApiKey;
 * import com.pulumi.gcp.projects.ApiKeyArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsIosKeyRestrictionsArgs;
 * 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) {
 *         var basic = new Project("basic", ProjectArgs.builder()
 *             .projectId("app")
 *             .name("app")
 *             .orgId("123456789")
 *             .build());
 *         var primary = new ApiKey("primary", ApiKeyArgs.builder()
 *             .name("key")
 *             .displayName("sample-key")
 *             .project(basic.name())
 *             .restrictions(ApiKeyRestrictionsArgs.builder()
 *                 .apiTargets(ApiKeyRestrictionsApiTargetArgs.builder()
 *                     .service("translate.googleapis.com")
 *                     .methods("GET*")
 *                     .build())
 *                 .iosKeyRestrictions(ApiKeyRestrictionsIosKeyRestrictionsArgs.builder()
 *                     .allowedBundleIds("com.google.app.macos")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:projects:ApiKey
 *     properties:
 *       name: key
 *       displayName: sample-key
 *       project: ${basic.name}
 *       restrictions:
 *         apiTargets:
 *           - service: translate.googleapis.com
 *             methods:
 *               - GET*
 *         iosKeyRestrictions:
 *           allowedBundleIds:
 *             - com.google.app.macos
 *   basic:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: app
 *       name: app
 *       orgId: '123456789'
 * ```
 * 
 * ### Minimal_key
 * A minimal example of a api keys key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.organizations.Project("basic", {
 *     projectId: "app",
 *     name: "app",
 *     orgId: "123456789",
 * });
 * const primary = new gcp.projects.ApiKey("primary", {
 *     name: "key",
 *     displayName: "sample-key",
 *     project: basic.name,
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.organizations.Project("basic",
 *     project_id="app",
 *     name="app",
 *     org_id="123456789")
 * primary = gcp.projects.ApiKey("primary",
 *     name="key",
 *     display_name="sample-key",
 *     project=basic.name)
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Organizations.Project("basic", new()
 *     {
 *         ProjectId = "app",
 *         Name = "app",
 *         OrgId = "123456789",
 *     });
 *     var primary = new Gcp.Projects.ApiKey("primary", new()
 *     {
 *         Name = "key",
 *         DisplayName = "sample-key",
 *         Project = basic.Name,
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("app"),
 * 			Name:      pulumi.String("app"),
 * 			OrgId:     pulumi.String("123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewApiKey(ctx, "primary", &projects.ApiKeyArgs{
 * 			Name:        pulumi.String("key"),
 * 			DisplayName: pulumi.String("sample-key"),
 * 			Project:     basic.Name,
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.projects.ApiKey;
 * import com.pulumi.gcp.projects.ApiKeyArgs;
 * 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) {
 *         var basic = new Project("basic", ProjectArgs.builder()
 *             .projectId("app")
 *             .name("app")
 *             .orgId("123456789")
 *             .build());
 *         var primary = new ApiKey("primary", ApiKeyArgs.builder()
 *             .name("key")
 *             .displayName("sample-key")
 *             .project(basic.name())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:projects:ApiKey
 *     properties:
 *       name: key
 *       displayName: sample-key
 *       project: ${basic.name}
 *   basic:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: app
 *       name: app
 *       orgId: '123456789'
 * ```
 * 
 * ### Server_key
 * A basic example of a server api keys key
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const basic = new gcp.organizations.Project("basic", {
 *     projectId: "app",
 *     name: "app",
 *     orgId: "123456789",
 * });
 * const primary = new gcp.projects.ApiKey("primary", {
 *     name: "key",
 *     displayName: "sample-key",
 *     project: basic.name,
 *     restrictions: {
 *         apiTargets: [{
 *             service: "translate.googleapis.com",
 *             methods: ["GET*"],
 *         }],
 *         serverKeyRestrictions: {
 *             allowedIps: ["127.0.0.1"],
 *         },
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * basic = gcp.organizations.Project("basic",
 *     project_id="app",
 *     name="app",
 *     org_id="123456789")
 * primary = gcp.projects.ApiKey("primary",
 *     name="key",
 *     display_name="sample-key",
 *     project=basic.name,
 *     restrictions=gcp.projects.ApiKeyRestrictionsArgs(
 *         api_targets=[gcp.projects.ApiKeyRestrictionsApiTargetArgs(
 *             service="translate.googleapis.com",
 *             methods=["GET*"],
 *         )],
 *         server_key_restrictions=gcp.projects.ApiKeyRestrictionsServerKeyRestrictionsArgs(
 *             allowed_ips=["127.0.0.1"],
 *         ),
 *     ))
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var basic = new Gcp.Organizations.Project("basic", new()
 *     {
 *         ProjectId = "app",
 *         Name = "app",
 *         OrgId = "123456789",
 *     });
 *     var primary = new Gcp.Projects.ApiKey("primary", new()
 *     {
 *         Name = "key",
 *         DisplayName = "sample-key",
 *         Project = basic.Name,
 *         Restrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsArgs
 *         {
 *             ApiTargets = new[]
 *             {
 *                 new Gcp.Projects.Inputs.ApiKeyRestrictionsApiTargetArgs
 *                 {
 *                     Service = "translate.googleapis.com",
 *                     Methods = new[]
 *                     {
 *                         "GET*",
 *                     },
 *                 },
 *             },
 *             ServerKeyRestrictions = new Gcp.Projects.Inputs.ApiKeyRestrictionsServerKeyRestrictionsArgs
 *             {
 *                 AllowedIps = new[]
 *                 {
 *                     "127.0.0.1",
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/organizations"
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/projects"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		basic, err := organizations.NewProject(ctx, "basic", &organizations.ProjectArgs{
 * 			ProjectId: pulumi.String("app"),
 * 			Name:      pulumi.String("app"),
 * 			OrgId:     pulumi.String("123456789"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = projects.NewApiKey(ctx, "primary", &projects.ApiKeyArgs{
 * 			Name:        pulumi.String("key"),
 * 			DisplayName: pulumi.String("sample-key"),
 * 			Project:     basic.Name,
 * 			Restrictions: &projects.ApiKeyRestrictionsArgs{
 * 				ApiTargets: projects.ApiKeyRestrictionsApiTargetArray{
 * 					&projects.ApiKeyRestrictionsApiTargetArgs{
 * 						Service: pulumi.String("translate.googleapis.com"),
 * 						Methods: pulumi.StringArray{
 * 							pulumi.String("GET*"),
 * 						},
 * 					},
 * 				},
 * 				ServerKeyRestrictions: &projects.ApiKeyRestrictionsServerKeyRestrictionsArgs{
 * 					AllowedIps: pulumi.StringArray{
 * 						pulumi.String("127.0.0.1"),
 * 					},
 * 				},
 * 			},
 * 		})
 * 		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.Project;
 * import com.pulumi.gcp.organizations.ProjectArgs;
 * import com.pulumi.gcp.projects.ApiKey;
 * import com.pulumi.gcp.projects.ApiKeyArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsArgs;
 * import com.pulumi.gcp.projects.inputs.ApiKeyRestrictionsServerKeyRestrictionsArgs;
 * 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) {
 *         var basic = new Project("basic", ProjectArgs.builder()
 *             .projectId("app")
 *             .name("app")
 *             .orgId("123456789")
 *             .build());
 *         var primary = new ApiKey("primary", ApiKeyArgs.builder()
 *             .name("key")
 *             .displayName("sample-key")
 *             .project(basic.name())
 *             .restrictions(ApiKeyRestrictionsArgs.builder()
 *                 .apiTargets(ApiKeyRestrictionsApiTargetArgs.builder()
 *                     .service("translate.googleapis.com")
 *                     .methods("GET*")
 *                     .build())
 *                 .serverKeyRestrictions(ApiKeyRestrictionsServerKeyRestrictionsArgs.builder()
 *                     .allowedIps("127.0.0.1")
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   primary:
 *     type: gcp:projects:ApiKey
 *     properties:
 *       name: key
 *       displayName: sample-key
 *       project: ${basic.name}
 *       restrictions:
 *         apiTargets:
 *           - service: translate.googleapis.com
 *             methods:
 *               - GET*
 *         serverKeyRestrictions:
 *           allowedIps:
 *             - 127.0.0.1
 *   basic:
 *     type: gcp:organizations:Project
 *     properties:
 *       projectId: app
 *       name: app
 *       orgId: '123456789'
 * ```
 * 
 * ## Import
 * Key can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/global/keys/{{name}}`
 * * `{{project}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, Key can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:projects/apiKey:ApiKey default projects/{{project}}/locations/global/keys/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:projects/apiKey:ApiKey default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:projects/apiKey:ApiKey default {{name}}
 * ```
 */
public class ApiKey internal constructor(
    override val javaResource: com.pulumi.gcp.projects.ApiKey,
) : KotlinCustomResource(javaResource, ApiKeyMapper) {
    /**
     * Human-readable display name of this API key. Modifiable by user.
     */
    public val displayName: Output?
        get() = javaResource.displayName().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Output only. An encrypted and signed value held by this key. This field can be accessed only through the `GetKeyString` method.
     */
    public val keyString: Output
        get() = javaResource.keyString().applyValue({ args0 -> args0 })

    /**
     * The resource name of the key. The name must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the name must match the regular expression: `a-z?`.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * The project for the resource
     */
    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * Key restrictions.
     */
    public val restrictions: Output?
        get() = javaResource.restrictions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Output only. Unique id in UUID4 format.
     */
    public val uid: Output
        get() = javaResource.uid().applyValue({ args0 -> args0 })
}

public object ApiKeyMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.projects.ApiKey::class == javaResource::class

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy