| Required role: | TenantReader | Requires any of the roles: | Admin, Workflow |
| POST | /api/jobs/ | Creates a new Job | |
|---|---|---|---|
| POST | /jobs/ | Creates a new Job |
import java.math.*
import java.util.*
import java.io.InputStream
import net.servicestack.client.*
/**
* Create job
*/
@Api(Description="Create job")
@ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=JobDto::class, StatusCode=201)
open class CreateJob : IBaseRequest, IHasTenantName, IPost
{
@ApiMember(DataType="string", IsRequired=true, ParameterType="header")
@Validate(Validator="NotEmpty")
override var tenantName:String? = null
/**
* The jobs name
*/
@ApiMember(DataType="string", Description="The jobs name", IsRequired=true, ParameterType="body")
@Validate(Validator="NotEmpty")
// @Validate(Validator="MaximumLength(300)")
open var name:String? = null
/**
* An additional message
*/
@ApiMember(DataType="string", Description="An additional message", ParameterType="body")
@Validate(Validator="MaximumLength(500)")
open var message:String? = null
/**
* The id of the configitem the job was created for
*/
@ApiMember(DataType="string", Description="The id of the configitem the job was created for", Format="guid", ParameterType="path")
open var configItemId:UUID? = null
/**
* The configitem type
*/
@ApiMember(Description="The configitem type", ParameterType="body")
open var configItemType:ObjectTypes? = null
/**
* The initial job state
*/
@ApiMember(Description="The initial job state", ParameterType="body")
open var state:JobStates? = null
/**
* The sub type of the job
*/
@ApiMember(Description="The sub type of the job", IsRequired=true, ParameterType="body")
@Validate(Validator="NotNull")
open var jobType:JobTypes? = null
/**
* Inform users when the job has finished
*/
@ApiMember(DataType="bool", Description="Inform users when the job has finished", ParameterType="body")
open var sendNotifications:Boolean? = null
}
enum class ObjectTypes
{
None,
ConfigItem,
Tenant,
Collection,
Resource,
ComputeNode,
VirtualMachine,
PhysicalMachine,
Disk,
Subnet,
IpAddress,
Job,
JobEvent,
FreezePeriod,
ResourceGroup,
Deployment,
ResourceGroupTemplate,
DeploymentTemplate,
ResourceProvider,
GenericResource,
Role,
Permission,
User,
PatchingWindow,
Update,
ReportDefinition,
TimeSeries,
DataPoint,
Action,
ActionAssignment,
UserNote,
}
enum class JobStates
{
Pending,
Starting,
Running,
Suspended,
Stopping,
Completed,
Failed,
}
enum class JobTypes
{
Create,
Update,
Delete,
Start,
Stop,
Restart,
Backup,
Restore,
Patch,
Action,
}
open class JobDto : IHasIdName, IHasTenantId, IAuditable, IHasObjectType
{
/**
* The id of the job
*/
open var id:UUID? = null
/**
* The id of the tenant
*/
override var tenantId:UUID? = null
/**
* The name of the job
*/
override var name:String? = null
override var objectType:ObjectTypes? = null
/**
* An additional message
*/
open var message:String? = null
/**
* Api link pointing to this object
*/
open var selfLink:String? = null
/**
* The id of the configitem the job belongs to
*/
open var configItemId:UUID? = null
/**
* The type of the configitem the job belongs to
*/
open var configItemType:ObjectTypes? = null
/**
* The job type
*/
open var jobType:JobTypes? = null
/**
* The current state of the job
*/
open var state:JobStates? = null
/**
* The timestamp, when the job got started
*/
open var startTime:Date? = null
/**
* The timestamp, when the job has finished
*/
open var endTime:Date? = null
/**
* The duration (in seconds) of the job
*/
open var duration:Int? = null
/**
* The id of the related workflow
*/
open var workflowId:String? = null
/**
* The id of the related scheduled task
*/
open var schedulerId:String? = null
/**
* The jobs progress in percent (0...100)
*/
open var progress:Double? = null
/**
* Contains various infos about the job
*/
open var config:HashMap<String,Object> = HashMap<String,Object>()
/**
* The time the job was created
*/
override var created:Date? = null
/**
* The user the job was created with
*/
override var createUser:String? = null
/**
* The user id the job was created with
*/
override var createUserId:String? = null
/**
* The user email the job was created with
*/
open var createUserEmail:String? = null
/**
* The time the job was last modified
*/
override var modified:Date? = null
/**
* The user the job was modified with
*/
override var modifyUser:String? = null
/**
* The user id the job was modified with
*/
override var modifyUserId:String? = null
/**
* True if the job is deleted
*/
override var isDeleted:Boolean? = null
/**
* The time the job was deleted
*/
override var deleted:Date? = null
/**
* The user the job was deleted with
*/
override var deleteUser:String? = null
/**
* The user id the job was deleted with
*/
override var deleteUserId:String? = null
/**
* Will be evaluated by event endpoints
*/
open var sendNotifications:Boolean? = null
/**
* True if it is in any of the 'running' states
*/
open var isRunning:Boolean? = null
/**
* Jobs with failed JobEvents are marked with NeedsAttention
*/
open var needsAttention:Boolean? = null
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /api/jobs/ HTTP/1.1
Host: core.starburst.svc
Accept: application/json
Content-Type: application/json
Content-Length: length
{"tenantName":"String","name":"String","message":"String","configItemId":"00000000-0000-0000-0000-000000000000","configItemType":"None","state":"Pending","jobType":"Create","sendNotifications":false,"txId":"00000000-0000-0000-0000-000000000000"}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"id":"00000000-0000-0000-0000-000000000000","tenantId":"00000000-0000-0000-0000-000000000000","name":"String","objectType":"Job","message":"String","selfLink":"String","configItemId":"00000000-0000-0000-0000-000000000000","configItemType":"None","jobType":"Create","state":"Pending","startTime":"0001-01-01T00:00:00.0000000Z","endTime":"0001-01-01T00:00:00.0000000Z","duration":0,"workflowId":"String","schedulerId":"String","progress":0,"config":{"String":{}},"created":"0001-01-01T00:00:00.0000000Z","createUser":"String","createUserId":"String","createUserEmail":"String","modified":"0001-01-01T00:00:00.0000000Z","modifyUser":"String","modifyUserId":"String","isDeleted":false,"deleted":"0001-01-01T00:00:00.0000000Z","deleteUser":"String","deleteUserId":"String","sendNotifications":false,"isRunning":false,"needsAttention":false}