# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Dict, List, Mapping, Optional, Tuple, Union
from .. import _utilities, _tables

__all__ = ['SpringCloudCertificate']


class SpringCloudCertificate(pulumi.CustomResource):
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 key_vault_certificate_id: Optional[pulumi.Input[str]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 resource_group_name: Optional[pulumi.Input[str]] = None,
                 service_name: Optional[pulumi.Input[str]] = None,
                 __props__=None,
                 __name__=None,
                 __opts__=None):
        """
        Manages an Azure Spring Cloud Certificate.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_azure as azure
        import pulumi_azuread as azuread

        example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="Southeast Asia")
        current = azure.core.get_client_config()
        example_service_principal = azuread.get_service_principal(display_name="Azure Spring Cloud Domain-Management")
        example_key_vault = azure.keyvault.KeyVault("exampleKeyVault",
            location=example_resource_group.location,
            resource_group_name=example_resource_group.name,
            tenant_id=current.tenant_id,
            sku_name="standard",
            access_policies=[
                azure.keyvault.KeyVaultAccessPolicyArgs(
                    tenant_id=current.tenant_id,
                    object_id=current.object_id,
                    secret_permissions=["set"],
                    certificate_permissions=[
                        "create",
                        "delete",
                        "get",
                        "update",
                    ],
                ),
                azure.keyvault.KeyVaultAccessPolicyArgs(
                    tenant_id=current.tenant_id,
                    object_id=example_service_principal.object_id,
                    secret_permissions=[
                        "get",
                        "list",
                    ],
                    certificate_permissions=[
                        "get",
                        "list",
                    ],
                ),
            ])
        example_certificate = azure.keyvault.Certificate("exampleCertificate",
            key_vault_id=example_key_vault.id,
            certificate_policy=azure.keyvault.CertificateCertificatePolicyArgs(
                issuer_parameters=azure.keyvault.CertificateCertificatePolicyIssuerParametersArgs(
                    name="Self",
                ),
                key_properties={
                    "exportable": True,
                    "key_size": 2048,
                    "key_type": "RSA",
                    "reuseKey": True,
                },
                lifetime_actions=[azure.keyvault.CertificateCertificatePolicyLifetimeActionArgs(
                    action=azure.keyvault.CertificateCertificatePolicyLifetimeActionActionArgs(
                        action_type="AutoRenew",
                    ),
                    trigger=azure.keyvault.CertificateCertificatePolicyLifetimeActionTriggerArgs(
                        days_before_expiry=30,
                    ),
                )],
                secret_properties=azure.keyvault.CertificateCertificatePolicySecretPropertiesArgs(
                    content_type="application/x-pkcs12",
                ),
                x509_certificate_properties=azure.keyvault.CertificateCertificatePolicyX509CertificatePropertiesArgs(
                    key_usages=[
                        "cRLSign",
                        "dataEncipherment",
                        "digitalSignature",
                        "keyAgreement",
                        "keyCertSign",
                        "keyEncipherment",
                    ],
                    subject="CN=contoso.com",
                    validity_in_months=12,
                ),
            ))
        example_spring_cloud_service = azure.appplatform.SpringCloudService("exampleSpringCloudService",
            resource_group_name=example_resource_group.name,
            location=example_resource_group.location)
        example_spring_cloud_certificate = azure.appplatform.SpringCloudCertificate("exampleSpringCloudCertificate",
            resource_group_name=example_spring_cloud_service.resource_group_name,
            service_name=example_spring_cloud_service.name,
            key_vault_certificate_id=example_certificate.id)
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] key_vault_certificate_id: Specifies the ID of the Key Vault Certificate resource. Changing this forces a new resource to be created.
        :param pulumi.Input[str] name: Specifies the name of the Spring Cloud Certificate. Changing this forces a new resource to be created.
        :param pulumi.Input[str] resource_group_name: Specifies the name of the resource group in which to create the Spring Cloud Certificate. Changing this forces a new resource to be created.
        :param pulumi.Input[str] service_name: Specifies the name of the Spring Cloud Service resource. Changing this forces a new resource to be created.
        """
        if __name__ is not None:
            warnings.warn("explicit use of __name__ is deprecated", DeprecationWarning)
            resource_name = __name__
        if __opts__ is not None:
            warnings.warn("explicit use of __opts__ is deprecated, use 'opts' instead", DeprecationWarning)
            opts = __opts__
        if opts is None:
            opts = pulumi.ResourceOptions()
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        if opts.version is None:
            opts.version = _utilities.get_version()
        if opts.id is None:
            if __props__ is not None:
                raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
            __props__ = dict()

            if key_vault_certificate_id is None:
                raise TypeError("Missing required property 'key_vault_certificate_id'")
            __props__['key_vault_certificate_id'] = key_vault_certificate_id
            __props__['name'] = name
            if resource_group_name is None:
                raise TypeError("Missing required property 'resource_group_name'")
            __props__['resource_group_name'] = resource_group_name
            if service_name is None:
                raise TypeError("Missing required property 'service_name'")
            __props__['service_name'] = service_name
        super(SpringCloudCertificate, __self__).__init__(
            'azure:appplatform/springCloudCertificate:SpringCloudCertificate',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            key_vault_certificate_id: Optional[pulumi.Input[str]] = None,
            name: Optional[pulumi.Input[str]] = None,
            resource_group_name: Optional[pulumi.Input[str]] = None,
            service_name: Optional[pulumi.Input[str]] = None) -> 'SpringCloudCertificate':
        """
        Get an existing SpringCloudCertificate resource's state with the given name, id, and optional extra
        properties used to qualify the lookup.

        :param str resource_name: The unique name of the resulting resource.
        :param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] key_vault_certificate_id: Specifies the ID of the Key Vault Certificate resource. Changing this forces a new resource to be created.
        :param pulumi.Input[str] name: Specifies the name of the Spring Cloud Certificate. Changing this forces a new resource to be created.
        :param pulumi.Input[str] resource_group_name: Specifies the name of the resource group in which to create the Spring Cloud Certificate. Changing this forces a new resource to be created.
        :param pulumi.Input[str] service_name: Specifies the name of the Spring Cloud Service resource. Changing this forces a new resource to be created.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = dict()

        __props__["key_vault_certificate_id"] = key_vault_certificate_id
        __props__["name"] = name
        __props__["resource_group_name"] = resource_group_name
        __props__["service_name"] = service_name
        return SpringCloudCertificate(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="keyVaultCertificateId")
    def key_vault_certificate_id(self) -> pulumi.Output[str]:
        """
        Specifies the ID of the Key Vault Certificate resource. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "key_vault_certificate_id")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        Specifies the name of the Spring Cloud Certificate. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="resourceGroupName")
    def resource_group_name(self) -> pulumi.Output[str]:
        """
        Specifies the name of the resource group in which to create the Spring Cloud Certificate. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "resource_group_name")

    @property
    @pulumi.getter(name="serviceName")
    def service_name(self) -> pulumi.Output[str]:
        """
        Specifies the name of the Spring Cloud Service resource. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "service_name")

    def translate_output_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

    def translate_input_property(self, prop):
        return _tables.SNAKE_TO_CAMEL_CASE_TABLE.get(prop) or prop

