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

com.pulumi.azure.apimanagement.kotlin.Api.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.azure.apimanagement.kotlin

import com.pulumi.azure.apimanagement.kotlin.outputs.ApiContact
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiImport
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiLicense
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiOauth2Authorization
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiOpenidAuthentication
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiSubscriptionKeyParameterNames
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.Deprecated
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiContact.Companion.toKotlin as apiContactToKotlin
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiImport.Companion.toKotlin as apiImportToKotlin
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiLicense.Companion.toKotlin as apiLicenseToKotlin
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiOauth2Authorization.Companion.toKotlin as apiOauth2AuthorizationToKotlin
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiOpenidAuthentication.Companion.toKotlin as apiOpenidAuthenticationToKotlin
import com.pulumi.azure.apimanagement.kotlin.outputs.ApiSubscriptionKeyParameterNames.Companion.toKotlin as apiSubscriptionKeyParameterNamesToKotlin

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

    public var args: ApiArgs = ApiArgs()

    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 ApiArgsBuilder.() -> Unit) {
        val builder = ApiArgsBuilder()
        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(): Api {
        val builtJavaResource = com.pulumi.azure.apimanagement.Api(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return Api(builtJavaResource)
    }
}

/**
 * Manages an API within an API Management Service.
 * ## Example Usage
 * 
 * ```typescript
 * import * as pulumi from "@pulumi/pulumi";
 * import * as azure from "@pulumi/azure";
 * const example = new azure.core.ResourceGroup("example", {
 *     name: "example-resources",
 *     location: "West Europe",
 * });
 * const exampleService = new azure.apimanagement.Service("example", {
 *     name: "example-apim",
 *     location: example.location,
 *     resourceGroupName: example.name,
 *     publisherName: "My Company",
 *     publisherEmail: "[email protected]",
 *     skuName: "Developer_1",
 * });
 * const exampleApi = new azure.apimanagement.Api("example", {
 *     name: "example-api",
 *     resourceGroupName: example.name,
 *     apiManagementName: exampleService.name,
 *     revision: "1",
 *     displayName: "Example API",
 *     path: "example",
 *     protocols: ["https"],
 *     "import": {
 *         contentFormat: "swagger-link-json",
 *         contentValue: "http://conferenceapi.azurewebsites.net/?format=json",
 *     },
 * });
 * ```
 * ```python
 * import pulumi
 * import pulumi_azure as azure
 * example = azure.core.ResourceGroup("example",
 *     name="example-resources",
 *     location="West Europe")
 * example_service = azure.apimanagement.Service("example",
 *     name="example-apim",
 *     location=example.location,
 *     resource_group_name=example.name,
 *     publisher_name="My Company",
 *     publisher_email="[email protected]",
 *     sku_name="Developer_1")
 * example_api = azure.apimanagement.Api("example",
 *     name="example-api",
 *     resource_group_name=example.name,
 *     api_management_name=example_service.name,
 *     revision="1",
 *     display_name="Example API",
 *     path="example",
 *     protocols=["https"],
 *     import_={
 *         "content_format": "swagger-link-json",
 *         "content_value": "http://conferenceapi.azurewebsites.net/?format=json",
 *     })
 * ```
 * ```csharp
 * using System.Collections.Generic;
 * using System.Linq;
 * using Pulumi;
 * using Azure = Pulumi.Azure;
 * return await Deployment.RunAsync(() =>
 * {
 *     var example = new Azure.Core.ResourceGroup("example", new()
 *     {
 *         Name = "example-resources",
 *         Location = "West Europe",
 *     });
 *     var exampleService = new Azure.ApiManagement.Service("example", new()
 *     {
 *         Name = "example-apim",
 *         Location = example.Location,
 *         ResourceGroupName = example.Name,
 *         PublisherName = "My Company",
 *         PublisherEmail = "[email protected]",
 *         SkuName = "Developer_1",
 *     });
 *     var exampleApi = new Azure.ApiManagement.Api("example", new()
 *     {
 *         Name = "example-api",
 *         ResourceGroupName = example.Name,
 *         ApiManagementName = exampleService.Name,
 *         Revision = "1",
 *         DisplayName = "Example API",
 *         Path = "example",
 *         Protocols = new[]
 *         {
 *             "https",
 *         },
 *         Import = new Azure.ApiManagement.Inputs.ApiImportArgs
 *         {
 *             ContentFormat = "swagger-link-json",
 *             ContentValue = "http://conferenceapi.azurewebsites.net/?format=json",
 *         },
 *     });
 * });
 * ```
 * ```go
 * package main
 * import (
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/apimanagement"
 * 	"github.com/pulumi/pulumi-azure/sdk/v5/go/azure/core"
 * 	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
 * )
 * func main() {
 * 	pulumi.Run(func(ctx *pulumi.Context) error {
 * 		example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
 * 			Name:     pulumi.String("example-resources"),
 * 			Location: pulumi.String("West Europe"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		exampleService, err := apimanagement.NewService(ctx, "example", &apimanagement.ServiceArgs{
 * 			Name:              pulumi.String("example-apim"),
 * 			Location:          example.Location,
 * 			ResourceGroupName: example.Name,
 * 			PublisherName:     pulumi.String("My Company"),
 * 			PublisherEmail:    pulumi.String("[email protected]"),
 * 			SkuName:           pulumi.String("Developer_1"),
 * 		})
 * 		if err != nil {
 * 			return err
 * 		}
 * 		_, err = apimanagement.NewApi(ctx, "example", &apimanagement.ApiArgs{
 * 			Name:              pulumi.String("example-api"),
 * 			ResourceGroupName: example.Name,
 * 			ApiManagementName: exampleService.Name,
 * 			Revision:          pulumi.String("1"),
 * 			DisplayName:       pulumi.String("Example API"),
 * 			Path:              pulumi.String("example"),
 * 			Protocols: pulumi.StringArray{
 * 				pulumi.String("https"),
 * 			},
 * 			Import: &apimanagement.ApiImportArgs{
 * 				ContentFormat: pulumi.String("swagger-link-json"),
 * 				ContentValue:  pulumi.String("http://conferenceapi.azurewebsites.net/?format=json"),
 * 			},
 * 		})
 * 		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.core.ResourceGroup;
 * import com.pulumi.azure.core.ResourceGroupArgs;
 * import com.pulumi.azure.apimanagement.Service;
 * import com.pulumi.azure.apimanagement.ServiceArgs;
 * import com.pulumi.azure.apimanagement.Api;
 * import com.pulumi.azure.apimanagement.ApiArgs;
 * import com.pulumi.azure.apimanagement.inputs.ApiImportArgs;
 * 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 example = new ResourceGroup("example", ResourceGroupArgs.builder()
 *             .name("example-resources")
 *             .location("West Europe")
 *             .build());
 *         var exampleService = new Service("exampleService", ServiceArgs.builder()
 *             .name("example-apim")
 *             .location(example.location())
 *             .resourceGroupName(example.name())
 *             .publisherName("My Company")
 *             .publisherEmail("[email protected]")
 *             .skuName("Developer_1")
 *             .build());
 *         var exampleApi = new Api("exampleApi", ApiArgs.builder()
 *             .name("example-api")
 *             .resourceGroupName(example.name())
 *             .apiManagementName(exampleService.name())
 *             .revision("1")
 *             .displayName("Example API")
 *             .path("example")
 *             .protocols("https")
 *             .import_(ApiImportArgs.builder()
 *                 .contentFormat("swagger-link-json")
 *                 .contentValue("http://conferenceapi.azurewebsites.net/?format=json")
 *                 .build())
 *             .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   example:
 *     type: azure:core:ResourceGroup
 *     properties:
 *       name: example-resources
 *       location: West Europe
 *   exampleService:
 *     type: azure:apimanagement:Service
 *     name: example
 *     properties:
 *       name: example-apim
 *       location: ${example.location}
 *       resourceGroupName: ${example.name}
 *       publisherName: My Company
 *       publisherEmail: [email protected]
 *       skuName: Developer_1
 *   exampleApi:
 *     type: azure:apimanagement:Api
 *     name: example
 *     properties:
 *       name: example-api
 *       resourceGroupName: ${example.name}
 *       apiManagementName: ${exampleService.name}
 *       revision: '1'
 *       displayName: Example API
 *       path: example
 *       protocols:
 *         - https
 *       import:
 *         contentFormat: swagger-link-json
 *         contentValue: http://conferenceapi.azurewebsites.net/?format=json
 * ```
 * 
 * ## Import
 * API Management API's can be imported using the `resource id`, e.g.
 * ```sh
 * $ pulumi import azure:apimanagement/api:Api example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ApiManagement/service/instance1/apis/api1;rev=1
 * ```
 */
public class Api internal constructor(
    override val javaResource: com.pulumi.azure.apimanagement.Api,
) : KotlinCustomResource(javaResource, ApiMapper) {
    /**
     * The Name of the API Management Service where this API should be created. Changing this forces a new resource to be created.
     */
    public val apiManagementName: Output
        get() = javaResource.apiManagementName().applyValue({ args0 -> args0 })

    /**
     * Type of API. Possible values are `graphql`, `http`, `soap`, and `websocket`. Defaults to `http`.
     */
    public val apiType: Output
        get() = javaResource.apiType().applyValue({ args0 -> args0 })

    /**
     * A `contact` block as documented below.
     */
    public val contact: Output?
        get() = javaResource.contact().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    apiContactToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * A description of the API Management API, which may include HTML formatting tags.
     */
    public val description: Output?
        get() = javaResource.description().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The display name of the API.
     */
    public val displayName: Output
        get() = javaResource.displayName().applyValue({ args0 -> args0 })

    /**
     * A `import` block as documented below.
     */
    public val `import`: Output?
        get() = javaResource.import_().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    apiImportToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * Is this the current API Revision?
     */
    public val isCurrent: Output
        get() = javaResource.isCurrent().applyValue({ args0 -> args0 })

    /**
     * Is this API Revision online/accessible via the Gateway?
     */
    public val isOnline: Output
        get() = javaResource.isOnline().applyValue({ args0 -> args0 })

    /**
     * A `license` block as documented below.
     */
    public val license: Output?
        get() = javaResource.license().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    apiLicenseToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * The name of the API Management API. Changing this forces a new resource to be created.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * An `oauth2_authorization` block as documented below.
     */
    public val oauth2Authorization: Output?
        get() = javaResource.oauth2Authorization().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> apiOauth2AuthorizationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * An `openid_authentication` block as documented below.
     */
    public val openidAuthentication: Output?
        get() = javaResource.openidAuthentication().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> apiOpenidAuthenticationToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * The Path for this API Management API, which is a relative URL which uniquely identifies this API and all of its resource paths within the API Management Service.
     */
    public val path: Output
        get() = javaResource.path().applyValue({ args0 -> args0 })

    /**
     * A list of protocols the operations in this API can be invoked. Possible values are `http`, `https`, `ws`, and `wss`.
     * > **NOTE:** `display_name`, `path` and `protocols` are required when `source_api_id` is not set.
     */
    public val protocols: Output>
        get() = javaResource.protocols().applyValue({ args0 -> args0.map({ args0 -> args0 }) })

    /**
     * The Name of the Resource Group where the API Management API exists. Changing this forces a new resource to be created.
     */
    public val resourceGroupName: Output
        get() = javaResource.resourceGroupName().applyValue({ args0 -> args0 })

    /**
     * The Revision which used for this API. Changing this forces a new resource to be created.
     */
    public val revision: Output
        get() = javaResource.revision().applyValue({ args0 -> args0 })

    /**
     * The description of the API Revision of the API Management API.
     */
    public val revisionDescription: Output?
        get() = javaResource.revisionDescription().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Absolute URL of the backend service implementing this API.
     */
    public val serviceUrl: Output
        get() = javaResource.serviceUrl().applyValue({ args0 -> args0 })

    /**
     * Should this API expose a SOAP frontend, rather than a HTTP frontend? Defaults to `false`.
     * > **NOTE:** This property has been deprecated in favour of the `api_type` property and will be removed in version 4.0 of the provider.
     */
    @Deprecated(
        message = """
  `soap_pass_through` will be removed in favour of the property `api_type` in version 4.0 of the
      AzureRM Provider
  """,
    )
    public val soapPassThrough: Output
        get() = javaResource.soapPassThrough().applyValue({ args0 -> args0 })

    /**
     * The API id of the source API, which could be in format `azurerm_api_management_api.example.id` or in format `azurerm_api_management_api.example.id;rev=1`
     */
    public val sourceApiId: Output?
        get() = javaResource.sourceApiId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * A `subscription_key_parameter_names` block as documented below.
     */
    public val subscriptionKeyParameterNames: Output
        get() = javaResource.subscriptionKeyParameterNames().applyValue({ args0 ->
            args0.let({ args0 ->
                apiSubscriptionKeyParameterNamesToKotlin(args0)
            })
        })

    /**
     * Should this API require a subscription key? Defaults to `true`.
     */
    public val subscriptionRequired: Output?
        get() = javaResource.subscriptionRequired().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * Absolute URL of the Terms of Service for the API.
     */
    public val termsOfServiceUrl: Output?
        get() = javaResource.termsOfServiceUrl().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The Version number of this API, if this API is versioned.
     */
    public val version: Output
        get() = javaResource.version().applyValue({ args0 -> args0 })

    /**
     * The description of the API Version of the API Management API.
     */
    public val versionDescription: Output?
        get() = javaResource.versionDescription().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * The ID of the Version Set which this API is associated with.
     * > **NOTE:** When `version` is set, `version_set_id` must also be specified
     */
    public val versionSetId: Output
        get() = javaResource.versionSetId().applyValue({ args0 -> args0 })
}

public object ApiMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.azure.apimanagement.Api::class == javaResource::class

    override fun map(javaResource: Resource): Api = Api(
        javaResource as
            com.pulumi.azure.apimanagement.Api,
    )
}

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy