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
import 'package:servicestack/servicestack.dart';

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

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

enum JobStates
{
    Pending,
    Starting,
    Running,
    Suspended,
    Stopping,
    Completed,
    Failed,
}

class JobDto implements IHasIdName, IHasTenantId, IAuditable, IHasObjectType, IConvertible
{
    /**
    * The id of the job
    */
    String id = "";
    /**
    * The id of the tenant
    */
    String tenantId = "";
    /**
    * The name of the job
    */
    String name = "";
    ObjectTypes objectType;
    /**
    * An additional message
    */
    String? message;
    /**
    * Api link pointing to this object
    */
    String selfLink = "";
    /**
    * The id of the configitem the job belongs to
    */
    String? configItemId;
    /**
    * The type of the configitem the job belongs to
    */
    ObjectTypes? configItemType;
    /**
    * The job type
    */
    JobTypes jobType;
    /**
    * The current state of the job
    */
    JobStates state;
    /**
    * The timestamp, when the job got started
    */
    DateTime startTime = DateTime(0);
    /**
    * The timestamp, when the job has finished
    */
    DateTime? endTime;
    /**
    * The duration (in seconds) of the job
    */
    int duration = 0;
    /**
    * The id of the related workflow
    */
    String? workflowId;
    /**
    * The id of the related scheduled task
    */
    String? schedulerId;
    /**
    * The jobs progress in percent (0...100)
    */
    double progress = 0;
    /**
    * Contains various infos about the job
    */
    Map<String,dynamic?> config = {};
    /**
    * The time the job was created
    */
    DateTime created = DateTime(0);
    /**
    * The user the job was created with
    */
    String createUser = "";
    /**
    * The user id the job was created with
    */
    String createUserId = "";
    /**
    * The user email the job was created with
    */
    String createUserEmail = "";
    /**
    * The time the job was last modified
    */
    DateTime modified = DateTime(0);
    /**
    * The user the job was modified with
    */
    String modifyUser = "";
    /**
    * The user id the job was modified with
    */
    String modifyUserId = "";
    /**
    * True if the job is deleted
    */
    bool isDeleted;
    /**
    * The time the job was deleted
    */
    DateTime? deleted;
    /**
    * The user the job was deleted with
    */
    String? deleteUser;
    /**
    * The user id the job was deleted with
    */
    String? deleteUserId;
    /**
    * Will be evaluated by event endpoints
    */
    bool sendNotifications;
    /**
    * True if it is in any of the 'running' states
    */
    bool isRunning;
    /**
    * Jobs with failed JobEvents are marked with NeedsAttention
    */
    bool needsAttention;

    JobDto({this.id,this.tenantId,this.name,this.objectType,this.message,this.selfLink,this.configItemId,this.configItemType,this.jobType,this.state,this.startTime,this.endTime,this.duration,this.workflowId,this.schedulerId,this.progress,this.config,this.created,this.createUser,this.createUserId,this.createUserEmail,this.modified,this.modifyUser,this.modifyUserId,this.isDeleted,this.deleted,this.deleteUser,this.deleteUserId,this.sendNotifications,this.isRunning,this.needsAttention});
    JobDto.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        tenantId = json['tenantId'];
        name = json['name'];
        objectType = JsonConverters.fromJson(json['objectType'],'ObjectTypes',context!);
        message = json['message'];
        selfLink = json['selfLink'];
        configItemId = json['configItemId'];
        configItemType = JsonConverters.fromJson(json['configItemType'],'ObjectTypes',context!);
        jobType = JsonConverters.fromJson(json['jobType'],'JobTypes',context!);
        state = JsonConverters.fromJson(json['state'],'JobStates',context!);
        startTime = JsonConverters.fromJson(json['startTime'],'DateTime',context!);
        endTime = JsonConverters.fromJson(json['endTime'],'DateTime',context!);
        duration = json['duration'];
        workflowId = json['workflowId'];
        schedulerId = json['schedulerId'];
        progress = JsonConverters.toDouble(json['progress']);
        config = JsonConverters.fromJson(json['config'],'Map<String,dynamic?>',context!);
        created = JsonConverters.fromJson(json['created'],'DateTime',context!);
        createUser = json['createUser'];
        createUserId = json['createUserId'];
        createUserEmail = json['createUserEmail'];
        modified = JsonConverters.fromJson(json['modified'],'DateTime',context!);
        modifyUser = json['modifyUser'];
        modifyUserId = json['modifyUserId'];
        isDeleted = json['isDeleted'];
        deleted = JsonConverters.fromJson(json['deleted'],'DateTime',context!);
        deleteUser = json['deleteUser'];
        deleteUserId = json['deleteUserId'];
        sendNotifications = json['sendNotifications'];
        isRunning = json['isRunning'];
        needsAttention = json['needsAttention'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'tenantId': tenantId,
        'name': name,
        'objectType': JsonConverters.toJson(objectType,'ObjectTypes',context!),
        'message': message,
        'selfLink': selfLink,
        'configItemId': configItemId,
        'configItemType': JsonConverters.toJson(configItemType,'ObjectTypes',context!),
        'jobType': JsonConverters.toJson(jobType,'JobTypes',context!),
        'state': JsonConverters.toJson(state,'JobStates',context!),
        'startTime': JsonConverters.toJson(startTime,'DateTime',context!),
        'endTime': JsonConverters.toJson(endTime,'DateTime',context!),
        'duration': duration,
        'workflowId': workflowId,
        'schedulerId': schedulerId,
        'progress': progress,
        'config': JsonConverters.toJson(config,'Map<String,dynamic?>',context!),
        'created': JsonConverters.toJson(created,'DateTime',context!),
        'createUser': createUser,
        'createUserId': createUserId,
        'createUserEmail': createUserEmail,
        'modified': JsonConverters.toJson(modified,'DateTime',context!),
        'modifyUser': modifyUser,
        'modifyUserId': modifyUserId,
        'isDeleted': isDeleted,
        'deleted': JsonConverters.toJson(deleted,'DateTime',context!),
        'deleteUser': deleteUser,
        'deleteUserId': deleteUserId,
        'sendNotifications': sendNotifications,
        'isRunning': isRunning,
        'needsAttention': needsAttention
    };

