/*
 * 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';

const models = require('./index');

/**
 * An execution of a job
 *
 * @extends models['ProxyResource']
 */
class JobExecution extends models['ProxyResource'] {
  /**
   * Create a JobExecution.
   * @property {number} [jobVersion] The job version number.
   * @property {string} [stepName] The job step name.
   * @property {number} [stepId] The job step id.
   * @property {uuid} [jobExecutionId] The unique identifier of the job
   * execution.
   * @property {string} [lifecycle] The detailed state of the job execution.
   * Possible values include: 'Created', 'InProgress',
   * 'WaitingForChildJobExecutions', 'WaitingForRetry', 'Succeeded',
   * 'SucceededWithSkipped', 'Failed', 'TimedOut', 'Canceled', 'Skipped'
   * @property {string} [provisioningState] The ARM provisioning state of the
   * job execution. Possible values include: 'Created', 'InProgress',
   * 'Succeeded', 'Failed', 'Canceled'
   * @property {date} [createTime] The time that the job execution was created.
   * @property {date} [startTime] The time that the job execution started.
   * @property {date} [endTime] The time that the job execution completed.
   * @property {number} [currentAttempts] Number of times the job execution has
   * been attempted.
   * @property {date} [currentAttemptStartTime] Start time of the current
   * attempt.
   * @property {string} [lastMessage] The last status or error message.
   * @property {object} [target] The target that this execution is executed on.
   * @property {string} [target.type] The type of the target. Possible values
   * include: 'TargetGroup', 'SqlDatabase', 'SqlElasticPool', 'SqlShardMap',
   * 'SqlServer'
   * @property {string} [target.serverName] The server name.
   * @property {string} [target.databaseName] The database name.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of JobExecution
   *
   * @returns {object} metadata of JobExecution
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'JobExecution',
      type: {
        name: 'Composite',
        className: 'JobExecution',
        modelProperties: {
          id: {
            required: false,
            readOnly: true,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            readOnly: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          },
          jobVersion: {
            required: false,
            readOnly: true,
            serializedName: 'properties.jobVersion',
            type: {
              name: 'Number'
            }
          },
          stepName: {
            required: false,
            readOnly: true,
            serializedName: 'properties.stepName',
            type: {
              name: 'String'
            }
          },
          stepId: {
            required: false,
            readOnly: true,
            serializedName: 'properties.stepId',
            type: {
              name: 'Number'
            }
          },
          jobExecutionId: {
            required: false,
            readOnly: true,
            serializedName: 'properties.jobExecutionId',
            type: {
              name: 'String'
            }
          },
          lifecycle: {
            required: false,
            readOnly: true,
            serializedName: 'properties.lifecycle',
            type: {
              name: 'String'
            }
          },
          provisioningState: {
            required: false,
            readOnly: true,
            serializedName: 'properties.provisioningState',
            type: {
              name: 'String'
            }
          },
          createTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.createTime',
            type: {
              name: 'DateTime'
            }
          },
          startTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.startTime',
            type: {
              name: 'DateTime'
            }
          },
          endTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.endTime',
            type: {
              name: 'DateTime'
            }
          },
          currentAttempts: {
            required: false,
            serializedName: 'properties.currentAttempts',
            type: {
              name: 'Number'
            }
          },
          currentAttemptStartTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.currentAttemptStartTime',
            type: {
              name: 'DateTime'
            }
          },
          lastMessage: {
            required: false,
            readOnly: true,
            serializedName: 'properties.lastMessage',
            type: {
              name: 'String'
            }
          },
          target: {
            required: false,
            readOnly: true,
            serializedName: 'properties.target',
            type: {
              name: 'Composite',
              className: 'JobExecutionTarget'
            }
          }
        }
      }
    };
  }
}

module.exports = JobExecution;
