Skip to content

UDT schema #1404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: edge
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1296,4 +1296,7 @@ DaprConfigurationStoreProperties
configurationStores
configurationstores
Oras
oras
oras
apiVersions
openAPI
zA
100 changes: 100 additions & 0 deletions docs/content/reference/resource-schema/udt/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
type: docs
title: "User Defined Resource Type Schema"
linkTitle: "User Defined Resource Type"
description: "Schema reference document for a User defined Resource Type"
categories: "Schema"
weight: 100
---

## Overview

Radius supports creation of user defined types, which have an user defined schema.
These types can be managed using [rad resource-type](docs/content/reference/cli/rad_resource-type.md) command.

## Schema Format

{{< tabs "Resource Manifest" >}}

{{< codetab >}}

{{< rad file="snippets/postgres.yaml" embed=true marker="//SAMPLE" >}}

{{< /codetab >}}

{{< /tabs >}}

## Top-level

Manifest file has below keys at the top level:

| Key | Required | Description | Example |
|-----|----------|---------|---------|
| **name** | yes | The namespace in which the resource type is registered | `MyCompany.Resources` |
| [**types**](#types) | yes | type names in the specified namespace. The resource type manifest usually has one type that should be registered. | `postgresDatabases` |

### types

| Key | Required | Description | Example |
|-----|-------------|---------|-----------|
| [**resource type name**](#resource-type-name) | yes | The namespace in which the resource type is registered | `MyCompany.Resources` |

## resource type name

| Key | Required | Description | Example |
|-----|-------------|---------|
| **description** | yes | Description of the resource type | `A postgreSQL database` |
| [**apiVersions**](#apiVersions) | yes | api versions which support this resource type | `2025-01-01-preview` |

## apiVersions

| Key | Required |Description | Example |
|-----|-------------|---------|
| [**api version name**](#api-version-name) | yes | a specific api version which supports this resource type | `2025-01-01-preview` |

## api version name

| Key | Required | Description |
|-----|-------------|----------|
| [**schema**](#schema) | yes | openAPI v3 structural schema of the resource type in a specific api version. Radius supports a subset of open API capabilities. This is covered in subsequent sections |

## schema

`schema` holds the description of the structural schema for new resource type use using [Open API v3](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#schema-object)

| Key | Required | Description |
|-----|-------------|------------|
| **type**| yes | type of `schema`. This is always `object`, representing a open API v3 object |
| [**properties**](#properties)| yes | properties which are valid for a resource of the specified resource type|

### properties

| Key | Required | Description | Example |
|-----|-------------|---------|----------|
| [**property name**](#property-name)| yes | A property name. Property names MUST be strings and SHOULD conform to the regular expression: ^[a-zA-Z0-9\.\-_]+$.| logging-verbosity |

### property name

| Key | Required | Description | Example |
|-----|-------------|---------|----------|
| **type** | yes | type of the value of property. This can be `integer`, `number`, `string` or `boolean` | `true` |
| **description** | no | description of the property | "The size of database to provision" |


#### example

```
properties:
host:
type: string
description: hostname
port:
type: integer
description: server listening port
cost:
type: number
description: cost till date
shared:
type: boolean
description: is this resource shared between different applications
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: MyCompany.Resources
types:
postgresDatabases:
description: A postgreSQL database
apiVersions:
'2023-10-01-preview':
schema:
type: object
properties:
environment:
type: string
application:
type: string
description: The resource ID of the application.
status:
type: object
properties:
binding:
type: object
properties:
database:
type: string
description: The name of the database.
host:
type: string
description: The host name of the database.
port:
type: string
description: The port number of the database.
username:
type: string
description: The username for the database.
password:
type: string
description: The password for the database.
capabilities: ["SupportsRecipes"]