Skip to main content

Model

Coming soon

In preparation. This page describes the target interface to gather your feedback; nothing is usable yet.

Generated APIs are in preparation: this manifest is not accepted by sng apply yet.

apiVersionapibuilder.stackngo.io/v1alpha1
kindModel
Applied bysng apply (upcoming)

What it is for​

A Model describes a data collection of the generated API: its name, its primary key, and its typed properties. The GeneratedAPI derives the storage and the operations from it.

Attaching to an API

A Model or a View is attached to its GeneratedAPI by spec.application, which carries the name of the GeneratedAPI of the same tenant (application: blog). Without spec.application, a resource is only picked by a GeneratedAPI that selects it by its labels (selector).

Minimal example​

apiVersion: apibuilder.stackngo.io/v1alpha1
kind: Model
metadata:
name: posts
spec:
application: blog
modelName: posts
properties:
id: {type: uuid}
title: {type: text}

Complete annotated example​

apiVersion: apibuilder.stackngo.io/v1alpha1
kind: Model
metadata:
name: posts
spec:
application: blog # name of the GeneratedAPI that uses this model
modelName: posts # model key in the generated API
primary: id # key property
properties: # required
id: {type: uuid}
title: {type: text}
tags: {type: array, itemsType: text}

Fields​

Model​

Model déclare un modèle de données de votre API générée.

ChampDescriptionDéfautValidation
apiVersion stringapibuilder.stackngo.io/v1alpha1
kind stringModel
metadata ObjectMetaSeul metadata.name est à renseigner (nom de la ressource dans votre tenant).
spec ModelSpec
status ModelStatus

ModelSpec​

ModelSpec décrit le modèle : son nom, sa clé primaire et ses propriétés.

ChampDescriptionDéfautValidation
application stringApplication est le nom de l'API générée (GeneratedAPI) du même tenant qui utilise ce modèle.MaxLength: 253
Optional: {}
modelName stringModelName est le nom du modèle, repris par les View. Vide : nom du manifeste.
primary stringPrimary est la propriété qui sert de clé primaire (facultatif).
properties object (keys:string, values:ModelProperty)Properties : propriétés du modèle, par nom, avec leur type (uuid, text, array…).

ModelStatus​

ModelStatus est l'état constaté par la plateforme.

ChampDescriptionDéfautValidation
observedGeneration integerObservedGeneration est la dernière version du manifeste prise en compte.

ModelProperty​

ModelProperty décrit une propriété du modèle.

ChampDescriptionDéfautValidation
type stringType est le type de la propriété (uuid, text, array…).
itemsType stringItemsType est le type des éléments quand type vaut array.

Status and conditions​

status.observedGeneration shows the last version taken into account. Merge errors appear on the GeneratedAPI (Synced, reason MergeFailed).

What happens when you apply​

Changing a Model regenerates the API it is attached to.

See also​