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

com.pulumi.gcp.networkservices.kotlin.GrpcRoute.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.12.0.0
Show newest version
@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.gcp.networkservices.kotlin

import com.pulumi.core.Output
import com.pulumi.gcp.networkservices.kotlin.outputs.GrpcRouteRule
import com.pulumi.gcp.networkservices.kotlin.outputs.GrpcRouteRule.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
import kotlin.collections.List
import kotlin.collections.Map

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

    public var args: GrpcRouteArgs = GrpcRouteArgs()

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

/**
 * ## Example Usage
 * ### Network Services Grpc Route Basic
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.networkservices.GrpcRoute("default", {
 *     name: "my-grpc-route",
 *     labels: {
 *         foo: "bar",
 *     },
 *     description: "my description",
 *     hostnames: ["example"],
 *     rules: [{
 *         matches: [{
 *             headers: [{
 *                 key: "key",
 *                 value: "value",
 *             }],
 *         }],
 *         action: {
 *             retryPolicy: {
 *                 retryConditions: ["cancelled"],
 *                 numRetries: 1,
 *             },
 *         },
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.networkservices.GrpcRoute("default",
 *     name="my-grpc-route",
 *     labels={
 *         "foo": "bar",
 *     },
 *     description="my description",
 *     hostnames=["example"],
 *     rules=[gcp.networkservices.GrpcRouteRuleArgs(
 *         matches=[gcp.networkservices.GrpcRouteRuleMatchArgs(
 *             headers=[gcp.networkservices.GrpcRouteRuleMatchHeaderArgs(
 *                 key="key",
 *                 value="value",
 *             )],
 *         )],
 *         action=gcp.networkservices.GrpcRouteRuleActionArgs(
 *             retry_policy=gcp.networkservices.GrpcRouteRuleActionRetryPolicyArgs(
 *                 retry_conditions=["cancelled"],
 *                 num_retries=1,
 *             ),
 *         ),
 *     )])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.NetworkServices.GrpcRoute("default", new()
 *     {
 *         Name = "my-grpc-route",
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *         Description = "my description",
 *         Hostnames = new[]
 *         {
 *             "example",
 *         },
 *         Rules = new[]
 *         {
 *             new Gcp.NetworkServices.Inputs.GrpcRouteRuleArgs
 *             {
 *                 Matches = new[]
 *                 {
 *                     new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchArgs
 *                     {
 *                         Headers = new[]
 *                         {
 *                             new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchHeaderArgs
 *                             {
 *                                 Key = "key",
 *                                 Value = "value",
 *                             },
 *                         },
 *                     },
 *                 },
 *                 Action = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionArgs
 *                 {
 *                     RetryPolicy = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionRetryPolicyArgs
 *                     {
 *                         RetryConditions = new[]
 *                         {
 *                             "cancelled",
 *                         },
 *                         NumRetries = 1,
 *                     },
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkservices"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := networkservices.NewGrpcRoute(ctx, "default", &networkservices.GrpcRouteArgs{
 * 			Name: pulumi.String("my-grpc-route"),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 			Description: pulumi.String("my description"),
 * 			Hostnames: pulumi.StringArray{
 * 				pulumi.String("example"),
 * 			},
 * 			Rules: networkservices.GrpcRouteRuleArray{
 * 				&networkservices.GrpcRouteRuleArgs{
 * 					Matches: networkservices.GrpcRouteRuleMatchArray{
 * 						&networkservices.GrpcRouteRuleMatchArgs{
 * 							Headers: networkservices.GrpcRouteRuleMatchHeaderArray{
 * 								&networkservices.GrpcRouteRuleMatchHeaderArgs{
 * 									Key:   pulumi.String("key"),
 * 									Value: pulumi.String("value"),
 * 								},
 * 							},
 * 						},
 * 					},
 * 					Action: &networkservices.GrpcRouteRuleActionArgs{
 * 						RetryPolicy: &networkservices.GrpcRouteRuleActionRetryPolicyArgs{
 * 							RetryConditions: pulumi.StringArray{
 * 								pulumi.String("cancelled"),
 * 							},
 * 							NumRetries: pulumi.Int(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.networkservices.GrpcRoute;
 * import com.pulumi.gcp.networkservices.GrpcRouteArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionRetryPolicyArgs;
 * 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 default_ = new GrpcRoute("default", GrpcRouteArgs.builder()
 *             .name("my-grpc-route")
 *             .labels(Map.of("foo", "bar"))
 *             .description("my description")
 *             .hostnames("example")
 *             .rules(GrpcRouteRuleArgs.builder()
 *                 .matches(GrpcRouteRuleMatchArgs.builder()
 *                     .headers(GrpcRouteRuleMatchHeaderArgs.builder()
 *                         .key("key")
 *                         .value("value")
 *                         .build())
 *                     .build())
 *                 .action(GrpcRouteRuleActionArgs.builder()
 *                     .retryPolicy(GrpcRouteRuleActionRetryPolicyArgs.builder()
 *                         .retryConditions("cancelled")
 *                         .numRetries(1)
 *                         .build())
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:networkservices:GrpcRoute
 *     properties:
 *       name: my-grpc-route
 *       labels:
 *         foo: bar
 *       description: my description
 *       hostnames:
 *         - example
 *       rules:
 *         - matches:
 *             - headers:
 *                 - key: key
 *                   value: value
 *           action:
 *             retryPolicy:
 *               retryConditions:
 *                 - cancelled
 *               numRetries: 1
 * ```
 * 
 * ### Network Services Grpc Route Matches And Actions
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.networkservices.GrpcRoute("default", {
 *     name: "my-grpc-route",
 *     labels: {
 *         foo: "bar",
 *     },
 *     description: "my description",
 *     hostnames: ["example"],
 *     rules: [{
 *         matches: [
 *             {
 *                 headers: [{
 *                     key: "key",
 *                     value: "value",
 *                 }],
 *             },
 *             {
 *                 headers: [{
 *                     key: "key",
 *                     value: "value",
 *                 }],
 *                 method: {
 *                     grpcService: "foo",
 *                     grpcMethod: "bar",
 *                     caseSensitive: true,
 *                 },
 *             },
 *         ],
 *         action: {
 *             faultInjectionPolicy: {
 *                 delay: {
 *                     fixedDelay: "1s",
 *                     percentage: 1,
 *                 },
 *                 abort: {
 *                     httpStatus: 500,
 *                     percentage: 1,
 *                 },
 *             },
 *             retryPolicy: {
 *                 retryConditions: ["cancelled"],
 *                 numRetries: 1,
 *             },
 *         },
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.networkservices.GrpcRoute("default",
 *     name="my-grpc-route",
 *     labels={
 *         "foo": "bar",
 *     },
 *     description="my description",
 *     hostnames=["example"],
 *     rules=[gcp.networkservices.GrpcRouteRuleArgs(
 *         matches=[
 *             gcp.networkservices.GrpcRouteRuleMatchArgs(
 *                 headers=[gcp.networkservices.GrpcRouteRuleMatchHeaderArgs(
 *                     key="key",
 *                     value="value",
 *                 )],
 *             ),
 *             gcp.networkservices.GrpcRouteRuleMatchArgs(
 *                 headers=[gcp.networkservices.GrpcRouteRuleMatchHeaderArgs(
 *                     key="key",
 *                     value="value",
 *                 )],
 *                 method=gcp.networkservices.GrpcRouteRuleMatchMethodArgs(
 *                     grpc_service="foo",
 *                     grpc_method="bar",
 *                     case_sensitive=True,
 *                 ),
 *             ),
 *         ],
 *         action=gcp.networkservices.GrpcRouteRuleActionArgs(
 *             fault_injection_policy=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyArgs(
 *                 delay=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs(
 *                     fixed_delay="1s",
 *                     percentage=1,
 *                 ),
 *                 abort=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs(
 *                     http_status=500,
 *                     percentage=1,
 *                 ),
 *             ),
 *             retry_policy=gcp.networkservices.GrpcRouteRuleActionRetryPolicyArgs(
 *                 retry_conditions=["cancelled"],
 *                 num_retries=1,
 *             ),
 *         ),
 *     )])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.NetworkServices.GrpcRoute("default", new()
 *     {
 *         Name = "my-grpc-route",
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *         Description = "my description",
 *         Hostnames = new[]
 *         {
 *             "example",
 *         },
 *         Rules = new[]
 *         {
 *             new Gcp.NetworkServices.Inputs.GrpcRouteRuleArgs
 *             {
 *                 Matches = new[]
 *                 {
 *                     new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchArgs
 *                     {
 *                         Headers = new[]
 *                         {
 *                             new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchHeaderArgs
 *                             {
 *                                 Key = "key",
 *                                 Value = "value",
 *                             },
 *                         },
 *                     },
 *                     new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchArgs
 *                     {
 *                         Headers = new[]
 *                         {
 *                             new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchHeaderArgs
 *                             {
 *                                 Key = "key",
 *                                 Value = "value",
 *                             },
 *                         },
 *                         Method = new Gcp.NetworkServices.Inputs.GrpcRouteRuleMatchMethodArgs
 *                         {
 *                             GrpcService = "foo",
 *                             GrpcMethod = "bar",
 *                             CaseSensitive = true,
 *                         },
 *                     },
 *                 },
 *                 Action = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionArgs
 *                 {
 *                     FaultInjectionPolicy = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyArgs
 *                     {
 *                         Delay = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs
 *                         {
 *                             FixedDelay = "1s",
 *                             Percentage = 1,
 *                         },
 *                         Abort = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs
 *                         {
 *                             HttpStatus = 500,
 *                             Percentage = 1,
 *                         },
 *                     },
 *                     RetryPolicy = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionRetryPolicyArgs
 *                     {
 *                         RetryConditions = new[]
 *                         {
 *                             "cancelled",
 *                         },
 *                         NumRetries = 1,
 *                     },
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkservices"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := networkservices.NewGrpcRoute(ctx, "default", &networkservices.GrpcRouteArgs{
 * 			Name: pulumi.String("my-grpc-route"),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 			Description: pulumi.String("my description"),
 * 			Hostnames: pulumi.StringArray{
 * 				pulumi.String("example"),
 * 			},
 * 			Rules: networkservices.GrpcRouteRuleArray{
 * 				&networkservices.GrpcRouteRuleArgs{
 * 					Matches: networkservices.GrpcRouteRuleMatchArray{
 * 						&networkservices.GrpcRouteRuleMatchArgs{
 * 							Headers: networkservices.GrpcRouteRuleMatchHeaderArray{
 * 								&networkservices.GrpcRouteRuleMatchHeaderArgs{
 * 									Key:   pulumi.String("key"),
 * 									Value: pulumi.String("value"),
 * 								},
 * 							},
 * 						},
 * 						&networkservices.GrpcRouteRuleMatchArgs{
 * 							Headers: networkservices.GrpcRouteRuleMatchHeaderArray{
 * 								&networkservices.GrpcRouteRuleMatchHeaderArgs{
 * 									Key:   pulumi.String("key"),
 * 									Value: pulumi.String("value"),
 * 								},
 * 							},
 * 							Method: &networkservices.GrpcRouteRuleMatchMethodArgs{
 * 								GrpcService:   pulumi.String("foo"),
 * 								GrpcMethod:    pulumi.String("bar"),
 * 								CaseSensitive: pulumi.Bool(true),
 * 							},
 * 						},
 * 					},
 * 					Action: &networkservices.GrpcRouteRuleActionArgs{
 * 						FaultInjectionPolicy: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyArgs{
 * 							Delay: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs{
 * 								FixedDelay: pulumi.String("1s"),
 * 								Percentage: pulumi.Int(1),
 * 							},
 * 							Abort: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs{
 * 								HttpStatus: pulumi.Int(500),
 * 								Percentage: pulumi.Int(1),
 * 							},
 * 						},
 * 						RetryPolicy: &networkservices.GrpcRouteRuleActionRetryPolicyArgs{
 * 							RetryConditions: pulumi.StringArray{
 * 								pulumi.String("cancelled"),
 * 							},
 * 							NumRetries: pulumi.Int(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.networkservices.GrpcRoute;
 * import com.pulumi.gcp.networkservices.GrpcRouteArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionRetryPolicyArgs;
 * 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 default_ = new GrpcRoute("default", GrpcRouteArgs.builder()
 *             .name("my-grpc-route")
 *             .labels(Map.of("foo", "bar"))
 *             .description("my description")
 *             .hostnames("example")
 *             .rules(GrpcRouteRuleArgs.builder()
 *                 .matches(
 *                     GrpcRouteRuleMatchArgs.builder()
 *                         .headers(GrpcRouteRuleMatchHeaderArgs.builder()
 *                             .key("key")
 *                             .value("value")
 *                             .build())
 *                         .build(),
 *                     GrpcRouteRuleMatchArgs.builder()
 *                         .headers(GrpcRouteRuleMatchHeaderArgs.builder()
 *                             .key("key")
 *                             .value("value")
 *                             .build())
 *                         .method(GrpcRouteRuleMatchMethodArgs.builder()
 *                             .grpcService("foo")
 *                             .grpcMethod("bar")
 *                             .caseSensitive(true)
 *                             .build())
 *                         .build())
 *                 .action(GrpcRouteRuleActionArgs.builder()
 *                     .faultInjectionPolicy(GrpcRouteRuleActionFaultInjectionPolicyArgs.builder()
 *                         .delay(GrpcRouteRuleActionFaultInjectionPolicyDelayArgs.builder()
 *                             .fixedDelay("1s")
 *                             .percentage(1)
 *                             .build())
 *                         .abort(GrpcRouteRuleActionFaultInjectionPolicyAbortArgs.builder()
 *                             .httpStatus(500)
 *                             .percentage(1)
 *                             .build())
 *                         .build())
 *                     .retryPolicy(GrpcRouteRuleActionRetryPolicyArgs.builder()
 *                         .retryConditions("cancelled")
 *                         .numRetries(1)
 *                         .build())
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:networkservices:GrpcRoute
 *     properties:
 *       name: my-grpc-route
 *       labels:
 *         foo: bar
 *       description: my description
 *       hostnames:
 *         - example
 *       rules:
 *         - matches:
 *             - headers:
 *                 - key: key
 *                   value: value
 *             - headers:
 *                 - key: key
 *                   value: value
 *               method:
 *                 grpcService: foo
 *                 grpcMethod: bar
 *                 caseSensitive: true
 *           action:
 *             faultInjectionPolicy:
 *               delay:
 *                 fixedDelay: 1s
 *                 percentage: 1
 *               abort:
 *                 httpStatus: 500
 *                 percentage: 1
 *             retryPolicy:
 *               retryConditions:
 *                 - cancelled
 *               numRetries: 1
 * ```
 * 
 * ### Network Services Grpc Route Actions
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as gcp from "@pulumi/gcp";
 * const _default = new gcp.networkservices.GrpcRoute("default", {
 *     name: "my-grpc-route",
 *     labels: {
 *         foo: "bar",
 *     },
 *     description: "my description",
 *     hostnames: ["example"],
 *     rules: [{
 *         action: {
 *             faultInjectionPolicy: {
 *                 delay: {
 *                     fixedDelay: "1s",
 *                     percentage: 1,
 *                 },
 *                 abort: {
 *                     httpStatus: 500,
 *                     percentage: 1,
 *                 },
 *             },
 *             retryPolicy: {
 *                 retryConditions: ["cancelled"],
 *                 numRetries: 1,
 *             },
 *         },
 *     }],
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_gcp as gcp
 * default = gcp.networkservices.GrpcRoute("default",
 *     name="my-grpc-route",
 *     labels={
 *         "foo": "bar",
 *     },
 *     description="my description",
 *     hostnames=["example"],
 *     rules=[gcp.networkservices.GrpcRouteRuleArgs(
 *         action=gcp.networkservices.GrpcRouteRuleActionArgs(
 *             fault_injection_policy=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyArgs(
 *                 delay=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs(
 *                     fixed_delay="1s",
 *                     percentage=1,
 *                 ),
 *                 abort=gcp.networkservices.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs(
 *                     http_status=500,
 *                     percentage=1,
 *                 ),
 *             ),
 *             retry_policy=gcp.networkservices.GrpcRouteRuleActionRetryPolicyArgs(
 *                 retry_conditions=["cancelled"],
 *                 num_retries=1,
 *             ),
 *         ),
 *     )])
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Gcp = Pulumi.Gcp;
 * return await Deployment.RunAsync(() =>
 * {
 *     var @default = new Gcp.NetworkServices.GrpcRoute("default", new()
 *     {
 *         Name = "my-grpc-route",
 *         Labels =
 *         {
 *             { "foo", "bar" },
 *         },
 *         Description = "my description",
 *         Hostnames = new[]
 *         {
 *             "example",
 *         },
 *         Rules = new[]
 *         {
 *             new Gcp.NetworkServices.Inputs.GrpcRouteRuleArgs
 *             {
 *                 Action = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionArgs
 *                 {
 *                     FaultInjectionPolicy = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyArgs
 *                     {
 *                         Delay = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs
 *                         {
 *                             FixedDelay = "1s",
 *                             Percentage = 1,
 *                         },
 *                         Abort = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs
 *                         {
 *                             HttpStatus = 500,
 *                             Percentage = 1,
 *                         },
 *                     },
 *                     RetryPolicy = new Gcp.NetworkServices.Inputs.GrpcRouteRuleActionRetryPolicyArgs
 *                     {
 *                         RetryConditions = new[]
 *                         {
 *                             "cancelled",
 *                         },
 *                         NumRetries = 1,
 *                     },
 *                 },
 *             },
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/networkservices"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		_, err := networkservices.NewGrpcRoute(ctx, "default", &networkservices.GrpcRouteArgs{
 * 			Name: pulumi.String("my-grpc-route"),
 * 			Labels: pulumi.StringMap{
 * 				"foo": pulumi.String("bar"),
 * 			},
 * 			Description: pulumi.String("my description"),
 * 			Hostnames: pulumi.StringArray{
 * 				pulumi.String("example"),
 * 			},
 * 			Rules: networkservices.GrpcRouteRuleArray{
 * 				&networkservices.GrpcRouteRuleArgs{
 * 					Action: &networkservices.GrpcRouteRuleActionArgs{
 * 						FaultInjectionPolicy: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyArgs{
 * 							Delay: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs{
 * 								FixedDelay: pulumi.String("1s"),
 * 								Percentage: pulumi.Int(1),
 * 							},
 * 							Abort: &networkservices.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs{
 * 								HttpStatus: pulumi.Int(500),
 * 								Percentage: pulumi.Int(1),
 * 							},
 * 						},
 * 						RetryPolicy: &networkservices.GrpcRouteRuleActionRetryPolicyArgs{
 * 							RetryConditions: pulumi.StringArray{
 * 								pulumi.String("cancelled"),
 * 							},
 * 							NumRetries: pulumi.Int(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.networkservices.GrpcRoute;
 * import com.pulumi.gcp.networkservices.GrpcRouteArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyDelayArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionFaultInjectionPolicyAbortArgs;
 * import com.pulumi.gcp.networkservices.inputs.GrpcRouteRuleActionRetryPolicyArgs;
 * 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 default_ = new GrpcRoute("default", GrpcRouteArgs.builder()
 *             .name("my-grpc-route")
 *             .labels(Map.of("foo", "bar"))
 *             .description("my description")
 *             .hostnames("example")
 *             .rules(GrpcRouteRuleArgs.builder()
 *                 .action(GrpcRouteRuleActionArgs.builder()
 *                     .faultInjectionPolicy(GrpcRouteRuleActionFaultInjectionPolicyArgs.builder()
 *                         .delay(GrpcRouteRuleActionFaultInjectionPolicyDelayArgs.builder()
 *                             .fixedDelay("1s")
 *                             .percentage(1)
 *                             .build())
 *                         .abort(GrpcRouteRuleActionFaultInjectionPolicyAbortArgs.builder()
 *                             .httpStatus(500)
 *                             .percentage(1)
 *                             .build())
 *                         .build())
 *                     .retryPolicy(GrpcRouteRuleActionRetryPolicyArgs.builder()
 *                         .retryConditions("cancelled")
 *                         .numRetries(1)
 *                         .build())
 *                     .build())
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   default:
 *     type: gcp:networkservices:GrpcRoute
 *     properties:
 *       name: my-grpc-route
 *       labels:
 *         foo: bar
 *       description: my description
 *       hostnames:
 *         - example
 *       rules:
 *         - action:
 *             faultInjectionPolicy:
 *               delay:
 *                 fixedDelay: 1s
 *                 percentage: 1
 *               abort:
 *                 httpStatus: 500
 *                 percentage: 1
 *             retryPolicy:
 *               retryConditions:
 *                 - cancelled
 *               numRetries: 1
 * ```
 * 
 * ## Import
 * GrpcRoute can be imported using any of these accepted formats:
 * * `projects/{{project}}/locations/global/grpcRoutes/{{name}}`
 * * `{{project}}/{{name}}`
 * * `{{name}}`
 * When using the `pulumi import` command, GrpcRoute can be imported using one of the formats above. For example:
 * ```sh
 * $ pulumi import gcp:networkservices/grpcRoute:GrpcRoute default projects/{{project}}/locations/global/grpcRoutes/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:networkservices/grpcRoute:GrpcRoute default {{project}}/{{name}}
 * ```
 * ```sh
 * $ pulumi import gcp:networkservices/grpcRoute:GrpcRoute default {{name}}
 * ```
 */
