# 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, Mapping, Optional, Sequence, Union, overload
from .. import _utilities
from . import outputs
from ._inputs import *

__all__ = ['HubArgs', 'Hub']

@pulumi.input_type
class HubArgs:
    def __init__(__self__, *,
                 web_pubsub_id: pulumi.Input[str],
                 anonymous_connections_enabled: Optional[pulumi.Input[bool]] = None,
                 event_handlers: Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]] = None,
                 name: Optional[pulumi.Input[str]] = None):
        """
        The set of arguments for constructing a Hub resource.
        :param pulumi.Input[str] web_pubsub_id: Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        :param pulumi.Input[bool] anonymous_connections_enabled: Is anonymous connections are allowed for this hub? Defaults to `false`.
               Possible values are `true`, `false`.
        :param pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]] event_handlers: An `event_handler` block as defined below.
        :param pulumi.Input[str] name: The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        """
        pulumi.set(__self__, "web_pubsub_id", web_pubsub_id)
        if anonymous_connections_enabled is not None:
            pulumi.set(__self__, "anonymous_connections_enabled", anonymous_connections_enabled)
        if event_handlers is not None:
            pulumi.set(__self__, "event_handlers", event_handlers)
        if name is not None:
            pulumi.set(__self__, "name", name)

    @property
    @pulumi.getter(name="webPubsubId")
    def web_pubsub_id(self) -> pulumi.Input[str]:
        """
        Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "web_pubsub_id")

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

    @property
    @pulumi.getter(name="anonymousConnectionsEnabled")
    def anonymous_connections_enabled(self) -> Optional[pulumi.Input[bool]]:
        """
        Is anonymous connections are allowed for this hub? Defaults to `false`.
        Possible values are `true`, `false`.
        """
        return pulumi.get(self, "anonymous_connections_enabled")

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

    @property
    @pulumi.getter(name="eventHandlers")
    def event_handlers(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]]:
        """
        An `event_handler` block as defined below.
        """
        return pulumi.get(self, "event_handlers")

    @event_handlers.setter
    def event_handlers(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]]):
        pulumi.set(self, "event_handlers", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "name")

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


@pulumi.input_type
class _HubState:
    def __init__(__self__, *,
                 anonymous_connections_enabled: Optional[pulumi.Input[bool]] = None,
                 event_handlers: Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 web_pubsub_id: Optional[pulumi.Input[str]] = None):
        """
        Input properties used for looking up and filtering Hub resources.
        :param pulumi.Input[bool] anonymous_connections_enabled: Is anonymous connections are allowed for this hub? Defaults to `false`.
               Possible values are `true`, `false`.
        :param pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]] event_handlers: An `event_handler` block as defined below.
        :param pulumi.Input[str] name: The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        :param pulumi.Input[str] web_pubsub_id: Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        if anonymous_connections_enabled is not None:
            pulumi.set(__self__, "anonymous_connections_enabled", anonymous_connections_enabled)
        if event_handlers is not None:
            pulumi.set(__self__, "event_handlers", event_handlers)
        if name is not None:
            pulumi.set(__self__, "name", name)
        if web_pubsub_id is not None:
            pulumi.set(__self__, "web_pubsub_id", web_pubsub_id)

    @property
    @pulumi.getter(name="anonymousConnectionsEnabled")
    def anonymous_connections_enabled(self) -> Optional[pulumi.Input[bool]]:
        """
        Is anonymous connections are allowed for this hub? Defaults to `false`.
        Possible values are `true`, `false`.
        """
        return pulumi.get(self, "anonymous_connections_enabled")

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

    @property
    @pulumi.getter(name="eventHandlers")
    def event_handlers(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]]:
        """
        An `event_handler` block as defined below.
        """
        return pulumi.get(self, "event_handlers")

    @event_handlers.setter
    def event_handlers(self, value: Optional[pulumi.Input[Sequence[pulumi.Input['HubEventHandlerArgs']]]]):
        pulumi.set(self, "event_handlers", value)

    @property
    @pulumi.getter
    def name(self) -> Optional[pulumi.Input[str]]:
        """
        The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "name")

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

    @property
    @pulumi.getter(name="webPubsubId")
    def web_pubsub_id(self) -> Optional[pulumi.Input[str]]:
        """
        Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "web_pubsub_id")

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


