Model
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.
apiVersion | apibuilder.stackngo.io/v1alpha1 |
kind | Model |
| Applied by | sng 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.
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.
| Champ | Description | Défaut | Validation |
|---|---|---|---|
apiVersion string | apibuilder.stackngo.io/v1alpha1 | ||
kind string | Model | ||
metadata ObjectMeta | Seul 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.
| Champ | Description | Défaut | Validation |
|---|---|---|---|
application string | Application est le nom de l'API générée (GeneratedAPI) du même tenant qui utilise ce modèle. | MaxLength: 253 Optional: {} | |
modelName string | ModelName est le nom du modèle, repris par les View. Vide : nom du manifeste. | ||
primary string | Primary 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.
| Champ | Description | Défaut | Validation |
|---|---|---|---|
observedGeneration integer | ObservedGeneration est la dernière version du manifeste prise en compte. |
ModelProperty
ModelProperty décrit une propriété du modèle.
| Champ | Description | Défaut | Validation |
|---|---|---|---|
type string | Type est le type de la propriété (uuid, text, array…). | ||
itemsType string | ItemsType 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.