GET | /status |
---|
<?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 HealthStatus : string
{
case Unhealthy = 'Unhealthy';
case Degraded = 'Degraded';
case Healthy = 'Healthy';
}
class HealthCheckReportEntry implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Key=null,
/** @var string|null */
public ?string $Description=null,
/** @var DateInterval|null */
public ?DateInterval $Duration=null,
/** @var HealthStatus|null */
public ?HealthStatus $Status=null,
/** @var string|null */
public ?string $Error=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Key'])) $this->Key = $o['Key'];
if (isset($o['Description'])) $this->Description = $o['Description'];
if (isset($o['Duration'])) $this->Duration = JsonConverters::from('DateInterval', $o['Duration']);
if (isset($o['Status'])) $this->Status = JsonConverters::from('HealthStatus', $o['Status']);
if (isset($o['Error'])) $this->Error = $o['Error'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Key)) $o['Key'] = $this->Key;
if (isset($this->Description)) $o['Description'] = $this->Description;
if (isset($this->Duration)) $o['Duration'] = JsonConverters::to('DateInterval', $this->Duration);
if (isset($this->Status)) $o['Status'] = JsonConverters::to('HealthStatus', $this->Status);
if (isset($this->Error)) $o['Error'] = $this->Error;
return empty($o) ? new class(){} : $o;
}
}
class HealthCheckReport implements JsonSerializable
{
public function __construct(
/** @var HealthStatus|null */
public ?HealthStatus $Status=null,
/** @var DateInterval|null */
public ?DateInterval $Duration=null,
/** @var string */
public string $Version='',
/** @var string|null */
public ?string $BuildDate=null,
/** @var array<HealthCheckReportEntry>|null */
public ?array $Entries=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Status'])) $this->Status = JsonConverters::from('HealthStatus', $o['Status']);
if (isset($o['Duration'])) $this->Duration = JsonConverters::from('DateInterval', $o['Duration']);
if (isset($o['Version'])) $this->Version = $o['Version'];
if (isset($o['BuildDate'])) $this->BuildDate = $o['BuildDate'];
if (isset($o['Entries'])) $this->Entries = JsonConverters::fromArray('HealthCheckReportEntry', $o['Entries']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Status)) $o['Status'] = JsonConverters::to('HealthStatus', $this->Status);
if (isset($this->Duration)) $o['Duration'] = JsonConverters::to('DateInterval', $this->Duration);
if (isset($this->Version)) $o['Version'] = $this->Version;
if (isset($this->BuildDate)) $o['BuildDate'] = $this->BuildDate;
if (isset($this->Entries)) $o['Entries'] = JsonConverters::toArray('HealthCheckReportEntry', $this->Entries);
return empty($o) ? new class(){} : $o;
}
}
class HealthResponse implements JsonSerializable
{
public function __construct(
/** @var HealthCheckReport|null */
public ?HealthCheckReport $Result=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Result'])) $this->Result = JsonConverters::from('HealthCheckReport', $o['Result']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Result)) $o['Result'] = JsonConverters::to('HealthCheckReport', $this->Result);
return empty($o) ? new class(){} : $o;
}
}
class HealthRequest implements IGet, JsonSerializable
{
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
return empty($o) ? new class(){} : $o;
}
}
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
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /status HTTP/1.1 Host: prod-api-auth-mb-dhc.rapp-customers.co.uk Accept: application/json
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"Result":{"Status":"Unhealthy","Duration":"PT0S","Version":"String","BuildDate":"String"}}