class Hub(pulumi.CustomResource):
    @overload
    def __init__(__self__,
                 resource_name: str,
                 opts: Optional[pulumi.ResourceOptions] = None,
                 anonymous_connections_enabled: Optional[pulumi.Input[bool]] = None,
                 event_handlers: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubEventHandlerArgs']]]]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 web_pubsub_id: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        """
        Manages the hub settings for a Web Pubsub.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_azure as azure

        example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="east us")
        example_user_assigned_identity = azure.authorization.UserAssignedIdentity("exampleUserAssignedIdentity",
            resource_group_name=example_resource_group.name,
            location=example_resource_group.location)
        example_service = azure.webpubsub.Service("exampleService",
            location=example_resource_group.location,
            resource_group_name=example_resource_group.name,
            sku="Standard_S1",
            capacity=1)
        example_hub = azure.webpubsub.Hub("exampleHub",
            web_pubsub_id=example_service.id,
            event_handlers=[
                azure.webpubsub.HubEventHandlerArgs(
                    url_template="https://test.com/api/{hub}/{event}",
                    user_event_pattern="*",
                    system_events=[
                        "connect",
                        "connected",
                    ],
                ),
                azure.webpubsub.HubEventHandlerArgs(
                    url_template="https://test.com/api/{hub}/{event}",
                    user_event_pattern="event1, event2",
                    system_events=["connected"],
                    auth=azure.webpubsub.HubEventHandlerAuthArgs(
                        managed_identity_id=example_user_assigned_identity.id,
                    ),
                ),
            ],
            anonymous_connections_enabled=True,
            opts=pulumi.ResourceOptions(depends_on=[example_service]))
        ```

        ## Import

        Web Pubsub Hub can be imported using the `resource id`, e.g.

        ```sh
         $ pulumi import azure:webpubsub/hub:Hub example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SignalRService/webPubsub/webpubsub1/hubs/webpubsubhub1
        ```

        :param str resource_name: The name of the resource.
        :param pulumi.ResourceOptions opts: Options for the resource.
        :param pulumi.Input[bool] anonymous_connections_enabled: Is anonymous connections are allowed for this hub? Defaults to `false`.
               Possible values are `true`, `false`.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubEventHandlerArgs']]]] event_handlers: An `event_handler` block as defined below.
        :param pulumi.Input[str] name: The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        :param pulumi.Input[str] web_pubsub_id: Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        ...
    @overload
    def __init__(__self__,
                 resource_name: str,
                 args: HubArgs,
                 opts: Optional[pulumi.ResourceOptions] = None):
        """
        Manages the hub settings for a Web Pubsub.

        ## Example Usage

        ```python
        import pulumi
        import pulumi_azure as azure

        example_resource_group = azure.core.ResourceGroup("exampleResourceGroup", location="east us")
        example_user_assigned_identity = azure.authorization.UserAssignedIdentity("exampleUserAssignedIdentity",
            resource_group_name=example_resource_group.name,
            location=example_resource_group.location)
        example_service = azure.webpubsub.Service("exampleService",
            location=example_resource_group.location,
            resource_group_name=example_resource_group.name,
            sku="Standard_S1",
            capacity=1)
        example_hub = azure.webpubsub.Hub("exampleHub",
            web_pubsub_id=example_service.id,
            event_handlers=[
                azure.webpubsub.HubEventHandlerArgs(
                    url_template="https://test.com/api/{hub}/{event}",
                    user_event_pattern="*",
                    system_events=[
                        "connect",
                        "connected",
                    ],
                ),
                azure.webpubsub.HubEventHandlerArgs(
                    url_template="https://test.com/api/{hub}/{event}",
                    user_event_pattern="event1, event2",
                    system_events=["connected"],
                    auth=azure.webpubsub.HubEventHandlerAuthArgs(
                        managed_identity_id=example_user_assigned_identity.id,
                    ),
                ),
            ],
            anonymous_connections_enabled=True,
            opts=pulumi.ResourceOptions(depends_on=[example_service]))
        ```

        ## Import

        Web Pubsub Hub can be imported using the `resource id`, e.g.

        ```sh
         $ pulumi import azure:webpubsub/hub:Hub example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.SignalRService/webPubsub/webpubsub1/hubs/webpubsubhub1
        ```

        :param str resource_name: The name of the resource.
        :param HubArgs 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(HubArgs, 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,
                 anonymous_connections_enabled: Optional[pulumi.Input[bool]] = None,
                 event_handlers: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubEventHandlerArgs']]]]] = None,
                 name: Optional[pulumi.Input[str]] = None,
                 web_pubsub_id: Optional[pulumi.Input[str]] = None,
                 __props__=None):
        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__ = HubArgs.__new__(HubArgs)

            __props__.__dict__["anonymous_connections_enabled"] = anonymous_connections_enabled
            __props__.__dict__["event_handlers"] = event_handlers
            __props__.__dict__["name"] = name
            if web_pubsub_id is None and not opts.urn:
                raise TypeError("Missing required property 'web_pubsub_id'")
            __props__.__dict__["web_pubsub_id"] = web_pubsub_id
        super(Hub, __self__).__init__(
            'azure:webpubsub/hub:Hub',
            resource_name,
            __props__,
            opts)

    @staticmethod
    def get(resource_name: str,
            id: pulumi.Input[str],
            opts: Optional[pulumi.ResourceOptions] = None,
            anonymous_connections_enabled: Optional[pulumi.Input[bool]] = None,
            event_handlers: Optional[pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubEventHandlerArgs']]]]] = None,
            name: Optional[pulumi.Input[str]] = None,
            web_pubsub_id: Optional[pulumi.Input[str]] = None) -> 'Hub':
        """
        Get an existing Hub 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[bool] anonymous_connections_enabled: Is anonymous connections are allowed for this hub? Defaults to `false`.
               Possible values are `true`, `false`.
        :param pulumi.Input[Sequence[pulumi.Input[pulumi.InputType['HubEventHandlerArgs']]]] event_handlers: An `event_handler` block as defined below.
        :param pulumi.Input[str] name: The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        :param pulumi.Input[str] web_pubsub_id: Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))

        __props__ = _HubState.__new__(_HubState)

        __props__.__dict__["anonymous_connections_enabled"] = anonymous_connections_enabled
        __props__.__dict__["event_handlers"] = event_handlers
        __props__.__dict__["name"] = name
        __props__.__dict__["web_pubsub_id"] = web_pubsub_id
        return Hub(resource_name, opts=opts, __props__=__props__)

    @property
    @pulumi.getter(name="anonymousConnectionsEnabled")
    def anonymous_connections_enabled(self) -> pulumi.Output[Optional[bool]]:
        """
        Is anonymous connections are allowed for this hub? Defaults to `false`.
        Possible values are `true`, `false`.
        """
        return pulumi.get(self, "anonymous_connections_enabled")

    @property
    @pulumi.getter(name="eventHandlers")
    def event_handlers(self) -> pulumi.Output[Optional[Sequence['outputs.HubEventHandler']]]:
        """
        An `event_handler` block as defined below.
        """
        return pulumi.get(self, "event_handlers")

    @property
    @pulumi.getter
    def name(self) -> pulumi.Output[str]:
        """
        The name of the Web Pubsub hub service. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "name")

    @property
    @pulumi.getter(name="webPubsubId")
    def web_pubsub_id(self) -> pulumi.Output[str]:
        """
        Specify the id of the Web Pubsub. Changing this forces a new resource to be created.
        """
        return pulumi.get(self, "web_pubsub_id")

