com.pulumi.cloudflare.kotlin.ApiShieldSchema.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-cloudflare-kotlin Show documentation
Show all versions of pulumi-cloudflare-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
The newest version!
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.cloudflare.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
/**
* Builder for [ApiShieldSchema].
*/
@PulumiTagMarker
public class ApiShieldSchemaResourceBuilder internal constructor() {
public var name: String? = null
public var args: ApiShieldSchemaArgs = ApiShieldSchemaArgs()
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 ApiShieldSchemaArgsBuilder.() -> Unit) {
val builder = ApiShieldSchemaArgsBuilder()
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(): ApiShieldSchema {
val builtJavaResource = com.pulumi.cloudflare.ApiShieldSchema(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ApiShieldSchema(builtJavaResource)
}
}
/**
* Provides a resource to manage a schema in API Shield Schema Validation 2.0.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as cloudflare from "@pulumi/cloudflare";
* import * as std from "@pulumi/std";
* const petstoreSchema = new cloudflare.ApiShieldSchema("petstore_schema", {
* zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
* name: "myschema",
* kind: "openapi_v3",
* validationEnabled: true,
* source: std.file({
* input: "./schemas/petstore.json",
* }).then(invoke => invoke.result),
* });
* ```
* ```python
* import pulumi
* import pulumi_cloudflare as cloudflare
* import pulumi_std as std
* petstore_schema = cloudflare.ApiShieldSchema("petstore_schema",
* zone_id="0da42c8d2132a9ddaf714f9e7c920711",
* name="myschema",
* kind="openapi_v3",
* validation_enabled=True,
* source=std.file(input="./schemas/petstore.json").result)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Cloudflare = Pulumi.Cloudflare;
* using Std = Pulumi.Std;
* return await Deployment.RunAsync(() =>
* {
* var petstoreSchema = new Cloudflare.ApiShieldSchema("petstore_schema", new()
* {
* ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
* Name = "myschema",
* Kind = "openapi_v3",
* ValidationEnabled = true,
* Source = Std.File.Invoke(new()
* {
* Input = "./schemas/petstore.json",
* }).Apply(invoke => invoke.Result),
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
* "github.com/pulumi/pulumi-std/sdk/go/std"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* invokeFile, err := std.File(ctx, &std.FileArgs{
* Input: "./schemas/petstore.json",
* }, nil)
* if err != nil {
* return err
* }
* _, err = cloudflare.NewApiShieldSchema(ctx, "petstore_schema", &cloudflare.ApiShieldSchemaArgs{
* ZoneId: pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
* Name: pulumi.String("myschema"),
* Kind: pulumi.String("openapi_v3"),
* ValidationEnabled: pulumi.Bool(true),
* Source: pulumi.String(invokeFile.Result),
* })
* 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.cloudflare.ApiShieldSchema;
* import com.pulumi.cloudflare.ApiShieldSchemaArgs;
* 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 petstoreSchema = new ApiShieldSchema("petstoreSchema", ApiShieldSchemaArgs.builder()
* .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
* .name("myschema")
* .kind("openapi_v3")
* .validationEnabled(true)
* .source(StdFunctions.file(FileArgs.builder()
* .input("./schemas/petstore.json")
* .build()).result())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* petstoreSchema:
* type: cloudflare:ApiShieldSchema
* name: petstore_schema
* properties:
* zoneId: 0da42c8d2132a9ddaf714f9e7c920711
* name: myschema
* kind: openapi_v3
* validationEnabled: true # optional, default false
* source:
* fn::invoke:
* Function: std:file
* Arguments:
* input: ./schemas/petstore.json
* Return: result
* ```
*
*/
public class ApiShieldSchema internal constructor(
override val javaResource: com.pulumi.cloudflare.ApiShieldSchema,
) : KotlinCustomResource(javaResource, ApiShieldSchemaMapper) {
/**
* Kind of schema. Defaults to `openapi_v3`. **Modifying this attribute will force creation of a new resource.**
*/
public val kind: Output?
get() = javaResource.kind().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
/**
* Name of the schema. **Modifying this attribute will force creation of a new resource.**
*/
public val name: Output
get() = javaResource.name().applyValue({ args0 -> args0 })
/**
* Schema file bytes. **Modifying this attribute will force creation of a new resource.**
*/
public val source: Output
get() = javaResource.source().applyValue({ args0 -> args0 })
/**
* Flag whether schema is enabled for validation.
*/
public val validationEnabled: Output?
get() = javaResource.validationEnabled().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* The zone identifier to target for the resource. **Modifying this attribute will force creation of a new resource.**
*/
public val zoneId: Output
get() = javaResource.zoneId().applyValue({ args0 -> args0 })
}
public object ApiShieldSchemaMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.cloudflare.ApiShieldSchema::class == javaResource::class
override fun map(javaResource: Resource): ApiShieldSchema = ApiShieldSchema(
javaResource as
com.pulumi.cloudflare.ApiShieldSchema,
)
}
/**
* @see [ApiShieldSchema].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ApiShieldSchema].
*/
public suspend fun apiShieldSchema(
name: String,
block: suspend ApiShieldSchemaResourceBuilder.() -> Unit,
): ApiShieldSchema {
val builder = ApiShieldSchemaResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ApiShieldSchema].
* @param name The _unique_ name of the resulting resource.
*/
public fun apiShieldSchema(name: String): ApiShieldSchema {
val builder = ApiShieldSchemaResourceBuilder()
builder.name(name)
return builder.build()
}