# coding: utf-8

"""
    Artifact Keeper API

    Enterprise artifact registry supporting 45+ package formats.

    The version of the OpenAPI document: 1.0.0-rc.3
    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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing import Optional, Set
from typing_extensions import Self

class CreateGateRequest(BaseModel):
    """
    CreateGateRequest
    """ # noqa: E501
    action: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    enforce_on_download: Optional[StrictBool] = None
    enforce_on_promotion: Optional[StrictBool] = None
    max_critical_issues: Optional[StrictInt] = None
    max_high_issues: Optional[StrictInt] = None
    max_medium_issues: Optional[StrictInt] = None
    min_health_score: Optional[StrictInt] = None
    min_metadata_score: Optional[StrictInt] = None
    min_quality_score: Optional[StrictInt] = None
    min_security_score: Optional[StrictInt] = None
    name: StrictStr
    repository_id: Optional[StrictStr] = None
    required_checks: Optional[List[StrictStr]] = None
    __properties: ClassVar[List[str]] = ["action", "description", "enforce_on_download", "enforce_on_promotion", "max_critical_issues", "max_high_issues", "max_medium_issues", "min_health_score", "min_metadata_score", "min_quality_score", "min_security_score", "name", "repository_id", "required_checks"]

    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 CreateGateRequest 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 description (nullable) is None
        # and model_fields_set contains the field
        if self.description is None and "description" in self.model_fields_set:
            _dict['description'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "action": obj.get("action"),
            "description": obj.get("description"),
            "enforce_on_download": obj.get("enforce_on_download"),
            "enforce_on_promotion": obj.get("enforce_on_promotion"),
            "max_critical_issues": obj.get("max_critical_issues"),
            "max_high_issues": obj.get("max_high_issues"),
            "max_medium_issues": obj.get("max_medium_issues"),
            "min_health_score": obj.get("min_health_score"),
            "min_metadata_score": obj.get("min_metadata_score"),
            "min_quality_score": obj.get("min_quality_score"),
            "min_security_score": obj.get("min_security_score"),
            "name": obj.get("name"),
            "repository_id": obj.get("repository_id"),
            "required_checks": obj.get("required_checks")
        })
        return _obj


