# coding: utf-8

"""
    Inventory

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from legit_api_client.models.sdlc_asset_type import SdlcAssetType
from typing import Optional, Set
from typing_extensions import Self

class SdlcAssetDto(BaseModel):
    """
    SdlcAssetDto
    """ # noqa: E501
    id: Optional[StrictStr] = None
    sdlc_asset_type: Optional[SdlcAssetType] = Field(default=None, alias="sdlcAssetType")
    sdlc_asset_meta_type_display_text: Optional[StrictStr] = Field(default=None, alias="sdlcAssetMetaTypeDisplayText")
    is_integrated: Optional[StrictBool] = Field(default=None, alias="isIntegrated")
    setup_success_status_time: Optional[datetime] = Field(default=None, alias="setupSuccessStatusTime")
    integration_id: Optional[StrictStr] = Field(default=None, alias="integrationId")
    url: Optional[StrictStr] = None
    urls: Optional[List[StrictStr]] = None
    owner: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["id", "sdlcAssetType", "sdlcAssetMetaTypeDisplayText", "isIntegrated", "setupSuccessStatusTime", "integrationId", "url", "urls", "owner"]

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


    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[Self]:
        """Create an instance of SdlcAssetDto 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,
        )
        # set to None if id (nullable) is None
        # and model_fields_set contains the field
        if self.id is None and "id" in self.model_fields_set:
            _dict['id'] = None

        # set to None if sdlc_asset_meta_type_display_text (nullable) is None
        # and model_fields_set contains the field
        if self.sdlc_asset_meta_type_display_text is None and "sdlc_asset_meta_type_display_text" in self.model_fields_set:
            _dict['sdlcAssetMetaTypeDisplayText'] = None

        # set to None if setup_success_status_time (nullable) is None
        # and model_fields_set contains the field
        if self.setup_success_status_time is None and "setup_success_status_time" in self.model_fields_set:
            _dict['setupSuccessStatusTime'] = None

        # set to None if integration_id (nullable) is None
        # and model_fields_set contains the field
        if self.integration_id is None and "integration_id" in self.model_fields_set:
            _dict['integrationId'] = None

        # set to None if url (nullable) is None
        # and model_fields_set contains the field
        if self.url is None and "url" in self.model_fields_set:
            _dict['url'] = None

        # set to None if urls (nullable) is None
        # and model_fields_set contains the field
        if self.urls is None and "urls" in self.model_fields_set:
            _dict['urls'] = None

        # set to None if owner (nullable) is None
        # and model_fields_set contains the field
        if self.owner is None and "owner" in self.model_fields_set:
            _dict['owner'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of SdlcAssetDto 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"),
            "sdlcAssetType": obj.get("sdlcAssetType"),
            "sdlcAssetMetaTypeDisplayText": obj.get("sdlcAssetMetaTypeDisplayText"),
            "isIntegrated": obj.get("isIntegrated"),
            "setupSuccessStatusTime": obj.get("setupSuccessStatusTime"),
            "integrationId": obj.get("integrationId"),
            "url": obj.get("url"),
            "urls": obj.get("urls"),
            "owner": obj.get("owner")
        })
        return _obj


