Blazor Diffusion

<back to all web services

UpdateArtifactReport

Artifacts
Requires Authentication
Required role:Admin
<?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};


// @DataContract
class AuditBase implements JsonSerializable
{
    public function __construct(
        // @DataMember(Order=1)
        /** @var DateTime */
        public DateTime $createdDate=new DateTime(),

        // @DataMember(Order=2)
        // @Required()
        /** @var string */
        public string $createdBy='',

        // @DataMember(Order=3)
        /** @var DateTime */
        public DateTime $modifiedDate=new DateTime(),

        // @DataMember(Order=4)
        // @Required()
        /** @var string */
        public string $modifiedBy='',

        // @DataMember(Order=5)
        /** @var DateTime|null */
        public ?DateTime $deletedDate=null,

        // @DataMember(Order=6)
        /** @var string|null */
        public ?string $deletedBy=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
        if (isset($o['createdBy'])) $this->createdBy = $o['createdBy'];
        if (isset($o['modifiedDate'])) $this->modifiedDate = JsonConverters::from('DateTime', $o['modifiedDate']);
        if (isset($o['modifiedBy'])) $this->modifiedBy = $o['modifiedBy'];
        if (isset($o['deletedDate'])) $this->deletedDate = JsonConverters::from('DateTime', $o['deletedDate']);
        if (isset($o['deletedBy'])) $this->deletedBy = $o['deletedBy'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
        if (isset($this->createdBy)) $o['createdBy'] = $this->createdBy;
        if (isset($this->modifiedDate)) $o['modifiedDate'] = JsonConverters::to('DateTime', $this->modifiedDate);
        if (isset($this->modifiedBy)) $o['modifiedBy'] = $this->modifiedBy;
        if (isset($this->deletedDate)) $o['deletedDate'] = JsonConverters::to('DateTime', $this->deletedDate);
        if (isset($this->deletedBy)) $o['deletedBy'] = $this->deletedBy;
        return empty($o) ? new class(){} : $o;
    }
}

class Artifact extends AuditBase implements JsonSerializable
{
    /**
     * @param DateTime $createdDate
     * @param string $createdBy
     * @param DateTime $modifiedDate
     * @param string $modifiedBy
     * @param DateTime|null $deletedDate
     * @param string|null $deletedBy
     */
    public function __construct(
        DateTime $createdDate=new DateTime(),
        string $createdBy='',
        DateTime $modifiedDate=new DateTime(),
        string $modifiedBy='',
        ?DateTime $deletedDate=null,
        ?string $deletedBy=null,
        /** @var int */
        public int $id=0,
        // @References("typeof(BlazorDiffusion.ServiceModel.Creative)")
        /** @var int */
        public int $creativeId=0,

        /** @var string */
        public string $fileName='',
        /** @var string */
        public string $filePath='',
        /** @var string */
        public string $contentType='',
        /** @var int */
        public int $contentLength=0,
        /** @var int */
        public int $width=0,
        /** @var int */
        public int $height=0,
        /** @var int */
        public int $seed=0,
        /** @var string */
        public string $prompt='',
        /** @var bool|null */
        public ?bool $nsfw=null,
        /** @var int|null */
        public ?int $averageHash=null,
        /** @var int|null */
        public ?int $perceptualHash=null,
        /** @var int|null */
        public ?int $differenceHash=null,
        /** @var string|null */
        public ?string $background=null,
        /** @var string|null */
        public ?string $lqip=null,
        /** @var int */
        public int $quality=0,
        /** @var int */
        public int $likesCount=0,
        /** @var int */
        public int $albumsCount=0,
        /** @var int */
        public int $downloadsCount=0,
        /** @var int */
        public int $searchCount=0,
        /** @var int */
        public int $temporalScore=0,
        /** @var int */
        public int $score=0,
        /** @var int */
        public int $rank=0,
        /** @var string */
        public string $refId='',
        /** @var array<string,string>|null */
        public ?array $versions=null
    ) {
        parent::__construct($createdDate,$createdBy,$modifiedDate,$modifiedBy,$deletedDate,$deletedBy);
    }

