You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/reference/resource-schema/udt/index.md
+36-126
Original file line number
Diff line number
Diff line change
@@ -7,14 +7,12 @@ categories: "Schema"
7
7
weight: 100
8
8
---
9
9
10
-
## User defined types
10
+
## Overview
11
11
12
12
Radius supports creation of user defined types, which have an user defined schema.
13
13
These types can be managed using [rad resource-type](docs/content/reference/cli/rad_resource-type.md) command.
14
14
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
18
16
19
17
{{< tabs "Resource Manifest" >}}
20
18
@@ -26,165 +24,77 @@ in this manifest. A sample manifest is shown below:
26
24
27
25
{{< /tabs >}}
28
26
29
-
## Resource type manifest schema
27
+
## Top-level
30
28
31
29
Manifest file has below keys at the top level:
32
30
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`|
37
35
38
36
### types
39
37
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`|
43
41
44
42
## resource type name
45
43
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`|
50
48
51
49
## apiVersions
52
50
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`|
56
54
57
55
## api version name
58
56
59
-
| Key |Description|Required|
57
+
| Key |Required|Description|
60
58
|-----|-------------|----------|
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 |
62
60
63
61
## schema
64
62
65
63
`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)
66
64
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|
72
69
73
70
### properties
74
71
75
-
| Key |Description|Example|Required |
72
+
| Key |Required|Description|Example |
76
73
|-----|-------------|---------|----------|
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 |
78
75
79
76
### property name
80
77
81
-
| Key |Description|Example|Required |
78
+
| Key |Required|Description|Example |
82
79
|-----|-------------|---------|----------|
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" |
94
82
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 |
102
83
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
123
85
124
86
```
125
87
properties:
126
88
host:
127
89
type: string
128
90
description: hostname
129
-
maxLength: 20
130
91
port:
131
-
type: uint32
92
+
type: integer
132
93
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
145
100
```
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.
0 commit comments