# coding: utf-8

"""
    Sonatype Lifecycle Public REST API

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

    The version of the OpenAPI document: 1.201.0-02
    Contact: community@sonatype.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sonatype_iq_api_client.models.download_config import DownloadConfig
from sonatype_iq_api_client.models.proxy_config import ProxyConfig
from sonatype_iq_api_client.models.reachability_config import ReachabilityConfig
from typing import Optional, Set
from typing_extensions import Self

class ApiCiConfigurationDto(BaseModel):
    """
    ApiCiConfigurationDto
    """ # noqa: E501
    advanced_properties: Optional[List[StrictStr]] = Field(default=None, alias="advancedProperties")
    download: Optional[DownloadConfig] = None
    enable_debug_logging: Optional[StrictBool] = Field(default=None, alias="enableDebugLogging")
    fail_build_on_network_error: Optional[StrictBool] = Field(default=None, alias="failBuildOnNetworkError")
    fail_build_on_policy_warnings: Optional[StrictBool] = Field(default=None, alias="failBuildOnPolicyWarnings")
    fail_build_on_reachability_errors: Optional[StrictBool] = Field(default=None, alias="failBuildOnReachabilityErrors")
    fail_build_on_scanning_errors: Optional[StrictBool] = Field(default=None, alias="failBuildOnScanningErrors")
    module_excludes: Optional[List[StrictStr]] = Field(default=None, alias="moduleExcludes")
    parameter_priority: Optional[StrictStr] = Field(default=None, alias="parameterPriority")
    proxy: Optional[ProxyConfig] = None
    reachability: Optional[ReachabilityConfig] = None
    result_file: Optional[StrictStr] = Field(default=None, alias="resultFile")
    sarif_file: Optional[StrictStr] = Field(default=None, alias="sarifFile")
    scan_patterns: Optional[List[StrictStr]] = Field(default=None, alias="scanPatterns")
    unstable_build_on_policy_warnings: Optional[StrictBool] = Field(default=None, alias="unstableBuildOnPolicyWarnings")
    __properties: ClassVar[List[str]] = ["advancedProperties", "download", "enableDebugLogging", "failBuildOnNetworkError", "failBuildOnPolicyWarnings", "failBuildOnReachabilityErrors", "failBuildOnScanningErrors", "moduleExcludes", "parameterPriority", "proxy", "reachability", "resultFile", "sarifFile", "scanPatterns", "unstableBuildOnPolicyWarnings"]

    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 ApiCiConfigurationDto 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,
        )
        # override the default output from pydantic by calling `to_dict()` of download
        if self.download:
            _dict['download'] = self.download.to_dict()
        # override the default output from pydantic by calling `to_dict()` of proxy
        if self.proxy:
            _dict['proxy'] = self.proxy.to_dict()
        # override the default output from pydantic by calling `to_dict()` of reachability
        if self.reachability:
            _dict['reachability'] = self.reachability.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ApiCiConfigurationDto from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "advancedProperties": obj.get("advancedProperties"),
            "download": DownloadConfig.from_dict(obj["download"]) if obj.get("download") is not None else None,
            "enableDebugLogging": obj.get("enableDebugLogging"),
            "failBuildOnNetworkError": obj.get("failBuildOnNetworkError"),
            "failBuildOnPolicyWarnings": obj.get("failBuildOnPolicyWarnings"),
            "failBuildOnReachabilityErrors": obj.get("failBuildOnReachabilityErrors"),
            "failBuildOnScanningErrors": obj.get("failBuildOnScanningErrors"),
            "moduleExcludes": obj.get("moduleExcludes"),
            "parameterPriority": obj.get("parameterPriority"),
            "proxy": ProxyConfig.from_dict(obj["proxy"]) if obj.get("proxy") is not None else None,
            "reachability": ReachabilityConfig.from_dict(obj["reachability"]) if obj.get("reachability") is not None else None,
            "resultFile": obj.get("resultFile"),
            "sarifFile": obj.get("sarifFile"),
            "scanPatterns": obj.get("scanPatterns"),
            "unstableBuildOnPolicyWarnings": obj.get("unstableBuildOnPolicyWarnings")
        })
        return _obj


