![JAR search and dependency download from the Maven repository](/logo.png)
com.pulumi.azure.apimanagement.kotlin.ApiPolicy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-azure-kotlin Show documentation
Show all versions of pulumi-azure-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.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.azure.apimanagement.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 [ApiPolicy].
*/
@PulumiTagMarker
public class ApiPolicyResourceBuilder internal constructor() {
public var name: String? = null
public var args: ApiPolicyArgs = ApiPolicyArgs()
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 ApiPolicyArgsBuilder.() -> Unit) {
val builder = ApiPolicyArgsBuilder()
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(): ApiPolicy {
val builtJavaResource = com.pulumi.azure.apimanagement.ApiPolicy(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return ApiPolicy(builtJavaResource)
}
}
/**
* Manages an API Management API Policy
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as azure from "@pulumi/azure";
* const example = azure.apimanagement.getApi({
* name: "my-api",
* apiManagementName: "example-apim",
* resourceGroupName: "search-service",
* revision: "2",
* });
* const exampleApiPolicy = new azure.apimanagement.ApiPolicy("example", {
* apiName: example.then(example => example.name),
* apiManagementName: example.then(example => example.apiManagementName),
* resourceGroupName: example.then(example => example.resourceGroupName),
* xmlContent: `
*
*
*
*
* `,
* });
* ```
* ```python
* import pulumi
* import pulumi_azure as azure
* example = azure.apimanagement.get_api(name="my-api",
* api_management_name="example-apim",
* resource_group_name="search-service",
* revision="2")
* example_api_policy = azure.apimanagement.ApiPolicy("example",
* api_name=example.name,
* api_management_name=example.api_management_name,
* resource_group_name=example.resource_group_name,
* xml_content="""
*
*
*
*
* """)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Azure = Pulumi.Azure;
* return await Deployment.RunAsync(() =>
* {
* var example = Azure.ApiManagement.GetApi.Invoke(new()
* {
* Name = "my-api",
* ApiManagementName = "example-apim",
* ResourceGroupName = "search-service",
* Revision = "2",
* });
* var exampleApiPolicy = new Azure.ApiManagement.ApiPolicy("example", new()
* {
* ApiName = example.Apply(getApiResult => getApiResult.Name),
* ApiManagementName = example.Apply(getApiResult => getApiResult.ApiManagementName),
* ResourceGroupName = example.Apply(getApiResult => getApiResult.ResourceGroupName),
* XmlContent = @"
*
*
*
*
* ",
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-azure/sdk/v5/go/azure/apimanagement"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* example, err := apimanagement.LookupApi(ctx, &apimanagement.LookupApiArgs{
* Name: "my-api",
* ApiManagementName: "example-apim",
* ResourceGroupName: "search-service",
* Revision: "2",
* }, nil)
* if err != nil {
* return err
* }
* _, err = apimanagement.NewApiPolicy(ctx, "example", &apimanagement.ApiPolicyArgs{
* ApiName: pulumi.String(example.Name),
* ApiManagementName: pulumi.String(example.ApiManagementName),
* ResourceGroupName: pulumi.String(example.ResourceGroupName),
* XmlContent: 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.azure.apimanagement.ApimanagementFunctions;
* import com.pulumi.azure.apimanagement.inputs.GetApiArgs;
* import com.pulumi.azure.apimanagement.ApiPolicy;
* import com.pulumi.azure.apimanagement.ApiPolicyArgs;
* 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 example = ApimanagementFunctions.getApi(GetApiArgs.builder()
* .name("my-api")
* .apiManagementName("example-apim")
* .resourceGroupName("search-service")
* .revision("2")
* .build());
* var exampleApiPolicy = new ApiPolicy("exampleApiPolicy", ApiPolicyArgs.builder()
* .apiName(example.applyValue(getApiResult -> getApiResult.name()))
* .apiManagementName(example.applyValue(getApiResult -> getApiResult.apiManagementName()))
* .resourceGroupName(example.applyValue(getApiResult -> getApiResult.resourceGroupName()))
* .xmlContent("""
*
*
*
*
*
* """)
* .build());
* }
* }
* ```
* ```yaml
* resources:
* exampleApiPolicy:
* type: azure:apimanagement:ApiPolicy
* name: example
* properties:
* apiName: ${example.name}
* apiManagementName: ${example.apiManagementName}
* resourceGroupName: ${example.resourceGroupName}
* xmlContent: |
*
*
*
*
*
* variables:
* example:
* fn::invoke:
* Function: azure:apimanagement:getApi
* Arguments:
* name: my-api
* apiManagementName: example-apim
* resourceGroupName: search-service
* revision: '2'
* ```
*
* ## Import
* API Management API Policy can be imported using the `resource id`, e.g.
* ```sh
* $ pulumi import azure:apimanagement/apiPolicy:ApiPolicy example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.ApiManagement/service/service1/apis/exampleId
* ```
*/
public class ApiPolicy internal constructor(
override val javaResource: com.pulumi.azure.apimanagement.ApiPolicy,
) : KotlinCustomResource(javaResource, ApiPolicyMapper) {
/**
* The name of the API Management Service. Changing this forces a new resource to be created.
*/
public val apiManagementName: Output
get() = javaResource.apiManagementName().applyValue({ args0 -> args0 })
/**
* The ID of the API Management API within the API Management Service. Changing this forces a new resource to be created.
*/
public val apiName: Output
get() = javaResource.apiName().applyValue({ args0 -> args0 })
/**
* The name of the Resource Group in which the API Management Service exists. Changing this forces a new resource to be created.
*/
public val resourceGroupName: Output
get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })
/**
* The XML Content for this Policy as a string.
*/
public val xmlContent: Output
get() = javaResource.xmlContent().applyValue({ args0 -> args0 })
/**
* A link to a Policy XML Document, which must be publicly available.
*/
public val xmlLink: Output?
get() = javaResource.xmlLink().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })
}
public object ApiPolicyMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.azure.apimanagement.ApiPolicy::class == javaResource::class
override fun map(javaResource: Resource): ApiPolicy = ApiPolicy(
javaResource as
com.pulumi.azure.apimanagement.ApiPolicy,
)
}
/**
* @see [ApiPolicy].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [ApiPolicy].
*/
public suspend fun apiPolicy(name: String, block: suspend ApiPolicyResourceBuilder.() -> Unit): ApiPolicy {
val builder = ApiPolicyResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [ApiPolicy].
* @param name The _unique_ name of the resulting resource.
*/
public fun apiPolicy(name: String): ApiPolicy {
val builder = ApiPolicyResourceBuilder()
builder.name(name)
return builder.build()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy