# 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 copy
import warnings
import sys
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
if sys.version_info >= (3, 11):
    from typing import NotRequired, TypedDict, TypeAlias
else:
    from typing_extensions import NotRequired, TypedDict, TypeAlias
from .. import _utilities

__all__ = ['PluginAttachmentArgs', 'PluginAttachment']

@pulumi.input_type
class PluginAttachmentArgs:
    def __init__(__self__, *,
                 api_id: pulumi.Input[str],
                 group_id: pulumi.Input[str],
                 plugin_id: pulumi.Input[str],
                 stage_name: pulumi.Input[str]):
        """
        The set of arguments for constructing a PluginAttachment resource.
        :param pulumi.Input[str] api_id: The api_id that plugin attaches to.
        :param pulumi.Input[str] group_id: The group that the api belongs to.
        :param pulumi.Input[str] plugin_id: The plugin that attaches to the api.
        :param pulumi.Input[str] stage_name: Stage that the plugin attaches to.
        """
        pulumi.set(__self__, "api_id", api_id)
        pulumi.set(__self__, "group_id", group_id)
        pulumi.set(__self__, "plugin_id", plugin_id)
        pulumi.set(__self__, "stage_name", stage_name)

    @property
    @pulumi.getter(name="apiId")
    def api_id(self) -> pulumi.Input[str]:
        """
        The api_id that plugin attaches to.
        """
        return pulumi.get(self, "api_id")

    @api_id.setter
    def api_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "api_id", value)

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> pulumi.Input[str]:
        """
        The group that the api belongs to.
        """
        return pulumi.get(self, "group_id")

    @group_id.setter
    def group_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "group_id", value)

    @property
    @pulumi.getter(name="pluginId")
    def plugin_id(self) -> pulumi.Input[str]:
        """
        The plugin that attaches to the api.
        """
        return pulumi.get(self, "plugin_id")

    @plugin_id.setter
    def plugin_id(self, value: pulumi.Input[str]):
        pulumi.set(self, "plugin_id", value)

    @property
    @pulumi.getter(name="stageName")
    def stage_name(self) -> pulumi.Input[str]:
        """
        Stage that the plugin attaches to.
        """
        return pulumi.get(self, "stage_name")

    @stage_name.setter
    def stage_name(self, value: pulumi.Input[str]):
        pulumi.set(self, "stage_name", value)


@pulumi.input_type
class _PluginAttachmentState:
    def __init__(__self__, *,
                 api_id: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 plugin_id: Optional[pulumi.Input[str]] = None,
                 stage_name: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering PluginAttachment resources.
        :param pulumi.Input[str] api_id: The api_id that plugin attaches to.
        :param pulumi.Input[str] group_id: The group that the api belongs to.
        :param pulumi.Input[str] plugin_id: The plugin that attaches to the api.
        :param pulumi.Input[str] stage_name: Stage that the plugin attaches to.
        """
        if api_id is not None:
            pulumi.set(__self__, "api_id", api_id)
        if group_id is not None:
            pulumi.set(__self__, "group_id", group_id)
        if plugin_id is not None:
            pulumi.set(__self__, "plugin_id", plugin_id)
        if stage_name is not None:
            pulumi.set(__self__, "stage_name", stage_name)

    @property
    @pulumi.getter(name="apiId")
    def api_id(self) -> Optional[pulumi.Input[str]]:
        """
        The api_id that plugin attaches to.
        """
        return pulumi.get(self, "api_id")

    @api_id.setter
    def api_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "api_id", value)

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> Optional[pulumi.Input[str]]:
        """
        The group that the api belongs to.
        """
        return pulumi.get(self, "group_id")

    @group_id.setter
    def group_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "group_id", value)

    @property
    @pulumi.getter(name="pluginId")
    def plugin_id(self) -> Optional[pulumi.Input[str]]:
        """
        The plugin that attaches to the api.
        """
        return pulumi.get(self, "plugin_id")

    @plugin_id.setter
    def plugin_id(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "plugin_id", value)

    @property
    @pulumi.getter(name="stageName")
    def stage_name(self) -> Optional[pulumi.Input[str]]:
        """
        Stage that the plugin attaches to.
        """
        return pulumi.get(self, "stage_name")

    @stage_name.setter
    def stage_name(self, value: Optional[pulumi.Input[str]]):
        pulumi.set(self, "stage_name", value)


class PluginAttachment(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 api_id: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 plugin_id: Optional[pulumi.Input[str]] = None,
                 stage_name: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        ## Example Usage

        Basic Usage

        ```python
        import pulumi
        import json
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "terraform_example"
        example = alicloud.apigateway.Group("example",
            name=name,
            description=name)
        example_api = alicloud.apigateway.Api("example",
            group_id=example.id,
            name=name,
            description=name,
            auth_type="APP",
            force_nonce_check=False,
            request_config={
                "protocol": "HTTP",
                "method": "GET",
                "path": "/example/path",
                "mode": "MAPPING",
            },
            service_type="HTTP",
            http_service_config={
                "address": "http://apigateway-backend.alicloudapi.com:8080",
                "method": "GET",
                "path": "/web/cloudapi",
                "timeout": 12,
                "aone_name": "cloudapi-openapi",
            },
            request_parameters=[{
                "name": "example",
                "type": "STRING",
                "required": "OPTIONAL",
                "in_": "QUERY",
                "in_service": "QUERY",
                "name_service": "exampleservice",
            }],
            stage_names=[
                "RELEASE",
                "TEST",
            ])
        example_plugin = alicloud.apigateway.Plugin("example",
            description="tf_example",
            plugin_name="tf_example",
            plugin_data=json.dumps({
                "allowOrigins": "api.foo.com",
                "allowMethods": "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
                "allowHeaders": "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
                "exposeHeaders": "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
                "maxAge": 172800,
                "allowCredentials": True,
            }),
            plugin_type="cors")
        example_plugin_attachment = alicloud.apigateway.PluginAttachment("example",
            api_id=example_api.api_id,
            group_id=example.id,
            plugin_id=example_plugin.id,
            stage_name="RELEASE")
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[str] api_id: The api_id that plugin attaches to.
        :param pulumi.Input[str] group_id: The group that the api belongs to.
        :param pulumi.Input[str] plugin_id: The plugin that attaches to the api.
        :param pulumi.Input[str] stage_name: Stage that the plugin attaches to.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: PluginAttachmentArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        ## Example Usage

        Basic Usage

        ```python
        import pulumi
        import json
        import pulumi_alicloud as alicloud

        config = pulumi.Config()
        name = config.get("name")
        if name is None:
            name = "terraform_example"
        example = alicloud.apigateway.Group("example",
            name=name,
            description=name)
        example_api = alicloud.apigateway.Api("example",
            group_id=example.id,
            name=name,
            description=name,
            auth_type="APP",
            force_nonce_check=False,
            request_config={
                "protocol": "HTTP",
                "method": "GET",
                "path": "/example/path",
                "mode": "MAPPING",
            },
            service_type="HTTP",
            http_service_config={
                "address": "http://apigateway-backend.alicloudapi.com:8080",
                "method": "GET",
                "path": "/web/cloudapi",
                "timeout": 12,
                "aone_name": "cloudapi-openapi",
            },
            request_parameters=[{
                "name": "example",
                "type": "STRING",
                "required": "OPTIONAL",
                "in_": "QUERY",
                "in_service": "QUERY",
                "name_service": "exampleservice",
            }],
            stage_names=[
                "RELEASE",
                "TEST",
            ])
        example_plugin = alicloud.apigateway.Plugin("example",
            description="tf_example",
            plugin_name="tf_example",
            plugin_data=json.dumps({
                "allowOrigins": "api.foo.com",
                "allowMethods": "GET,POST,PUT,DELETE,HEAD,OPTIONS,PATCH",
                "allowHeaders": "Authorization,Accept,Accept-Ranges,Cache-Control,Range,Date,Content-Type,Content-Length,Content-MD5,User-Agent,X-Ca-Signature,X-Ca-Signature-Headers,X-Ca-Signature-Method,X-Ca-Key,X-Ca-Timestamp,X-Ca-Nonce,X-Ca-Stage,X-Ca-Request-Mode,x-ca-deviceid",
                "exposeHeaders": "Content-MD5,Server,Date,Latency,X-Ca-Request-Id,X-Ca-Error-Code,X-Ca-Error-Message",
                "maxAge": 172800,
                "allowCredentials": True,
            }),
            plugin_type="cors")
        example_plugin_attachment = alicloud.apigateway.PluginAttachment("example",
            api_id=example_api.api_id,
            group_id=example.id,
            plugin_id=example_plugin.id,
            stage_name="RELEASE")
        ```

        :param str resource_name: The name of the resource.
        :param PluginAttachmentArgs args: The arguments to use to populate this resource's properties.
        :param pulumi.ResourceOptions opts: Options for the resource.
        """
        ...
    def __init__(__self__, resource_name: str, *args, **kwargs):
        resource_args, opts = _utilities.get_resource_args_opts(PluginAttachmentArgs, pulumi.ResourceOptions, *args, **kwargs)
        if resource_args is not None:
            __self__._internal_init(resource_name, opts, **resource_args.__dict__)
        else:
            __self__._internal_init(resource_name, *args, **kwargs)

    def _internal_init(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 api_id: Optional[pulumi.Input[str]] = None,
                 group_id: Optional[pulumi.Input[str]] = None,
                 plugin_id: Optional[pulumi.Input[str]] = None,
                 stage_name: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
        if not isinstance(opts, pulumi.ResourceOptions):
            raise TypeError('Expected resource options to be a ResourceOptions instance')
        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__ = PluginAttachmentArgs.__new__(PluginAttachmentArgs)

            if api_id is None and not opts.urn:
                raise TypeError("Missing required property 'api_id'")
            __props__.__dict__["api_id"] = api_id
            if group_id is None and not opts.urn:
                raise TypeError("Missing required property 'group_id'")
            __props__.__dict__["group_id"] = group_id
            if plugin_id is None and not opts.urn:
                raise TypeError("Missing required property 'plugin_id'")
            __props__.__dict__["plugin_id"] = plugin_id
            if stage_name is None and not opts.urn:
                raise TypeError("Missing required property 'stage_name'")
            __props__.__dict__["stage_name"] = stage_name
        super(PluginAttachment, __self__).__init__(
            'alicloud:apigateway/pluginAttachment:PluginAttachment',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            api_id: Optional[pulumi.Input[str]] = None,
            group_id: Optional[pulumi.Input[str]] = None,
            plugin_id: Optional[pulumi.Input[str]] = None,
            stage_name: Optional[pulumi.Input[str]] = None) -> 'PluginAttachment':
        """
        Get an existing PluginAttachment 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] api_id: The api_id that plugin attaches to.
        :param pulumi.Input[str] group_id: The group that the api belongs to.
        :param pulumi.Input[str] plugin_id: The plugin that attaches to the api.
        :param pulumi.Input[str] stage_name: Stage that the plugin attaches to.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _PluginAttachmentState.__new__(_PluginAttachmentState)

        __props__.__dict__["api_id"] = api_id
        __props__.__dict__["group_id"] = group_id
        __props__.__dict__["plugin_id"] = plugin_id
        __props__.__dict__["stage_name"] = stage_name
        return PluginAttachment(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="apiId")
    def api_id(self) -> pulumi.Output[str]:
        """
        The api_id that plugin attaches to.
        """
        return pulumi.get(self, "api_id")

    @property
    @pulumi.getter(name="groupId")
    def group_id(self) -> pulumi.Output[str]:
        """
        The group that the api belongs to.
        """
        return pulumi.get(self, "group_id")

    @property
    @pulumi.getter(name="pluginId")
    def plugin_id(self) -> pulumi.Output[str]:
        """
        The plugin that attaches to the api.
        """
        return pulumi.get(self, "plugin_id")

    @property
    @pulumi.getter(name="stageName")
    def stage_name(self) -> pulumi.Output[str]:
        """
        Stage that the plugin attaches to.
        """
        return pulumi.get(self, "stage_name")

