sonar-clone-widgets
Clones the widget corresponding to the guid passed in the input record. The name of the cloned widget has a Copy of prefix added.
Command properties
| Property | Description |
|---|---|
| Command type | Processing query |
| Required permission | Administrator |
| License usage | N/A |
| Parallel execution | Not supported |
| Distributed execution | Runs on Data Node (mapper) |
Syntax
Options
[run=BOOL]- Specify
tto actually clone the widget. If not specified, nothing is actually cloned, and you can preview only the shape of the clone result record (default:f).
Input fields
| Field | Type | Required | Description |
|---|---|---|---|
| guid | string | Required | The GUID of the widget to clone |
Output fields
Returns all fields of the input record with the following fields added.
| Field | Type | Description |
|---|---|---|
| clone_guid | string | The GUID of the widget to be newly created. Because this is a random value generated fresh each time the command is called, the value previewed without run can differ from the value actually issued when cloning with run=t. Not included in records where _error was recorded due to a missing guid field, a nonexistent target, or a clone failure during run=t |
| clone_name | string | The name of the widget to be newly created (with the Copy of prefix). Like clone_guid, not included in records where _error was recorded |
| status | string | The processing result, included only when run with run=t. success or failure |
| _error | string | The error message if the clone failed |
Error codes
Parsing errors
| Error code | Message | Description |
|---|---|---|
| 300171 | No permission to list widgets | Run by an account without administrator permission |
Runtime errors
N/A
Description
For each input record, the sonar-clone-widgets command looks up the target widget by the guid field value, then prepares a clone with a new GUID and a name prefixed with Copy of. If the run option is not specified, nothing is actually cloned, and you can check only the shape of the clone result record. Because clone_guid is a random value generated fresh each time the command is called, the value you check at this point differs from the GUID that is actually issued when cloning with run=t. In practice, clone_name is the only value you can preview reliably. You must specify run=t to actually create the widget, and the processing result is then recorded in the status field.
The cloned widget is created without being placed on any dashboard tab. To also clone the widgets included in a dashboard tab, use the clone-widget option of the sonar-clone-dashboards command.
If the guid field is missing, guid field is required is recorded in the _error field; if the target widget cannot be found, widget not found is recorded, and the record is not cloned in either case. If the guid value is not in valid UUID format, query execution is aborted with an exception, so you must always provide a value in the same format as the guid output field of the sonar-widgets command.
Examples
-
Find a widget by name and preview the clone
sonar-widgets | search name == "Event count by source country" | fields guid | sonar-clone-widgetsBecause the
runoption is not specified, nothing is actually cloned, and you can preview only the name of the widget to be cloned. Becauseclone_guidis a value generated fresh each time the command is called, the GUID in this result cannot be used for the actual clone. -
Clone a widget with a specific GUID
json "[{'guid': '550e8400-e29b-41d4-a716-446655440001'}]" | sonar-clone-widgets run=tActually clones the widget with the specified GUID.
Change history
The sonar-clone-widgets command is available in the Sonar 4.0 series starting with 4.0.2609.0, where the command previously provided by the Experimental app was built into Sonar core. On versions without the built-in command, install the Experimental app to use it.