# coding: utf-8

"""
    Polyaxon SDKs and REST API specification.

         # noqa: E501

    The version of the OpenAPI document: 2.12.0-rc2
    Contact: contact@polyaxon.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
from inspect import getfullargspec
import pprint
import re  # noqa: F401
import json


from typing import Optional
from pydantic import BaseModel, Field
from polyaxon_sdk.models.v1_dag import V1Dag
from polyaxon_sdk.models.v1_dask_cluster import V1DaskCluster
from polyaxon_sdk.models.v1_job import V1Job
from polyaxon_sdk.models.v1_mpi_job import V1MPIJob
from polyaxon_sdk.models.v1_pytorch_job import V1PytorchJob
from polyaxon_sdk.models.v1_ray_cluster import V1RayCluster
from polyaxon_sdk.models.v1_service import V1Service
from polyaxon_sdk.models.v1_tf_job import V1TFJob

class V1RunSchema(BaseModel):
    """
    V1RunSchema
    """
    job: Optional[V1Job] = None
    service: Optional[V1Service] = None
    dag: Optional[V1Dag] = None
    tf_job: Optional[V1TFJob] = Field(None, alias="tfJob")
    pytorch_job: Optional[V1PytorchJob] = Field(None, alias="pytorchJob")
    mpi_job: Optional[V1MPIJob] = Field(None, alias="mpiJob")
    daskcluster: Optional[V1DaskCluster] = None
    raycluster: Optional[V1RayCluster] = None
    __properties = ["job", "service", "dag", "tfJob", "pytorchJob", "mpiJob", "daskcluster", "raycluster"]

    class Config:
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> V1RunSchema:
        """Create an instance of V1RunSchema from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of job
        if self.job:
            _dict['job'] = self.job.to_dict()
        # override the default output from pydantic by calling `to_dict()` of service
        if self.service:
            _dict['service'] = self.service.to_dict()
        # override the default output from pydantic by calling `to_dict()` of dag
        if self.dag:
            _dict['dag'] = self.dag.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tf_job
        if self.tf_job:
            _dict['tfJob'] = self.tf_job.to_dict()
        # override the default output from pydantic by calling `to_dict()` of pytorch_job
        if self.pytorch_job:
            _dict['pytorchJob'] = self.pytorch_job.to_dict()
        # override the default output from pydantic by calling `to_dict()` of mpi_job
        if self.mpi_job:
            _dict['mpiJob'] = self.mpi_job.to_dict()
        # override the default output from pydantic by calling `to_dict()` of daskcluster
        if self.daskcluster:
            _dict['daskcluster'] = self.daskcluster.to_dict()
        # override the default output from pydantic by calling `to_dict()` of raycluster
        if self.raycluster:
            _dict['raycluster'] = self.raycluster.to_dict()
        return _dict

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

        if type(obj) is not dict:
            return V1RunSchema.parse_obj(obj)

        _obj = V1RunSchema.parse_obj({
            "job": V1Job.from_dict(obj.get("job")) if obj.get("job") is not None else None,
            "service": V1Service.from_dict(obj.get("service")) if obj.get("service") is not None else None,
            "dag": V1Dag.from_dict(obj.get("dag")) if obj.get("dag") is not None else None,
            "tf_job": V1TFJob.from_dict(obj.get("tfJob")) if obj.get("tfJob") is not None else None,
            "pytorch_job": V1PytorchJob.from_dict(obj.get("pytorchJob")) if obj.get("pytorchJob") is not None else None,
            "mpi_job": V1MPIJob.from_dict(obj.get("mpiJob")) if obj.get("mpiJob") is not None else None,
            "daskcluster": V1DaskCluster.from_dict(obj.get("daskcluster")) if obj.get("daskcluster") is not None else None,
            "raycluster": V1RayCluster.from_dict(obj.get("raycluster")) if obj.get("raycluster") is not None else None
        })
        return _obj

