// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.azure.apimanagement;

import com.pulumi.azure.Utilities;
import com.pulumi.azure.apimanagement.CustomDomainArgs;
import com.pulumi.azure.apimanagement.inputs.CustomDomainState;
import com.pulumi.azure.apimanagement.outputs.CustomDomainDeveloperPortal;
import com.pulumi.azure.apimanagement.outputs.CustomDomainGateway;
import com.pulumi.azure.apimanagement.outputs.CustomDomainManagement;
import com.pulumi.azure.apimanagement.outputs.CustomDomainPortal;
import com.pulumi.azure.apimanagement.outputs.CustomDomainScm;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Manages a API Management Custom Domain.
 * 
 * ## Disclaimers
 * 
 * &gt; **Note:** It&#39;s possible to define Custom Domains both within the `azure.apimanagement.Service` resource via the `hostname_configurations` block and by using this resource. However it&#39;s not possible to use both methods to manage Custom Domains within an API Management Service, since there will be conflicts.
 * 
 * ## Example Usage
 * ```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.keyvault.KeyvaultFunctions;
 * import com.pulumi.azure.keyvault.inputs.GetKeyVaultArgs;
 * import com.pulumi.azure.apimanagement.Service;
 * import com.pulumi.azure.apimanagement.ServiceArgs;
 * import com.pulumi.azure.keyvault.Certificate;
 * import com.pulumi.azure.keyvault.CertificateArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicyArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicyIssuerParametersArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicyKeyPropertiesArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicySecretPropertiesArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicyX509CertificatePropertiesArgs;
 * import com.pulumi.azure.keyvault.inputs.CertificateCertificatePolicyX509CertificatePropertiesSubjectAlternativeNamesArgs;
 * import com.pulumi.azure.apimanagement.CustomDomain;
 * import com.pulumi.azure.apimanagement.CustomDomainArgs;
 * import com.pulumi.azure.apimanagement.inputs.CustomDomainGatewayArgs;
 * import com.pulumi.azure.apimanagement.inputs.CustomDomainDeveloperPortalArgs;
 * 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 exampleResourceGroup = new ResourceGroup(&#34;exampleResourceGroup&#34;, ResourceGroupArgs.builder()        
 *             .location(&#34;West Europe&#34;)
 *             .build());
 * 
 *         final var exampleKeyVault = KeyvaultFunctions.getKeyVault(GetKeyVaultArgs.builder()
 *             .name(&#34;mykeyvault&#34;)
 *             .resourceGroupName(&#34;some-resource-group&#34;)
 *             .build());
 * 
 *         var exampleService = new Service(&#34;exampleService&#34;, ServiceArgs.builder()        
 *             .location(exampleResourceGroup.location())
 *             .resourceGroupName(exampleResourceGroup.name())
 *             .publisherName(&#34;pub1&#34;)
 *             .publisherEmail(&#34;pub1@email.com&#34;)
 *             .skuName(&#34;Developer_1&#34;)
 *             .build());
 * 
 *         var exampleCertificate = new Certificate(&#34;exampleCertificate&#34;, CertificateArgs.builder()        
 *             .keyVaultId(exampleKeyVault.applyValue(getKeyVaultResult -&gt; getKeyVaultResult.id()))
 *             .certificatePolicy(CertificateCertificatePolicyArgs.builder()
 *                 .issuerParameters(CertificateCertificatePolicyIssuerParametersArgs.builder()
 *                     .name(&#34;Self&#34;)
 *                     .build())
 *                 .keyProperties(CertificateCertificatePolicyKeyPropertiesArgs.builder()
 *                     .exportable(true)
 *                     .keySize(2048)
 *                     .keyType(&#34;RSA&#34;)
 *                     .reuseKey(true)
 *                     .build())
 *                 .lifetimeActions(CertificateCertificatePolicyLifetimeActionArgs.builder()
 *                     .action(CertificateCertificatePolicyLifetimeActionActionArgs.builder()
 *                         .actionType(&#34;AutoRenew&#34;)
 *                         .build())
 *                     .trigger(CertificateCertificatePolicyLifetimeActionTriggerArgs.builder()
 *                         .daysBeforeExpiry(30)
 *                         .build())
 *                     .build())
 *                 .secretProperties(CertificateCertificatePolicySecretPropertiesArgs.builder()
 *                     .contentType(&#34;application/x-pkcs12&#34;)
 *                     .build())
 *                 .x509CertificateProperties(CertificateCertificatePolicyX509CertificatePropertiesArgs.builder()
 *                     .keyUsages(                    
 *                         &#34;cRLSign&#34;,
 *                         &#34;dataEncipherment&#34;,
 *                         &#34;digitalSignature&#34;,
 *                         &#34;keyAgreement&#34;,
 *                         &#34;keyCertSign&#34;,
 *                         &#34;keyEncipherment&#34;)
 *                     .subject(&#34;CN=api.example.com&#34;)
 *                     .validityInMonths(12)
 *                     .subjectAlternativeNames(CertificateCertificatePolicyX509CertificatePropertiesSubjectAlternativeNamesArgs.builder()
 *                         .dnsNames(                        
 *                             &#34;api.example.com&#34;,
 *                             &#34;portal.example.com&#34;)
 *                         .build())
 *                     .build())
 *                 .build())
 *             .build());
 * 
 *         var exampleCustomDomain = new CustomDomain(&#34;exampleCustomDomain&#34;, CustomDomainArgs.builder()        
 *             .apiManagementId(exampleService.id())
 *             .gateways(CustomDomainGatewayArgs.builder()
 *                 .hostName(&#34;api.example.com&#34;)
 *                 .keyVaultId(exampleCertificate.versionlessSecretId())
 *                 .build())
 *             .developerPortals(CustomDomainDeveloperPortalArgs.builder()
 *                 .hostName(&#34;portal.example.com&#34;)
 *                 .keyVaultId(exampleCertificate.versionlessSecretId())
 *                 .build())
 *             .build());
 * 
 *     }
 * }
 * ```
 * 
 * ## Import
 * 
 * API Management Custom Domains can be imported using the `resource id`, e.g.
 * 
 * ```sh
 *  $ pulumi import azure:apimanagement/customDomain:CustomDomain example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ApiManagement/service/instance1/customDomains/default
 * ```
 * 
 */
