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
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using ServiceStack;
using ServiceStack.DataAnnotations;
using CoreService.ServiceModel.Dtos.Jobs.Crud;
using YCO.Dune.Models.Enums;
using CoreService.ServiceModel.Enums;
using CoreService.ServiceModel.Dtos.Jobs.Responses;

namespace CoreService.ServiceModel.Dtos.Jobs.Crud
{
    ///<summary>
    ///Create job
    ///</summary>
    [Api(Description="Create job")]
    [ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(CoreService.ServiceModel.Dtos.Jobs.Responses.JobDto), StatusCode=201)]
    public partial class CreateJob
        : IBaseRequest, IHasTenantName, IPost
    {
        [ApiMember(DataType="string", IsRequired=true, ParameterType="header")]
        [Validate("NotEmpty")]
        public virtual string TenantName { get; set; }

        ///<summary>
        ///The jobs name
        ///</summary>
        [ApiMember(DataType="string", Description="The jobs name", IsRequired=true, ParameterType="body")]
        [Validate("NotEmpty")]
        [Validate("MaximumLength(300)")]
        public virtual string Name { get; set; }

        ///<summary>
        ///An additional message
        ///</summary>
        [ApiMember(DataType="string", Description="An additional message", ParameterType="body")]
        [Validate("MaximumLength(500)")]
        public virtual string? Message { get; set; }

        ///<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 virtual Guid? ConfigItemId { get; set; }

        ///<summary>
        ///The configitem type
        ///</summary>
        [ApiMember(Description="The configitem type", ParameterType="body")]
        public virtual ObjectTypes? ConfigItemType { get; set; }

        ///<summary>
        ///The initial job state
        ///</summary>
        [ApiMember(Description="The initial job state", ParameterType="body")]
        public virtual JobStates? State { get; set; }

        ///<summary>
        ///The sub type of the job
        ///</summary>
        [ApiMember(Description="The sub type of the job", IsRequired=true, ParameterType="body")]
        [Validate("NotNull")]
        public virtual JobTypes JobType { get; set; }

        ///<summary>
        ///Inform users when the job has finished
        ///</summary>
        [ApiMember(DataType="bool", Description="Inform users when the job has finished", ParameterType="body")]
        public virtual bool? SendNotifications { get; set; }
    }

}

namespace CoreService.ServiceModel.Dtos.Jobs.Responses
{
    public partial class JobDto
        : IHasIdName, IHasTenantId, IAuditable, IHasObjectType
    {
        ///<summary>
        ///The id of the job
        ///</summary>
        public virtual Guid Id { get; set; }
        ///<summary>
        ///The id of the tenant
        ///</summary>
        public virtual Guid TenantId { get; set; }
        ///<summary>
        ///The name of the job
        ///</summary>
        public virtual string Name { get; set; }
        public virtual ObjectTypes ObjectType { get; set; }
        ///<summary>
        ///An additional message
        ///</summary>
        public virtual string? Message { get; set; }
        ///<summary>
        ///Api link pointing to this object
        ///</summary>
        public virtual string SelfLink { get; set; }
        ///<summary>
        ///The id of the configitem the job belongs to
        ///</summary>
        public virtual Guid? ConfigItemId { get; set; }
        ///<summary>
        ///The type of the configitem the job belongs to
        ///</summary>
        public virtual ObjectTypes? ConfigItemType { get; set; }
        ///<summary>
        ///The job type
        ///</summary>
        public virtual JobTypes JobType { get; set; }
        ///<summary>
        ///The current state of the job
        ///</summary>
        public virtual JobStates State { get; set; }
        ///<summary>
        ///The timestamp, when the job got started
        ///</summary>
        public virtual DateTime StartTime { get; set; }
        ///<summary>
        ///The timestamp, when the job has finished
        ///</summary>
        public virtual DateTime? EndTime { get; set; }
        ///<summary>
        ///The duration (in seconds) of the job
        ///</summary>
        public virtual int Duration { get; set; }
        ///<summary>
        ///The id of the related workflow
        ///</summary>
        public virtual string? WorkflowId { get; set; }
        ///<summary>
        ///The id of the related scheduled task
        ///</summary>
        public virtual string? SchedulerId { get; set; }
        ///<summary>
        ///The jobs progress in percent (0...100)
        ///</summary>
        public virtual double Progress { get; set; }
        ///<summary>
        ///Contains various infos about the job
        ///</summary>
        public virtual Dictionary<string, Object> Config { get; set; } = new();
        ///<summary>
        ///The time the job was created
        ///</summary>
        public virtual DateTime Created { get; set; }
        ///<summary>
        ///The user the job was created with
        ///</summary>
        public virtual string CreateUser { get; set; }
        ///<summary>
        ///The user id the job was created with
        ///</summary>
        public virtual string CreateUserId { get; set; }
        ///<summary>
        ///The user email the job was created with
        ///</summary>
        public virtual string CreateUserEmail { get; set; }
        ///<summary>
        ///The time the job was last modified
        ///</summary>
        public virtual DateTime Modified { get; set; }
        ///<summary>
        ///The user the job was modified with
        ///</summary>
        public virtual string ModifyUser { get; set; }
        ///<summary>
        ///The user id the job was modified with
        ///</summary>
        public virtual string ModifyUserId { get; set; }
        ///<summary>
        ///True if the job is deleted
        ///</summary>
        public virtual bool IsDeleted { get; set; }
        ///<summary>
        ///The time the job was deleted
        ///</summary>
        public virtual DateTime? Deleted { get; set; }
        ///<summary>
        ///The user the job was deleted with
        ///</summary>
        public virtual string? DeleteUser { get; set; }
        ///<summary>
        ///The user id the job was deleted with
        ///</summary>
        public virtual string? DeleteUserId { get; set; }
        ///<summary>
        ///Will be evaluated by event endpoints
        ///</summary>
        public virtual bool SendNotifications { get; set; }
        ///<summary>
        ///True if it is in any of the 'running' states
        ///</summary>
        public virtual bool IsRunning { get; set; }
        ///<summary>
        ///Jobs with failed JobEvents are marked with NeedsAttention
        ///</summary>
        public virtual bool NeedsAttention { get; set; }
    }

}

namespace CoreService.ServiceModel.Enums
{
    public enum JobStates
    {
        Pending,
        Starting,
        Running,
        Suspended,
        Stopping,
        Completed,
        Failed,
    }

    public enum JobTypes
    {
        Create,
        Update,
        Delete,
        Start,
        Stop,
        Restart,
        Backup,
        Restore,
        Patch,
        Action,
    }

}

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,
    }

}

C# 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}