CoreService

<back to all web services

ScanDeploymentResources

Deployment - Operations

Trigger the resource scan workflow

Requires Authentication
Required role:TenantReader
The following routes are available for this service:
POST/api/deployments/{Id}/scanresourcesScan the resources
POST/deployments/{Id}/scanresourcesScan the resources
<?php namespace dtos;

use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};


enum ObjectTypes : string
{
    case None = 'None';
    case ConfigItem = 'ConfigItem';
    case Tenant = 'Tenant';
    case Collection = 'Collection';
    case Resource = 'Resource';
    case ComputeNode = 'ComputeNode';
    case VirtualMachine = 'VirtualMachine';
    case PhysicalMachine = 'PhysicalMachine';
    case Disk = 'Disk';
    case Subnet = 'Subnet';
    case IPAddress = 'IPAddress';
    case Job = 'Job';
    case JobEvent = 'JobEvent';
    case FreezePeriod = 'FreezePeriod';
    case ResourceGroup = 'ResourceGroup';
    case Deployment = 'Deployment';
    case ResourceGroupTemplate = 'ResourceGroupTemplate';
    case DeploymentTemplate = 'DeploymentTemplate';
    case ResourceProvider = 'ResourceProvider';
    case GenericResource = 'GenericResource';
    case Role = 'Role';
    case Permission = 'Permission';
    case User = 'User';
    case PatchingWindow = 'PatchingWindow';
    case Update = 'Update';
    case ReportDefinition = 'ReportDefinition';
    case TimeSeries = 'TimeSeries';
    case DataPoint = 'DataPoint';
    case Action = 'Action';
    case ActionAssignment = 'ActionAssignment';
    case UserNote = 'UserNote';
}

enum JobTypes : string
{
    case Create = 'Create';
    case Update = 'Update';
    case Delete = 'Delete';
    case Start = 'Start';
    case Stop = 'Stop';
    case Restart = 'Restart';
    case Backup = 'Backup';
    case Restore = 'Restore';
    case Patch = 'Patch';
    case Action = 'Action';
}

