# coding: utf-8

"""
    AI Hub API

    The AI Hub REST API. See https://docs.instabase.com/api-sdk/ for more details.

    The version of the OpenAPI document: 0.1
    Contact: support@instabase.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 typing import Any, ClassVar, Dict, List, Optional, Union
from pydantic import BaseModel, StrictBool, StrictFloat, StrictInt, StrictStr
from pydantic import Field
from aihub.models.run_deployment_request_settings import RunDeploymentRequestSettings
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class RunDeploymentRequest(BaseModel):
    """
    RunDeploymentRequest
    """ # noqa: E501
    batch_id: Optional[StrictInt] = Field(default=None, description="Required unless using `input_dir` or `manual_upstream_integration`. The batch ID of a batch created with the [Batches endpoint](/api-sdk/api-reference/batches/create-batch/). All files uploaded to the batch are used as input for the run.")
    input_dir: Optional[StrictInt] = Field(default=None, description="Required unless using `batch_id` or `manual_upstream_integration`. The path of the input folder in a connected drive or Instabase Drive. See [Specifying file paths](/api-sdk/api-reference/run-reference#specifying-file-paths).")
    manual_upstream_integration: Optional[StrictBool] = Field(default=None, description="Use the deployment's upstream integration as a source rather than a `batch_id` or `input_dir`. Requires an upstream integration to be configured for the deployment.")
    from_timestamp: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the earliest date in Unix time milliseconds from which to pull emails.")
    to_timestamp: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Required if `manual_upstream_integration` is true and the upstream integration is a mailbox integration. Specifies the latest date in Unix time milliseconds from which to pull emails.")
    version: Optional[StrictStr] = Field(default=None, description="Version of the app to use. If not specified, defaults to the latest production version.")
    output_workspace: Optional[StrictStr] = Field(default=None, description="The workspace in which to run the app. The output is saved to the default drive of the specified workspace. If not defined, the default is:  - **Community accounts**: Runs in and saves to the personal workspace's Instabase Drive (`<USER-ID>/my-repo/Instabase Drive`).  - **Organization accounts**: Runs in and saves to the organization's default drive (`<ORGANIZATION-ID>/<USER-ID>/<default-drive>`). ")
    output_dir: Optional[StrictStr] = Field(default=None, description="Defines a specific location for the output to be saved in a connected drive or Instabase Drive. If defined, overrides the `output_workspace` value. See [Specifying file paths](/api-sdk/api-reference/run-reference#specifying-file-paths).")
    settings: Optional[RunDeploymentRequestSettings] = None
    __properties: ClassVar[List[str]] = ["batch_id", "input_dir", "manual_upstream_integration", "from_timestamp", "to_timestamp", "version", "output_workspace", "output_dir", "settings"]

    model_config = {
        "populate_by_name": True,
        "validate_assignment": True
    }


    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) -> Self:
        """Create an instance of RunDeploymentRequest 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of settings
        if self.settings:
            _dict['settings'] = self.settings.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Dict) -> Self:
        """Create an instance of RunDeploymentRequest from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "batch_id": obj.get("batch_id"),
            "input_dir": obj.get("input_dir"),
            "manual_upstream_integration": obj.get("manual_upstream_integration"),
            "from_timestamp": obj.get("from_timestamp"),
            "to_timestamp": obj.get("to_timestamp"),
            "version": obj.get("version"),
            "output_workspace": obj.get("output_workspace"),
            "output_dir": obj.get("output_dir"),
            "settings": RunDeploymentRequestSettings.from_dict(obj.get("settings")) if obj.get("settings") is not None else None
        })
        return _obj


