GET | /RestApi/sitefinity/scheduling/scheduled-tasks |
---|
<?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 OrderByType : string
{
case ScheduledFor = 'ScheduledFor';
case LastExecutionDate = 'LastExecutionDate';
case Status = 'Status';
case NameAsc = 'NameAsc';
case NameDesc = 'NameDesc';
}
enum FilterByType : string
{
case All = 'All';
case Pending = 'Pending';
case Started = 'Started';
case Stopped = 'Stopped';
case Failed = 'Failed';
case Recurring = 'Recurring';
}
class GetScheduledTasks implements JsonSerializable
{
public function __construct(
/** @var int */
public int $Skip=0,
/** @var int */
public int $Take=0,
/** @var string|null */
public ?string $SearchTerm=null,
/** @var OrderByType|null */
public ?OrderByType $OrderBy=null,
/** @var FilterByType|null */
public ?FilterByType $FilterBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Skip'])) $this->Skip = $o['Skip'];
if (isset($o['Take'])) $this->Take = $o['Take'];
if (isset($o['SearchTerm'])) $this->SearchTerm = $o['SearchTerm'];
if (isset($o['OrderBy'])) $this->OrderBy = JsonConverters::from('OrderByType', $o['OrderBy']);
if (isset($o['FilterBy'])) $this->FilterBy = JsonConverters::from('FilterByType', $o['FilterBy']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Skip)) $o['Skip'] = $this->Skip;
if (isset($this->Take)) $o['Take'] = $this->Take;
if (isset($this->SearchTerm)) $o['SearchTerm'] = $this->SearchTerm;
if (isset($this->OrderBy)) $o['OrderBy'] = JsonConverters::to('OrderByType', $this->OrderBy);
if (isset($this->FilterBy)) $o['FilterBy'] = JsonConverters::to('FilterByType', $this->FilterBy);
return empty($o) ? new class(){} : $o;
}
}
class ScheduledTaskViewModel implements JsonSerializable
{
public function __construct(
/** @var string */
public string $TaskId='',
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Title=null,
/** @var string|null */
public ?string $Status=null,
/** @var string|null */
public ?string $ErrorMessage=null,
/** @var string|null */
public ?string $RecurringInterval=null,
/** @var DateTime */
public DateTime $ScheduledForDate=new DateTime(),
/** @var DateTime|null */
public ?DateTime $LastExecutionTime=null,
/** @var string|null */
public ?string $Hash=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['TaskId'])) $this->TaskId = $o['TaskId'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Title'])) $this->Title = $o['Title'];
if (isset($o['Status'])) $this->Status = $o['Status'];
if (isset($o['ErrorMessage'])) $this->ErrorMessage = $o['ErrorMessage'];
if (isset($o['RecurringInterval'])) $this->RecurringInterval = $o['RecurringInterval'];
if (isset($o['ScheduledForDate'])) $this->ScheduledForDate = JsonConverters::from('DateTime', $o['ScheduledForDate']);
if (isset($o['LastExecutionTime'])) $this->LastExecutionTime = JsonConverters::from('DateTime', $o['LastExecutionTime']);
if (isset($o['Hash'])) $this->Hash = $o['Hash'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->TaskId)) $o['TaskId'] = $this->TaskId;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Title)) $o['Title'] = $this->Title;
if (isset($this->Status)) $o['Status'] = $this->Status;
if (isset($this->ErrorMessage)) $o['ErrorMessage'] = $this->ErrorMessage;
if (isset($this->RecurringInterval)) $o['RecurringInterval'] = $this->RecurringInterval;
if (isset($this->ScheduledForDate)) $o['ScheduledForDate'] = JsonConverters::to('DateTime', $this->ScheduledForDate);
if (isset($this->LastExecutionTime)) $o['LastExecutionTime'] = JsonConverters::to('DateTime', $this->LastExecutionTime);
if (isset($this->Hash)) $o['Hash'] = $this->Hash;
return empty($o) ? new class(){} : $o;
}
}
class GetScheduledTasksResponse implements JsonSerializable
{
public function __construct(
/** @var array<ScheduledTaskViewModel>|null */
public ?array $Items=null,
/** @var int */
public int $TotalCount=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Items'])) $this->Items = JsonConverters::fromArray('ScheduledTaskViewModel', $o['Items']);
if (isset($o['TotalCount'])) $this->TotalCount = $o['TotalCount'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Items)) $o['Items'] = JsonConverters::toArray('ScheduledTaskViewModel', $this->Items);
if (isset($this->TotalCount)) $o['TotalCount'] = $this->TotalCount;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /RestApi/sitefinity/scheduling/scheduled-tasks HTTP/1.1 Host: www.asg.com.au Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { TotalCount: 0 }