public class GrpcRoute internal constructor(
    override val javaResource: com.pulumi.gcp.networkservices.GrpcRoute,
) : KotlinCustomResource(javaResource, GrpcRouteMapper) {
    /**
     * Time the GrpcRoute was created in UTC.
     */
    public val createTime: Output
        get() = javaResource.createTime().applyValue({ args0 -> args0 })

    /**
     * A free-text description of the resource. Max length 1024 characters.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
     */
    public val effectiveLabels: Output>
        get() = javaResource.effectiveLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * List of gateways this GrpcRoute is attached to, as one of the routing rules to route the requests served by the gateway.
     */
    public val gateways: Output>?
        get() = javaResource.gateways().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * Required. Service hostnames with an optional port for which this route describes traffic.
     */
    public val hostnames: Output>
        get() = javaResource.hostnames().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * Set of label tags associated with the GrpcRoute resource. **Note**: This field is non-authoritative, and will only
     * manage the labels present in your configuration. Please refer to the field 'effective_labels' for all of the labels
     * present on the resource.
     */
    public val labels: Output>?
        get() = javaResource.labels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * List of meshes this GrpcRoute is attached to, as one of the routing rules to route the requests served by the mesh.
     */
    public val meshes: Output>?
        get() = javaResource.meshes().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0
                })
            }).orElse(null)
        })

    /**
     * Name of the GrpcRoute resource.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    public val project: Output
        get() = javaResource.project().applyValue({ args0 -> args0 })

    /**
     * The combination of labels configured directly on the resource
     * and default labels configured on the provider.
     */
    public val pulumiLabels: Output>
        get() = javaResource.pulumiLabels().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.key.to(args0.value)
            }).toMap()
        })

    /**
     * Rules that define how traffic is routed and handled.
     * Structure is documented below.
     */
    public val rules: Output>
        get() = javaResource.rules().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    toKotlin(args0)
                })
            })
        })

    /**
     * Server-defined URL of this resource.
     */
    public val selfLink: Output
        get() = javaResource.selfLink().applyValue({ args0 -> args0 })

    /**
     * Time the GrpcRoute was updated in UTC.
     */
    public val updateTime: Output
        get() = javaResource.updateTime().applyValue({ args0 -> args0 })
}

public object GrpcRouteMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.gcp.networkservices.GrpcRoute::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy