feat(xo-cli rest): support patch method

This commit is contained in:
Julien Fontanet
2023-06-26 16:08:47 +02:00
parent 0f0c0ec0d0
commit 8956a99745
5 changed files with 49 additions and 0 deletions

View File

@@ -48,6 +48,7 @@
- @vates/node-vsphere-soap major
- @xen-orchestra/vmware-explorer patch
- xen-api patch
- xo-cli minor
- xo-server patch
- xo-server-auth-oidc minor
- xo-server-perf-alert patch

View File

@@ -92,6 +92,18 @@ Usage:
xo-cli rest get vms/<VM UUID>
xo-cli rest get tasks/<task id>/actions wait=result
xo-cli rest patch <object> <name>=<value>...
Update properties of an object (not all properties are writable).
<object>
Full path of the object to update
<name>=<value>...
Properties to update on the object
Examples:
xo-cli rest patch vms/<VM UUID> name_label='My VM' name_description='Its description
xo-cli rest post <action> <name>=<value>...
Execute an action.

View File

@@ -110,6 +110,18 @@ Usage:
xo-cli rest get vms/<VM UUID>
xo-cli rest get tasks/<task id>/actions wait=result
xo-cli rest patch <object> <name>=<value>...
Update properties of an object (not all properties are writable).
<object>
Full path of the object to update
<name>=<value>...
Properties to update on the object
Examples:
xo-cli rest patch vms/<VM UUID> name_label='My VM' name_description='Its description
xo-cli rest post <action> <name>=<value>...
Execute an action.

View File

@@ -313,6 +313,18 @@ const help = wrap(
$name rest get vms/<VM UUID>
$name rest get tasks/<task id>/actions wait=result
$name rest patch <object> <name>=<value>...
Update properties of an object (not all properties are writable).
<object>
Full path of the object to update
<name>=<value>...
Properties to update on the object
Examples:
$name rest patch vms/<VM UUID> name_label='My VM' name_description='Its description
$name rest post <action> <name>=<value>...
Execute an action.

View File

@@ -61,6 +61,18 @@ const COMMANDS = {
return this.json ? JSON.stringify(result, null, 2) : result
},
async patch([path, ...params]) {
const response = await this.exec(path, {
body: JSON.stringify(parseParams(params)),
headers: {
'content-type': 'application/json',
},
method: 'PATCH',
})
return await response.text()
},
async post([path, ...params]) {
const response = await this.exec(path, {
body: JSON.stringify(parseParams(params)),