# coding: utf-8


"""
IGNORE:
    Nutanix Data Protection APIs

    Business Continuity with full spectrum of Disaster Recovery and Backup solution. Spanning across Single PC, Cross AZ, MultiSite. Configuration of Recovery points, Protection policies, Recovery Plans. Execution and monitoring of back up and recovery orchestrations on OnPrem as well as Cloud.  # noqa: E501

    OpenAPI spec version: 4.3.1
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
IGNORE
"""
import pprint
import json
import ast
import re  # noqa: F401

import six
from pathlib import Path
from ntnx_dataprotection_py_client.models.common.v1.response.ApiLink import ApiLink  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.common.v1.response.ExternalizableAbstractModel import ExternalizableAbstractModel  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.config.ExecutionStepEntityReference import ExecutionStepEntityReference  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.config.ExecutionStepResult import ExecutionStepResult  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.config.OperationType import OperationType  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.config.RecoveryPlanJobExecutionStatus import RecoveryPlanJobExecutionStatus  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.config.RecoveryPlanJobPhaseType import RecoveryPlanJobPhaseType  # noqa: F401,E501
from ntnx_dataprotection_py_client.models.dataprotection.v4.error.AppMessage import AppMessage  # noqa: F401,E501

class RecoveryPlanJobExecutionStep(ExternalizableAbstractModel):

    """A step executes an action. Each step has its external identifier and the status of the action it is/was performing.

    :param error_message: (:attr:`error_message`) 
    :type error_message: 
    
    
    :param stage_ext_id: (:attr:`stage_ext_id`) External identifier of a recovery plan stage.
    :type stage_ext_id: 
    
    
    :param phase: (:attr:`phase`) 
    :type phase: 
    
    
    :param operation_type: (:attr:`operation_type`) 
    :type operation_type: 
    
    
    :param step_description: (:attr:`step_description`) User readable message for the action being performed for the current step.
    :type step_description: 
     max=1000 chars
    
    :param affected_entities: (:attr:`affected_entities`) List of affected entities.
    :type affected_entities: 
    
    
    :param execution_step_results: (:attr:`execution_step_results`) Result for an execution step.
    :type execution_step_results: 
    
    
    :param status: (:attr:`status`) 
    :type status: 
    
    
    :param start_time: (:attr:`start_time`) Time in ISO-8601 format when the current step started.
    :type start_time: 
    
    
    :param end_time: (:attr:`end_time`) Time in ISO-8601 format when the current step ended.
    :type end_time: 
    
    
    :param percentage_complete: (:attr:`percentage_complete`) The completed percentage for a step in the recovery plan job.
    :type percentage_complete: 
    
     min=0, max=100

    """
    """
    IGNORE:
    Attributes:
      swagger_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    IGNORE
    """  # noqa: E501
    swagger_types = {
        'error_message': 'dataprotection.v4.error.AppMessage',
        'stage_ext_id': 'str',
        'phase': 'dataprotection.v4.config.RecoveryPlanJobPhaseType',
        'operation_type': 'dataprotection.v4.config.OperationType',
        'step_description': 'str',
        'affected_entities': 'list[dataprotection.v4.config.ExecutionStepEntityReference]',
        'execution_step_results': 'list[dataprotection.v4.config.ExecutionStepResult]',
        'status': 'dataprotection.v4.config.RecoveryPlanJobExecutionStatus',
        'start_time': 'datetime',
        'end_time': 'datetime',
        'percentage_complete': 'int',
        'ext_id': 'str',
        'links': 'list[common.v1.response.ApiLink]',
        'tenant_id': 'str',
        '_reserved': 'dict(str, object)',
        '_object_type': 'str',
        '_unknown_fields': 'dict(str, object)',
    }

    attribute_map = {
        'error_message': 'errorMessage',
        'stage_ext_id': 'stageExtId',
        'phase': 'phase',
        'operation_type': 'operationType',
        'step_description': 'stepDescription',
        'affected_entities': 'affectedEntities',
        'execution_step_results': 'executionStepResults',
        'status': 'status',
        'start_time': 'startTime',
        'end_time': 'endTime',
        'percentage_complete': 'percentageComplete',
        'ext_id': 'extId',
        'links': 'links',
        'tenant_id': 'tenantId',
        '_reserved': '$reserved',
        '_object_type': '$objectType',
        '_unknown_fields': '$unknownFields',
    }



    def __init__(self, error_message=None, stage_ext_id=None, phase=None, operation_type=None, step_description=None, affected_entities=None, execution_step_results=None, status=None, start_time=None, end_time=None, percentage_complete=None, ext_id=None, links=None, tenant_id=None, *args, **kwargs):  # noqa: E501
        ExternalizableAbstractModel.__init__(self, ext_id, links, tenant_id, *args, **kwargs)
        self.__error_message = None
        self.__stage_ext_id = None
        self.__phase = None
        self.__operation_type = None
        self.__step_description = None
        self.__affected_entities = None
        self.__execution_step_results = None
        self.__status = None
        self.__start_time = None
        self.__end_time = None
        self.__percentage_complete = None
        self.discriminator = None
        if error_message is not None:
            self.__error_message = error_message
        if stage_ext_id is not None:
            self.__stage_ext_id = stage_ext_id
        if phase is not None:
            self.__phase = phase
        if operation_type is not None:
            self.__operation_type = operation_type
        if step_description is not None:
            self.__step_description = step_description
        if affected_entities is not None:
            self.__affected_entities = affected_entities
        if execution_step_results is not None:
            self.__execution_step_results = execution_step_results
        if status is not None:
            self.__status = status
        if start_time is not None:
            self.__start_time = start_time
        if end_time is not None:
            self.__end_time = end_time
        if percentage_complete is not None:
            self.__percentage_complete = percentage_complete

    def _initialize_object_type(self):
        return 'dataprotection.v4.config.RecoveryPlanJobExecutionStep'

    def _initialize_object_version(self):
        return 'v4.r3'


    @property
    def error_message(self):
        """
        

        :type:
            :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.error.AppMessage`
        """  # noqa: E501
        return self.__error_message

    @error_message.setter
    def error_message(self, error_message):

        self.__error_message = error_message

    @property
    def stage_ext_id(self):
        """
        External identifier of a recovery plan stage.

        :type:
                :class:`~str`
        """  # noqa: E501
        return self.__stage_ext_id

    @stage_ext_id.setter
    def stage_ext_id(self, stage_ext_id):
        if stage_ext_id is not None and not re.search('^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$', stage_ext_id):  # noqa: E501
            raise ValueError(r"Invalid value for `stage_ext_id`, must be a follow pattern or equal to `/^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/`")  # noqa: E501

        self.__stage_ext_id = stage_ext_id

    @property
    def phase(self):
        """
        

        :type:
            :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.config.RecoveryPlanJobPhaseType`
        """  # noqa: E501
        return self.__phase

    @phase.setter
    def phase(self, phase):

        self.__phase = phase

    @property
    def operation_type(self):
        """
        

        :type:
            :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.config.OperationType`
        """  # noqa: E501
        return self.__operation_type

    @operation_type.setter
    def operation_type(self, operation_type):

        self.__operation_type = operation_type

    @property
    def step_description(self):
        """
        User readable message for the action being performed for the current step.

        :type:
                :class:`~str`
        """  # noqa: E501
        return self.__step_description

    @step_description.setter
    def step_description(self, step_description):
        if step_description is not None and len(step_description) > 1000:
            raise ValueError("Invalid value for `step_description`, length must be less than or equal to `1000`")  # noqa: E501

        self.__step_description = step_description

    @property
    def affected_entities(self):
        """
        List of affected entities.

        :type:
             list[ :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.config.ExecutionStepEntityReference` ]
        """  # noqa: E501
        return self.__affected_entities

    @affected_entities.setter
    def affected_entities(self, affected_entities):

        self.__affected_entities = affected_entities

    @property
    def execution_step_results(self):
        """
        Result for an execution step.

        :type:
             list[ :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.config.ExecutionStepResult` ]
        """  # noqa: E501
        return self.__execution_step_results

    @execution_step_results.setter
    def execution_step_results(self, execution_step_results):

        self.__execution_step_results = execution_step_results

    @property
    def status(self):
        """
        

        :type:
            :class:`~ntnx_dataprotection_py_client.models.dataprotection.v4.config.RecoveryPlanJobExecutionStatus`
        """  # noqa: E501
        return self.__status

    @status.setter
    def status(self, status):

        self.__status = status

    @property
    def start_time(self):
        """
        Time in ISO-8601 format when the current step started.

        :type:
                :class:`~datetime`
        """  # noqa: E501
        return self.__start_time

    @start_time.setter
    def start_time(self, start_time):

        self.__start_time = start_time

    @property
    def end_time(self):
        """
        Time in ISO-8601 format when the current step ended.

        :type:
                :class:`~datetime`
        """  # noqa: E501
        return self.__end_time

    @end_time.setter
    def end_time(self, end_time):

        self.__end_time = end_time

    @property
    def percentage_complete(self):
        """
        The completed percentage for a step in the recovery plan job.

        :type:
                :class:`~int`
        """  # noqa: E501
        return self.__percentage_complete

    @percentage_complete.setter
    def percentage_complete(self, percentage_complete):
        if percentage_complete is not None and percentage_complete > 100:  # noqa: E501
            raise ValueError("Invalid value for `percentage_complete`, must be a value less than or equal to `100`")  # noqa: E501
        if percentage_complete is not None and percentage_complete < 0:  # noqa: E501
            raise ValueError("Invalid value for `percentage_complete`, must be a value greater than or equal to `0`")  # noqa: E501

        self.__percentage_complete = percentage_complete

    def _to_dict(self, sanitize):
        """Returns the model properties as a dict. Omits None properties based on the provided "sanitize" parameter.

        :param sanitize: A flag to omit None properties if set to True
        :type sanitize: bool
        """

        result = {}
        for attr, attr_type in six.iteritems(self.swagger_types):

            value = getattr(self, attr)
            if isinstance(value, list):
                result[attr] = list(map(
                    lambda x: x._to_dict(sanitize) if hasattr(x, "_to_dict") else x,
                    value
                ))
            elif hasattr(value, "_to_dict"):
                result[attr] = value._to_dict(sanitize)
            elif isinstance(value, Path):
                result[attr] = str(value)
            elif isinstance(value, dict):
                result[attr] = dict(map(
                    lambda item: (item[0], item[1]._to_dict(sanitize)) if hasattr(item[1], "_to_dict")
                    else (
                        (item[0], str(item[1])) if item[0] == 'path' and '$objectType' in value and value['$objectType'] == 'pathlib.Path'
                        else item
                    ),
                    six.iteritems(value)
                ))
            else:
                if sanitize:
                    if value is not None:
                        result[attr] = value
                else:
                    result[attr] = value
        if issubclass(RecoveryPlanJobExecutionStep, dict):
            for key, value in six.iteritems(self):
                result[key] = value

        # handle unknown fields
        result['_unknown_fields'] = {}
        unknown = self.get_unknown_fields()
        if sanitize:
            unknown = self._sanitize_for_serialization(unknown)

        return {**result, **unknown}


    def to_dict(self):
        """Returns the model properties as a dictionary"""
        return self._to_dict(False)

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self._to_dict(True))

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, RecoveryPlanJobExecutionStep):
            return False

        return self.__dict__ == other.__dict__

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        return not self == other

