# coding: utf-8

"""
    WordLift API

    WordLift API

    The version of the OpenAPI document: 1.0
    Contact: hello@wordlift.io
    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 typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class SubmitJobBody(BaseModel):
    """
    SubmitJobBody
    """ # noqa: E501
    snapshot_date: StrictStr = Field(description="Logical KPI day to calculate in `YYYY-MM-DD` format.")
    force_rerun: Optional[StrictBool] = Field(default=False, description="If `true`, ignore the 24-hour freshness rule and replace a currently active job.")
    stage_retries: Optional[Annotated[int, Field(strict=True, ge=0)]] = Field(default=1, description="Number of retries allowed for each stage before the job fails.")
    limit_documents: Optional[Annotated[int, Field(strict=True, ge=1)]] = None
    limit_urls: Optional[Annotated[int, Field(strict=True, ge=1)]] = None
    skip_validation: Optional[StrictBool] = Field(default=False, description="If `true`, skip the SHACL/rich-snippet validation stage.")
    replace_validation: Optional[StrictBool] = Field(default=False, description="If `true`, replace previously persisted validation output for the same graph/day.")
    __properties: ClassVar[List[str]] = ["snapshot_date", "force_rerun", "stage_retries", "limit_documents", "limit_urls", "skip_validation", "replace_validation"]

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "snapshot_date": obj.get("snapshot_date"),
            "force_rerun": obj.get("force_rerun") if obj.get("force_rerun") is not None else False,
            "stage_retries": obj.get("stage_retries") if obj.get("stage_retries") is not None else 1,
            "limit_documents": obj.get("limit_documents"),
            "limit_urls": obj.get("limit_urls"),
            "skip_validation": obj.get("skip_validation") if obj.get("skip_validation") is not None else False,
            "replace_validation": obj.get("replace_validation") if obj.get("replace_validation") is not None else False
        })
        return _obj


