Blazor Diffusion

<back to all web services

QueryApiProviders

import 'package:servicestack/servicestack.dart';

// @DataContract
abstract class QueryBase
{
    // @DataMember(Order=1)
    int? skip;

    // @DataMember(Order=2)
    int? take;

    // @DataMember(Order=3)
    String? orderBy;

    // @DataMember(Order=4)
    String? orderByDesc;

    // @DataMember(Order=5)
    String? include;

    // @DataMember(Order=6)
    String? fields;

    // @DataMember(Order=7)
    Map<String,String?>? meta;

    QueryBase({this.skip,this.take,this.orderBy,this.orderByDesc,this.include,this.fields,this.meta});
    QueryBase.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        skip = json['skip'];
        take = json['take'];
        orderBy = json['orderBy'];
        orderByDesc = json['orderByDesc'];
        include = json['include'];
        fields = json['fields'];
        meta = JsonConverters.toStringMap(json['meta']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'skip': skip,
        'take': take,
        'orderBy': orderBy,
        'orderByDesc': orderByDesc,
        'include': include,
        'fields': fields,
        'meta': meta
    };

    getTypeName() => "QueryBase";
    TypeContext? context = _ctx;
}

abstract class QueryDb<T> extends QueryBase
{
    QueryDb();
    QueryDb.fromJson(Map<String, dynamic> json) : super.fromJson(json);
    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson();
    getTypeName() => "QueryDb<$T>";
    TypeContext? context = _ctx;
}

class ApiProviderModel implements IConvertible
{
    String? model;
    String? apiModel;

    ApiProviderModel({this.model,this.apiModel});
    ApiProviderModel.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        model = json['model'];
        apiModel = json['apiModel'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'model': model,
        'apiModel': apiModel
    };

    getTypeName() => "ApiProviderModel";
    TypeContext? context = _ctx;
}

enum AiProvider
{
    OpenAiProvider,
    GoogleAiProvider,
}

class ApiType implements IConvertible
{
    int? id;
    AiProvider? provider;
    String? name;
    String? website;
    String? apiBaseUrl;
    String? heartbeatUrl;
    String? icon;
    Map<String,String?>? apiModels = {};

    ApiType({this.id,this.provider,this.name,this.website,this.apiBaseUrl,this.heartbeatUrl,this.icon,this.apiModels});
    ApiType.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        provider = JsonConverters.fromJson(json['provider'],'AiProvider',context!);
        name = json['name'];
        website = json['website'];
        apiBaseUrl = json['apiBaseUrl'];
        heartbeatUrl = json['heartbeatUrl'];
        icon = json['icon'];
        apiModels = JsonConverters.toStringMap(json['apiModels']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'provider': JsonConverters.toJson(provider,'AiProvider',context!),
        'name': name,
        'website': website,
        'apiBaseUrl': apiBaseUrl,
        'heartbeatUrl': heartbeatUrl,
        'icon': icon,
        'apiModels': apiModels
    };

    getTypeName() => "ApiType";
    TypeContext? context = _ctx;
}

class ApiProvider implements IConvertible
{
    int? id;
    String? name;
    String? apiBaseUrl;
    int? apiTypeId;
    String? apiKeyVar;
    String? apiKey;
    String? apiKeyHeader;
    String? heartbeatUrl;
    int? concurrency;
    int? priority;
    bool? enabled;
    DateTime? offlineDate;
    DateTime? createdDate;
    List<ApiProviderModel>? models = [];
    ApiType? apiType;
    // @ignore()
    List<String>? selectedModels = [];

    ApiProvider({this.id,this.name,this.apiBaseUrl,this.apiTypeId,this.apiKeyVar,this.apiKey,this.apiKeyHeader,this.heartbeatUrl,this.concurrency,this.priority,this.enabled,this.offlineDate,this.createdDate,this.models,this.apiType,this.selectedModels});
    ApiProvider.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        id = json['id'];
        name = json['name'];
        apiBaseUrl = json['apiBaseUrl'];
        apiTypeId = json['apiTypeId'];
        apiKeyVar = json['apiKeyVar'];
        apiKey = json['apiKey'];
        apiKeyHeader = json['apiKeyHeader'];
        heartbeatUrl = json['heartbeatUrl'];
        concurrency = json['concurrency'];
        priority = json['priority'];
        enabled = json['enabled'];
        offlineDate = JsonConverters.fromJson(json['offlineDate'],'DateTime',context!);
        createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
        models = JsonConverters.fromJson(json['models'],'List<ApiProviderModel>',context!);
        apiType = JsonConverters.fromJson(json['apiType'],'ApiType',context!);
        selectedModels = JsonConverters.fromJson(json['selectedModels'],'List<String>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'id': id,
        'name': name,
        'apiBaseUrl': apiBaseUrl,
        'apiTypeId': apiTypeId,
        'apiKeyVar': apiKeyVar,
        'apiKey': apiKey,
        'apiKeyHeader': apiKeyHeader,
        'heartbeatUrl': heartbeatUrl,
        'concurrency': concurrency,
        'priority': priority,
        'enabled': enabled,
        'offlineDate': JsonConverters.toJson(offlineDate,'DateTime',context!),
        'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
        'models': JsonConverters.toJson(models,'List<ApiProviderModel>',context!),
        'apiType': JsonConverters.toJson(apiType,'ApiType',context!),
        'selectedModels': JsonConverters.toJson(selectedModels,'List<String>',context!)
    };

