# coding: utf-8

"""
    Lumos Connectors

    # The Lumos Connector API ## Intro This API is a self-describing API which allows third-party systems to easily integrate with Lumos. It provides endpoints to retrieve information about each connector, their capabilities.  We call individual libraries that proxy Lumos requests to app-specific requests, and then app-specific responses to Lumos responses, a **connector**.  ## How to use this API 1. You can call the `list_connector_app_ids` to see the list of available connector app IDs, e.g. `pagerduty`. One app ID is required to call most other APIs. 2. Calling `info` explains * what kind of authentication credentials the integration requires * which capabilities the integration supports * what input parameters are required for each capability for the given connector  ## Authenticating with a connector There are two broad categories of authentication - Shared Secret (e.g. API keys) and OAuth-like.  TODO: explain more details - look at `info.authentication_schema` - if it's OAuth - setup needs to call - `get_authorization_url` - `handle_authorization_callback` - steady state needs to call `refresh_access_token` - `validate_credentials` will check that your creds are good, and let you know what the unique tenant ID is  ## Reading customer account data TODO: write more docs - `list_resources` - `list_entitlements` - `find_entitlement_associations`  ## Pagination TODO: write more docs - `response.page.token` may contain an opaque string - pass this string back to the next request `request.page.token` to get the next set of data

    The version of the OpenAPI document: 0.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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


from __future__ import annotations
from inspect import getfullargspec
import json
import pprint
import re  # noqa: F401
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
from typing import Optional
from connector.generated.models.error_response import ErrorResponse
from connector.generated.models.unassign_entitlement_response import UnassignEntitlementResponse
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal, Self
from pydantic import Field

UNASSIGNENTITLEMENT200RESPONSE_ANY_OF_SCHEMAS = ["ErrorResponse", "UnassignEntitlementResponse"]

class UnassignEntitlement200Response(BaseModel):
    """
    UnassignEntitlement200Response
    """

    # data type: UnassignEntitlementResponse
    anyof_schema_1_validator: Optional[UnassignEntitlementResponse] = None
    # data type: ErrorResponse
    anyof_schema_2_validator: Optional[ErrorResponse] = None
    if TYPE_CHECKING:
        actual_instance: Optional[Union[ErrorResponse, UnassignEntitlementResponse]] = None
    else:
        actual_instance: Any = None
    any_of_schemas: Set[str] = { "ErrorResponse", "UnassignEntitlementResponse" }

    model_config = {
        "validate_assignment": True,
        "protected_namespaces": (),
    }

    def __init__(self, *args, **kwargs) -> None:
        if args:
            if len(args) > 1:
                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
            if kwargs:
                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
            super().__init__(actual_instance=args[0])
        else:
            super().__init__(**kwargs)

    @field_validator('actual_instance')
    def actual_instance_must_validate_anyof(cls, v):
        instance = UnassignEntitlement200Response.model_construct()
        error_messages = []
        # validate data type: UnassignEntitlementResponse
        if not isinstance(v, UnassignEntitlementResponse):
            error_messages.append(f"Error! Input type `{type(v)}` is not `UnassignEntitlementResponse`")
        else:
            return v

        # validate data type: ErrorResponse
        if not isinstance(v, ErrorResponse):
            error_messages.append(f"Error! Input type `{type(v)}` is not `ErrorResponse`")
        else:
            return v

        if error_messages:
            # no match
            raise ValueError("No match found when setting the actual_instance in UnassignEntitlement200Response with anyOf schemas: ErrorResponse, UnassignEntitlementResponse. Details: " + ", ".join(error_messages))
        else:
            return v

    @classmethod
    def from_dict(cls, obj: Dict[str, Any]) -> Self:
        return cls.from_json(json.dumps(obj))

    @classmethod
    def from_json(cls, json_str: str) -> Self:
        """Returns the object represented by the json string"""
        instance = cls.model_construct()
        error_messages = []
        # anyof_schema_1_validator: Optional[UnassignEntitlementResponse] = None
        try:
            instance.actual_instance = UnassignEntitlementResponse.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))
        # anyof_schema_2_validator: Optional[ErrorResponse] = None
        try:
            instance.actual_instance = ErrorResponse.from_json(json_str)
            return instance
        except (ValidationError, ValueError) as e:
             error_messages.append(str(e))

        if error_messages:
            # no match
            raise ValueError("No match found when deserializing the JSON string into UnassignEntitlement200Response with anyOf schemas: ErrorResponse, UnassignEntitlementResponse. Details: " + ", ".join(error_messages))
        else:
            return instance

    def to_json(self) -> str:
        """Returns the JSON representation of the actual instance"""
        if self.actual_instance is None:
            return "null"

        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
            return self.actual_instance.to_json()
        else:
            return json.dumps(self.actual_instance)

    def to_dict(self) -> Optional[Union[Dict[str, Any], ErrorResponse, UnassignEntitlementResponse]]:
        """Returns the dict representation of the actual instance"""
        if self.actual_instance is None:
            return None

        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
            return self.actual_instance.to_dict()
        else:
            return self.actual_instance

    def to_str(self) -> str:
        """Returns the string representation of the actual instance"""
        return pprint.pformat(self.model_dump())


