Skip to content

Commit 2aae198

Browse files
(DOCS) Reference for expected resource operations stdout
This change adds documentation for the `stdout` JSON Schemas indicating how DSC validates the expected output for the resource operations.
1 parent be13fcd commit 2aae198

File tree

10 files changed

+730
-0
lines changed

10 files changed

+730
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: JSON schema reference for the expected stdout from the delete resource operation
3+
ms.date: 02/28/2025
4+
ms.topic: reference
5+
title: DSC resource delete operation stdout schema reference
6+
---
7+
8+
# DSC resource delete operation stdout schema reference
9+
10+
## Synopsis
11+
12+
DSC doesn't expect the **Delete** operation for a resource to return any JSON to stdout.
13+
14+
## Metadata
15+
16+
```yaml
17+
SchemaDialect: https://json-schema.org/draft/2020-12/schema
18+
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/resource/stdout/delete.json
19+
Type: 'null'
20+
```
21+
22+
## Description
23+
24+
DSC resources that implement the **Delete** operation shouldn't emit any data to stdout. DSC
25+
doesn't expect any output for the **Delete** operation and ignores any data emitted to stdout when
26+
invoking the operation.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
description: JSON schema reference for the expected stdout from the export resource operation
3+
ms.date: 07/29/2025
4+
ms.topic: reference
5+
title: DSC resource export operation stdout schema reference
6+
---
7+
8+
# DSC resource export operation stdout schema reference
9+
10+
## Synopsis
11+
12+
Represents the actual state of a resource instance in DSC. DSC expects every JSON Line emitted to
13+
stdout for the **Export** operation to adhere to this schema.
14+
15+
## Metadata
16+
17+
```yaml
18+
SchemaDialect: https://json-schema.org/draft/2020-12/schema
19+
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/resource/stdout/export.json
20+
Type: object
21+
```
22+
23+
## Description
24+
25+
DSC expects a resource implementing the **Export** operation to return a series of JSON Lines.
26+
27+
The data that DSC expects depends on whether the resource kind is defined as `exporter`:
28+
29+
- When the resource kind is `exporter`, DSC expects the resource to return JSON Lines representing
30+
DSC resource instance definitions to recursively export.
31+
- When the resource kind isn't `exporter`, DSC expects the resource to return JSON Lines
32+
representing the actual state of every instance of the resource on the system.
33+
34+
## Typical resource expected output
35+
36+
DSC expects a typical resource implementing the **Export** operation to return a series of JSON
37+
Lines.
38+
39+
Each JSON Line represents the actual state of a resource instance in DSC. DSC expects every JSON
40+
Line emitted to stdout for the **Export** operation to adhere to this schema.
41+
42+
The output must be a JSON object. The object must be a valid representation of an instance of the
43+
resource.
44+
45+
Command resources define their instance schema with the [schema.command][01] or
46+
[schema.embedded][02] fields in their resource manifest. If a command resource returns JSON that is
47+
invalid against the resource instance schema, DSC raises an error.
48+
49+
Adapted resource instances are validated by their adapter when the adapter invokes them.
50+
51+
## Exporter resource expected output
52+
53+
DSC expects an exporter resource (one with the [kind][03] field in its manifest set to `exporter`)
54+
to return a series of JSON Lines.
55+
56+
Each JSON Line represents a DSC resource instance definition to recursively invoke the **Export**
57+
operation for. DSC expects every JSON Line emitted to stdout for the **Export** operation to adhere
58+
to this schema.
59+
60+
The output must be a JSON object adhering to [DSC resource instance][04] schema, rather than the
61+
instance schema for a specific resource. DSC expects the object to define at least the [name][05]
62+
and [type][06] fields. If the object defines the [properties][07] field, DSC passes those
63+
properties to the resource when recursively exporting it so that the resource may filter the
64+
exported instance results.
65+
66+
<!-- Reference link definitions -->
67+
[01]: ../manifest/schema/property.md
68+
[02]: ../manifest/schema/embedded.md
69+
[03]: ../manifest/root.md#kind
70+
[04]: ../../config/resource.md
71+
[05]: ../../config/resource.md#name
72+
[06]: ../../config/resource.md#type
73+
[07]: ../../config/resource.md#properties-1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
description: JSON schema reference for the expected stdout from the get resource operation
3+
ms.date: 07/29/2025
4+
ms.topic: reference
5+
title: DSC resource get operation stdout schema reference
6+
---
7+
8+
# DSC resource get operation stdout schema reference
9+
10+
## Synopsis
11+
12+
Represents the actual state of a resource instance in DSC. DSC expects the JSON Line emitted to
13+
stdout for the **Get** operation to adhere to this schema.
14+
15+
## Metadata
16+
17+
```yaml
18+
SchemaDialect: https://json-schema.org/draft/2020-12/schema
19+
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/resource/stdout/get.json
20+
Type: object
21+
```
22+
23+
## Description
24+
25+
Represents the actual state of a resource instance in DSC. DSC expects the JSON Line emitted to
26+
stdout for the **Get** operation to adhere to this schema.
27+
28+
The output must be a JSON object. The object must be a valid representation of an instance of the
29+
resource.
30+
31+
Command resources define their instance schema with the [schema.command][01] or
32+
[schema.embedded][02] fields in their resource manifest. If a command resource returns JSON that is
33+
invalid against the resource instance schema, DSC raises an error.
34+
35+
Adapted resource instances are validated by their adapter when the adapter invokes them.
36+
37+
<!-- Reference link definitions -->
38+
[01]: ../manifest/schema/property.md
39+
[02]: ../manifest/schema/embedded.md
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
---
2+
description: JSON schema reference for the expected stdout from the list resource operation
3+
ms.date: 07/29/2025
4+
ms.topic: reference
5+
title: DSC resource list operation stdout schema reference
6+
---
7+
8+
# DSC resource list operation stdout schema reference
9+
10+
## Synopsis
11+
12+
Defines the representation of an adapted resource in DSC. DSC expects every JSON Line emitted to
13+
stdout for the **List** operation to adhere to this schema.
14+
15+
## Metadata
16+
17+
```yaml
18+
SchemaDialect: https://json-schema.org/draft/2020-12/schema
19+
SchemaID: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/resource/stdout/list.json
20+
Type: object
21+
```
22+
23+
## Description
24+
25+
Defines the representation of an adapted resource in DSC. DSC expects every JSON Line emitted to
26+
stdout for the **List** operation to adhere to this schema.
27+
28+
DSC includes the following adapter resources:
29+
30+
- [Microsoft.DSC/PowerShell][01] run PowerShell and enables you to use PowerShell DSC (PSDSC)
31+
resources implemented as PowerShell classes in DSC.
32+
- [Microsoft.Windows/WindowsPowerShell][02] runs Windows PowerShell and enables you to use any
33+
available PSDSC resources in DSC. This adapter is only available when you install DSC on
34+
Windows.
35+
- [Microsoft.Windows/WMI][03] enables you to use WMI classes as resources in DSC. This adapter is
36+
only available when you install DSC on Windows.
37+
38+
## Required Properties
39+
40+
The output for the `discover` operation must include these properties:
41+
42+
- [type](#type)
43+
- [kind](#kind)
44+
- [version](#version)
45+
- [capabilities](#capabilities)
46+
- [path](#path)
47+
- [directory](#directory)
48+
- [implementedAs](#implementedas)
49+
- [properties](#properties-1)
50+
- [requireAdapter](#requireadapter)
51+
52+
## Properties
53+
54+
### type
55+
56+
The `type` property represents the fully qualified type name of the resource. It's used to specify
57+
the resource in configuration documents and as the value of the `--resource` flag when using the
58+
`dsc resource *` commands. For more information about resource type names, see
59+
[DSC Resource fully qualified type name schema reference][04].
60+
61+
```yaml
62+
Type: string
63+
Required: true
64+
Pattern: ^\w+(\.\w+){0,2}\/\w+$
65+
```
66+
67+
### kind
68+
69+
The `kind` property defines how DSC should handle the adapted resource. DSC supports several kinds
70+
of resources: `resource`, `group`, `adapter`, `importer`, and `exporter`.
71+
72+
For more information, see [DSC resource kinds][05].
73+
74+
```yaml
75+
Type: string
76+
Required: false
77+
ValidValues: [resource, adapter, group, importer, exporter]
78+
```
79+
80+
### version
81+
82+
The `version` property represents the current version of the adapted resource as a valid semantic
83+
version (semver) string. The version applies to the adapted resource, not the software it manages.
84+
85+
```yaml
86+
Type: string
87+
Required: true
88+
Pattern: ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
89+
```
90+
91+
### capabilities
92+
93+
Defines the list of capabilities for the adapted resource. DSC resources always have at least one
94+
capability. Resource capabilities define the operations you can invoke for a resource and how the
95+
resource behaves when invoked.
96+
97+
DSC resources may have the following capabilities:
98+
99+
- `get` - The resource can retrieve the current state of an instance.
100+
- `set` - The resource can enforce the desired state for an instance.
101+
- `setHandlesExist` - The resource handles deleting an instance during a **Set** operation.
102+
- `whatIf` - The resource can report how it would change state for an instance during a **Set** operation.
103+
- `test` - The resource implements the **Test** operation and doesn't rely on synthetic testing.
104+
- `delete` - The resource can remove an instance.
105+
- `export` - The resource can enumerate every instance.
106+
- `resolve` - The resource can resolve nested instances from an external source.
107+
108+
For more information about resource capabilities, see [DSC resource capabilities][06]. For more
109+
information about the operations you can invoke for a resource, see [DSC resource operations][07].
110+
111+
```yaml
112+
Type: array
113+
Required: true
114+
ItemsMustBeUnique: true
115+
ItemsType: string
116+
ItemsValidValues: [
117+
get,
118+
set,
119+
setHandlesExist,
120+
whatIf,
121+
test,
122+
delete,
123+
export,
124+
resolve
125+
]
126+
```
127+
128+
### path
129+
130+
Indicates the path to the adapted resource on the file system.
131+
132+
```yaml
133+
Type: string
134+
Required: true
135+
```
136+
137+
### directory
138+
139+
Indicates the path to the folder containing the adapted resource on the file system.
140+
141+
```yaml
142+
Type: string
143+
Required: true
144+
```
145+
146+
### implementedAs
147+
148+
Indicates that the adapted resource uses a custom implementation. The name can be used to
149+
distinguish between different implementations for the adapted resources.
150+
151+
```yaml
152+
Type: string
153+
Required: true
154+
```
155+
156+
### author
157+
158+
Indicates the name of the person or organization that developed and maintains the adapted Resource.
159+
160+
```yaml
161+
Type: [string, 'null']
162+
Required: false
163+
Pattern: ^\w+( \w+)*
164+
```
165+
166+
### properties
167+
168+
Defines the adapted resource's property names.
169+
170+
```yaml
171+
Type: array
172+
Required: false
173+
ItemsType: string
174+
ItemsPattern: ^\w+$
175+
```
176+
177+
### requireAdapter
178+
179+
Defines the fully qualified type name of the adapter that the adapted resource depends on. An
180+
adapter should always set this value to its own fully qualified resource type name.
181+
182+
```yaml
183+
Type: string
184+
Required: true
185+
Pattern: ^\w+(\.\w+){0,2}\/\w+$
186+
```
187+
188+
<!-- Reference link definitions -->
189+
[01]: ../../../resources/Microsoft/DSC/PowerShell/index.md
190+
[02]: ../../../resources/Microsoft/Windows/WindowsPowerShell/index.md
191+
[03]: ../../../resources/Microsoft/Windows/WMI/index.md
192+
[04]: ../../definitions/resourceType.md
193+
[05]: ../../../../concepts/resources/kinds.md
194+
[06]: ../../../../concepts/resources/capabilities.md
195+
[07]: ../../../../concepts/resources/operations.md

0 commit comments

Comments
 (0)