CoreService

<back to all web services

CreateJob

Job - CRUD

Create job

Requires Authentication
Required role:TenantReaderRequires any of the roles:Admin, Workflow
The following routes are available for this service:
POST/api/jobs/Creates a new Job
POST/jobs/Creates a new Job
Imports System
Imports System.IO
Imports System.Collections
Imports System.Collections.Generic
Imports System.Runtime.Serialization
Imports ServiceStack
Imports ServiceStack.DataAnnotations
Imports CoreService.ServiceModel.Dtos.Jobs.Crud
Imports YCO.Dune.Models.Enums
Imports CoreService.ServiceModel.Enums
Imports CoreService.ServiceModel.Dtos.Jobs.Responses

Namespace Global

    Namespace CoreService.ServiceModel.Dtos.Jobs.Crud

        '''<Summary>
        '''Create job
        '''</Summary>
        <Api(Description:="Create job")>
        <ApiResponse(Description:="Success", IsDefaultResponse:=true, ResponseType:=GetType(JobDto), StatusCode:=201)>
        Public Partial Class CreateJob
            Implements IBaseRequest
            Implements IHasTenantName
            Implements IPost
            <ApiMember(DataType:="string", IsRequired:=true, ParameterType:="header")>
            <Validate(Validator:="NotEmpty")>
            Public Overridable Property TenantName As String Implements IHasTenantName.TenantName

            '''<Summary>
            '''The jobs name
            '''</Summary>
            <ApiMember(DataType:="string", Description:="The jobs name", IsRequired:=true, ParameterType:="body")>
            <Validate(Validator:="NotEmpty")>
            <Validate(Validator:="MaximumLength(300)")>
            Public Overridable Property Name As String

            '''<Summary>
            '''An additional message
            '''</Summary>
            <ApiMember(DataType:="string", Description:="An additional message", ParameterType:="body")>
            <Validate(Validator:="MaximumLength(500)")>
            Public Overridable Property Message As String

            '''<Summary>
            '''The id of the configitem the job was created for
            '''</Summary>
            <ApiMember(DataType:="string", Description:="The id of the configitem the job was created for", Format:="guid", ParameterType:="path")>
            Public Overridable Property ConfigItemId As Guid?

            '''<Summary>
            '''The configitem type
            '''</Summary>
            <ApiMember(Description:="The configitem type", ParameterType:="body")>
            Public Overridable Property ConfigItemType As ObjectTypes?

            '''<Summary>
            '''The initial job state
            '''</Summary>
            <ApiMember(Description:="The initial job state", ParameterType:="body")>
            Public Overridable Property State As JobStates?

            '''<Summary>
            '''The sub type of the job
            '''</Summary>
            <ApiMember(Description:="The sub type of the job", IsRequired:=true, ParameterType:="body")>
            <Validate(Validator:="NotNull")>
            Public Overridable Property JobType As JobTypes

            '''<Summary>
            '''Inform users when the job has finished
            '''</Summary>
            <ApiMember(DataType:="bool", Description:="Inform users when the job has finished", ParameterType:="body")>
            Public Overridable Property SendNotifications As Boolean?
        End Class
    End Namespace

    Namespace CoreService.ServiceModel.Dtos.Jobs.Responses

        Public Partial Class JobDto
            Implements IHasIdName
            Implements IHasTenantId
            Implements IAuditable
            Implements IHasObjectType
            '''<Summary>
            '''The id of the job
            '''</Summary>
            Public Overridable Property Id As Guid
            '''<Summary>
            '''The id of the tenant
            '''</Summary>
            Public Overridable Property TenantId As Guid Implements IHasTenantId.TenantId
            '''<Summary>
            '''The name of the job
            '''</Summary>
            Public Overridable Property Name As String Implements IHasIdName.Name
            Public Overridable Property ObjectType As ObjectTypes Implements IHasObjectType.ObjectType
            '''<Summary>
            '''An additional message
            '''</Summary>
            Public Overridable Property Message As String
            '''<Summary>
            '''Api link pointing to this object
            '''</Summary>
            Public Overridable Property SelfLink As String
            '''<Summary>
            '''The id of the configitem the job belongs to
            '''</Summary>
            Public Overridable Property ConfigItemId As Guid?
            '''<Summary>
            '''The type of the configitem the job belongs to
            '''</Summary>
            Public Overridable Property ConfigItemType As ObjectTypes?
            '''<Summary>
            '''The job type
            '''</Summary>
            Public Overridable Property JobType As JobTypes
            '''<Summary>
            '''The current state of the job
            '''</Summary>
            Public Overridable Property State As JobStates
            '''<Summary>
            '''The timestamp, when the job got started
            '''</Summary>
            Public Overridable Property StartTime As Date
            '''<Summary>
            '''The timestamp, when the job has finished
            '''</Summary>
            Public Overridable Property EndTime As Date?
            '''<Summary>
            '''The duration (in seconds) of the job
            '''</Summary>
            Public Overridable Property Duration As Integer
            '''<Summary>
            '''The id of the related workflow
            '''</Summary>
            Public Overridable Property WorkflowId As String
            '''<Summary>
            '''The id of the related scheduled task
            '''</Summary>
            Public Overridable Property SchedulerId As String
            '''<Summary>
            '''The jobs progress in percent (0...100)
            '''</Summary>
            Public Overridable Property Progress As Double
            '''<Summary>
            '''Contains various infos about the job
            '''</Summary>
            Public Overridable Property Config As Dictionary(Of String, Object) = New Dictionary(Of String, Object)
            '''<Summary>
            '''The time the job was created
            '''</Summary>
            Public Overridable Property Created As Date Implements IAuditable.Created
            '''<Summary>
            '''The user the job was created with
            '''</Summary>
            Public Overridable Property CreateUser As String Implements IAuditable.CreateUser
            '''<Summary>
            '''The user id the job was created with
            '''</Summary>
            Public Overridable Property CreateUserId As String Implements IAuditable.CreateUserId
            '''<Summary>
            '''The user email the job was created with
            '''</Summary>
            Public Overridable Property CreateUserEmail As String
            '''<Summary>
            '''The time the job was last modified
            '''</Summary>
            Public Overridable Property Modified As Date Implements IAuditable.Modified
            '''<Summary>
            '''The user the job was modified with
            '''</Summary>
            Public Overridable Property ModifyUser As String Implements IAuditable.ModifyUser
            '''<Summary>
            '''The user id the job was modified with
            '''</Summary>
            Public Overridable Property ModifyUserId As String Implements IAuditable.ModifyUserId
            '''<Summary>
            '''True if the job is deleted
            '''</Summary>
            Public Overridable Property IsDeleted As Boolean Implements IAuditable.IsDeleted
            '''<Summary>
            '''The time the job was deleted
            '''</Summary>
            Public Overridable Property Deleted As Date? Implements IAuditable.Deleted
            '''<Summary>
            '''The user the job was deleted with
            '''</Summary>
            Public Overridable Property DeleteUser As String Implements IAuditable.DeleteUser
            '''<Summary>
            '''The user id the job was deleted with
            '''</Summary>
            Public Overridable Property DeleteUserId As String Implements IAuditable.DeleteUserId
            '''<Summary>
            '''Will be evaluated by event endpoints
            '''</Summary>
            Public Overridable Property SendNotifications As Boolean
            '''<Summary>
            '''True if it is in any of the 'running' states
            '''</Summary>
            Public Overridable Property IsRunning As Boolean
            '''<Summary>
            '''Jobs with failed JobEvents are marked with NeedsAttention
            '''</Summary>
            Public Overridable Property NeedsAttention As Boolean
        End Class
    End Namespace

    Namespace CoreService.ServiceModel.Enums

        Public Enum JobStates
            Pending
            Starting
            Running
            Suspended
            Stopping
            Completed
            Failed
        End Enum

        Public Enum JobTypes
            Create
            Update
            Delete
            Start
            [Stop]
            Restart
            Backup
            Restore
            Patch
            Action
        End Enum
    End Namespace

    Namespace YCO.Dune.Models.Enums

        Public Enum 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
        End Enum
    End Namespace
End Namespace

VB.NET CreateJob DTOs

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

HTTP + JSON

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}