enum JobStates : string
{
    case Pending = 'Pending';
    case Starting = 'Starting';
    case Running = 'Running';
    case Suspended = 'Suspended';
    case Stopping = 'Stopping';
    case Completed = 'Completed';
    case Failed = 'Failed';
}

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

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['tenantId'])) $this->tenantId = $o['tenantId'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['objectType'])) $this->objectType = JsonConverters::from('ObjectTypes', $o['objectType']);
        if (isset($o['message'])) $this->message = $o['message'];
        if (isset($o['selfLink'])) $this->selfLink = $o['selfLink'];
        if (isset($o['configItemId'])) $this->configItemId = $o['configItemId'];
        if (isset($o['configItemType'])) $this->configItemType = JsonConverters::from('ObjectTypes', $o['configItemType']);
        if (isset($o['jobType'])) $this->jobType = JsonConverters::from('JobTypes', $o['jobType']);
        if (isset($o['state'])) $this->state = JsonConverters::from('JobStates', $o['state']);
        if (isset($o['startTime'])) $this->startTime = JsonConverters::from('DateTime', $o['startTime']);
        if (isset($o['endTime'])) $this->endTime = JsonConverters::from('DateTime', $o['endTime']);
        if (isset($o['duration'])) $this->duration = $o['duration'];
        if (isset($o['workflowId'])) $this->workflowId = $o['workflowId'];
        if (isset($o['schedulerId'])) $this->schedulerId = $o['schedulerId'];
        if (isset($o['progress'])) $this->progress = $o['progress'];
        if (isset($o['config'])) $this->config = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','Object']), $o['config']);
        if (isset($o['created'])) $this->created = JsonConverters::from('DateTime', $o['created']);
        if (isset($o['createUser'])) $this->createUser = $o['createUser'];
        if (isset($o['createUserId'])) $this->createUserId = $o['createUserId'];
        if (isset($o['createUserEmail'])) $this->createUserEmail = $o['createUserEmail'];
        if (isset($o['modified'])) $this->modified = JsonConverters::from('DateTime', $o['modified']);
        if (isset($o['modifyUser'])) $this->modifyUser = $o['modifyUser'];
        if (isset($o['modifyUserId'])) $this->modifyUserId = $o['modifyUserId'];
        if (isset($o['isDeleted'])) $this->isDeleted = $o['isDeleted'];
        if (isset($o['deleted'])) $this->deleted = JsonConverters::from('DateTime', $o['deleted']);
        if (isset($o['deleteUser'])) $this->deleteUser = $o['deleteUser'];
        if (isset($o['deleteUserId'])) $this->deleteUserId = $o['deleteUserId'];
        if (isset($o['sendNotifications'])) $this->sendNotifications = $o['sendNotifications'];
        if (isset($o['isRunning'])) $this->isRunning = $o['isRunning'];
        if (isset($o['needsAttention'])) $this->needsAttention = $o['needsAttention'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->tenantId)) $o['tenantId'] = $this->tenantId;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->objectType)) $o['objectType'] = JsonConverters::to('ObjectTypes', $this->objectType);
        if (isset($this->message)) $o['message'] = $this->message;
        if (isset($this->selfLink)) $o['selfLink'] = $this->selfLink;
        if (isset($this->configItemId)) $o['configItemId'] = $this->configItemId;
        if (isset($this->configItemType)) $o['configItemType'] = JsonConverters::to('ObjectTypes', $this->configItemType);
        if (isset($this->jobType)) $o['jobType'] = JsonConverters::to('JobTypes', $this->jobType);
        if (isset($this->state)) $o['state'] = JsonConverters::to('JobStates', $this->state);
        if (isset($this->startTime)) $o['startTime'] = JsonConverters::to('DateTime', $this->startTime);
        if (isset($this->endTime)) $o['endTime'] = JsonConverters::to('DateTime', $this->endTime);
        if (isset($this->duration)) $o['duration'] = $this->duration;
        if (isset($this->workflowId)) $o['workflowId'] = $this->workflowId;
        if (isset($this->schedulerId)) $o['schedulerId'] = $this->schedulerId;
        if (isset($this->progress)) $o['progress'] = $this->progress;
        if (isset($this->config)) $o['config'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','Object']), $this->config);
        if (isset($this->created)) $o['created'] = JsonConverters::to('DateTime', $this->created);
        if (isset($this->createUser)) $o['createUser'] = $this->createUser;
        if (isset($this->createUserId)) $o['createUserId'] = $this->createUserId;
        if (isset($this->createUserEmail)) $o['createUserEmail'] = $this->createUserEmail;
        if (isset($this->modified)) $o['modified'] = JsonConverters::to('DateTime', $this->modified);
        if (isset($this->modifyUser)) $o['modifyUser'] = $this->modifyUser;
        if (isset($this->modifyUserId)) $o['modifyUserId'] = $this->modifyUserId;
        if (isset($this->isDeleted)) $o['isDeleted'] = $this->isDeleted;
        if (isset($this->deleted)) $o['deleted'] = JsonConverters::to('DateTime', $this->deleted);
        if (isset($this->deleteUser)) $o['deleteUser'] = $this->deleteUser;
        if (isset($this->deleteUserId)) $o['deleteUserId'] = $this->deleteUserId;
        if (isset($this->sendNotifications)) $o['sendNotifications'] = $this->sendNotifications;
        if (isset($this->isRunning)) $o['isRunning'] = $this->isRunning;
        if (isset($this->needsAttention)) $o['needsAttention'] = $this->needsAttention;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Trigger the resource scan workflow */
// @Api(Description="Trigger the resource scan workflow")
// @ApiResponse(Description="Operation started", IsDefaultResponse=true, ResponseType="typeof(CoreService.ServiceModel.Dtos.Jobs.Responses.JobDto)", StatusCode=202)
class ScanDeploymentResources implements IActionRequest, IHasId, IHasTenantName, IPost, JsonSerializable
{
    public function __construct(
        /** @description The primary key of every config item */
        // @ApiMember(DataType="string", Description="The primary key of every config item", Format="guid", IsRequired=true, ParameterType="path")
        /** @var string */
        public string $id='',

        // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
        // @Validate(Validator="NotEmpty")
        /** @var string */
        public string $tenantName='',

        /** @description Inform users when the job has finished */
        // @ApiMember(DataType="bool", Description="Inform users when the job has finished", ParameterType="body")
        /** @var bool|null */
        public ?bool $sendNotifications=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['tenantName'])) $this->tenantName = $o['tenantName'];
        if (isset($o['sendNotifications'])) $this->sendNotifications = $o['sendNotifications'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->tenantName)) $o['tenantName'] = $this->tenantName;
        if (isset($this->sendNotifications)) $o['sendNotifications'] = $this->sendNotifications;
        return empty($o) ? new class(){} : $o;
    }
}

PHP ScanDeploymentResources 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/deployments/{Id}/scanresources HTTP/1.1 
Host: core.starburst.svc 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"id":"00000000-0000-0000-0000-000000000000","tenantName":"String","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}