# 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.197.0-01
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from sonatype_iq_api_client.models.api_composite_value_dto_boolean import ApiCompositeValueDTOBoolean
from sonatype_iq_api_client.models.api_composite_value_dto_integer import ApiCompositeValueDTOInteger
from sonatype_iq_api_client.models.api_composite_value_dto_string import ApiCompositeValueDTOString
from typing import Optional, Set
from typing_extensions import Self

class ApiCompositeSourceControlDTO(BaseModel):
    """
    ApiCompositeSourceControlDTO
    """ # noqa: E501
    base_branch: Optional[ApiCompositeValueDTOString] = Field(default=None, alias="baseBranch")
    close_pr_after_days: Optional[ApiCompositeValueDTOInteger] = Field(default=None, alias="closePrAfterDays")
    close_pr_after_days_open_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="closePrAfterDaysOpenEnabled")
    close_pr_on_failed_checks_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="closePrOnFailedChecksEnabled")
    commit_status_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="commitStatusEnabled")
    id: Optional[StrictStr] = None
    inner_source_automated_updates_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="innerSourceAutomatedUpdatesEnabled")
    manual_pull_requests_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="manualPullRequestsEnabled")
    owner_id: Optional[StrictStr] = Field(default=None, alias="ownerId")
    provider: Optional[ApiCompositeValueDTOString] = None
    pull_request_commenting_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="pullRequestCommentingEnabled")
    remediation_pull_requests_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="remediationPullRequestsEnabled")
    repository_url: Optional[StrictStr] = Field(default=None, alias="repositoryUrl")
    source_control_evaluations_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="sourceControlEvaluationsEnabled")
    source_control_scan_target: Optional[ApiCompositeValueDTOString] = Field(default=None, alias="sourceControlScanTarget")
    ssh_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="sshEnabled")
    status_checks_enabled: Optional[ApiCompositeValueDTOBoolean] = Field(default=None, alias="statusChecksEnabled")
    token: Optional[ApiCompositeValueDTOString] = None
    username: Optional[ApiCompositeValueDTOString] = None
    __properties: ClassVar[List[str]] = ["baseBranch", "closePrAfterDays", "closePrAfterDaysOpenEnabled", "closePrOnFailedChecksEnabled", "commitStatusEnabled", "id", "innerSourceAutomatedUpdatesEnabled", "manualPullRequestsEnabled", "ownerId", "provider", "pullRequestCommentingEnabled", "remediationPullRequestsEnabled", "repositoryUrl", "sourceControlEvaluationsEnabled", "sourceControlScanTarget", "sshEnabled", "statusChecksEnabled", "token", "username"]

    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 ApiCompositeSourceControlDTO 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 base_branch
        if self.base_branch:
            _dict['baseBranch'] = self.base_branch.to_dict()
        # override the default output from pydantic by calling `to_dict()` of close_pr_after_days
        if self.close_pr_after_days:
            _dict['closePrAfterDays'] = self.close_pr_after_days.to_dict()
        # override the default output from pydantic by calling `to_dict()` of close_pr_after_days_open_enabled
        if self.close_pr_after_days_open_enabled:
            _dict['closePrAfterDaysOpenEnabled'] = self.close_pr_after_days_open_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of close_pr_on_failed_checks_enabled
        if self.close_pr_on_failed_checks_enabled:
            _dict['closePrOnFailedChecksEnabled'] = self.close_pr_on_failed_checks_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of commit_status_enabled
        if self.commit_status_enabled:
            _dict['commitStatusEnabled'] = self.commit_status_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of inner_source_automated_updates_enabled
        if self.inner_source_automated_updates_enabled:
            _dict['innerSourceAutomatedUpdatesEnabled'] = self.inner_source_automated_updates_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of manual_pull_requests_enabled
        if self.manual_pull_requests_enabled:
            _dict['manualPullRequestsEnabled'] = self.manual_pull_requests_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of provider
        if self.provider:
            _dict['provider'] = self.provider.to_dict()
        # override the default output from pydantic by calling `to_dict()` of pull_request_commenting_enabled
        if self.pull_request_commenting_enabled:
            _dict['pullRequestCommentingEnabled'] = self.pull_request_commenting_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of remediation_pull_requests_enabled
        if self.remediation_pull_requests_enabled:
            _dict['remediationPullRequestsEnabled'] = self.remediation_pull_requests_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source_control_evaluations_enabled
        if self.source_control_evaluations_enabled:
            _dict['sourceControlEvaluationsEnabled'] = self.source_control_evaluations_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source_control_scan_target
        if self.source_control_scan_target:
            _dict['sourceControlScanTarget'] = self.source_control_scan_target.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ssh_enabled
        if self.ssh_enabled:
            _dict['sshEnabled'] = self.ssh_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of status_checks_enabled
        if self.status_checks_enabled:
            _dict['statusChecksEnabled'] = self.status_checks_enabled.to_dict()
        # override the default output from pydantic by calling `to_dict()` of token
        if self.token:
            _dict['token'] = self.token.to_dict()
        # override the default output from pydantic by calling `to_dict()` of username
        if self.username:
            _dict['username'] = self.username.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "baseBranch": ApiCompositeValueDTOString.from_dict(obj["baseBranch"]) if obj.get("baseBranch") is not None else None,
            "closePrAfterDays": ApiCompositeValueDTOInteger.from_dict(obj["closePrAfterDays"]) if obj.get("closePrAfterDays") is not None else None,
            "closePrAfterDaysOpenEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["closePrAfterDaysOpenEnabled"]) if obj.get("closePrAfterDaysOpenEnabled") is not None else None,
            "closePrOnFailedChecksEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["closePrOnFailedChecksEnabled"]) if obj.get("closePrOnFailedChecksEnabled") is not None else None,
            "commitStatusEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["commitStatusEnabled"]) if obj.get("commitStatusEnabled") is not None else None,
            "id": obj.get("id"),
            "innerSourceAutomatedUpdatesEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["innerSourceAutomatedUpdatesEnabled"]) if obj.get("innerSourceAutomatedUpdatesEnabled") is not None else None,
            "manualPullRequestsEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["manualPullRequestsEnabled"]) if obj.get("manualPullRequestsEnabled") is not None else None,
            "ownerId": obj.get("ownerId"),
            "provider": ApiCompositeValueDTOString.from_dict(obj["provider"]) if obj.get("provider") is not None else None,
            "pullRequestCommentingEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["pullRequestCommentingEnabled"]) if obj.get("pullRequestCommentingEnabled") is not None else None,
            "remediationPullRequestsEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["remediationPullRequestsEnabled"]) if obj.get("remediationPullRequestsEnabled") is not None else None,
            "repositoryUrl": obj.get("repositoryUrl"),
            "sourceControlEvaluationsEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["sourceControlEvaluationsEnabled"]) if obj.get("sourceControlEvaluationsEnabled") is not None else None,
            "sourceControlScanTarget": ApiCompositeValueDTOString.from_dict(obj["sourceControlScanTarget"]) if obj.get("sourceControlScanTarget") is not None else None,
            "sshEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["sshEnabled"]) if obj.get("sshEnabled") is not None else None,
            "statusChecksEnabled": ApiCompositeValueDTOBoolean.from_dict(obj["statusChecksEnabled"]) if obj.get("statusChecksEnabled") is not None else None,
            "token": ApiCompositeValueDTOString.from_dict(obj["token"]) if obj.get("token") is not None else None,
            "username": ApiCompositeValueDTOString.from_dict(obj["username"]) if obj.get("username") is not None else None
        })
        return _obj


