Skip to main content

enterprise_ai.contracts

Source: sdks/python/src/enterprise_ai/contracts/__init__.py. Back to the Python SDK reference index.

note

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:

NameTypeRequiredDescription
pathstryesLocation of the error, path segments joined by / (for example spec/tools/0), or <root> for the whole document.
messagestryesStatus message (up to 2000 characters).

Model ValidationResult​

Outcome of :func:validate.

Fields:

NameTypeRequiredDescription
contractstryesName of the contract checked, or unknown when it could not be detected.
errorslist[SchemaIssue]noList of SchemaIssue, sorted by path; empty when the document is valid.

Attributes:

NameTypeRequiredDescription
validboolyesTrue 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).

NameTypeDefaultRequiredDescription
namestryesName 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).

NameTypeDefaultRequiredDescription
namestryesName of the contract, for example agent-manifest.
documentAnyyesDocument 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.

NameTypeDefaultRequiredDescription
documentAnyyesDocument to validate, usually a dict decoded from JSON or YAML.
namestr | NoneNonenoContract 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).

NameTypeDefaultRequiredDescription
manifestdict[str, Any]yesManifest of any kind (Agent, Model, Tool...), sent as the JSON body.
validate_firstboolTruenoWhen 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).

NameTypeDefaultRequiredDescription
kindstryesKind of manifest, without case: Agent, Model, Tool, Skill, Plugin, Connector or Channel.
namestryesName 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).

NameTypeDefaultRequiredDescription
namestryesContract 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.

NameTypeDefaultRequiredDescription
namestryesContract 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).

NameTypeDefaultRequiredDescription
documentAnyyesDocument 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).

NameTypeDefaultRequiredDescription
documentAnyyesDocument to validate, usually a dict decoded from JSON or YAML.
namestr | NoneNonenoContract 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.

NameTypeDefaultRequiredDescription
pathstr | PathyesPath 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.

NameTypeDefaultRequiredDescription
pathstr | PathyesPath of a JSON or YAML file, possibly holding several YAML documents.
namestr | NoneNonenoContract 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.

NameTypeDefaultRequiredDescription
documentsIterable[Any]yesIterable of manifests; the contract of each is detected from its kind.

Returns: list[ValidationResult]. List of ValidationResult, one per document, in the same order.