@ResourceType(type="azure:apimanagement/customDomain:CustomDomain")
public class CustomDomain extends com.pulumi.resources.CustomResource {
    /**
     * The ID of the API Management service for which to configure Custom Domains. Changing this forces a new API Management Custom Domain resource to be created.
     * 
     */
    @Export(name="apiManagementId", refs={String.class}, tree="[0]")
    private Output<String> apiManagementId;

    /**
     * @return The ID of the API Management service for which to configure Custom Domains. Changing this forces a new API Management Custom Domain resource to be created.
     * 
     */
    public Output<String> apiManagementId() {
        return this.apiManagementId;
    }
    /**
     * One or more `developer_portal` blocks as defined below.
     * 
     */
    @Export(name="developerPortals", refs={List.class,CustomDomainDeveloperPortal.class}, tree="[0,1]")
    private Output</* @Nullable */ List<CustomDomainDeveloperPortal>> developerPortals;

    /**
     * @return One or more `developer_portal` blocks as defined below.
     * 
     */
    public Output<Optional<List<CustomDomainDeveloperPortal>>> developerPortals() {
        return Codegen.optional(this.developerPortals);
    }
    /**
     * One or more `gateway` blocks as defined below.
     * 
     */
    @Export(name="gateways", refs={List.class,CustomDomainGateway.class}, tree="[0,1]")
    private Output</* @Nullable */ List<CustomDomainGateway>> gateways;

    /**
     * @return One or more `gateway` blocks as defined below.
     * 
     */
    public Output<Optional<List<CustomDomainGateway>>> gateways() {
        return Codegen.optional(this.gateways);
    }
    /**
     * One or more `management` blocks as defined below.
     * 
     */
    @Export(name="managements", refs={List.class,CustomDomainManagement.class}, tree="[0,1]")
    private Output</* @Nullable */ List<CustomDomainManagement>> managements;

    /**
     * @return One or more `management` blocks as defined below.
     * 
     */
    public Output<Optional<List<CustomDomainManagement>>> managements() {
        return Codegen.optional(this.managements);
    }
    /**
     * One or more `portal` blocks as defined below.
     * 
     */
    @Export(name="portals", refs={List.class,CustomDomainPortal.class}, tree="[0,1]")
    private Output</* @Nullable */ List<CustomDomainPortal>> portals;

    /**
     * @return One or more `portal` blocks as defined below.
     * 
     */
    public Output<Optional<List<CustomDomainPortal>>> portals() {
        return Codegen.optional(this.portals);
    }
    /**
     * One or more `scm` blocks as defined below.
     * 
     */
    @Export(name="scms", refs={List.class,CustomDomainScm.class}, tree="[0,1]")
    private Output</* @Nullable */ List<CustomDomainScm>> scms;

    /**
     * @return One or more `scm` blocks as defined below.
     * 
     */
    public Output<Optional<List<CustomDomainScm>>> scms() {
        return Codegen.optional(this.scms);
    }

    /**
     *
     * @param name The _unique_ name of the resulting resource.
     */
    public CustomDomain(String name) {
        this(name, CustomDomainArgs.Empty);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     */
    public CustomDomain(String name, CustomDomainArgs args) {
        this(name, args, null);
    }
    /**
     *
     * @param name The _unique_ name of the resulting resource.
     * @param args The arguments to use to populate this resource's properties.
     * @param options A bag of options that control this resource's behavior.
     */
    public CustomDomain(String name, CustomDomainArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:apimanagement/customDomain:CustomDomain", name, args == null ? CustomDomainArgs.Empty : args, makeResourceOptions(options, Codegen.empty()));
    }

    private CustomDomain(String name, Output<String> id, @Nullable CustomDomainState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        super("azure:apimanagement/customDomain:CustomDomain", name, state, makeResourceOptions(options, id));
    }

    private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output<String> id) {
        var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder()
            .version(Utilities.getVersion())
            .build();
        return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id);
    }

    /**
     * Get an existing Host resource's state with the given name, ID, and optional extra
     * properties used to qualify the lookup.
     *
     * @param name The _unique_ name of the resulting resource.
     * @param id The _unique_ provider ID of the resource to lookup.
     * @param state
     * @param options Optional settings to control the behavior of the CustomResource.
     */
    public static CustomDomain get(String name, Output<String> id, @Nullable CustomDomainState state, @Nullable com.pulumi.resources.CustomResourceOptions options) {
        return new CustomDomain(name, id, state, options);
    }
}
