Add rules to an organization preset
POST/api/public/v1/policy-presets/{key}/rules beta
Rules from a source, as on create; a sentence already in the preset with the same dimension is skipped and returned in skipped. 409 PRESET_CHANGED for a stale revision; 409 PRESET_READ_ONLY for a built-in.
curl --fail-with-body -X POST 'https://app.openlatch.ai/api/public/v1/policy-presets/<preset_key>/rules' \ -H "Authorization: Bearer $OPENLATCH_API_KEY" \ -H 'Content-Type: application/json' \ -d '{"revision":<revision>,"source":{"sentences":[{"sentence":"Ask before a deploy to production.","dimension":"safety"}]}}'import jsonimport osimport urllib.request
body = '{"revision":<revision>,"source":{"sentences":[{"sentence":"Ask before a deploy to production.","dimension":"safety"}]}}'request = urllib.request.Request( 'https://app.openlatch.ai/api/public/v1/policy-presets/<preset_key>/rules', method='POST', data=body.encode(), headers={ 'Authorization': 'Bearer ' + os.environ['OPENLATCH_API_KEY'], 'Content-Type': 'application/json', },)with urllib.request.urlopen(request) as response: text = response.read().decode() print(json.dumps(json.loads(text), indent=2) if text else response.status)#!/usr/bin/env bashset -euo pipefail
curl -sS --fail-with-body -X POST 'https://app.openlatch.ai/api/public/v1/policy-presets/<preset_key>/rules' \ -H "Authorization: Bearer $OPENLATCH_API_KEY" \ -H 'Content-Type: application/json' \ -d '{"revision":<revision>,"source":{"sentences":[{"sentence":"Ask before a deploy to production.","dimension":"safety"}]}}' | jq .$headers = @{ Authorization = "Bearer $env:OPENLATCH_API_KEY"}$body = '{"revision":<revision>,"source":{"sentences":[{"sentence":"Ask before a deploy to production.","dimension":"safety"}]}}'Invoke-RestMethod -Method POST -Uri 'https://app.openlatch.ai/api/public/v1/policy-presets/<preset_key>/rules' -Headers $headers -ContentType 'application/json; charset=utf-8' -Body $body | ConvertTo-Json -Depth 20Autorización
Sección titulada «Autorización»| Rol en la organización | Este punto de conexión |
|---|---|
owner | Permitido |
admin | Permitido |
editor | Permitido |
viewer | No permitido |
Una clave tiene el rol que su propietario ocupa en la organización. Consulte Autenticación.
Ámbito de la clave de API: presets:write
Parámetros de ruta
Sección titulada «Parámetros de ruta»| Parámetro | Tipo | Descripción |
|---|---|---|
key | string | Obligatorio. |
Parámetros de encabezado
Sección titulada «Parámetros de encabezado»| Parámetro | Tipo | Descripción |
|---|---|---|
Idempotency-Key | string or null | Optional. Makes the request safe to retry: the same key and the same request, within 24 hours, returns the stored response with Idempotent-Replayed: true and runs once. |
Cuerpo de la solicitud
Sección titulada «Cuerpo de la solicitud»| Campo | Tipo | Descripción |
|---|---|---|
revision | integer | Obligatorio. |
source | object | Obligatorio. Exactly one of the three: intent policy ids, a preset selection, or typed sentences. |
source.intent_policy_ids | array of string (uuid) or null | |
source.preset | object or null | |
source.preset.intents | array of object | Obligatorio. |
source.preset.key | string | Obligatorio. |
source.sentences | array of object or null |
Respuesta
Sección titulada «Respuesta»- 200 OK — la llamada se completó correctamente.
- 400 Bad Request —
BAD_REQUEST - 401 Unauthorized —
UNAUTHORIZED - 402 Payment Required —
license_expired - 403 Forbidden —
FEATURE_DISABLED,FORBIDDEN,INSUFFICIENT_SCOPE - 404 Not Found —
NOT_FOUND - 409 Conflict —
IDEMPOTENCY_IN_PROGRESS,NOT_RATIFIED,PRESET_CHANGED,PRESET_READ_ONLY - 422 Unprocessable Content —
IDEMPOTENCY_KEY_REUSED,INVALID_ID,SELECTION_TOO_LARGE,VALIDATION_ERROR - 429 Too Many Requests —
TOO_MANY_REQUESTS - 500 Internal Server Error —
INTERNAL_SERVER_ERROR,tenant_isolation_violation - 503 Service Unavailable —
FEATURE_STATE_UNAVAILABLE,SERVICE_UNAVAILABLE
Campos de la respuesta
Sección titulada «Campos de la respuesta»| Campo | Tipo | Descripción |
|---|---|---|
data | object | Obligatorio. A create or an add: the preset, and the sentences not added because already in it. |
data.created_by | object or null | |
data.created_by.name | string | Obligatorio. |
data.default_selected | boolean | Obligatorio. False for a framework preset, otherwise true. |
data.description | string | Obligatorio. |
data.framework | object or null | Obligatorio. Set on a framework preset; null on every other. |
data.framework.notice | object or null | Obligatorio. |
data.framework.source | object | Obligatorio. |
data.key | string | Obligatorio. |
data.kind | string — one of builtin, organization | Obligatorio. |
data.revision | integer or null | |
data.rules | array of object | Obligatorio. |
data.rules[].capability | object or null | |
data.rules[].citation | object or null | Obligatorio. What the rule cites, for a framework preset's rule; null for every other. |
data.rules[].dimension | string — one of quality, economics, security, safety, compliance | Obligatorio. |
data.rules[].intent_key | string | Obligatorio. |
data.rules[].sentence | string | Obligatorio. |
data.skipped | array of string | |
data.title | string | Obligatorio. |
Ejemplo de respuesta
Sección titulada «Ejemplo de respuesta»{ "data": { "created_by": { "name": "release-bot" }, "default_selected": false, "description": "string", "framework": { "notice": "string", "source": { "framework_url": "https://app.openlatch.ai/", "github_url": "https://app.openlatch.ai/", "license_name": "release-bot", "license_url": "https://app.openlatch.ai/", "name": "release-bot", "source_commit": "string", "source_date": "string" } }, "key": "string", "kind": "builtin", "revision": 3, "rules": [ { "capability": "enforce", "citation": { "entries": [ {} ], "items": [ {} ] }, "dimension": "quality", "intent_key": "string", "sentence": "string" } ], "skipped": [ "string" ], "title": "string" }}