|
| 1 | +--- |
| 2 | +type: docs |
| 3 | +title: "Overview: User Defined Type Resource schemas" |
| 4 | +linkTitle: "Overview" |
| 5 | +description: "Schema docs for the resources of user defined type that can comprise a Radius Application" |
| 6 | +categories: "Overview" |
| 7 | +weight: 100 |
| 8 | +--- |
| 9 | + |
| 10 | +## User defined types |
| 11 | + |
| 12 | +Radius supports creation of user defined types, which have an user defined schema. |
| 13 | +These types can be managed using [rad resource-type](docs/content/reference/cli/rad_resource-type.md) command. |
| 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 | + |
| 18 | +{{< codetab >}} |
| 19 | + |
| 20 | +{{< rad file="snippets/postgres.yaml" embed=true marker="//SAMPLE" >}} |
| 21 | + |
| 22 | +{{< /codetab >}} |
| 23 | + |
| 24 | +## Resource type manifest schema |
| 25 | + |
| 26 | +Manifest file has below keys at the top level: |
| 27 | + |
| 28 | +| Key | Description | Example | |
| 29 | +|-----|-------------|---------| |
| 30 | +| **name** | The namespace in which the resource type is registered | `MyCompany.Resources` | |
| 31 | +| [**types**](#types) | type-names in the specified namespace. The resource type manifest usually has one type that should be registered. | `postgresDatabases` | |
| 32 | + |
| 33 | +### types |
| 34 | + |
| 35 | +| Key | Description | Example | |
| 36 | +|-----|-------------|---------| |
| 37 | +| [**name of the resource type**](#resource-type-name) | The namespace in which the resource type is registered | `MyCompany.Resources` | |
| 38 | + |
| 39 | +## resource type name |
| 40 | + |
| 41 | +| Key | Description | Example | |
| 42 | +|-----|-------------|---------| |
| 43 | +| **description** | Description of the resource type | `A postgreSQL database` | |
| 44 | +| [**apiVersions**](#apiVersions) | api-versions which support this resource type | `2025-01-01-preview` | |
| 45 | + |
| 46 | +## apiVersions |
| 47 | + |
| 48 | +| Key | Description | Example | |
| 49 | +|-----|-------------|---------| |
| 50 | +| [**apiversion name**](#api-version-name) | a specific api version which supports this resource type | `2025-01-01-preview` | |
| 51 | + |
| 52 | +## api version name |
| 53 | + |
| 54 | +| Key | Description | |
| 55 | +|-----|-------------| |
| 56 | +| [**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 | |
| 57 | + |
| 58 | +## schema |
| 59 | + |
| 60 | +`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) |
| 61 | + |
| 62 | +| Key | Description | |
| 63 | +|-----|-------------| |
| 64 | +| **type**| type of `schema`. This is always object, representing a open API v3 object | |
| 65 | +| [**properties**](#properties)| properties which are valid for a resource of the specified resource type| |
| 66 | +| **required** | list of properties that are required for a resource | |
| 67 | + |
| 68 | +### properties |
| 69 | + |
| 70 | +| Key | Description | Example | |
| 71 | +|-----|-------------|---------| |
| 72 | +| **type**| type of `schema`. This is always object, representing a open API v3 object | | |
| 73 | +| [**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 | |
| 74 | + |
| 75 | +### property name |
| 76 | + |
| 77 | +| Key | Description | Example | |
| 78 | +|-----|-------------|---------| |
| 79 | +| **type**| type of the value of property. This can be any primitive type defined in [Open API v3 data types](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.2.md#data-types) OR an array OR a map | [examples](#examples) | |
| 80 | + |
| 81 | + |
| 82 | +#### Examples |
| 83 | + |
| 84 | +##### primitive type property |
| 85 | + |
| 86 | +``` |
| 87 | + properties: |
| 88 | + size: |
| 89 | + type: string |
| 90 | + description: The size of database to provision |
| 91 | + enum: |
| 92 | + - S |
| 93 | + - M |
| 94 | + - L |
| 95 | + - XL |
| 96 | + host: |
| 97 | + type: string |
| 98 | + description: hostname |
| 99 | + maxLength: 20 |
| 100 | +``` |
| 101 | + |
| 102 | +##### array |
| 103 | + |
| 104 | +`array` must specify a `type` for item |
| 105 | + |
| 106 | +``` |
| 107 | +schema: |
| 108 | + openAPIV3Schema: |
| 109 | + type: object |
| 110 | + properties: |
| 111 | + ports: |
| 112 | + type: array |
| 113 | + description: "ports this resource binds to" |
| 114 | + item: |
| 115 | + type: integer |
| 116 | + format: uint32 |
| 117 | +``` |
| 118 | + |
| 119 | +##### map |
| 120 | + |
| 121 | +We support map through `addionalProperties`. This is useful when the resource type allows for dynamic (user defined) keys. We still must specify a type for the value of the property. |
| 122 | + |
| 123 | +``` |
| 124 | +schema: |
| 125 | + openAPIV3Schema: |
| 126 | + type: object |
| 127 | + properties: |
| 128 | + name: |
| 129 | + type: string |
| 130 | + description: The name of the resource |
| 131 | + labels: |
| 132 | + type: object |
| 133 | + description: A map of labels for the resource |
| 134 | + additionalProperties: |
| 135 | + type: string |
| 136 | +``` |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
0 commit comments