# 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.196.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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class ApiSourceControlDTO(BaseModel):
    """
    ApiSourceControlDTO
    """ # noqa: E501
    base_branch: Optional[StrictStr] = Field(default=None, alias="baseBranch")
    close_pr_after_days: Optional[StrictInt] = Field(default=None, alias="closePrAfterDays")
    close_pr_after_days_open_enabled: Optional[StrictBool] = Field(default=None, alias="closePrAfterDaysOpenEnabled")
    close_pr_on_failed_checks_enabled: Optional[StrictBool] = Field(default=None, alias="closePrOnFailedChecksEnabled")
    commit_status_enabled: Optional[StrictBool] = Field(default=None, alias="commitStatusEnabled")
    enable_pull_requests: Optional[StrictBool] = Field(default=None, alias="enablePullRequests")
    enable_status_checks: Optional[StrictBool] = Field(default=None, alias="enableStatusChecks")
    id: Optional[StrictStr] = None
    inner_source_automated_updates_enabled: Optional[StrictBool] = Field(default=None, alias="innerSourceAutomatedUpdatesEnabled")
    manual_pull_requests_enabled: Optional[StrictBool] = Field(default=None, alias="manualPullRequestsEnabled")
    owner_id: Optional[StrictStr] = Field(default=None, alias="ownerId")
    provider: Optional[StrictStr] = None
    pull_request_commenting_enabled: Optional[StrictBool] = Field(default=None, alias="pullRequestCommentingEnabled")
    remediation_pull_requests_enabled: Optional[StrictBool] = Field(default=None, alias="remediationPullRequestsEnabled")
    repository_url: Optional[StrictStr] = Field(default=None, alias="repositoryUrl")
    source_control_evaluations_enabled: Optional[StrictBool] = Field(default=None, alias="sourceControlEvaluationsEnabled")
    source_control_scan_target: Optional[StrictStr] = Field(default=None, alias="sourceControlScanTarget")
    ssh_enabled: Optional[StrictBool] = Field(default=None, alias="sshEnabled")
    status_checks_enabled: Optional[StrictBool] = Field(default=None, alias="statusChecksEnabled")
    token: Optional[StrictStr] = None
    username: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["baseBranch", "closePrAfterDays", "closePrAfterDaysOpenEnabled", "closePrOnFailedChecksEnabled", "commitStatusEnabled", "enablePullRequests", "enableStatusChecks", "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 ApiSourceControlDTO 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "baseBranch": obj.get("baseBranch"),
            "closePrAfterDays": obj.get("closePrAfterDays"),
            "closePrAfterDaysOpenEnabled": obj.get("closePrAfterDaysOpenEnabled"),
            "closePrOnFailedChecksEnabled": obj.get("closePrOnFailedChecksEnabled"),
            "commitStatusEnabled": obj.get("commitStatusEnabled"),
            "enablePullRequests": obj.get("enablePullRequests"),
            "enableStatusChecks": obj.get("enableStatusChecks"),
            "id": obj.get("id"),
            "innerSourceAutomatedUpdatesEnabled": obj.get("innerSourceAutomatedUpdatesEnabled"),
            "manualPullRequestsEnabled": obj.get("manualPullRequestsEnabled"),
            "ownerId": obj.get("ownerId"),
            "provider": obj.get("provider"),
            "pullRequestCommentingEnabled": obj.get("pullRequestCommentingEnabled"),
            "remediationPullRequestsEnabled": obj.get("remediationPullRequestsEnabled"),
            "repositoryUrl": obj.get("repositoryUrl"),
            "sourceControlEvaluationsEnabled": obj.get("sourceControlEvaluationsEnabled"),
            "sourceControlScanTarget": obj.get("sourceControlScanTarget"),
            "sshEnabled": obj.get("sshEnabled"),
            "statusChecksEnabled": obj.get("statusChecksEnabled"),
            "token": obj.get("token"),
            "username": obj.get("username")
        })
        return _obj


