Skip to content

Commit 016bc79

Browse files
committed
add new format
1 parent 7d63a1e commit 016bc79

File tree

2 files changed

+61
-166
lines changed

2 files changed

+61
-166
lines changed

docs/content/reference/resource-schema/udt/index.md

+36-126
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ categories: "Schema"
77
weight: 100
88
---
99

10-
## User defined types
10+
## Overview
1111

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

15-
`rad resource-type create` command takes a resource type manifest as input argument. Users define an openAPI schema for their type
16-
in this manifest. A sample manifest is shown below:
17-
15+
## Schema Format
1816

1917
{{< tabs "Resource Manifest" >}}
2018

@@ -26,165 +24,77 @@ in this manifest. A sample manifest is shown below:
2624

2725
{{< /tabs >}}
2826

29-
## Resource type manifest schema
27+
## Top-level
3028

3129
Manifest file has below keys at the top level:
3230

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

3836
### types
3937

40-
| Key | Description | Example | Required |
41-
|-----|-------------|---------|----------|
42-
| [**resource type name**](#resource-type-name) | The namespace in which the resource type is registered | `MyCompany.Resources` | yes |
38+
| Key | Required | Description | Example |
39+
|-----|-------------|---------|-----------|
40+
| [**resource type name**](#resource-type-name) | yes | The namespace in which the resource type is registered | `MyCompany.Resources` |
4341

4442
## resource type name
4543

46-
| Key | Description | Example | Required |
47-
|-----|-------------|---------|----------|
48-
| **description** | Description of the resource type | `A postgreSQL database` | yes |
49-
| [**apiVersions**](#apiVersions) | api versions which support this resource type | `2025-01-01-preview` | yes |
44+
| Key | Required | Description | Example |
45+
|-----|-------------|---------|
46+
| **description** | yes | Description of the resource type | `A postgreSQL database` |
47+
| [**apiVersions**](#apiVersions) | yes | api versions which support this resource type | `2025-01-01-preview` |
5048

5149
## apiVersions
5250

53-
| Key | Description | Example | Required |
54-
|-----|-------------|---------|----------|
55-
| [**api version name**](#api-version-name) | a specific api version which supports this resource type | `2025-01-01-preview` | yes |
51+
| Key | Required |Description | Example |
52+
|-----|-------------|---------|
53+
| [**api version name**](#api-version-name) | yes | a specific api version which supports this resource type | `2025-01-01-preview` |
5654

5755
## api version name
5856

59-
| Key | Description | Required |
57+
| Key | Required | Description |
6058
|-----|-------------|----------|
61-
| [**schema**](#schema) | 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 | yes |
59+
| [**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 |
6260

6361
## schema
6462

6563
`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)
6664

67-
| Key | Description | Required|
68-
|-----|-------------|-----------
69-
| **type**| type of `schema`. This is always `object`, representing a open API v3 object | yes |
70-
| [**properties**](#properties)| properties which are valid for a resource of the specified resource type| yes |
71-
| **required** | list of properties that are required for a resource | no |
65+
| Key | Required | Description |
66+
|-----|-------------|------------|
67+
| **type**| yes | type of `schema`. This is always `object`, representing a open API v3 object |
68+
| [**properties**](#properties)| yes | properties which are valid for a resource of the specified resource type|
7269

7370
### properties
7471

75-
| Key | Description | Example | Required |
72+
| Key | Required | Description | Example |
7673
|-----|-------------|---------|----------|
77-
| [**property name**](#property-name)| A property name. Property names MUST be strings and SHOULD conform to the regular expression: ^[a-zA-Z0-9\.\-_]+$.| logging-verbosity | yes |
74+
| [**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 |
7875

7976
### property name
8077

81-
| Key | Description | Example | Required |
78+
| Key | Required | Description | Example |
8279
|-----|-------------|---------|----------|
83-
| **type** | type of the value of property. This can be any [primitive type](#primitive-type-property), an [array](#array-type-property) or a[map](#map-type-property) | - | yes |
84-
| **description** | description of the property | "The size of database to provision" | no |
85-
86-
Depending on the type, there can be more keys in a property.
87-
88-
89-
#### primitive type property
90-
91-
A property can be any primitive data type defined in [Open API v3 data types](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#data-types).
92-
93-
** Numeric values **
80+
| **type** | yes | type of the value of property. This can be `integer`, `number`, `string` or `boolean` | `true` |
81+
| **description** | no | description of the property | "The size of database to provision" |
9482

95-
| Type | Format | Description |
96-
|------|---------|-------------|
97-
| integer | int32 | signed 32 bits |
98-
| integer | int64 | signed 64 bits (a.k.a long) |
99-
| integer | uint32 | unsigned 32 bits |
100-
| number | float | a float value |
101-
| number | double | a double precision value |
10283

103-
** Strings **
104-
105-
| Type | Format | Description |
106-
|------|---------|-------------|
107-
| string | _ | any string |
108-
| string | byte | base64 encoded characters |
109-
| string | binary | any sequence of octets |
110-
| string | date | As defined by full-date - RFC3339 |
111-
| string | date-time | As defined by date-time - RFC3339 |
112-
| string | password | A hint to UIs to obscure input |
113-
114-
** Boolean **
115-
116-
| Type | Format | Description |
117-
|------|---------|-------------|
118-
| boolean | - | `true` or `false` |
119-
120-
121-
122-
**Example**
84+
#### example
12385

12486
```
12587
properties:
12688
host:
12789
type: string
12890
description: hostname
129-
maxLength: 20
13091
port:
131-
type: uint32
92+
type: integer
13293
description: server listening port
133-
created:
134-
type: string
135-
description: date on which the resource was created
136-
format: date
137-
size:
138-
type: string
139-
description: The size of database to provision
140-
enum:
141-
- S
142-
- M
143-
- L
144-
- XL
94+
cost:
95+
type: number
96+
description: cost till date
97+
shared:
98+
type: boolean
99+
description: is this resource shared between different applications
145100
```
146-
#### array type property
147-
148-
Arrays can be used to store a collection of items of same type.
149-
A property of type `array` must specify a `type` for each `item`.
150-
151-
```
152-
schema:
153-
openAPIV3Schema:
154-
type: object
155-
properties:
156-
ports:
157-
type: array
158-
description: "ports this resource binds to"
159-
item:
160-
type: integer
161-
format: uint32
162-
```
163-
164-
The above example specifies "ports" is an array property and each item in this array is of type integer.
165-
166-
#### map type property
167-
168-
We support map through `addionalProperties`. This is useful when the resource type allows for dynamic (user defined) keys. The keys are always `string` type. We must specify a type for the value of the property.
169-
170-
```
171-
schema:
172-
openAPIV3Schema:
173-
type: object
174-
properties:
175-
name:
176-
type: string
177-
description: The name of the resource
178-
labels:
179-
type: object
180-
description: A map of labels for the resource
181-
additionalProperties:
182-
type: string
183-
```
184-
185-
In the above example, we allow the resource to have labels such as "namespace:app, env: prod". Note that we did not have to define "namespace" and "env" explicitly by using this approach, which would not work for allowing labels.
186-
187-
188-
189-
190-

docs/content/reference/resource-schema/udt/snippets/postgres.yaml

+25-40
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,35 @@ types:
33
postgresDatabases:
44
description: A postgreSQL database
55
apiVersions:
6-
'2025-01-01-preview':
6+
'2023-10-01-preview':
77
schema:
88
type: object
99
properties:
10-
size:
10+
environment:
1111
type: string
12-
description: |
13-
The size of database to provision:
14-
- 'S': 0.5 vCPU, 2 GiB memory, 20 GiB storage
15-
- 'M': 1 vCPU, 4 GiB memory, 40 GiB storage
16-
- 'L': 2 vCPU, 8 GiB memory, 60 GiB storage
17-
- 'XL': 4 vCPU, 16 GiB memory, 100 GiB storage
18-
enum:
19-
- S
20-
- M
21-
- L
22-
- XL
23-
logging-verbosity:
12+
application:
2413
type: string
25-
description: >
26-
The logging level for the database:
27-
- 'TERSE': Not recommended; does not provide guidance on what to do about an error
28-
- 'DEFAULT': Recommended level
29-
- 'VERBOSE': Use only if you plan to actually look up the Postgres source code
30-
enum:
31-
- TERSE
32-
- DEFAULT
33-
- VERBOSE
34-
connection-string:
35-
type: string
36-
readOnly: true
37-
description: 'Fully qualified string to connect to the resource'
38-
env-variable: POSTGRESQL_CONNECTION_STRING
39-
credentials:
14+
description: The resource ID of the application.
15+
status:
4016
type: object
41-
readOnly: true
4217
properties:
43-
username:
44-
type: string
45-
description: 'Username for the database'
46-
env-variable: POSTGRESQL_USERNAME
47-
password:
48-
type: string
49-
description: 'Password for the database user'
50-
env-variable: POSTGRESQL_PASSWORD
51-
required:
52-
- size
18+
binding:
19+
type: object
20+
properties:
21+
database:
22+
type: string
23+
description: The name of the database.
24+
host:
25+
type: string
26+
description: The host name of the database.
27+
port:
28+
type: string
29+
description: The port number of the database.
30+
username:
31+
type: string
32+
description: The username for the database.
33+
password:
34+
type: string
35+
description: The password for the database.
36+
capabilities: ["SupportsRecipes"]
37+

0 commit comments

Comments
 (0)