# coding: utf-8

"""
    ThousandEyes for OpenTelemetry

     Configure ThousandEyes to stream or push test data to a OpenTelemetry compliant endpoint with the ThousandEyes for OpenTelemetry API. 

    The version of the OpenAPI document: 7.0.0
    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 typing import Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictBool, StrictStr
from pydantic import Field
from streaming_api.models.audit_operation import AuditOperation
from streaming_api.models.endpoint_type import EndpointType
from streaming_api.models.put_stream_tag_match_inner import PutStreamTagMatchInner
from streaming_api.models.stream_response_links import StreamResponseLinks
from streaming_api.models.stream_type import StreamType
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class CreateStreamResponse(BaseModel):
    """
    CreateStreamResponse
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="The data stream ID")
    enabled: Optional[StrictBool] = Field(default=None, description="Flag to enable or disable the stream integration.")
    links: Optional[StreamResponseLinks] = Field(default=None, alias="_links")
    type: Optional[StreamType] = None
    endpoint_type: Optional[EndpointType] = Field(default=None, alias="endpointType")
    stream_endpoint_url: Optional[StrictStr] = Field(default=None, description="The URL ThousandEyes sends data stream to. For a URL to be valid, it needs to: - Be syntactically correct. - Be reachable. - Use the HTTPS protocol. - When using the `grpc` endpointType, streamEndpointUrl cannot contain paths:     - Valid . `grpc` - `https://example.com`     - Invalid . `grpc` - `https://example.com/collector`.     - Valid . `http` - `https://example.com/collector`.      - When using the `http` endpointType, the endpoint must match the exact final full URL (including the path if there is one) to which the metrics will be sent. Examples below:     - `https://api.honeycomb.io:443/v1/metrics`     - `https://ingest.eu0.signalfx.com/v2/datapoint/otlp`", alias="streamEndpointUrl")
    custom_headers: Optional[Dict[str, StrictStr]] = Field(default=None, description="Custom headers", alias="customHeaders")
    tag_match: Optional[List[PutStreamTagMatchInner]] = Field(default=None, description="A collection of tags that determine what tests are included in the data stream. These tag values are also included as attributes in the data stream metrics.", alias="tagMatch")
    audit_operation: Optional[AuditOperation] = Field(default=None, alias="auditOperation")
    __properties: ClassVar[List[str]] = ["id", "enabled", "_links", "type", "endpointType", "streamEndpointUrl", "customHeaders", "tagMatch", "auditOperation"]

    model_config = {
        "populate_by_name": True,
        "validate_assignment": True
    }


    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) -> Self:
        """Create an instance of CreateStreamResponse 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.
        * OpenAPI `readOnly` fields are excluded.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
                "id",
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of links
        if self.links:
            _dict['_links'] = self.links.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in tag_match (list)
        _items = []
        if self.tag_match:
            for _item in self.tag_match:
                if _item:
                    _items.append(_item.to_dict())
            _dict['tagMatch'] = _items
        # override the default output from pydantic by calling `to_dict()` of audit_operation
        if self.audit_operation:
            _dict['auditOperation'] = self.audit_operation.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of CreateStreamResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "enabled": obj.get("enabled"),
            "_links": StreamResponseLinks.from_dict(obj.get("_links")) if obj.get("_links") is not None else None,
            "type": obj.get("type"),
            "endpointType": obj.get("endpointType"),
            "streamEndpointUrl": obj.get("streamEndpointUrl"),
            "customHeaders": obj.get("customHeaders"),
            "tagMatch": [PutStreamTagMatchInner.from_dict(_item) for _item in obj.get("tagMatch")] if obj.get("tagMatch") is not None else None,
            "auditOperation": AuditOperation.from_dict(obj.get("auditOperation")) if obj.get("auditOperation") is not None else None
        })
        return _obj


