utic-public-types 0.1.0.dev0__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.
File without changes
File without changes
@@ -0,0 +1 @@
1
+ This directory is intended to live elsewhere soon.
@@ -0,0 +1,222 @@
1
+ import yaml
2
+ from openapi_pydantic.util import PydanticSchema, construct_open_api_with_schema_class
3
+ from openapi_pydantic.v3 import Info, OpenAPI, Operation, PathItem
4
+
5
+ from utic_public_types.plugins.models import (
6
+ PluginAPIVersion,
7
+ PluginEncryptionProfile,
8
+ PluginInvocationInput,
9
+ PluginInvocationOutput,
10
+ PluginSettings,
11
+ UnstructuredPluginSignature,
12
+ )
13
+
14
+
15
+ def construct_openapi_schema() -> OpenAPI:
16
+ return OpenAPI(
17
+ openapi="3.1.0",
18
+ info=Info(
19
+ title="Unstructured Platform Plugin",
20
+ version=PluginAPIVersion.v20241022,
21
+ summary="HTTP interface for adding capabilities to Unstructured Platform",
22
+ license={
23
+ "name": "Apache 2.0",
24
+ "url": "https://www.apache.org/licenses/LICENSE-2.0.html",
25
+ },
26
+ ),
27
+ servers=[
28
+ {
29
+ "url": "{host}:{port}",
30
+ "description": "When deployed, the server will be invoked as a Kubernetes Sidecar",
31
+ "variables": {
32
+ "host": {
33
+ "default": "127.0.0.1",
34
+ "description": "When deployed within Platform, all incoming requests "
35
+ "will come from sidecars in the same Kubernetes pod.",
36
+ },
37
+ "port": {
38
+ "default": "8000",
39
+ "description": "The platform will only invoke a plugin at port 8000",
40
+ },
41
+ },
42
+ }
43
+ ],
44
+ paths={
45
+ "/id": PathItem(
46
+ get=Operation(
47
+ operationId="get-plugin-id",
48
+ summary="Identify Plugin",
49
+ description="Return the ID of the plugin for debugging and observability",
50
+ responses={
51
+ "200": {
52
+ "description": "The ID of the plugin for debugging and observability",
53
+ "content": {
54
+ "text/*": {
55
+ "example": "acmecorp-fluxcapacitor-v10.21.2015",
56
+ },
57
+ "application/json": {
58
+ "example": '"acmecorp-fluxcapacitor-v10.21.2015"',
59
+ },
60
+ },
61
+ }
62
+ },
63
+ )
64
+ ),
65
+ "/encryption": PathItem(
66
+ get=Operation(
67
+ operationId="get-plugin-encryption",
68
+ summary="Describe encryption capabilities and requirements",
69
+ description="Describe the plugins capabilities and requirements for secure inputs and outputs, "
70
+ "including ability to provide a certificate that, if validated by Platform, will be "
71
+ "used to encrypt all inputs for to the plugin.",
72
+ responses={
73
+ "200": {
74
+ "description": "The plugins capabilities and requirements for secure inputs and outputs",
75
+ "content": {
76
+ "application/json": {
77
+ "schema": PydanticSchema(
78
+ schema_class=PluginEncryptionProfile
79
+ )
80
+ }
81
+ },
82
+ },
83
+ "404": {
84
+ "description": "The plugin does not support encrypted IO",
85
+ },
86
+ },
87
+ )
88
+ ),
89
+ "/settings": PathItem(
90
+ get=Operation(
91
+ operationId="get-plugin-settings",
92
+ summary="Describe available settings",
93
+ description="Describe the plugins user-configurable settings",
94
+ responses={
95
+ "200": {
96
+ "description": "The plugins user-configurable settings",
97
+ "content": {
98
+ "application/json": {
99
+ "schema": PydanticSchema(
100
+ schema_class=PluginSettings
101
+ )
102
+ }
103
+ },
104
+ },
105
+ "404": {
106
+ "description": "The plugin does not support user-configurable settings",
107
+ },
108
+ },
109
+ )
110
+ ),
111
+ "/ready": PathItem(
112
+ get=Operation(
113
+ operationId="plugin-ready",
114
+ summary="Check that configuration is provided and well-formed. Do not perform remote calls.",
115
+ description="Orchestrator will not attempt to invoke until this endpoints returns 200 OK",
116
+ responses={
117
+ "200": {
118
+ "description": "The plugin configuration is provided and well-formed.",
119
+ },
120
+ "400": {
121
+ "description": "Configuration was either not provided, or does not appear well-formed.",
122
+ },
123
+ "5XX": {
124
+ "description": "An error occurred which is not necessarily related to the provided config.",
125
+ },
126
+ },
127
+ )
128
+ ),
129
+ "/check": PathItem(
130
+ post=Operation(
131
+ operationId="plugin-check",
132
+ summary="Perform a lightweight but thorough check of current configuration",
133
+ description="Differs from /ready because this endpoint is expected to perform any necessary "
134
+ "outbound connections, etc. to confirm the validity of provided configuration.",
135
+ responses={
136
+ "200": {
137
+ "description": "The configuration was used in a successful capabilities check.",
138
+ },
139
+ "400": {
140
+ "description": "There is an issue with the provided configuration "
141
+ "and the plugin will not function correctly.",
142
+ },
143
+ "5XX": {
144
+ "description": "The plugin failed due to an issue not likely to be related to configuration.", # noqa
145
+ },
146
+ },
147
+ )
148
+ ),
149
+ "/schema": PathItem(
150
+ get=Operation(
151
+ operationId="get-plugin-schema",
152
+ summary="Describe Input & Output Formats",
153
+ description="Return a description of the plugin inputs and output expectations",
154
+ responses={
155
+ "2XX": {
156
+ "description": "The plugin schema",
157
+ "content": {
158
+ "application/json": {
159
+ "schema": PydanticSchema(
160
+ schema_class=UnstructuredPluginSignature
161
+ )
162
+ }
163
+ },
164
+ }
165
+ },
166
+ )
167
+ ),
168
+ "/invoke": PathItem(
169
+ post=Operation(
170
+ operationId="invoke-plugin",
171
+ summary="Perform Work",
172
+ description="The plugin should perform work. Body includes details on the work item.",
173
+ requestBody={
174
+ "required": True,
175
+ "content": {
176
+ "application/json": {
177
+ "schema": PydanticSchema(
178
+ schema_class=PluginInvocationInput
179
+ ),
180
+ }
181
+ },
182
+ },
183
+ responses={
184
+ "2XX": {
185
+ "description": "The invocation results",
186
+ "content": {
187
+ "application/json": {
188
+ "schema": PydanticSchema(
189
+ schema_class=PluginInvocationOutput
190
+ ),
191
+ }
192
+ },
193
+ },
194
+ "404": {
195
+ "description": "The plugin could not locate the specified input",
196
+ },
197
+ },
198
+ )
199
+ ),
200
+ },
201
+ )
202
+
203
+
204
+ def full_spec():
205
+ open_api = construct_openapi_schema()
206
+ open_api = construct_open_api_with_schema_class(open_api)
207
+ return open_api.model_dump(
208
+ by_alias=True,
209
+ mode="json",
210
+ exclude_none=True,
211
+ exclude_unset=True,
212
+ )
213
+
214
+
215
+ if __name__ == "__main__":
216
+ with open("openapi-draft.yaml", "w") as file:
217
+ file.write(
218
+ yaml.dump(
219
+ full_spec(),
220
+ sort_keys=False,
221
+ )
222
+ )