# coding: utf-8

"""
    Instana REST API documentation

    Documentation for INSTANA REST API

    The version of the OpenAPI document: 1.309.1268
    Contact: support@instana.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from importlib import import_module
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Union
from typing import Optional, Set
from typing_extensions import Self

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from instana_client.models.bidirectional_ms_teams_app_integration import BidirectionalMsTeamsAppIntegration
    from instana_client.models.bidirectional_slack_app_integration import BidirectionalSlackAppIntegration
    from instana_client.models.email_integration import EmailIntegration
    from instana_client.models.google_chat_integration import GoogleChatIntegration
    from instana_client.models.office365_integration import Office365Integration
    from instana_client.models.opsgenie_integration import OpsgenieIntegration
    from instana_client.models.pagerduty_integration import PagerdutyIntegration
    from instana_client.models.prometheus_webhook_integration import PrometheusWebhookIntegration
    from instana_client.models.salesforce_integration import SalesforceIntegration
    from instana_client.models.service_now_enhanced_integration import ServiceNowEnhancedIntegration
    from instana_client.models.service_now_integration import ServiceNowIntegration
    from instana_client.models.slack_integration import SlackIntegration
    from instana_client.models.splunk_integration import SplunkIntegration
    from instana_client.models.victor_ops_integration import VictorOpsIntegration
    from instana_client.models.watson_ai_ops_webhook_integration import WatsonAIOpsWebhookIntegration
    from instana_client.models.webex_teams_webhook_integration import WebexTeamsWebhookIntegration
    from instana_client.models.webhook_integration import WebhookIntegration
    from instana_client.models.z_chat_ops_integration import ZChatOpsIntegration

class AbstractIntegration(BaseModel):
    """
    AbstractIntegration
    """ # noqa: E501
    id: StrictStr = Field(description="Unique ID of the returned Alert Channel")
    kind: StrictStr = Field(description="The type of the Alerting Channel.")
    name: StrictStr = Field(description="The name of the Alerting Channel.")
    __properties: ClassVar[List[str]] = ["id", "kind", "name"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    # JSON field name that stores the object type
    __discriminator_property_name: ClassVar[str] = 'kind'

    # discriminator mappings
    __discriminator_value_class_map: ClassVar[Dict[str, str]] = {
        'BIDIRECTIONAL_MS_TEAMS': 'BidirectionalMsTeamsAppIntegration','BIDIRECTIONAL_SLACK': 'BidirectionalSlackAppIntegration','EMAIL': 'EmailIntegration','GOOGLE_CHAT': 'GoogleChatIntegration','OFFICE_365': 'Office365Integration','OPS_GENIE': 'OpsgenieIntegration','PAGER_DUTY': 'PagerdutyIntegration','PROMETHEUS_WEBHOOK': 'PrometheusWebhookIntegration','SALESFORCE': 'SalesforceIntegration','SERVICE_NOW_APPLICATION': 'ServiceNowEnhancedIntegration','SERVICE_NOW_WEBHOOK': 'ServiceNowIntegration','SLACK': 'SlackIntegration','SPLUNK': 'SplunkIntegration','VICTOR_OPS': 'VictorOpsIntegration','WATSON_AIOPS_WEBHOOK': 'WatsonAIOpsWebhookIntegration','WEBEX_TEAMS_WEBHOOK': 'WebexTeamsWebhookIntegration','WEB_HOOK': 'WebhookIntegration','Z_CHATOPS': 'ZChatOpsIntegration'
    }

    @classmethod
    def get_discriminator_value(cls, obj: Dict[str, Any]) -> Optional[str]:
        """Returns the discriminator value (object type) of the data"""
        discriminator_value = obj[cls.__discriminator_property_name]
        if discriminator_value:
            return cls.__discriminator_value_class_map.get(discriminator_value)
        else:
            return None

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Union[BidirectionalMsTeamsAppIntegration, BidirectionalSlackAppIntegration, EmailIntegration, GoogleChatIntegration, Office365Integration, OpsgenieIntegration, PagerdutyIntegration, PrometheusWebhookIntegration, SalesforceIntegration, ServiceNowEnhancedIntegration, ServiceNowIntegration, SlackIntegration, SplunkIntegration, VictorOpsIntegration, WatsonAIOpsWebhookIntegration, WebexTeamsWebhookIntegration, WebhookIntegration, ZChatOpsIntegration]]:
        """Create an instance of AbstractIntegration from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict[str, Any]) -> Optional[Union[BidirectionalMsTeamsAppIntegration, BidirectionalSlackAppIntegration, EmailIntegration, GoogleChatIntegration, Office365Integration, OpsgenieIntegration, PagerdutyIntegration, PrometheusWebhookIntegration, SalesforceIntegration, ServiceNowEnhancedIntegration, ServiceNowIntegration, SlackIntegration, SplunkIntegration, VictorOpsIntegration, WatsonAIOpsWebhookIntegration, WebexTeamsWebhookIntegration, WebhookIntegration, ZChatOpsIntegration]]:
        """Create an instance of AbstractIntegration from a dict"""
        # look up the object type based on discriminator mapping
        object_type = cls.get_discriminator_value(obj)
        if object_type ==  'BidirectionalMsTeamsAppIntegration':
            return import_module("instana_client.models.bidirectional_ms_teams_app_integration").BidirectionalMsTeamsAppIntegration.from_dict(obj)
        if object_type ==  'BidirectionalSlackAppIntegration':
            return import_module("instana_client.models.bidirectional_slack_app_integration").BidirectionalSlackAppIntegration.from_dict(obj)
        if object_type ==  'EmailIntegration':
            return import_module("instana_client.models.email_integration").EmailIntegration.from_dict(obj)
        if object_type ==  'GoogleChatIntegration':
            return import_module("instana_client.models.google_chat_integration").GoogleChatIntegration.from_dict(obj)
        if object_type ==  'Office365Integration':
            return import_module("instana_client.models.office365_integration").Office365Integration.from_dict(obj)
        if object_type ==  'OpsgenieIntegration':
            return import_module("instana_client.models.opsgenie_integration").OpsgenieIntegration.from_dict(obj)
        if object_type ==  'PagerdutyIntegration':
            return import_module("instana_client.models.pagerduty_integration").PagerdutyIntegration.from_dict(obj)
        if object_type ==  'PrometheusWebhookIntegration':
            return import_module("instana_client.models.prometheus_webhook_integration").PrometheusWebhookIntegration.from_dict(obj)
        if object_type ==  'SalesforceIntegration':
            return import_module("instana_client.models.salesforce_integration").SalesforceIntegration.from_dict(obj)
        if object_type ==  'ServiceNowEnhancedIntegration':
            return import_module("instana_client.models.service_now_enhanced_integration").ServiceNowEnhancedIntegration.from_dict(obj)
        if object_type ==  'ServiceNowIntegration':
            return import_module("instana_client.models.service_now_integration").ServiceNowIntegration.from_dict(obj)
        if object_type ==  'SlackIntegration':
            return import_module("instana_client.models.slack_integration").SlackIntegration.from_dict(obj)
        if object_type ==  'SplunkIntegration':
            return import_module("instana_client.models.splunk_integration").SplunkIntegration.from_dict(obj)
        if object_type ==  'VictorOpsIntegration':
            return import_module("instana_client.models.victor_ops_integration").VictorOpsIntegration.from_dict(obj)
        if object_type ==  'WatsonAIOpsWebhookIntegration':
            return import_module("instana_client.models.watson_ai_ops_webhook_integration").WatsonAIOpsWebhookIntegration.from_dict(obj)
        if object_type ==  'WebexTeamsWebhookIntegration':
            return import_module("instana_client.models.webex_teams_webhook_integration").WebexTeamsWebhookIntegration.from_dict(obj)
        if object_type ==  'WebhookIntegration':
            return import_module("instana_client.models.webhook_integration").WebhookIntegration.from_dict(obj)
        if object_type ==  'ZChatOpsIntegration':
            return import_module("instana_client.models.z_chat_ops_integration").ZChatOpsIntegration.from_dict(obj)

        raise ValueError("AbstractIntegration failed to lookup discriminator value from " +
                            json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
                            ", mapping: " + json.dumps(cls.__discriminator_value_class_map))


