/*
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See License.txt in the project root for
 * license information.
 *
 * Code generated by Microsoft (R) AutoRest Code Generator.
 * Changes may cause incorrect behavior and will be lost if the code is
 * regenerated.
 */

'use strict';

/**
 * Represents a repair task, which includes information about what kind of
 * repair was requested, what its progress is, and what its final result was.
 *
 * This type supports the Service Fabric platform; it is not meant to be used
 * directly from your code.
 *
 */
class RepairTask {
  /**
   * Create a RepairTask.
   * @property {string} taskId The ID of the repair task.
   * @property {string} [version] The version of the repair task.
   * When creating a new repair task, the version must be set to zero.  When
   * updating a repair task,
   * the version is used for optimistic concurrency checks.  If the version is
   * set to zero, the update will not check for write conflicts.  If the
   * version is set to a non-zero value, then the
   * update will only succeed if the actual current version of the repair task
   * matches this value.
   * @property {string} [description] A description of the purpose of the
   * repair task, or other informational details.
   * May be set when the repair task is created, and is immutable once set.
   * @property {string} state The workflow state of the repair task. Valid
   * initial states are Created, Claimed, and Preparing. Possible values
   * include: 'Invalid', 'Created', 'Claimed', 'Preparing', 'Approved',
   * 'Executing', 'Restoring', 'Completed'
   * @property {number} [flags] A bitwise-OR of the following values, which
   * gives additional details about the status of the repair task.
   * - 1 - Cancellation of the repair has been requested
   * - 2 - Abort of the repair has been requested
   * - 4 - Approval of the repair was forced via client request
   * @property {string} action The requested repair action. Must be specified
   * when the repair task is created, and is immutable once set.
   * @property {object} [target] The target object determines what actions the
   * system will take to prepare for the impact of the repair, prior to
   * approving execution of the repair.
   * May be set when the repair task is created, and is immutable once set.
   * @property {string} [target.kind] Polymorphic Discriminator
   * @property {string} [executor] The name of the repair executor. Must be
   * specified in Claimed and later states, and is immutable once set.
   * @property {string} [executorData] A data string that the repair executor
   * can use to store its internal state.
   * @property {object} [impact] The impact object determines what actions the
   * system will take to prepare for the impact of the repair, prior to
   * approving execution of the repair.
   * Impact must be specified by the repair executor when transitioning to the
   * Preparing state, and is immutable once set.
   * @property {string} [impact.kind] Polymorphic Discriminator
   * @property {string} [resultStatus] A value describing the overall result of
   * the repair task execution. Must be specified in the Restoring and later
   * states, and is immutable once set. Possible values include: 'Invalid',
   * 'Succeeded', 'Cancelled', 'Interrupted', 'Failed', 'Pending'
   * @property {number} [resultCode] A numeric value providing additional
   * details about the result of the repair task execution.
   * May be specified in the Restoring and later states, and is immutable once
   * set.
   * @property {string} [resultDetails] A string providing additional details
   * about the result of the repair task execution.
   * May be specified in the Restoring and later states, and is immutable once
   * set.
   * @property {object} [history] An object that contains timestamps of the
   * repair task's state transitions.
   * These timestamps are updated by the system, and cannot be directly
   * modified.
   * @property {date} [history.createdUtcTimestamp] The time when the repair
   * task entered the Created state.
   * @property {date} [history.claimedUtcTimestamp] The time when the repair
   * task entered the Claimed state.
   * @property {date} [history.preparingUtcTimestamp] The time when the repair
   * task entered the Preparing state.
   * @property {date} [history.approvedUtcTimestamp] The time when the repair
   * task entered the Approved state
   * @property {date} [history.executingUtcTimestamp] The time when the repair
   * task entered the Executing state
   * @property {date} [history.restoringUtcTimestamp] The time when the repair
   * task entered the Restoring state
   * @property {date} [history.completedUtcTimestamp] The time when the repair
   * task entered the Completed state
   * @property {date} [history.preparingHealthCheckStartUtcTimestamp] The time
   * when the repair task started the health check in the Preparing state.
   * @property {date} [history.preparingHealthCheckEndUtcTimestamp] The time
   * when the repair task completed the health check in the Preparing state.
   * @property {date} [history.restoringHealthCheckStartUtcTimestamp] The time
   * when the repair task started the health check in the Restoring state.
   * @property {date} [history.restoringHealthCheckEndUtcTimestamp] The time
   * when the repair task completed the health check in the Restoring state.
   * @property {string} [preparingHealthCheckState] The workflow state of the
   * health check when the repair task is in the Preparing state. Possible
   * values include: 'NotStarted', 'InProgress', 'Succeeded', 'Skipped',
   * 'TimedOut'
   * @property {string} [restoringHealthCheckState] The workflow state of the
   * health check when the repair task is in the Restoring state. Possible
   * values include: 'NotStarted', 'InProgress', 'Succeeded', 'Skipped',
   * 'TimedOut'
   * @property {boolean} [performPreparingHealthCheck] A value to determine if
   * health checks will be performed when the repair task enters the Preparing
   * state.
   * @property {boolean} [performRestoringHealthCheck] A value to determine if
   * health checks will be performed when the repair task enters the Restoring
   * state.
   */
  constructor() {
  }

