CoreService

<back to all web services

CreatePatchingWindow

Patching - CRUD

Create a new patching window

Requires Authentication
Requires any of the roles:TenantReader, Admin, TenantAdmin
The following routes are available for this service:
POST/api/patching/windowsCreates a new patching window
POST/patching/windowsCreates a new patching window
<?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 MonthlyDayOccurence : int
{
    case First = 1;
    case Second = 2;
    case Third = 3;
    case Fourth = 4;
}

class PatchingWindowDto implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $id='',
        /** @var string */
        public string $name='',
        /** @var DayOfWeek|null */
        public ?DayOfWeek $dayOfWeek=null,
        /** @var MonthlyDayOccurence|null */
        public ?MonthlyDayOccurence $monthlyOccurence=null,
        /** @var DateInterval|null */
        public ?DateInterval $timeOfDay=null,
        /** @var DateInterval|null */
        public ?DateInterval $duration=null,
        /** @var bool|null */
        public ?bool $isDefault=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['dayOfWeek'])) $this->dayOfWeek = JsonConverters::from('DayOfWeek', $o['dayOfWeek']);
        if (isset($o['monthlyOccurence'])) $this->monthlyOccurence = JsonConverters::from('MonthlyDayOccurence', $o['monthlyOccurence']);
        if (isset($o['timeOfDay'])) $this->timeOfDay = JsonConverters::from('DateInterval', $o['timeOfDay']);
        if (isset($o['duration'])) $this->duration = JsonConverters::from('DateInterval', $o['duration']);
        if (isset($o['isDefault'])) $this->isDefault = $o['isDefault'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->dayOfWeek)) $o['dayOfWeek'] = JsonConverters::to('DayOfWeek', $this->dayOfWeek);
        if (isset($this->monthlyOccurence)) $o['monthlyOccurence'] = JsonConverters::to('MonthlyDayOccurence', $this->monthlyOccurence);
        if (isset($this->timeOfDay)) $o['timeOfDay'] = JsonConverters::to('DateInterval', $this->timeOfDay);
        if (isset($this->duration)) $o['duration'] = JsonConverters::to('DateInterval', $this->duration);
        if (isset($this->isDefault)) $o['isDefault'] = $this->isDefault;
        return empty($o) ? new class(){} : $o;
    }
}

/** @description Create a new patching window */
// @Api(Description="Create a new patching window")
// @ApiResponse(Description="Success", IsDefaultResponse=true, ResponseType="typeof(CoreService.ServiceModel.Dtos.Patching.Responses.PatchingWindowDto)", StatusCode=201)
class CreatePatchingWindow implements IBaseRequest, IPost, IHasTenantName, JsonSerializable
{
    public function __construct(
        // @ApiMember(DataType="string", IsRequired=true, ParameterType="header")
        // @Validate(Validator="NotEmpty")
        /** @var string */
        public string $tenantName='',

        /** @description Occurence of week day in the month */
        // @ApiMember(Description="Occurence of week day in the month", IsRequired=true)
        /** @var MonthlyDayOccurence|null */
        public ?MonthlyDayOccurence $monthlyOccurence=null,

        /** @description The day of the week, when patching will happen */
        // @ApiMember(Description="The day of the week, when patching will happen", IsRequired=true)
        /** @var DayOfWeek|null */
        public ?DayOfWeek $dayOfWeek=null,

        /** @description The time, when the patching window will start */
        // @ApiMember(DataType="string", Description="The time, when the patching window will start", Format="time", IsRequired=true, ParameterType="body")
        /** @var DateInterval|null */
        public ?DateInterval $timeOfDay=null,

        /** @description The max duration (hours) of the window wherein patchings can be started */
        // @ApiMember(DataType="string", Description="The max duration (hours) of the window wherein patchings can be started", Format="time", ParameterType="body")
        /** @var DateInterval|null */
        public ?DateInterval $duration=null,

        /** @description It's the default patching window for new resource groups */
        // @ApiMember(DataType="boolean", Description="It's the default patching window for new resource groups", ParameterType="body")
        /** @var bool|null */
        public ?bool $isDefault=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['tenantName'])) $this->tenantName = $o['tenantName'];
        if (isset($o['monthlyOccurence'])) $this->monthlyOccurence = JsonConverters::from('MonthlyDayOccurence', $o['monthlyOccurence']);
        if (isset($o['dayOfWeek'])) $this->dayOfWeek = JsonConverters::from('DayOfWeek', $o['dayOfWeek']);
        if (isset($o['timeOfDay'])) $this->timeOfDay = JsonConverters::from('DateInterval', $o['timeOfDay']);
        if (isset($o['duration'])) $this->duration = JsonConverters::from('TimeSpan', $o['duration']);
        if (isset($o['isDefault'])) $this->isDefault = $o['isDefault'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->tenantName)) $o['tenantName'] = $this->tenantName;
        if (isset($this->monthlyOccurence)) $o['monthlyOccurence'] = JsonConverters::to('MonthlyDayOccurence', $this->monthlyOccurence);
        if (isset($this->dayOfWeek)) $o['dayOfWeek'] = JsonConverters::to('DayOfWeek', $this->dayOfWeek);
        if (isset($this->timeOfDay)) $o['timeOfDay'] = JsonConverters::to('DateInterval', $this->timeOfDay);
        if (isset($this->duration)) $o['duration'] = JsonConverters::to('TimeSpan', $this->duration);
        if (isset($this->isDefault)) $o['isDefault'] = $this->isDefault;
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreatePatchingWindow 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/patching/windows HTTP/1.1 
Host: core.starburst.svc 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"tenantName":"String","monthlyOccurence":"First","dayOfWeek":"Sunday","timeOfDay":"00:00:00","duration":"00:00:00","isDefault":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","name":"String","dayOfWeek":"Sunday","monthlyOccurence":"First","timeOfDay":"00:00:00","duration":"00:00:00","isDefault":false}