|
1 | | -# Copyright 2026 UCP Authors |
2 | | -# |
3 | | -# Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | -# you may not use this file except in compliance with the License. |
5 | | -# You may obtain a copy of the License at |
6 | | -# |
7 | | -# http://www.apache.org/licenses/LICENSE-2.0 |
8 | | -# |
9 | | -# Unless required by applicable law or agreed to in writing, software |
10 | | -# distributed under the License is distributed on an "AS IS" BASIS, |
11 | | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | -# See the License for the specific language governing permissions and |
13 | | -# limitations under the License. |
14 | | - |
15 | | -# generated by datamodel-codegen |
16 | | -# pylint: disable=all |
17 | | -# pyformat: disable |
| 1 | +"""Capability models.""" |
18 | 2 |
|
19 | 3 | from __future__ import annotations |
20 | 4 |
|
21 | | -from typing import Annotated, Any |
22 | | - |
23 | | -from pydantic import AnyUrl, BaseModel, ConfigDict, Field |
24 | | -from typing_extensions import TypeAliasType |
25 | | - |
26 | | -from .common.types import reverse_domain_name |
27 | | - |
28 | | -UcpCapability = TypeAliasType( |
29 | | - "UcpCapability", Annotated[Any, Field(..., title="UCP Capability")] |
| 5 | +from .models import ( |
| 6 | + CapabilityBase, |
| 7 | + CapabilityBusinessSchema, |
| 8 | + CapabilityPlatformSchema, |
| 9 | + CapabilityResponseSchema, |
30 | 10 | ) |
31 | | -""" |
32 | | -Schema for UCP capabilities and extensions. Extensions are capabilities with an 'extends' field. Uses reverse-domain naming for governance. |
33 | | -""" |
34 | | - |
35 | | - |
36 | | -Extends = TypeAliasType( |
37 | | - "Extends", |
38 | | - Annotated[ |
39 | | - list[reverse_domain_name.ReverseDomainName], Field(..., min_length=1) |
40 | | - ], |
41 | | -) |
42 | | -""" |
43 | | -Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions. |
44 | | -""" |
45 | | - |
46 | | - |
47 | | -class Base(BaseModel): |
48 | | - model_config = ConfigDict( |
49 | | - extra="allow", |
50 | | - ) |
51 | | - version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$") |
52 | | - """ |
53 | | - Entity version in YYYY-MM-DD format. |
54 | | - """ |
55 | | - spec: AnyUrl | None = None |
56 | | - """ |
57 | | - URL to human-readable specification document. |
58 | | - """ |
59 | | - schema_: AnyUrl | None = Field(None, alias="schema") |
60 | | - """ |
61 | | - URL to JSON Schema defining this entity's structure and payloads. |
62 | | - """ |
63 | | - id: str | None = None |
64 | | - """ |
65 | | - Unique identifier for this entity instance. Used to disambiguate when multiple instances exist. |
66 | | - """ |
67 | | - config: dict[str, Any] | None = None |
68 | | - """ |
69 | | - Entity-specific configuration. Structure defined by each entity's schema. |
70 | | - """ |
71 | | - extends: reverse_domain_name.ReverseDomainName | Extends | None = None |
72 | | - """ |
73 | | - Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions. |
74 | | - """ |
75 | | - |
76 | | - |
77 | | -class PlatformSchema(BaseModel): |
78 | | - """ |
79 | | - Full capability declaration for platform-level discovery. Includes spec/schema URLs for agent fetching. |
80 | | - """ |
81 | | - |
82 | | - model_config = ConfigDict( |
83 | | - extra="allow", |
84 | | - ) |
85 | | - version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$") |
86 | | - """ |
87 | | - Entity version in YYYY-MM-DD format. |
88 | | - """ |
89 | | - spec: AnyUrl |
90 | | - """ |
91 | | - URL to human-readable specification document. |
92 | | - """ |
93 | | - schema_: AnyUrl = Field(..., alias="schema") |
94 | | - """ |
95 | | - URL to JSON Schema defining this entity's structure and payloads. |
96 | | - """ |
97 | | - id: str | None = None |
98 | | - """ |
99 | | - Unique identifier for this entity instance. Used to disambiguate when multiple instances exist. |
100 | | - """ |
101 | | - config: dict[str, Any] | None = None |
102 | | - """ |
103 | | - Entity-specific configuration. Structure defined by each entity's schema. |
104 | | - """ |
105 | | - extends: reverse_domain_name.ReverseDomainName | Extends | None = None |
106 | | - """ |
107 | | - Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions. |
108 | | - """ |
109 | | - |
110 | | - |
111 | | -class BusinessSchema(BaseModel): |
112 | | - """ |
113 | | - Capability declaration for business/merchant discovery. Requires the `schema` URL so platforms can fetch and compose it during negotiation; may also include business-specific config overrides. |
114 | | - """ |
115 | | - |
116 | | - model_config = ConfigDict( |
117 | | - extra="allow", |
118 | | - ) |
119 | | - version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$") |
120 | | - """ |
121 | | - Entity version in YYYY-MM-DD format. |
122 | | - """ |
123 | | - spec: AnyUrl | None = None |
124 | | - """ |
125 | | - URL to human-readable specification document. |
126 | | - """ |
127 | | - schema_: AnyUrl = Field(..., alias="schema") |
128 | | - """ |
129 | | - URL to JSON Schema defining this entity's structure and payloads. |
130 | | - """ |
131 | | - id: str | None = None |
132 | | - """ |
133 | | - Unique identifier for this entity instance. Used to disambiguate when multiple instances exist. |
134 | | - """ |
135 | | - config: dict[str, Any] | None = None |
136 | | - """ |
137 | | - Entity-specific configuration. Structure defined by each entity's schema. |
138 | | - """ |
139 | | - extends: reverse_domain_name.ReverseDomainName | Extends | None = None |
140 | | - """ |
141 | | - Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions. |
142 | | - """ |
143 | | - |
144 | | - |
145 | | -class ResponseSchema(BaseModel): |
146 | | - """ |
147 | | - Capability reference in responses. Only name/version required to confirm active capabilities. |
148 | | - """ |
149 | 11 |
|
150 | | - model_config = ConfigDict( |
151 | | - extra="allow", |
152 | | - ) |
153 | | - version: str = Field(..., pattern="^\\d{4}-\\d{2}-\\d{2}$") |
154 | | - """ |
155 | | - Entity version in YYYY-MM-DD format. |
156 | | - """ |
157 | | - spec: AnyUrl | None = None |
158 | | - """ |
159 | | - URL to human-readable specification document. |
160 | | - """ |
161 | | - schema_: AnyUrl | None = Field(None, alias="schema") |
162 | | - """ |
163 | | - URL to JSON Schema defining this entity's structure and payloads. |
164 | | - """ |
165 | | - id: str | None = None |
166 | | - """ |
167 | | - Unique identifier for this entity instance. Used to disambiguate when multiple instances exist. |
168 | | - """ |
169 | | - config: dict[str, Any] | None = None |
170 | | - """ |
171 | | - Entity-specific configuration. Structure defined by each entity's schema. |
172 | | - """ |
173 | | - extends: reverse_domain_name.ReverseDomainName | Extends | None = None |
174 | | - """ |
175 | | - Parent capability(s) this extends. Present for extensions, absent for root capabilities. Use array for multi-parent extensions. |
176 | | - """ |
| 12 | +Base = CapabilityBase |
| 13 | +__all__ = [ |
| 14 | + "CapabilityBase", |
| 15 | + "CapabilityBusinessSchema", |
| 16 | + "CapabilityPlatformSchema", |
| 17 | + "CapabilityResponseSchema", |
| 18 | + "Base", |
| 19 | +] |
0 commit comments