  /**
   * Defines the metadata of RepairTask
   *
   * @returns {object} metadata of RepairTask
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'RepairTask',
      type: {
        name: 'Composite',
        className: 'RepairTask',
        modelProperties: {
          taskId: {
            required: true,
            serializedName: 'TaskId',
            type: {
              name: 'String'
            }
          },
          version: {
            required: false,
            serializedName: 'Version',
            type: {
              name: 'String'
            }
          },
          description: {
            required: false,
            serializedName: 'Description',
            type: {
              name: 'String'
            }
          },
          state: {
            required: true,
            serializedName: 'State',
            type: {
              name: 'String'
            }
          },
          flags: {
            required: false,
            serializedName: 'Flags',
            type: {
              name: 'Number'
            }
          },
          action: {
            required: true,
            serializedName: 'Action',
            type: {
              name: 'String'
            }
          },
          target: {
            required: false,
            serializedName: 'Target',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'Kind',
                clientName: 'kind'
              },
              uberParent: 'RepairTargetDescriptionBase',
              className: 'RepairTargetDescriptionBase'
            }
          },
          executor: {
            required: false,
            serializedName: 'Executor',
            type: {
              name: 'String'
            }
          },
          executorData: {
            required: false,
            serializedName: 'ExecutorData',
            type: {
              name: 'String'
            }
          },
          impact: {
            required: false,
            serializedName: 'Impact',
            type: {
              name: 'Composite',
              polymorphicDiscriminator: {
                serializedName: 'Kind',
                clientName: 'kind'
              },
              uberParent: 'RepairImpactDescriptionBase',
              className: 'RepairImpactDescriptionBase'
            }
          },
          resultStatus: {
            required: false,
            serializedName: 'ResultStatus',
            type: {
              name: 'String'
            }
          },
          resultCode: {
            required: false,
            serializedName: 'ResultCode',
            type: {
              name: 'Number'
            }
          },
          resultDetails: {
            required: false,
            serializedName: 'ResultDetails',
            type: {
              name: 'String'
            }
          },
          history: {
            required: false,
            serializedName: 'History',
            type: {
              name: 'Composite',
              className: 'RepairTaskHistory'
            }
          },
          preparingHealthCheckState: {
            required: false,
            serializedName: 'PreparingHealthCheckState',
            type: {
              name: 'String'
            }
          },
          restoringHealthCheckState: {
            required: false,
            serializedName: 'RestoringHealthCheckState',
            type: {
              name: 'String'
            }
          },
          performPreparingHealthCheck: {
            required: false,
            serializedName: 'PerformPreparingHealthCheck',
            type: {
              name: 'Boolean'
            }
          },
          performRestoringHealthCheck: {
            required: false,
            serializedName: 'PerformRestoringHealthCheck',
            type: {
              name: 'Boolean'
            }
          }
        }
      }
    };
  }
}

module.exports = RepairTask;