    getTypeName() => "ApiProvider";
    TypeContext? context = _ctx;
}

class QueryApiProviders extends QueryDb<ApiProvider> implements IConvertible
{
    String? name;

    QueryApiProviders({this.name});
    QueryApiProviders.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        name = json['name'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'name': name
    });

    getTypeName() => "QueryApiProviders";
    TypeContext? context = _ctx;
}

// @DataContract
abstract class AuditBase
{
    // @DataMember(Order=1)
    DateTime? createdDate;

    // @DataMember(Order=2)
    // @required()
    String? createdBy;

    // @DataMember(Order=3)
    DateTime? modifiedDate;

    // @DataMember(Order=4)
    // @required()
    String? modifiedBy;

    // @DataMember(Order=5)
    DateTime? deletedDate;

    // @DataMember(Order=6)
    String? deletedBy;

    AuditBase({this.createdDate,this.createdBy,this.modifiedDate,this.modifiedBy,this.deletedDate,this.deletedBy});
    AuditBase.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
        createdBy = json['createdBy'];
        modifiedDate = JsonConverters.fromJson(json['modifiedDate'],'DateTime',context!);
        modifiedBy = json['modifiedBy'];
        deletedDate = JsonConverters.fromJson(json['deletedDate'],'DateTime',context!);
        deletedBy = json['deletedBy'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
        'createdBy': createdBy,
        'modifiedDate': JsonConverters.toJson(modifiedDate,'DateTime',context!),
        'modifiedBy': modifiedBy,
        'deletedDate': JsonConverters.toJson(deletedDate,'DateTime',context!),
        'deletedBy': deletedBy
    };

    getTypeName() => "AuditBase";
    TypeContext? context = _ctx;
}

class Artifact extends AuditBase implements IConvertible
{
    int? id;
    // @References(typeof(Creative))
    int? creativeId;

    String? fileName;
    String? filePath;
    String? contentType;
    int? contentLength;
    int? width;
    int? height;
    int? seed;
    String? prompt;
    bool? nsfw;
    int? averageHash;
    int? perceptualHash;
    int? differenceHash;
    String? background;
    String? lqip;
    int? quality;
    int? likesCount;
    int? albumsCount;
    int? downloadsCount;
    int? searchCount;
    int? temporalScore;
    int? score;
    int? rank;
    String? refId;
    Map<String,String?>? versions = {};

    Artifact({this.id,this.creativeId,this.fileName,this.filePath,this.contentType,this.contentLength,this.width,this.height,this.seed,this.prompt,this.nsfw,this.averageHash,this.perceptualHash,this.differenceHash,this.background,this.lqip,this.quality,this.likesCount,this.albumsCount,this.downloadsCount,this.searchCount,this.temporalScore,this.score,this.rank,this.refId,this.versions});
    Artifact.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        id = json['id'];
        creativeId = json['creativeId'];
        fileName = json['fileName'];
        filePath = json['filePath'];
        contentType = json['contentType'];
        contentLength = json['contentLength'];
        width = json['width'];
        height = json['height'];
        seed = json['seed'];
        prompt = json['prompt'];
        nsfw = json['nsfw'];
        averageHash = json['averageHash'];
        perceptualHash = json['perceptualHash'];
        differenceHash = json['differenceHash'];
        background = json['background'];
        lqip = json['lqip'];
        quality = json['quality'];
        likesCount = json['likesCount'];
        albumsCount = json['albumsCount'];
        downloadsCount = json['downloadsCount'];
        searchCount = json['searchCount'];
        temporalScore = json['temporalScore'];
        score = json['score'];
        rank = json['rank'];
        refId = json['refId'];
        versions = JsonConverters.toStringMap(json['versions']);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'id': id,
        'creativeId': creativeId,
        'fileName': fileName,
        'filePath': filePath,
        'contentType': contentType,
        'contentLength': contentLength,
        'width': width,
        'height': height,
        'seed': seed,
        'prompt': prompt,
        'nsfw': nsfw,
        'averageHash': averageHash,
        'perceptualHash': perceptualHash,
        'differenceHash': differenceHash,
        'background': background,
        'lqip': lqip,
        'quality': quality,
        'likesCount': likesCount,
        'albumsCount': albumsCount,
        'downloadsCount': downloadsCount,
        'searchCount': searchCount,
        'temporalScore': temporalScore,
        'score': score,
        'rank': rank,
        'refId': refId,
        'versions': versions
    });

    getTypeName() => "Artifact";
    TypeContext? context = _ctx;
}

class ArtifactResult extends Artifact implements IConvertible
{
    String? userPrompt;
    List<String>? artistNames = [];
    List<String>? modifierNames = [];
    int? primaryArtifactId;
    String? ownerRef;
    double? similarity;

    ArtifactResult({this.userPrompt,this.artistNames,this.modifierNames,this.primaryArtifactId,this.ownerRef,this.similarity});
    ArtifactResult.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        userPrompt = json['userPrompt'];
        artistNames = JsonConverters.fromJson(json['artistNames'],'List<String>',context!);
        modifierNames = JsonConverters.fromJson(json['modifierNames'],'List<String>',context!);
        primaryArtifactId = json['primaryArtifactId'];
        ownerRef = json['ownerRef'];
        similarity = JsonConverters.toDouble(json['similarity']);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'userPrompt': userPrompt,
        'artistNames': JsonConverters.toJson(artistNames,'List<String>',context!),
        'modifierNames': JsonConverters.toJson(modifierNames,'List<String>',context!),
        'primaryArtifactId': primaryArtifactId,
        'ownerRef': ownerRef,
        'similarity': similarity
    });

    getTypeName() => "ArtifactResult";
    TypeContext? context = _ctx;
}

// @DataContract
class QueryResponse<T> implements IConvertible
{
    // @DataMember(Order=1)
    int? offset;

    // @DataMember(Order=2)
    int? total;

    // @DataMember(Order=3)
    List<ArtifactResult>? results;

    // @DataMember(Order=4)
    Map<String,String?>? meta;

    // @DataMember(Order=5)
    ResponseStatus? responseStatus;

    QueryResponse({this.offset,this.total,this.results,this.meta,this.responseStatus});
    QueryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        offset = json['offset'];
        total = json['total'];
        results = JsonConverters.fromJson(json['results'],'List<ArtifactResult>',context!);
        meta = JsonConverters.toStringMap(json['meta']);
        responseStatus = JsonConverters.fromJson(json['responseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'offset': offset,
        'total': total,
        'results': JsonConverters.toJson(results,'List<ArtifactResult>',context!),
        'meta': meta,
        'responseStatus': JsonConverters.toJson(responseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "QueryResponse<$T>";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'blazordiffusion.com', types: <String, TypeInfo> {
    'ApiProviderModel': TypeInfo(TypeOf.Class, create:() => ApiProviderModel()),
    'AiProvider': TypeInfo(TypeOf.Enum, enumValues:AiProvider.values),
    'ApiType': TypeInfo(TypeOf.Class, create:() => ApiType()),
    'ApiProvider': TypeInfo(TypeOf.Class, create:() => ApiProvider()),
    'List<ApiProviderModel>': TypeInfo(TypeOf.Class, create:() => <ApiProviderModel>[]),
    'QueryApiProviders': TypeInfo(TypeOf.Class, create:() => QueryApiProviders()),
    'List<ApiProvider>': TypeInfo(TypeOf.Class, create:() => <ApiProvider>[]),
    'Artifact': TypeInfo(TypeOf.Class, create:() => Artifact()),
    'ArtifactResult': TypeInfo(TypeOf.Class, create:() => ArtifactResult()),
    'List<ArtifactResult>': TypeInfo(TypeOf.Class, create:() => <ArtifactResult>[]),
});

Dart QueryApiProviders 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 /json/reply/QueryApiProviders HTTP/1.1 
Host: blazordiffusion.com 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"name":"String","skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"offset":0,"total":0,"results":[{"id":0,"name":"String","apiBaseUrl":"String","apiTypeId":0,"apiKeyVar":"String","apiKey":"String","apiKeyHeader":"String","heartbeatUrl":"String","concurrency":0,"priority":0,"enabled":false,"offlineDate":"0001-01-01T00:00:00","createdDate":"0001-01-01T00:00:00","models":[{"model":"String","apiModel":"String"}],"apiType":{"id":0,"provider":"OpenAiProvider","name":"String","website":"String","apiBaseUrl":"String","heartbeatUrl":"String","icon":"String","apiModels":{"String":"String"}},"selectedModels":["String"]}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}