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

/**
 * Information about a Job.
 *
 * @extends models['ProxyResource']
 */
class Job extends models['ProxyResource'] {
  /**
   * Create a Job.
   * @member {string} [schedulingPriority] Scheduling priority. Scheduling
   * priority associated with the job. Possible values include: 'low',
   * 'normal', 'high'. Default value: 'normal' .
   * @member {object} [cluster] Cluster. Resource ID of the cluster associated
   * with the job.
   * @member {string} [cluster.id] The ID of the resource
   * @member {object} [mountVolumes] Mount volumes. Collection of mount volumes
   * available to the job during execution. These volumes are mounted before
   * the job execution and unmouted after the job completion. The volumes are
   * mounted at location specified by $AZ_BATCHAI_JOB_MOUNT_ROOT environment
   * variable.
   * @member {array} [mountVolumes.azureFileShares] A collection of Azure File
   * Shares that are to be mounted to the cluster nodes.
   * @member {array} [mountVolumes.azureBlobFileSystems] A collection of Azure
   * Blob Containers that are to be mounted to the cluster nodes.
   * @member {array} [mountVolumes.fileServers] A collection of Batch AI File
   * Servers that are to be mounted to the cluster nodes.
   * @member {array} [mountVolumes.unmanagedFileSystems] A collection of
   * unmanaged file systems that are to be mounted to the cluster nodes.
   * @member {number} [nodeCount] Number of compute nodes to run the job on.
   * The job will be gang scheduled on that many compute nodes
   * @member {object} [containerSettings] If provided the job will run in the
   * specified container. If the container was downloaded as part of cluster
   * setup then the same container image will be used. If not provided, the job
   * will run on the VM.
   * @member {object} [containerSettings.imageSourceRegistry] Information about
   * docker image and docker registry to download the container from.
   * @member {string} [containerSettings.imageSourceRegistry.serverUrl] URL for
   * image repository.
   * @member {string} [containerSettings.imageSourceRegistry.image] The name of
   * the image in the image repository.
   * @member {object} [containerSettings.imageSourceRegistry.credentials]
   * Credentials to access the private docker repository.
   * @member {string}
   * [containerSettings.imageSourceRegistry.credentials.username] User name to
   * login to the repository.
   * @member {string}
   * [containerSettings.imageSourceRegistry.credentials.password] User password
   * to login to the docker repository. One of password or
   * passwordSecretReference must be specified.
   * @member {object}
   * [containerSettings.imageSourceRegistry.credentials.passwordSecretReference]
   * KeyVault Secret storing the password. Users can store their secrets in
   * Azure KeyVault and pass it to the Batch AI service to integrate with
   * KeyVault. One of password or passwordSecretReference must be specified.
   * @member {object}
   * [containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault]
   * Fully qualified resource indentifier of the Key Vault.
   * @member {string}
   * [containerSettings.imageSourceRegistry.credentials.passwordSecretReference.sourceVault.id]
   * The ID of the resource
   * @member {string}
   * [containerSettings.imageSourceRegistry.credentials.passwordSecretReference.secretUrl]
   * The URL referencing a secret in the Key Vault.
   * @member {string} [containerSettings.shmSize] Size of /dev/shm. Please
   * refer to docker documentation for supported argument formats.
   * @member {string} [toolType] The toolkit type of this job. Possible values
   * are: cntk, tensorflow, caffe, caffe2, chainer, pytorch, custom, custommpi,
   * horovod. Possible values include: 'cntk', 'tensorflow', 'caffe', 'caffe2',
   * 'chainer', 'horovod', 'custommpi', 'custom'
   * @member {object} [cntkSettings] Specifies the settings for CNTK (aka
   * Microsoft Cognitive Toolkit) job.
   * @member {string} [cntkSettings.languageType] The language to use for
   * launching CNTK (aka Microsoft Cognitive Toolkit) job. Valid values are
   * 'BrainScript' or 'Python'.
   * @member {string} [cntkSettings.configFilePath] Specifies the path of the
   * BrainScript config file. This property can be specified only if the
   * languageType is 'BrainScript'.
   * @member {string} [cntkSettings.pythonScriptFilePath] Python script to
   * execute. This property can be specified only if the languageType is
   * 'Python'.
   * @member {string} [cntkSettings.pythonInterpreterPath] The path to the
   * Python interpreter. This property can be specified only if the
   * languageType is 'Python'.
   * @member {string} [cntkSettings.commandLineArgs] Command line arguments
   * that need to be passed to the python script or cntk executable.
   * @member {number} [cntkSettings.processCount] Number of processes to launch
   * for the job execution. The default value for this property is equal to
   * nodeCount property
   * @member {object} [pyTorchSettings] Specifies the settings for pyTorch job.
   * @member {string} [pyTorchSettings.pythonScriptFilePath] The python script
   * to execute.
   * @member {string} [pyTorchSettings.pythonInterpreterPath] The path to the
   * Python interpreter.
   * @member {string} [pyTorchSettings.commandLineArgs] Command line arguments
   * that need to be passed to the python script.
   * @member {number} [pyTorchSettings.processCount] Number of processes to
   * launch for the job execution. The default value for this property is equal
   * to nodeCount property
   * @member {string} [pyTorchSettings.communicationBackend] Type of the
   * communication backend for distributed jobs. Valid values are 'TCP', 'Gloo'
   * or 'MPI'. Not required for non-distributed jobs.
   * @member {object} [tensorFlowSettings] Specifies the settings for Tensor
   * Flow job.
   * @member {string} [tensorFlowSettings.pythonScriptFilePath] The python
   * script to execute.
   * @member {string} [tensorFlowSettings.pythonInterpreterPath] The path to
   * the Python interpreter.
   * @member {string} [tensorFlowSettings.masterCommandLineArgs] Command line
   * arguments that need to be passed to the python script for the master task.
   * @member {string} [tensorFlowSettings.workerCommandLineArgs] Command line
   * arguments that need to be passed to the python script for the worker task.
   * Optional for single process jobs.
   * @member {string} [tensorFlowSettings.parameterServerCommandLineArgs]
   * Command line arguments that need to be passed to the python script for the
   * parameter server. Optional for single process jobs.
   * @member {number} [tensorFlowSettings.workerCount] The number of worker
   * tasks. If specified, the value must be less than or equal to (nodeCount *
   * numberOfGPUs per VM). If not specified, the default value is equal to
   * nodeCount. This property can be specified only for distributed TensorFlow
   * training.
   * @member {number} [tensorFlowSettings.parameterServerCount] The number of
   * parameter server tasks. If specified, the value must be less than or equal
   * to nodeCount. If not specified, the default value is equal to 1 for
   * distributed TensorFlow training. This property can be specified only for
   * distributed TensorFlow training.
   * @member {object} [caffeSettings] Specifies the settings for Caffe job.
   * @member {string} [caffeSettings.configFilePath] Path of the config file
   * for the job. This property cannot be specified if pythonScriptFilePath is
   * specified.
   * @member {string} [caffeSettings.pythonScriptFilePath] Python script to
   * execute. This property cannot be specified if configFilePath is specified.
   * @member {string} [caffeSettings.pythonInterpreterPath] The path to the
   * Python interpreter. The property can be specified only if the
   * pythonScriptFilePath is specified.
   * @member {string} [caffeSettings.commandLineArgs] Command line arguments
   * that need to be passed to the Caffe job.
   * @member {number} [caffeSettings.processCount] Number of processes to
   * launch for the job execution. The default value for this property is equal
   * to nodeCount property
   * @member {object} [caffe2Settings] Specifies the settings for Caffe2 job.
   * @member {string} [caffe2Settings.pythonScriptFilePath] The python script
   * to execute.
   * @member {string} [caffe2Settings.pythonInterpreterPath] The path to the
   * Python interpreter.
   * @member {string} [caffe2Settings.commandLineArgs] Command line arguments
   * that need to be passed to the python script.
   * @member {object} [chainerSettings] Specifies the settings for Chainer job.
   * @member {string} [chainerSettings.pythonScriptFilePath] The python script
   * to execute.
   * @member {string} [chainerSettings.pythonInterpreterPath] The path to the
   * Python interpreter.
   * @member {string} [chainerSettings.commandLineArgs] Command line arguments
   * that need to be passed to the python script.
   * @member {number} [chainerSettings.processCount] Number of processes to
   * launch for the job execution. The default value for this property is equal
   * to nodeCount property
   * @member {object} [customToolkitSettings] Specifies the settings for custom
   * tool kit job.
   * @member {string} [customToolkitSettings.commandLine] The command line to
   * execute on the master node.
   * @member {object} [customMpiSettings] Specifies the settings for custom MPI
   * job.
   * @member {string} [customMpiSettings.commandLine] The command line to be
   * executed by mpi runtime on each compute node.
   * @member {number} [customMpiSettings.processCount] Number of processes to
   * launch for the job execution. The default value for this property is equal
   * to nodeCount property
   * @member {object} [horovodSettings] Specifies the settings for Horovod job.
   * @member {string} [horovodSettings.pythonScriptFilePath] The python script
   * to execute.
   * @member {string} [horovodSettings.pythonInterpreterPath] The path to the
   * Python interpreter.
   * @member {string} [horovodSettings.commandLineArgs] Command line arguments
   * that need to be passed to the python script.
   * @member {number} [horovodSettings.processCount] Number of processes to
   * launch for the job execution. The default value for this property is equal
   * to nodeCount property
   * @member {object} [jobPreparation] Specifies the actions to be performed
   * before tool kit is launched. The specified actions will run on all the
   * nodes that are part of the job
   * @member {string} [jobPreparation.commandLine] The command line to execute.
   * If containerSettings is specified on the job, this commandLine will be
   * executed in the same container as job. Otherwise it will be executed on
   * the node.
   * @member {string} [jobOutputDirectoryPathSegment] Output directory path
   * segment. A segment of job's output directories path created by Batch AI.
   * Batch AI creates job's output directories under an unique path to avoid
   * conflicts between jobs. This value contains a path segment generated by
   * Batch AI to make the path unique and can be used to find the output
   * directory on the node or mounted filesystem.
   * @member {string} [stdOutErrPathPrefix] Standard output directory path
   * prefix. The path where the Batch AI service stores stdout, stderror and
   * execution log of the job.
   * @member {array} [inputDirectories] Input directories. A list of input
   * directories for the job.
   * @member {array} [outputDirectories] Output directories. A list of output
   * directories for the job.
   * @member {array} [environmentVariables] Environment variables. A collection
   * of user defined environment variables to be setup for the job.
   * @member {array} [secrets] Secrets. A collection of user defined
   * environment variables with secret values to be setup for the job. Server
   * will never report values of these variables back.
   * @member {object} [constraints] Constraints associated with the Job.
   * @member {moment.duration} [constraints.maxWallClockTime] Max time the job
   * can run. Default value: 1 week.
   * @member {date} [creationTime] Creation time. The creation time of the job.
   * @member {string} [provisioningState] Provisioning state. The provisioned
   * state of the Batch AI job. Possible values include: 'creating',
   * 'succeeded', 'failed', 'deleting'
   * @member {date} [provisioningStateTransitionTime] Provisioning state
   * transition time. The time at which the job entered its current
   * provisioning state.
   * @member {string} [executionState] Execution state. The current state of
   * the job. Possible values are: queued - The job is queued and able to run.
   * A job enters this state when it is created, or when it is awaiting a retry
   * after a failed run. running - The job is running on a compute cluster.
   * This includes job-level preparation such as downloading resource files or
   * set up container specified on the job - it does not necessarily mean that
   * the job command line has started executing. terminating - The job is
   * terminated by the user, the terminate operation is in progress. succeeded
   * - The job has completed running succesfully and exited with exit code 0.
   * failed - The job has finished unsuccessfully (failed with a non-zero exit
   * code) and has exhausted its retry limit. A job is also marked as failed if
   * an error occurred launching the job. Possible values include: 'queued',
   * 'running', 'terminating', 'succeeded', 'failed'
   * @member {date} [executionStateTransitionTime] Execution state transition
   * time. The time at which the job entered its current execution state.
   * @member {object} [executionInfo] Information about the execution of a job.
   * @member {date} [executionInfo.startTime] The time at which the job started
   * running. 'Running' corresponds to the running state. If the job has been
   * restarted or retried, this is the most recent time at which the job
   * started running. This property is present only for job that are in the
   * running or completed state.
   * @member {date} [executionInfo.endTime] The time at which the job
   * completed. This property is only returned if the job is in completed
   * state.
   * @member {number} [executionInfo.exitCode] The exit code of the job. This
   * property is only returned if the job is in completed state.
   * @member {array} [executionInfo.errors] A collection of errors encountered
   * by the service during job execution.
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of Job
   *
   * @returns {object} metadata of Job
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'Job',
      type: {
        name: 'Composite',
        className: 'Job',
        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'
            }
          },
          schedulingPriority: {
            required: false,
            serializedName: 'properties.schedulingPriority',
            defaultValue: 'normal',
            type: {
              name: 'String'
            }
          },
          cluster: {
            required: false,
            serializedName: 'properties.cluster',
            type: {
              name: 'Composite',
              className: 'ResourceId'
            }
          },
          mountVolumes: {
            required: false,
            serializedName: 'properties.mountVolumes',
            type: {
              name: 'Composite',
              className: 'MountVolumes'
            }
          },
          nodeCount: {
            required: false,
            serializedName: 'properties.nodeCount',
            type: {
              name: 'Number'
            }
          },
          containerSettings: {
            required: false,
            serializedName: 'properties.containerSettings',
            type: {
              name: 'Composite',
              className: 'ContainerSettings'
            }
          },
          toolType: {
            required: false,
            serializedName: 'properties.toolType',
            type: {
              name: 'String'
            }
          },
          cntkSettings: {
            required: false,
            serializedName: 'properties.cntkSettings',
            type: {
              name: 'Composite',
              className: 'CNTKsettings'
            }
          },
          pyTorchSettings: {
            required: false,
            serializedName: 'properties.pyTorchSettings',
            type: {
              name: 'Composite',
              className: 'PyTorchSettings'
            }
          },
          tensorFlowSettings: {
            required: false,
            serializedName: 'properties.tensorFlowSettings',
            type: {
              name: 'Composite',
              className: 'TensorFlowSettings'
            }
          },
          caffeSettings: {
            required: false,
            serializedName: 'properties.caffeSettings',
            type: {
              name: 'Composite',
              className: 'CaffeSettings'
            }
          },
          caffe2Settings: {
            required: false,
            serializedName: 'properties.caffe2Settings',
            type: {
              name: 'Composite',
              className: 'Caffe2Settings'
            }
          },
          chainerSettings: {
            required: false,
            serializedName: 'properties.chainerSettings',
            type: {
              name: 'Composite',
              className: 'ChainerSettings'
            }
          },
          customToolkitSettings: {
            required: false,
            serializedName: 'properties.customToolkitSettings',
            type: {
              name: 'Composite',
              className: 'CustomToolkitSettings'
            }
          },
          customMpiSettings: {
            required: false,
            serializedName: 'properties.customMpiSettings',
            type: {
              name: 'Composite',
              className: 'CustomMpiSettings'
            }
          },
          horovodSettings: {
            required: false,
            serializedName: 'properties.horovodSettings',
            type: {
              name: 'Composite',
              className: 'HorovodSettings'
            }
          },
          jobPreparation: {
            required: false,
            serializedName: 'properties.jobPreparation',
            type: {
              name: 'Composite',
              className: 'JobPreparation'
            }
          },
          jobOutputDirectoryPathSegment: {
            required: false,
            readOnly: true,
            serializedName: 'properties.jobOutputDirectoryPathSegment',
            type: {
              name: 'String'
            }
          },
          stdOutErrPathPrefix: {
            required: false,
            serializedName: 'properties.stdOutErrPathPrefix',
            type: {
              name: 'String'
            }
          },
          inputDirectories: {
            required: false,
            serializedName: 'properties.inputDirectories',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'InputDirectoryElementType',
                  type: {
                    name: 'Composite',
                    className: 'InputDirectory'
                  }
              }
            }
          },
          outputDirectories: {
            required: false,
            serializedName: 'properties.outputDirectories',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'OutputDirectoryElementType',
                  type: {
                    name: 'Composite',
                    className: 'OutputDirectory'
                  }
              }
            }
          },
          environmentVariables: {
            required: false,
            serializedName: 'properties.environmentVariables',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'EnvironmentVariableElementType',
                  type: {
                    name: 'Composite',
                    className: 'EnvironmentVariable'
                  }
              }
            }
          },
          secrets: {
            required: false,
            serializedName: 'properties.secrets',
            type: {
              name: 'Sequence',
              element: {
                  required: false,
                  serializedName: 'EnvironmentVariableWithSecretValueElementType',
                  type: {
                    name: 'Composite',
                    className: 'EnvironmentVariableWithSecretValue'
                  }
              }
            }
          },
          constraints: {
            required: false,
            serializedName: 'properties.constraints',
            type: {
              name: 'Composite',
              className: 'JobPropertiesConstraints'
            }
          },
          creationTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.creationTime',
            type: {
              name: 'DateTime'
            }
          },
          provisioningState: {
            required: false,
            nullable: false,
            readOnly: true,
            serializedName: 'properties.provisioningState',
            type: {
              name: 'String'
            }
          },
          provisioningStateTransitionTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.provisioningStateTransitionTime',
            type: {
              name: 'DateTime'
            }
          },
          executionState: {
            required: false,
            readOnly: true,
            serializedName: 'properties.executionState',
            type: {
              name: 'String'
            }
          },
          executionStateTransitionTime: {
            required: false,
            readOnly: true,
            serializedName: 'properties.executionStateTransitionTime',
            type: {
              name: 'DateTime'
            }
          },
          executionInfo: {
            required: false,
            serializedName: 'properties.executionInfo',
            type: {
              name: 'Composite',
              className: 'JobPropertiesExecutionInfo'
            }
          }
        }
      }
    };
  }
}

module.exports = Job;
