enterprise_ai.contracts
Source: sdks/python/src/enterprise_ai/contracts/__init__.py. Back to the Python SDK reference index.
This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.
Model SchemaIssue
One validation error: JSON pointer like location and message.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
path | str | yes | Location of the error, path segments joined by / (for example spec/tools/0), or <root> for the whole document. |
message | str | yes | Status message (up to 2000 characters). |
Model ValidationResult
Outcome of :func:validate.
Fields:
| Name | Type | Required | Description |
|---|---|---|---|
contract | str | yes | Name of the contract checked, or unknown when it could not be detected. |
errors | list[SchemaIssue] | no | List of SchemaIssue, sorted by path; empty when the document is valid. |
Attributes:
| Name | Type | Required | Description |
|---|---|---|---|
valid | bool | yes | True when errors is empty; the result is also truthy then. |
ValidationResult.raise_for_errors
raise_for_errors() -> None
Raise :class:~enterprise_ai.errors.ValidationError when invalid.
This element takes no parameter.
Returns: None.
Raises: ValidationError.
ValidationResult.to_dict
to_dict() -> dict[str, Any]
Plain dict form of the result, ready for JSON.
This element takes no parameter.
Returns: dict[str, Any]. {"contract", "valid", "errors"} with each error as a path: message string.
Class ContractsClient
/v1/contracts: the server side copy of the schemas and remote validation.
Resource
ContractsClient.get
get(name: str) -> Any
Get a contract. Returns the JSON Schema of the contract as published. Open to any authenticated caller. An unknown name answers 404 unknown_contract.
Route: /v1/contracts/{name} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the contract, for example agent-manifest. |
Returns: Any. Decoded JSON answer of the operation "Get a contract".
Raises: the typed errors of the transport (Errors).
ContractsClient.list
list() -> Any
List the contracts. Lists the published contracts with their name, title, kind, type, file, schema id and description. Open to any authenticated caller. next_cursor is always null.
Route: /v1/contracts (GET).
This element takes no parameter.
Returns: Any. Decoded JSON answer of the operation "List the contracts".
Raises: the typed errors of the transport (Errors).
ContractsClient.validate
validate(name: str, document: Any) -> Any
Validate a document against a contract. Validates the body against the contract, formats included, without storing anything. The answer gives contract, valid and errors, each with the JSON path of the faulty value and a message. Open to any authenticated caller. An unknown contract answers 404 unknown_contract.
Route: /v1/contracts/{name}/validate (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Name of the contract, for example agent-manifest. | |
document | Any | yes | Document to validate, sent as the JSON body of the request. |
Returns: Any. Decoded JSON answer of the operation "Validate a document against a contract".
Raises: the typed errors of the transport (Errors).
ContractsClient.validate_local
validate_local(document: Any, name: str | None = None) -> ValidationResult
Validate against the embedded schemas without any network call.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
document | Any | yes | Document to validate, usually a dict decoded from JSON or YAML. | |
name | str | None | None | no | Contract name, for example usage-event; None detects it from the kind of the document. |
Returns: ValidationResult. A ValidationResult: Outcome of :func:validate.
Class ManifestsClient
/v1/manifests: apply any manifest kind and export registry entries as manifests.
Resource
ManifestsClient.apply
apply(manifest: dict[str, Any], validate_first: bool = True) -> Any
Apply a manifest. Creates or updates the object described by a manifest, in one transaction. Needs tenant_admin or developer.
Route: /v1/manifests/apply (POST).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
manifest | dict[str, Any] | yes | Manifest of any kind (Agent, Model, Tool...), sent as the JSON body. | |
validate_first | bool | True | no | When True (default), the manifest is validated against the embedded schemas first and ValidationError is raised before any call. |
Returns: Any. Decoded JSON answer of the operation "Apply a manifest".
Raises: the typed errors of the transport (Errors).
ManifestsClient.get
get(kind: str, name: str) -> Any
Export a manifest. Returns the current manifest of an object of the tenant: built by the registry of the kind when it can export, otherwise the last applied document. Open to any member of the tenant. An unknown kind answers 422 unknown_kind (with the supported kinds); an unknown object 404 not_found.
Route: /v1/manifests/{kind}/{name} (GET).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
kind | str | yes | Kind of manifest, without case: Agent, Model, Tool, Skill, Plugin, Connector or Channel. | |
name | str | yes | Name of the object, the metadata.name of its manifest. |
Returns: Any. Decoded JSON answer of the operation "Export a manifest".
Raises: the typed errors of the transport (Errors).
Functions
index
index() -> dict[str, Any]
The embedded contracts/index.json.
This element takes no parameter.
Returns: dict[str, Any]. Decoded content of the index, with the contracts list; cached after the first read.
names
names() -> list[str]
Names of every contract (agent-manifest, usage-event...).
This element takes no parameter.
Returns: list[str]. List of contract names, in the order of index.json.
schema
schema(name: str) -> dict[str, Any]
JSON Schema of one contract (common included).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Contract name, for example usage-event; an unknown name raises KeyError. |
Returns: dict[str, Any]. The JSON Schema of the contract, as a dict.
Raises: KeyError.
example
example(name: str) -> dict[str, Any]
The embedded example document of one contract.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
name | str | yes | Contract name, for example agent-manifest. |
Returns: dict[str, Any]. The example document, decoded from examples/<name>.json.
detect
detect(document: Any) -> str | None
Guess the contract of a document from its kind (manifests only).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
document | Any | yes | Document to inspect; only a dict with a known kind is recognized. |
Returns: str \| None. Contract name such as agent-manifest, or None when the kind is unknown or absent.
validate
validate(document: Any, name: str | None = None) -> ValidationResult
Validate document against contract name (detected from kind when omitted).
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
document | Any | yes | Document to validate, usually a dict decoded from JSON or YAML. | |
name | str | None | None | no | Contract name, for example usage-event; None detects it from the kind of the document. |
Returns: ValidationResult. A ValidationResult: Outcome of :func:validate.
load_documents
load_documents(path: str | Path) -> list[Any]
Load every document of a JSON or (multi document) YAML file.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
path | str | Path | yes | Path of the file; a .yaml or .yml suffix is read as YAML, anything else as JSON. |
Returns: list[Any]. List of the decoded documents, empty YAML documents skipped.
validate_file
validate_file(path: str | Path, name: str | None = None) -> list[ValidationResult]
Validate every document of a file.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
path | str | Path | yes | Path of a JSON or YAML file, possibly holding several YAML documents. | |
name | str | None | None | no | Contract name applied to every document; None detects each from its kind. |
Returns: list[ValidationResult]. List of ValidationResult, one per document of the file.
validate_all
validate_all(documents: Iterable[Any]) -> list[ValidationResult]
Validate several manifests, each by its own kind.
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
documents | Iterable[Any] | yes | Iterable of manifests; the contract of each is detected from its kind. |
Returns: list[ValidationResult]. List of ValidationResult, one per document, in the same order.