# coding: utf-8

"""
    Identity Security Cloud V3 API

    Use these APIs to interact with the Identity Security Cloud platform to achieve repeatable, automated processes with greater scalability. We encourage you to join the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss to connect with other developers using our APIs.

    The version of the OpenAPI document: 3.0.0
    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
import warnings

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from sailpoint.v3.models.backup_options import BackupOptions
from typing import Optional, Set
from typing_extensions import Self

class BackupResponse(BaseModel):
    """
    BackupResponse
    """ # noqa: E501
    job_id: Optional[StrictStr] = Field(default=None, description="Unique id assigned to this backup.", alias="jobId")
    status: Optional[StrictStr] = Field(default=None, description="Status of the backup.")
    type: Optional[StrictStr] = Field(default=None, description="Type of the job, will always be BACKUP for this type of job.")
    tenant: Optional[StrictStr] = Field(default=None, description="The name of the tenant performing the upload")
    requester_name: Optional[StrictStr] = Field(default=None, description="The name of the requester.", alias="requesterName")
    file_exists: Optional[StrictBool] = Field(default=True, description="Whether or not a file was created and stored for this backup.", alias="fileExists")
    created: Optional[datetime] = Field(default=None, description="The time the job was started.")
    modified: Optional[datetime] = Field(default=None, description="The time of the last update to the job.")
    completed: Optional[datetime] = Field(default=None, description="The time the job was completed.")
    name: Optional[StrictStr] = Field(default=None, description="The name assigned to the upload file in the request body.")
    user_can_delete: Optional[StrictBool] = Field(default=True, description="Whether this backup can be deleted by a regular user.", alias="userCanDelete")
    is_partial: Optional[StrictBool] = Field(default=False, description="Whether this backup contains all supported object types or only some of them.", alias="isPartial")
    backup_type: Optional[StrictStr] = Field(default=None, description="Denotes how this backup was created. - MANUAL - The backup was created by a user. - AUTOMATED - The backup was created by devops. - AUTOMATED_DRAFT - The backup was created during a draft process. - UPLOADED - The backup was created by uploading an existing configuration file.", alias="backupType")
    options: Optional[BackupOptions] = None
    hydration_status: Optional[StrictStr] = Field(default=None, description="Whether the object details of this backup are ready.", alias="hydrationStatus")
    total_object_count: Optional[StrictInt] = Field(default=None, description="Number of objects contained in this backup.", alias="totalObjectCount")
    cloud_storage_status: Optional[StrictStr] = Field(default=None, description="Whether this backup has been transferred to a customer storage location.", alias="cloudStorageStatus")
    __properties: ClassVar[List[str]] = ["jobId", "status", "type", "tenant", "requesterName", "fileExists", "created", "modified", "completed", "name", "userCanDelete", "isPartial", "backupType", "options", "hydrationStatus", "totalObjectCount", "cloudStorageStatus"]

    @field_validator('status')
    def status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['NOT_STARTED', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'FAILED']):
            warnings.warn(f"must be one of enum values ('NOT_STARTED', 'IN_PROGRESS', 'COMPLETE', 'CANCELLED', 'FAILED') unknown value: {value}")
        return value

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['BACKUP']):
            warnings.warn(f"must be one of enum values ('BACKUP') unknown value: {value}")
        return value

    @field_validator('backup_type')
    def backup_type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['UPLOADED', 'AUTOMATED', 'MANUAL']):
            warnings.warn(f"must be one of enum values ('UPLOADED', 'AUTOMATED', 'MANUAL') unknown value: {value}")
        return value

    @field_validator('hydration_status')
    def hydration_status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['HYDRATED', 'NOT_HYDRATED']):
            warnings.warn(f"must be one of enum values ('HYDRATED', 'NOT_HYDRATED') unknown value: {value}")
        return value

    @field_validator('cloud_storage_status')
    def cloud_storage_status_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['SYNCED', 'NOT_SYNCED', 'SYNC_FAILED']):
            warnings.warn(f"must be one of enum values ('SYNCED', 'NOT_SYNCED', 'SYNC_FAILED') unknown value: {value}")
        return value

    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 BackupResponse 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,
        )
        # override the default output from pydantic by calling `to_dict()` of options
        if self.options:
            _dict['options'] = self.options.to_dict()
        # set to None if options (nullable) is None
        # and model_fields_set contains the field
        if self.options is None and "options" in self.model_fields_set:
            _dict['options'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "jobId": obj.get("jobId"),
            "status": obj.get("status"),
            "type": obj.get("type"),
            "tenant": obj.get("tenant"),
            "requesterName": obj.get("requesterName"),
            "fileExists": obj.get("fileExists") if obj.get("fileExists") is not None else True,
            "created": obj.get("created"),
            "modified": obj.get("modified"),
            "completed": obj.get("completed"),
            "name": obj.get("name"),
            "userCanDelete": obj.get("userCanDelete") if obj.get("userCanDelete") is not None else True,
            "isPartial": obj.get("isPartial") if obj.get("isPartial") is not None else False,
            "backupType": obj.get("backupType"),
            "options": BackupOptions.from_dict(obj["options"]) if obj.get("options") is not None else None,
            "hydrationStatus": obj.get("hydrationStatus"),
            "totalObjectCount": obj.get("totalObjectCount"),
            "cloudStorageStatus": obj.get("cloudStorageStatus")
        })
        return _obj


