certhub-sdk 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
certhub/__init__.py ADDED
@@ -0,0 +1,86 @@
1
+ """CertHub SDK for Python.
2
+
3
+ >>> from certhub import CertHub
4
+ >>> ch = CertHub() # API key from $CERTHUB_API_KEY
5
+ >>> products = ch.products.list()
6
+ """
7
+
8
+ from ._client import CertHub, Connection
9
+ from ._version import __version__
10
+ from .errors import (
11
+ AmbiguousRelationError,
12
+ APIError,
13
+ AuthenticationError,
14
+ CertHubError,
15
+ ConfigurationError,
16
+ ConnectionNotAllowedError,
17
+ DuplicateRecordsError,
18
+ FieldNotFoundError,
19
+ NotFoundError,
20
+ PermissionDeniedError,
21
+ RateLimitError,
22
+ ReadOnlyError,
23
+ ResponseValidationError,
24
+ ServerError,
25
+ TopicNotFoundError,
26
+ ValidationError,
27
+ )
28
+ from .fields import Field, FieldMap
29
+ from .models import (
30
+ ConnectedNodes,
31
+ GlobalElement,
32
+ KnowledgeTopic,
33
+ KnowledgeUnit,
34
+ Link,
35
+ Node,
36
+ Product,
37
+ Record,
38
+ RecordContext,
39
+ TopicVersion,
40
+ Trace,
41
+ UpsertResult,
42
+ UseCaseRelation,
43
+ )
44
+ from .snapshot import Coverage, Item, Snapshot, TopicSnapshot, TraceLink
45
+
46
+ __all__ = [
47
+ "APIError",
48
+ "AmbiguousRelationError",
49
+ "AuthenticationError",
50
+ "CertHub",
51
+ "CertHubError",
52
+ "ConfigurationError",
53
+ "ConnectedNodes",
54
+ "Connection",
55
+ "ConnectionNotAllowedError",
56
+ "Coverage",
57
+ "DuplicateRecordsError",
58
+ "Field",
59
+ "FieldMap",
60
+ "FieldNotFoundError",
61
+ "GlobalElement",
62
+ "Item",
63
+ "KnowledgeTopic",
64
+ "KnowledgeUnit",
65
+ "Link",
66
+ "Node",
67
+ "NotFoundError",
68
+ "PermissionDeniedError",
69
+ "Product",
70
+ "RateLimitError",
71
+ "ReadOnlyError",
72
+ "Record",
73
+ "RecordContext",
74
+ "ResponseValidationError",
75
+ "ServerError",
76
+ "Snapshot",
77
+ "TopicNotFoundError",
78
+ "TopicSnapshot",
79
+ "TopicVersion",
80
+ "Trace",
81
+ "TraceLink",
82
+ "UpsertResult",
83
+ "UseCaseRelation",
84
+ "ValidationError",
85
+ "__version__",
86
+ ]
certhub/__main__.py ADDED
@@ -0,0 +1,79 @@
1
+ """A tiny CLI to check a key and look around: ``certhub products``, ``certhub snapshot <product>``.
2
+
3
+ Output is JSON lines so it pipes into ``jq``. It is a smoke test, not a second interface.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import argparse
9
+ import json
10
+ import sys
11
+
12
+ from . import CertHub, CertHubError
13
+
14
+
15
+ def _print(obj: dict) -> None:
16
+ print(json.dumps(obj, ensure_ascii=False, default=str))
17
+
18
+
19
+ def main(argv: list[str] | None = None) -> int:
20
+ parser = argparse.ArgumentParser(prog="certhub", description="CertHub API smoke test (needs CERTHUB_API_KEY)")
21
+ parser.add_argument("--environment", help="prod (default) | staging | dev | sandbox")
22
+ sub = parser.add_subparsers(dest="command", required=True)
23
+ sub.add_parser("products", help="List the products the key can see")
24
+ topics = sub.add_parser("topics", help="List the knowledge topics of a product")
25
+ topics.add_argument("product_history_id")
26
+ fields = sub.add_parser("fields", help="List the fields of a knowledge topic (revision ID)")
27
+ fields.add_argument("knowledge_topic_id")
28
+ records = sub.add_parser("records", help="List the records of a knowledge topic (revision ID)")
29
+ records.add_argument("knowledge_topic_id")
30
+ snapshot = sub.add_parser("snapshot", help="Export topics, records and named traces of a product as JSON")
31
+ snapshot.add_argument("product_history_id")
32
+ snapshot.add_argument("--topic", action="append", dest="topics", help="topic name or history ID (repeatable)")
33
+ snapshot.add_argument("--version", help="product version, e.g. 1.2 (default: latest)")
34
+ snapshot.add_argument(
35
+ "--coverage",
36
+ action="append",
37
+ default=[],
38
+ metavar="SOURCE:TARGET",
39
+ help='print coverage to stderr, e.g. "System Requirements:Verification"; exit 2 on gaps',
40
+ )
41
+ args = parser.parse_args(argv)
42
+
43
+ try:
44
+ with CertHub(environment=args.environment) as ch:
45
+ if args.command == "products":
46
+ for p in ch.products.list():
47
+ _print({"name": p.name, "product_history_id": p.product_history_id, "version": p.version})
48
+ elif args.command == "topics":
49
+ for kt in ch.knowledge_topics.list(product_history_id=args.product_history_id):
50
+ _print({"name": kt.name, "id": kt.id, "history_id": kt.knowledge_topic_history_id, "type": kt.type})
51
+ elif args.command == "fields":
52
+ kt = ch.knowledge_topics.get(args.knowledge_topic_id)
53
+ for f in kt.fields.all:
54
+ _print({"certhub_key": f.certhub_key, "form_key": f.form_key, "label": f.label, "type": f.type})
55
+ elif args.command == "records":
56
+ kt = ch.knowledge_topics.get(args.knowledge_topic_id)
57
+ for r in ch.records.list(kt):
58
+ _print({"id": r.id, "name": r.name, "values": r.values(kt)})
59
+ elif args.command == "snapshot":
60
+ snap = ch.snapshot(args.product_history_id, topics=args.topics, version=args.version)
61
+ print(snap.to_json(indent=2))
62
+ gaps = 0
63
+ for pair in args.coverage:
64
+ source, _, target = pair.partition(":")
65
+ coverage = snap.coverage(source, target)
66
+ print(coverage, file=sys.stderr)
67
+ for item in coverage.uncovered:
68
+ print(f" missing: {item.name} ({item.id})", file=sys.stderr)
69
+ gaps += len(coverage.uncovered)
70
+ if gaps:
71
+ return 2
72
+ except CertHubError as exc:
73
+ print(f"error: {exc}", file=sys.stderr)
74
+ return 1
75
+ return 0
76
+
77
+
78
+ if __name__ == "__main__":
79
+ sys.exit(main())
certhub/_client.py ADDED
@@ -0,0 +1,218 @@
1
+ """The :class:`CertHub` client: one object, one API key, every public service."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from collections.abc import Iterable, Mapping
7
+ from dataclasses import dataclass
8
+
9
+ import httpx
10
+
11
+ from ._generated import Apis
12
+ from ._transport import Transport, base_urls_for
13
+ from ._version import __version__
14
+ from .errors import AmbiguousRelationError, ConfigurationError, ConnectionNotAllowedError
15
+ from .models import KnowledgeTopic, Record, Trace, UseCaseRelation
16
+ from .resources import GlobalElements, KnowledgeTopics, KnowledgeUnits, Products, Records, Traces
17
+ from .resources.techdoc import _normalize
18
+ from .resources.tracer import USE_CASE_RELATION
19
+ from .snapshot import Snapshot, build_snapshot
20
+
21
+ API_KEY_ENV = "CERTHUB_API_KEY"
22
+ ENVIRONMENT_ENV = "CERTHUB_ENVIRONMENT"
23
+
24
+
25
+ @dataclass(frozen=True)
26
+ class Connection:
27
+ """A use-case connection made by :meth:`CertHub.connect`."""
28
+
29
+ trace: Trace
30
+ relation: UseCaseRelation
31
+ source_topic: KnowledgeTopic
32
+
33
+
34
+ class CertHub:
35
+ """Client for the public CertHub API.
36
+
37
+ >>> ch = CertHub() # reads CERTHUB_API_KEY
38
+ >>> for product in ch.products.list():
39
+ ... print(product.name, product.product_history_id)
40
+
41
+ Args:
42
+ api_key: The key from Settings -> API Keys. Defaults to ``$CERTHUB_API_KEY``.
43
+ environment: ``prod`` (default, or ``$CERTHUB_ENVIRONMENT``); the others are internal.
44
+ base_urls: Override the URL of single services, e.g. ``{"records": "http://localhost:8000"}``.
45
+ timeout: Seconds per request.
46
+ max_retries: Retries for safe requests on 429/502/503/504 and network errors.
47
+ Requests that create something (``POST``) are never retried.
48
+ http_client: Bring your own ``httpx.Client`` (proxies, custom TLS, tests).
49
+ """
50
+
51
+ def __init__(
52
+ self,
53
+ api_key: str | None = None,
54
+ *,
55
+ environment: str | None = None,
56
+ base_urls: Mapping[str, str] | None = None,
57
+ timeout: float = 30.0,
58
+ max_retries: int = 2,
59
+ http_client: httpx.Client | None = None,
60
+ ) -> None:
61
+ api_key = api_key or os.environ.get(API_KEY_ENV)
62
+ if not api_key:
63
+ raise ConfigurationError(
64
+ f"No API key. Pass api_key= or set {API_KEY_ENV}. Create one in CertHub: Settings -> API Keys."
65
+ )
66
+ self.environment = environment or os.environ.get(ENVIRONMENT_ENV) or "prod"
67
+ urls = base_urls_for(self.environment)
68
+ urls.update(base_urls or {})
69
+ self._transport = Transport(
70
+ api_key=api_key,
71
+ base_urls=urls,
72
+ timeout=timeout,
73
+ max_retries=max_retries,
74
+ user_agent=f"certhub-sdk-python/{__version__}",
75
+ http_client=http_client,
76
+ )
77
+ #: The generated client of every public API: ``ch.api.records.read_record(id)`` and so on.
78
+ #: Typed models in, typed models out; regenerated from the OpenAPI documents
79
+ #: (``make update``). The resources below are the hand-written convenience layer on top.
80
+ self.api = Apis(self._transport)
81
+ self.products = Products(self._transport)
82
+ self.knowledge_units = KnowledgeUnits(self._transport)
83
+ self.knowledge_topics = KnowledgeTopics(self._transport)
84
+ self.records = Records(self._transport, self.knowledge_topics, self.knowledge_units)
85
+ self.traces = Traces(self._transport)
86
+ self.global_elements = GlobalElements(self._transport)
87
+
88
+ @property
89
+ def base_urls(self) -> dict[str, str]:
90
+ return dict(self._transport.base_urls)
91
+
92
+ def close(self) -> None:
93
+ self._transport.close()
94
+
95
+ def __enter__(self) -> CertHub: # noqa: PYI034 (typing.Self needs 3.11)
96
+ return self
97
+
98
+ def __exit__(self, *exc: object) -> None:
99
+ self.close()
100
+
101
+ def __repr__(self) -> str:
102
+ return f"CertHub(environment={self.environment!r})"
103
+
104
+ # -- cross-service workflows ---------------------------------------------------
105
+
106
+ def snapshot(
107
+ self,
108
+ product_history_id: str,
109
+ *,
110
+ topics: Iterable[str] | None = None,
111
+ version: str | None = None,
112
+ latest_approved: bool = False,
113
+ include_families: bool = False,
114
+ traces: bool = True,
115
+ max_workers: int = 4,
116
+ ) -> Snapshot:
117
+ """Everything about a product's topics in one consistent, joined view.
118
+
119
+ >>> snap = ch.snapshot(PRODUCT_ID, topics=["System Requirements", "Verification"])
120
+ >>> req = snap["System Requirements"].get("SR-001", field="req-id")
121
+ >>> req.values # fields by certhub-key
122
+ >>> req.linked("Verified By") # Items, named by the use case
123
+ >>> print(snap.coverage("System Requirements", "Verification"))
124
+
125
+ Args:
126
+ product_history_id: The product's history ID (the ID in the dashboard URL).
127
+ topics: Topic names or history IDs; all topics of the product when omitted
128
+ (one Records call per topic, so name the ones you need).
129
+ version: Pin the product version ("1.2"); the latest when omitted. Every
130
+ topic is taken at that version, so the run sees one snapshot.
131
+ latest_approved: The latest approved version instead of the latest.
132
+ include_families: Also the knowledge units the product shares through its
133
+ product families (a use case can link across them).
134
+ traces: Load and join the traces (Tracer + the topics' use-case relations).
135
+ max_workers: Requests in flight at once while loading topics (bounded on purpose).
136
+ """
137
+ return build_snapshot(
138
+ self,
139
+ product_history_id,
140
+ topics=topics,
141
+ version=version,
142
+ latest_approved=latest_approved,
143
+ include_families=include_families,
144
+ traces=traces,
145
+ max_workers=max_workers,
146
+ )
147
+
148
+ def connect(self, source: Record | str, target: Record | str, *, relation: str | None = None) -> Connection:
149
+ """Connect two records the way the CertHub use-case columns do.
150
+
151
+ This is what the dashboard does when a record is picked in a use-case column,
152
+ across three services:
153
+
154
+ 1. **Records**: load both records to learn their knowledge topics.
155
+ 2. **Tech Doc**: load the source topic's use-case relations and the target
156
+ topic's history ID, and pick the relation that points at the target topic
157
+ (``relation=`` names it when there are several, e.g. ``"Verified By"``).
158
+ 3. **Tracer**: create a ``connected_within_use_case`` trace, both ways when
159
+ the relation is bidirectional, so it shows in the right column on both sides.
160
+
161
+ Raises :class:`ConnectionNotAllowedError` when the use case does not connect the
162
+ two topics, and :class:`AmbiguousRelationError` when ``relation`` is needed.
163
+ """
164
+ src = source if isinstance(source, Record) and source.context else self.records.get(_record_id(source))
165
+ tgt = target if isinstance(target, Record) and target.context else self.records.get(_record_id(target))
166
+ if not src.knowledge_topic_id or not tgt.knowledge_topic_id:
167
+ raise ConnectionNotAllowedError("Both records must belong to a knowledge topic")
168
+
169
+ source_topic = self.knowledge_topics.get(src.knowledge_topic_id, include_use_case_config=True)
170
+ if tgt.knowledge_topic_id == src.knowledge_topic_id:
171
+ target_history_id = source_topic.knowledge_topic_history_id
172
+ else:
173
+ target_history_id = self.knowledge_topics.get(tgt.knowledge_topic_id).knowledge_topic_history_id
174
+
175
+ chosen = _pick_relation(source_topic, target_history_id, relation)
176
+ trace = self.traces.create(
177
+ src,
178
+ tgt,
179
+ relation_type=USE_CASE_RELATION,
180
+ bidirectional=chosen.bidirection,
181
+ manual_source="use_case",
182
+ )
183
+ return Connection(trace=trace, relation=chosen, source_topic=source_topic)
184
+
185
+
186
+ def _record_id(record: Record | str) -> str:
187
+ if isinstance(record, Record):
188
+ if not record.id:
189
+ raise ValueError("This Record has no id")
190
+ return record.id
191
+ return record
192
+
193
+
194
+ def _pick_relation(topic: KnowledgeTopic, target_history_id: str | None, relation: str | None) -> UseCaseRelation:
195
+ relations = topic.relations
196
+ to_target = [r for r in relations if target_history_id and r.target_knowledge_topic_history_id == target_history_id]
197
+ if relation is not None:
198
+ named = [r for r in to_target if _normalize(r.relation_name) == _normalize(relation)]
199
+ if not named:
200
+ raise ConnectionNotAllowedError(
201
+ f"{topic.name!r} has no relation {relation!r} to that record's topic. "
202
+ f"Relations to it: {_names(to_target) or 'none'}."
203
+ )
204
+ to_target = named
205
+ if not to_target:
206
+ available = ", ".join(f"{r.relation_name} -> {r.target_knowledge_topic_name}" for r in relations)
207
+ raise ConnectionNotAllowedError(
208
+ f"The use case of {topic.name!r} does not connect it to that record's topic. "
209
+ f"Its relations: {available or 'none (the topic is not part of a use case)'}. "
210
+ "Use ch.traces.create() for a plain trace instead."
211
+ )
212
+ if len(to_target) > 1:
213
+ raise AmbiguousRelationError(f"Several relations fit; pass relation= one of: {_names(to_target)}")
214
+ return to_target[0]
215
+
216
+
217
+ def _names(relations: list[UseCaseRelation]) -> str:
218
+ return ", ".join(repr(r.relation_name) for r in relations)
@@ -0,0 +1,33 @@
1
+ # Generated by scripts/generate.py from schemas/*.json. Do not edit: run `make generate`.
2
+ """The generated layer: every public CertHub API, as ``ch.api.<name>``."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import TYPE_CHECKING, Any
7
+
8
+ from .._runtime import Request
9
+ from .documents.api import DocumentsApi
10
+ from .records.api import RecordsApi
11
+ from .techdoc.api import TechDocApi
12
+ from .tracer.api import TracerApi
13
+
14
+ if TYPE_CHECKING:
15
+ from .._transport import Transport
16
+
17
+
18
+ class Apis:
19
+ """The generated clients, one per API in apis.toml."""
20
+
21
+ def __init__(self, transport: Transport) -> None:
22
+ self._transport = transport
23
+ self.techdoc = TechDocApi(transport)
24
+ self.records = RecordsApi(transport)
25
+ self.tracer = TracerApi(transport)
26
+ self.documents = DocumentsApi(transport)
27
+
28
+ def raw(self, request: Request) -> Any:
29
+ """Send a ``build_*`` request and return the decoded JSON, unvalidated."""
30
+ return self._transport.send(request)
31
+
32
+
33
+ __all__ = ["Apis", "DocumentsApi", "RecordsApi", "Request", "TechDocApi", "TracerApi"]
@@ -0,0 +1,9 @@
1
+ # Generated by scripts/generate.py from schemas/*.json. Do not edit: run `make generate`.
2
+ """Which host serves which generated API (from apis.toml)."""
3
+
4
+ SERVICES: dict[str, str] = {
5
+ "techdoc": "techdoc",
6
+ "records": "records",
7
+ "tracer": "tracer",
8
+ "documents": "documents",
9
+ }
@@ -0,0 +1 @@
1
+ # Generated by scripts/generate.py from schemas/documents.json. Do not edit: run `make generate`.
@@ -0,0 +1,65 @@
1
+ # Generated by scripts/generate.py from schemas/documents.json. Do not edit: run `make generate`.
2
+ """The public documents API: request builders and the generated client."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from collections.abc import Mapping
7
+ from typing import TYPE_CHECKING, Any
8
+
9
+ from ..._runtime import Request, dump, parse, segment
10
+ from . import models
11
+
12
+ if TYPE_CHECKING:
13
+ from ..._transport import Transport
14
+
15
+ SERVICE = "documents"
16
+
17
+
18
+ def build_create_new_document_history(body: models.DocumentHistoryCreate | Mapping[str, Any]) -> Request:
19
+ """Create New Document History.
20
+
21
+ ``POST /documents/histories/``
22
+ """
23
+ return Request(SERVICE, "POST", "/documents/histories/", params=None, json=dump(body))
24
+
25
+
26
+ def build_create_new_document_revision(
27
+ document_id: str, body: models.DocumentRevisionCreate | Mapping[str, Any]
28
+ ) -> Request:
29
+ """Create New Document Revision.
30
+
31
+ ``POST /documents/revisions/{document_id}``
32
+ """
33
+ return Request(SERVICE, "POST", f"/documents/revisions/{segment(document_id)}", params=None, json=dump(body))
34
+
35
+
36
+ class DocumentsApi:
37
+ """Every public operation of the documents API, one typed method each.
38
+
39
+ Generated: reach it as ``ch.api.documents``. Methods return Pydantic models from
40
+ ``certhub.openapi.documents``; ``ch.api.raw`` sends a ``build_*`` request
41
+ and returns the JSON as-is.
42
+ """
43
+
44
+ def __init__(self, transport: Transport) -> None:
45
+ self._transport = transport
46
+
47
+ def create_new_document_history(
48
+ self, body: models.DocumentHistoryCreate | Mapping[str, Any]
49
+ ) -> models.DocumentHistory:
50
+ """Create New Document History.
51
+
52
+ ``POST /documents/histories/``
53
+ """
54
+ return parse(models.DocumentHistory, self._transport.send(build_create_new_document_history(body)))
55
+
56
+ def create_new_document_revision(
57
+ self, document_id: str, body: models.DocumentRevisionCreate | Mapping[str, Any]
58
+ ) -> models.DocumentRevision:
59
+ """Create New Document Revision.
60
+
61
+ ``POST /documents/revisions/{document_id}``
62
+ """
63
+ return parse(
64
+ models.DocumentRevision, self._transport.send(build_create_new_document_revision(document_id, body))
65
+ )
@@ -0,0 +1,180 @@
1
+ # Generated by scripts/generate.py from schemas/documents.json. Do not edit: run `make generate`.
2
+
3
+ from __future__ import annotations
4
+
5
+ from datetime import datetime
6
+ from enum import Enum
7
+ from typing import Annotated, Any
8
+
9
+ from pydantic import BaseModel, ConfigDict, Field
10
+
11
+
12
+ class ApprovalProcessSettings(BaseModel):
13
+ model_config = ConfigDict(
14
+ extra="allow",
15
+ populate_by_name=True,
16
+ )
17
+ author_principal_id: Annotated[str | None, Field(title="Author Principal Id")] = None
18
+ reviewer_principal_ids: Annotated[list[str] | None, Field(title="Reviewer Principal Ids")] = None
19
+ owner_principal_id: Annotated[str | None, Field(title="Owner Principal Id")] = None
20
+ auto_publish: Annotated[bool | None, Field(title="Auto Publish")] = False
21
+
22
+
23
+ class DocumentContext(BaseModel):
24
+ model_config = ConfigDict(
25
+ extra="allow",
26
+ populate_by_name=True,
27
+ )
28
+ sop: Annotated[int | None, Field(title="Sop")] = None
29
+ work_instruction: Annotated[int | None, Field(title="Work Instruction")] = None
30
+ form: Annotated[int | None, Field(title="Form")] = None
31
+ product: Annotated[str | None, Field(title="Product")] = None
32
+ product_family: Annotated[str | None, Field(title="Product Family")] = None
33
+ group_id: Annotated[str | None, Field(title="Group Id")] = None
34
+ filter_tag: Annotated[str | None, Field(title="Filter Tag")] = None
35
+
36
+
37
+ class DocumentRevisionPreview(BaseModel):
38
+ model_config = ConfigDict(
39
+ extra="allow",
40
+ populate_by_name=True,
41
+ )
42
+ version: Annotated[str, Field(title="Version")]
43
+ commit_message: Annotated[str, Field(title="Commit Message")]
44
+ context: DocumentContext | None = None
45
+ revision_id: Annotated[str, Field(examples=["5eb7cf5a86d9755df3a6c593"], title="Revision Id")]
46
+ read_only: Annotated[bool | None, Field(title="Read Only")] = False
47
+ is_latest_approved: Annotated[bool | None, Field(title="Is Latest Approved")] = False
48
+ abbreviation: Annotated[str | None, Field(title="Abbreviation")] = None
49
+
50
+
51
+ class LastActionType(str, Enum):
52
+ created = "created"
53
+ updated = "updated"
54
+ published = "published"
55
+
56
+
57
+ class PageOrientation(str, Enum):
58
+ portrait = "portrait"
59
+ landscape = "landscape"
60
+
61
+
62
+ class TenantMetadata(BaseModel):
63
+ model_config = ConfigDict(
64
+ extra="allow",
65
+ populate_by_name=True,
66
+ )
67
+ tenant_id: Annotated[str, Field(title="Tenant Id")]
68
+
69
+
70
+ class ValidationError(BaseModel):
71
+ model_config = ConfigDict(
72
+ extra="allow",
73
+ populate_by_name=True,
74
+ )
75
+ loc: Annotated[list[str | int], Field(title="Location")]
76
+ msg: Annotated[str, Field(title="Message")]
77
+ type: Annotated[str, Field(title="Error Type")]
78
+ input: Annotated[Any | None, Field(title="Input")] = None
79
+ ctx: Annotated[dict[str, Any] | None, Field(title="Context")] = None
80
+
81
+
82
+ class AuditInfo(BaseModel):
83
+ model_config = ConfigDict(
84
+ extra="allow",
85
+ populate_by_name=True,
86
+ )
87
+ user_id_created: Annotated[str, Field(title="User Id Created")]
88
+ timestamp_created: Annotated[datetime, Field(title="Timestamp Created")]
89
+ user_id_last_updated: Annotated[str | None, Field(title="User Id Last Updated")] = None
90
+ timestamp_last_updated: Annotated[datetime | None, Field(title="Timestamp Last Updated")] = None
91
+ last_action: LastActionType
92
+ direct_approval_published_at: Annotated[datetime | None, Field(title="Direct Approval Published At")] = None
93
+ direct_approval_published_by: Annotated[str | None, Field(title="Direct Approval Published By")] = None
94
+
95
+
96
+ class DocumentHistory(BaseModel):
97
+ model_config = ConfigDict(
98
+ extra="allow",
99
+ populate_by_name=True,
100
+ )
101
+ id: Annotated[str | None, Field(alias="_id", title="Id")] = None
102
+ """
103
+ MongoDB document ObjectID
104
+ """
105
+ title: Annotated[str, Field(title="Title")]
106
+ current_version: Annotated[str | None, Field(title="Current Version")] = "0.0"
107
+ revisions: Annotated[list[DocumentRevisionPreview], Field(title="Revisions")]
108
+ creates_record: Annotated[bool | None, Field(title="Creates Record")] = False
109
+ template_id: Annotated[str | None, Field(title="Template Id")] = None
110
+ parent_folder_id: Annotated[str | None, Field(title="Parent Folder Id")] = None
111
+ tenant_metadata: TenantMetadata
112
+ abbreviation: Annotated[str | None, Field(title="Abbreviation")] = None
113
+ summary: Annotated[str | None, Field(title="Summary")] = None
114
+ audit_info: AuditInfo
115
+ jurisdiction_ids: Annotated[list[str] | None, Field(title="Jurisdiction Ids")] = None
116
+
117
+
118
+ class DocumentHistoryCreate(BaseModel):
119
+ model_config = ConfigDict(
120
+ extra="allow",
121
+ populate_by_name=True,
122
+ )
123
+ title: Annotated[str, Field(title="Title")]
124
+ template_id: Annotated[str | None, Field(title="Template Id")] = None
125
+ context: DocumentContext | None = None
126
+ parent_folder_id: Annotated[str | None, Field(title="Parent Folder Id")] = None
127
+ abbreviation: Annotated[str | None, Field(title="Abbreviation")] = None
128
+ jurisdiction_ids: Annotated[list[str] | None, Field(title="Jurisdiction Ids")] = None
129
+ page_orientation: PageOrientation | None = None
130
+
131
+
132
+ class DocumentRevision(BaseModel):
133
+ model_config = ConfigDict(
134
+ extra="allow",
135
+ populate_by_name=True,
136
+ )
137
+ id: Annotated[str | None, Field(alias="_id", title="Id")] = None
138
+ """
139
+ MongoDB document ObjectID
140
+ """
141
+ parent_id: Annotated[str | None, Field(title="Parent Id")] = None
142
+ title: Annotated[str, Field(title="Title")]
143
+ version: Annotated[str, Field(title="Version")]
144
+ commit_message: Annotated[str, Field(title="Commit Message")]
145
+ read_only: Annotated[bool | None, Field(title="Read Only")] = False
146
+ is_latest_approved: Annotated[bool | None, Field(title="Is Latest Approved")] = False
147
+ tenant_metadata: TenantMetadata
148
+ audit_info: AuditInfo
149
+ context: DocumentContext | None = None
150
+ approval_process_settings: ApprovalProcessSettings | None = None
151
+ approval_signature: Annotated[dict[str, Any] | None, Field(title="Approval Signature")] = None
152
+ data: Annotated[dict[str, Any] | None, Field(title="Data")] = {}
153
+ summary: Annotated[str | None, Field(title="Summary")] = None
154
+ abbreviation: Annotated[str | None, Field(title="Abbreviation")] = None
155
+ jurisdiction_ids: Annotated[list[str] | None, Field(title="Jurisdiction Ids")] = None
156
+ page_orientation: PageOrientation | None = "portrait"
157
+
158
+
159
+ class DocumentRevisionCreate(BaseModel):
160
+ model_config = ConfigDict(
161
+ extra="allow",
162
+ populate_by_name=True,
163
+ )
164
+ title: Annotated[str, Field(title="Title")]
165
+ data: Annotated[dict[str, Any], Field(title="Data")]
166
+ commit_message: Annotated[str, Field(title="Commit Message")]
167
+ context: DocumentContext | None
168
+ abbreviation: Annotated[str | None, Field(title="Abbreviation")] = None
169
+ approval_process_settings: ApprovalProcessSettings | None = None
170
+ jurisdiction_ids: Annotated[list[str] | None, Field(title="Jurisdiction Ids")] = None
171
+ summary: Annotated[str | None, Field(title="Summary")] = None
172
+ page_orientation: PageOrientation | None = None
173
+
174
+
175
+ class HTTPValidationError(BaseModel):
176
+ model_config = ConfigDict(
177
+ extra="allow",
178
+ populate_by_name=True,
179
+ )
180
+ detail: Annotated[list[ValidationError] | None, Field(title="Detail")] = None
@@ -0,0 +1 @@
1
+ # Generated by scripts/generate.py from schemas/records.json. Do not edit: run `make generate`.