Skip to content

Commit

Permalink
(SCHEMA) Add delete method and related capabilities to schemas
Browse files Browse the repository at this point in the history
This change adds the `delete` method-defining property to the resource manifest
schema and updates the `capabilities` enumeration to include `SetHandlesExist`
and `Delete`, as implemented in PowerShell#379.

It updates both the source and composed schemas.
  • Loading branch information
michaeltlombardi committed Apr 15, 2024
1 parent f9e7317 commit 37f2208
Show file tree
Hide file tree
Showing 11 changed files with 433 additions and 90 deletions.
89 changes: 68 additions & 21 deletions schemas/2024/04/bundled/outputs/resource/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"enum": [
"Get",
"Set",
"SetHandlesExist",
"Test",
"Delete",
"Export"
]
}
Expand Down Expand Up @@ -194,15 +196,18 @@
"get": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.get.json"
},
"export": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json"
},
"set": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json"
},
"test": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.test.json"
},
"delete": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json"
},
"export": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json"
},
"validate": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json"
},
Expand Down Expand Up @@ -275,24 +280,6 @@
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json",
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of every instance.",
"type": "object",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
}
}
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json",
Expand All @@ -319,6 +306,12 @@
"type": "boolean",
"default": false
},
"handlesExist": {
"title": "Resource handles _exist property",
"description": "Defines whether the DSC Resource has its own built-in handling for the `_exist` common property. Set this value to `true` if the DSC Resource handles instance deletion internally when receiving a `set` command where the instance defines the `_exist` property as `false`.",
"type": "boolean",
"default": false
},
"return": {
"description": "Defines whether the command returns a JSON blob of the DSC Resource's state after the set operation or the state and an array of the properties the DSC Resource modified.",
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/returnKind.json"
Expand Down Expand Up @@ -375,6 +368,60 @@
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json",
"title": "Delete method",
"description": "Defines how DSC must call the DSC Resource to delete an instance. Define this method for resources as an alternative to handling the `_exist` property in a `set` operation, which can lead to highly complex code. If the `set` operation for the resource is able to handle deleting an instance when `_exist` is `false`, set the `handlesExist` property of the set method definition to `true` instead.",
"type": "object",
"required": [
"executable",
"input"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
},
"input": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/inputKind.json"
}
},
"examples": [
{
"executable": "registry",
"args": [
"config",
"delete",
"--input",
"{json}"
],
"input": {
"arg": "{json}"
}
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json",
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of every instance.",
"type": "object",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
}
}
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json",
Expand Down
87 changes: 66 additions & 21 deletions schemas/2024/04/bundled/resource/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@
"get": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.get.json"
},
"export": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json"
},
"set": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json"
},
"test": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.test.json"
},
"delete": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json"
},
"export": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json"
},
"validate": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json"
},
Expand Down Expand Up @@ -167,24 +170,6 @@
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json",
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of every instance.",
"type": "object",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
}
}
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.set.json",
Expand All @@ -211,6 +196,12 @@
"type": "boolean",
"default": false
},
"handlesExist": {
"title": "Resource handles _exist property",
"description": "Defines whether the DSC Resource has its own built-in handling for the `_exist` common property. Set this value to `true` if the DSC Resource handles instance deletion internally when receiving a `set` command where the instance defines the `_exist` property as `false`.",
"type": "boolean",
"default": false
},
"return": {
"description": "Defines whether the command returns a JSON blob of the DSC Resource's state after the set operation or the state and an array of the properties the DSC Resource modified.",
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/returnKind.json"
Expand Down Expand Up @@ -267,6 +258,60 @@
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.delete.json",
"title": "Delete method",
"description": "Defines how DSC must call the DSC Resource to delete an instance. Define this method for resources as an alternative to handling the `_exist` property in a `set` operation, which can lead to highly complex code. If the `set` operation for the resource is able to handle deleting an instance when `_exist` is `false`, set the `handlesExist` property of the set method definition to `true` instead.",
"type": "object",
"required": [
"executable",
"input"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
},
"input": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/inputKind.json"
}
},
"examples": [
{
"executable": "registry",
"args": [
"config",
"delete",
"--input",
"{json}"
],
"input": {
"arg": "{json}"
}
}
]
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.export.json",
"title": "Get Method",
"description": "Defines how DSC must call the DSC Resource to get the current state of every instance.",
"type": "object",
"required": [
"executable"
],
"properties": {
"executable": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandExecutable.json"
},
"args": {
"$ref": "/PowerShell/DSC/main/schemas/2024/04/definitions/commandArgs.json"
}
}
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/resource/manifest.validate.json",
Expand Down
Loading

0 comments on commit 37f2208

Please sign in to comment.