    getTypeName() => "JobDto";
    TypeContext? context = _ctx;
}

/**
* Create job
*/
// @Api(Description="Create job")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType=typeof(JobDto), StatusCode=201)
class CreateJob implements IBaseRequest, IHasTenantName, IPost, IConvertible
{
    // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
    // @Validate(Validator="NotEmpty")
    String tenantName = "";

    /**
    * The jobs name
    */
    // @ApiMember(DataType="string", Description="The jobs name", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotEmpty")
    // @Validate(Validator="MaximumLength(300)")
    String name = "";

    /**
    * An additional message
    */
    // @ApiMember(DataType="string", Description="An additional message", ParameterType="body")
    // @Validate(Validator="MaximumLength(500)")
    String? message;

    /**
    * 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")
    String? configItemId;

    /**
    * The configitem type
    */
    // @ApiMember(Description="The configitem type", ParameterType="body")
    ObjectTypes? configItemType;

    /**
    * The initial job state
    */
    // @ApiMember(Description="The initial job state", ParameterType="body")
    JobStates? state;

    /**
    * The sub type of the job
    */
    // @ApiMember(Description="The sub type of the job", IsRequired=true, ParameterType="body")
    // @Validate(Validator="NotNull")
    JobTypes jobType;

    /**
    * Inform users when the job has finished
    */
    // @ApiMember(DataType="bool", Description="Inform users when the job has finished", ParameterType="body")
    bool? sendNotifications;

    CreateJob({this.tenantName,this.name,this.message,this.configItemId,this.configItemType,this.state,this.jobType,this.sendNotifications});
    CreateJob.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        tenantName = json['tenantName'];
        name = json['name'];
        message = json['message'];
        configItemId = json['configItemId'];
        configItemType = JsonConverters.fromJson(json['configItemType'],'ObjectTypes',context!);
        state = JsonConverters.fromJson(json['state'],'JobStates',context!);
        jobType = JsonConverters.fromJson(json['jobType'],'JobTypes',context!);
        sendNotifications = json['sendNotifications'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'tenantName': tenantName,
        'name': name,
        'message': message,
        'configItemId': configItemId,
        'configItemType': JsonConverters.toJson(configItemType,'ObjectTypes',context!),
        'state': JsonConverters.toJson(state,'JobStates',context!),
        'jobType': JsonConverters.toJson(jobType,'JobTypes',context!),
        'sendNotifications': sendNotifications
    };

    getTypeName() => "CreateJob";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'duneframework.com', types: <String, TypeInfo> {
    'ObjectTypes': TypeInfo(TypeOf.Enum, enumValues:ObjectTypes.values),
    'JobTypes': TypeInfo(TypeOf.Enum, enumValues:JobTypes.values),
    'JobStates': TypeInfo(TypeOf.Enum, enumValues:JobStates.values),
    'JobDto': TypeInfo(TypeOf.Class, create:() => JobDto()),
    'Map<String,dynamic?>': TypeInfo(TypeOf.Class, create:() => Map<String,dynamic?>()),
    'CreateJob': TypeInfo(TypeOf.Class, create:() => CreateJob()),
});

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