upsert_relationship
Add or update a Relationship · write tool
Adds a Relationship from a consumer Element in this Project to its provider, or updates one, under the consumer’s relationships; comments and formatting are kept. A Relationship is named by (from, to) plus id if given. With no id and several on the pair, returns ambiguous with each candidate’s file:line.
| Field | Type | Required | Notes |
|---|---|---|---|
project |
string | yes | The Project to edit, by id. |
from |
string | yes | The consumer Element, in this Project. |
to |
string | yes | The provider Element: an id in this Project, or project:id. |
fields |
map of id → any | Fields to set, as in YAML; null removes a field. Fields not given are left as they are. Default: {}. |
|
id |
string | The Relationship’s id, to pick one of several on a pair or to give a new one an id. | |
dry_run |
boolean | Check the write and return its diff without changing any file. Default: false. |
Output
Section titled “Output”| Field | Type | Required | Notes |
|---|---|---|---|
action |
"created" or "updated" or "removed" or "unchanged" |
yes | |
id |
string or null | yes | The qualified id written (bare for a Team, Environment or Project); null for a Deployment, or a Relationship without one. |
from |
string | ||
to |
string | ||
service |
string | ||
environment |
string | ||
target |
string | ||
files |
list of string | yes | |
diff |
string | yes | |
dryRun |
boolean | yes |
Example
Section titled “Example”Called over the Kitchen sink example Workspace.
Arguments:
{ "project": "sink", "from": "reports", "to": "search", "fields": { "description": "Looks up products in", "technology": "HTTPS" }, "dry_run": true}Result:
{ "action": "created", "id": null, "from": "sink:reports", "to": "sink:search", "files": [ "examples/kitchen-sink/archidocs/sink/reporting.yaml" ], "dryRun": true, "diff": "(the patch below)"}The diff, as a patch:
--- a/examples/kitchen-sink/archidocs/sink/reporting.yaml+++ b/examples/kitchen-sink/archidocs/sink/reporting.yaml@@ -10,3 +10,6 @@ - to: orders-db description: Reads order history from technology: SQL+ - to: search+ description: Looks up products in+ technology: HTTPSErrors
Section titled “Errors”A call that fails returns isError: true, with {code, message, suggestions?} as structuredContent. This tool returns:
invalid_inputwhen the arguments don’t fit the input above.not_foundwhen the Project, or an id it names, matches nothing.ambiguouswhen the arguments match more than one Relationship or Deployment.validation_failedwhen the write would add a check error. Nothing is written.read_onlywhen the server reads a published Workspace Bundle, or serves HTTP without--allow-writes.source_unavailablewhen the server can’t read the Workspace.
Error codes says what to do about each.
See also
Section titled “See also”Documents the beta branch at cd98671, ahead of the latest release, v1.4.0.