    /** @throws Exception */
    public function fromMap($o): void {
        parent::fromMap($o);
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['creativeId'])) $this->creativeId = $o['creativeId'];
        if (isset($o['fileName'])) $this->fileName = $o['fileName'];
        if (isset($o['filePath'])) $this->filePath = $o['filePath'];
        if (isset($o['contentType'])) $this->contentType = $o['contentType'];
        if (isset($o['contentLength'])) $this->contentLength = $o['contentLength'];
        if (isset($o['width'])) $this->width = $o['width'];
        if (isset($o['height'])) $this->height = $o['height'];
        if (isset($o['seed'])) $this->seed = $o['seed'];
        if (isset($o['prompt'])) $this->prompt = $o['prompt'];
        if (isset($o['nsfw'])) $this->nsfw = $o['nsfw'];
        if (isset($o['averageHash'])) $this->averageHash = $o['averageHash'];
        if (isset($o['perceptualHash'])) $this->perceptualHash = $o['perceptualHash'];
        if (isset($o['differenceHash'])) $this->differenceHash = $o['differenceHash'];
        if (isset($o['background'])) $this->background = $o['background'];
        if (isset($o['lqip'])) $this->lqip = $o['lqip'];
        if (isset($o['quality'])) $this->quality = $o['quality'];
        if (isset($o['likesCount'])) $this->likesCount = $o['likesCount'];
        if (isset($o['albumsCount'])) $this->albumsCount = $o['albumsCount'];
        if (isset($o['downloadsCount'])) $this->downloadsCount = $o['downloadsCount'];
        if (isset($o['searchCount'])) $this->searchCount = $o['searchCount'];
        if (isset($o['temporalScore'])) $this->temporalScore = $o['temporalScore'];
        if (isset($o['score'])) $this->score = $o['score'];
        if (isset($o['rank'])) $this->rank = $o['rank'];
        if (isset($o['refId'])) $this->refId = $o['refId'];
        if (isset($o['versions'])) $this->versions = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['versions']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = parent::jsonSerialize();
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->creativeId)) $o['creativeId'] = $this->creativeId;
        if (isset($this->fileName)) $o['fileName'] = $this->fileName;
        if (isset($this->filePath)) $o['filePath'] = $this->filePath;
        if (isset($this->contentType)) $o['contentType'] = $this->contentType;
        if (isset($this->contentLength)) $o['contentLength'] = $this->contentLength;
        if (isset($this->width)) $o['width'] = $this->width;
        if (isset($this->height)) $o['height'] = $this->height;
        if (isset($this->seed)) $o['seed'] = $this->seed;
        if (isset($this->prompt)) $o['prompt'] = $this->prompt;
        if (isset($this->nsfw)) $o['nsfw'] = $this->nsfw;
        if (isset($this->averageHash)) $o['averageHash'] = $this->averageHash;
        if (isset($this->perceptualHash)) $o['perceptualHash'] = $this->perceptualHash;
        if (isset($this->differenceHash)) $o['differenceHash'] = $this->differenceHash;
        if (isset($this->background)) $o['background'] = $this->background;
        if (isset($this->lqip)) $o['lqip'] = $this->lqip;
        if (isset($this->quality)) $o['quality'] = $this->quality;
        if (isset($this->likesCount)) $o['likesCount'] = $this->likesCount;
        if (isset($this->albumsCount)) $o['albumsCount'] = $this->albumsCount;
        if (isset($this->downloadsCount)) $o['downloadsCount'] = $this->downloadsCount;
        if (isset($this->searchCount)) $o['searchCount'] = $this->searchCount;
        if (isset($this->temporalScore)) $o['temporalScore'] = $this->temporalScore;
        if (isset($this->score)) $o['score'] = $this->score;
        if (isset($this->rank)) $o['rank'] = $this->rank;
        if (isset($this->refId)) $o['refId'] = $this->refId;
        if (isset($this->versions)) $o['versions'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->versions);
        return empty($o) ? new class(){} : $o;
    }
}

enum ReportType : string
{
    case Nsfw = 'Nsfw';
    case Malformed = 'Malformed';
    case Blurred = 'Blurred';
    case LowQuality = 'LowQuality';
    case Other = 'Other';
}

class ArtifactReport implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $id=0,
        // @References("typeof(BlazorDiffusion.ServiceModel.Artifact)")
        /** @var int */
        public int $artifactId=0,

        /** @var int */
        public int $appUserId=0,
        /** @var Artifact|null */
        public ?Artifact $artifact=null,
        /** @var ReportType|null */
        public ?ReportType $type=null,
        /** @var string|null */
        public ?string $description=null,
        /** @var DateTime */
        public DateTime $createdDate=new DateTime(),
        /** @var string|null */
        public ?string $notes=null,
        /** @var DateTime|null */
        public ?DateTime $actionedDate=null,
        /** @var string|null */
        public ?string $actionedBy=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['artifactId'])) $this->artifactId = $o['artifactId'];
        if (isset($o['appUserId'])) $this->appUserId = $o['appUserId'];
        if (isset($o['artifact'])) $this->artifact = JsonConverters::from('Artifact', $o['artifact']);
        if (isset($o['type'])) $this->type = JsonConverters::from('ReportType', $o['type']);
        if (isset($o['description'])) $this->description = $o['description'];
        if (isset($o['createdDate'])) $this->createdDate = JsonConverters::from('DateTime', $o['createdDate']);
        if (isset($o['notes'])) $this->notes = $o['notes'];
        if (isset($o['actionedDate'])) $this->actionedDate = JsonConverters::from('DateTime', $o['actionedDate']);
        if (isset($o['actionedBy'])) $this->actionedBy = $o['actionedBy'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->artifactId)) $o['artifactId'] = $this->artifactId;
        if (isset($this->appUserId)) $o['appUserId'] = $this->appUserId;
        if (isset($this->artifact)) $o['artifact'] = JsonConverters::to('Artifact', $this->artifact);
        if (isset($this->type)) $o['type'] = JsonConverters::to('ReportType', $this->type);
        if (isset($this->description)) $o['description'] = $this->description;
        if (isset($this->createdDate)) $o['createdDate'] = JsonConverters::to('DateTime', $this->createdDate);
        if (isset($this->notes)) $o['notes'] = $this->notes;
        if (isset($this->actionedDate)) $o['actionedDate'] = JsonConverters::to('DateTime', $this->actionedDate);
        if (isset($this->actionedBy)) $o['actionedBy'] = $this->actionedBy;
        return empty($o) ? new class(){} : $o;
    }
}

// @ValidateRequest(Validator="IsAdmin")
/**
 * @template IPatchDb of ArtifactReport
 */
class UpdateArtifactReport implements IPatchDb, JsonSerializable
{
    public function __construct(
        // @Validate(Validator="GreaterThan(0)")
        /** @var int */
        public int $artifactId=0,

        /** @var ReportType|null */
        public ?ReportType $type=null,
        /** @var string|null */
        public ?string $description=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['artifactId'])) $this->artifactId = $o['artifactId'];
        if (isset($o['type'])) $this->type = JsonConverters::from('ReportType', $o['type']);
        if (isset($o['description'])) $this->description = $o['description'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->artifactId)) $o['artifactId'] = $this->artifactId;
        if (isset($this->type)) $o['type'] = JsonConverters::to('ReportType', $this->type);
        if (isset($this->description)) $o['description'] = $this->description;
        return empty($o) ? new class(){} : $o;
    }
}

PHP UpdateArtifactReport DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /xml/reply/UpdateArtifactReport HTTP/1.1 
Host: blazordiffusion.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<UpdateArtifactReport xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BlazorDiffusion.ServiceModel">
  <ArtifactId>0</ArtifactId>
  <Description>String</Description>
  <Type>Nsfw</Type>
</UpdateArtifactReport>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<ArtifactReport xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BlazorDiffusion.ServiceModel">
  <ActionedBy>String</ActionedBy>
  <ActionedDate>0001-01-01T00:00:00</ActionedDate>
  <AppUserId>0</AppUserId>
  <Artifact>
    <CreatedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</CreatedDate>
    <CreatedBy xmlns="http://schemas.servicestack.net/types">String</CreatedBy>
    <ModifiedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</ModifiedDate>
    <ModifiedBy xmlns="http://schemas.servicestack.net/types">String</ModifiedBy>
    <DeletedDate xmlns="http://schemas.servicestack.net/types">0001-01-01T00:00:00</DeletedDate>
    <DeletedBy xmlns="http://schemas.servicestack.net/types">String</DeletedBy>
    <AlbumsCount>0</AlbumsCount>
    <AverageHash>0</AverageHash>
    <Background>String</Background>
    <ContentLength>0</ContentLength>
    <ContentType>String</ContentType>
    <CreativeId>0</CreativeId>
    <DifferenceHash>0</DifferenceHash>
    <DownloadsCount>0</DownloadsCount>
    <FileName>String</FileName>
    <FilePath>String</FilePath>
    <Height>0</Height>
    <Id>0</Id>
    <LikesCount>0</LikesCount>
    <Lqip>String</Lqip>
    <Nsfw>false</Nsfw>
    <PerceptualHash>0</PerceptualHash>
    <Prompt>String</Prompt>
    <Quality>0</Quality>
    <Rank>0</Rank>
    <RefId>String</RefId>
    <Score>0</Score>
    <SearchCount>0</SearchCount>
    <Seed>0</Seed>
    <TemporalScore>0</TemporalScore>
    <Versions xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Versions>
    <Width>0</Width>
  </Artifact>
  <ArtifactId>0</ArtifactId>
  <CreatedDate>0001-01-01T00:00:00</CreatedDate>
  <Description>String</Description>
  <Id>0</Id>
  <Notes>String</Notes>
  <Type>Nsfw</Type>
</ArtifactReport>