Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
test-it
Pydantic Schema Registry
Commits
e224e9ac
Commit
e224e9ac
authored
Nov 27, 2020
by
ozzeh
Browse files
Add basic Event model
parent
c4e3e1a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
schema_registry/__init__.py
View file @
e224e9ac
from
.client
import
SchemaRegistry
,
Schema
from
.reflection
import
SchemaReflector
from
.models
import
Event
from
.errors
import
SchemaRegistryError
,
ModelNotRegisteredError
schema_registry/client.py
View file @
e224e9ac
...
...
@@ -147,6 +147,11 @@ class SchemaRegistry:
include
=
set
([
"schema_arn"
,
"schema_name"
,
"schema_version"
])
)
def
reflect_event
(
self
)
->
Dict
[
str
,
SchemaReflector
]:
pass
def
send_event
(
self
,
event_bus
,
sender
,
model
:
BaseModel
,
extra_resources
:
List
[
str
]
=
None
):
...
...
schema_registry/models.py
View file @
e224e9ac
from
typing
import
List
,
Optional
,
Dict
,
Literal
from
datetime
import
datetime
from
pydantic
import
create_model
,
BaseModel
,
Field
,
PrivateAttr
from
pydantic
import
create_model
,
BaseModel
,
Field
,
PrivateAttr
,
Json
from
.utils
import
camel_generator
...
...
@@ -57,3 +57,30 @@ class _SchemaVersionsPageModel(_AWSResponseModel):
class
_SchemaPageModel
(
_AWSResponseModel
):
schemas
:
List
[
_SchemaModel
]
class
Event
(
BaseModel
):
event_version
:
str
id
:
str
detail_type
:
str
=
Field
(...,
alias
=
"detail-type"
)
detail
:
Json
source
:
str
account
:
str
region
:
str
time
:
datetime
resources
:
List
[
str
]
@
property
def
schema_registry
(
self
)
->
str
:
return
self
.
detail_type
.
split
(
"/"
,
1
)[
0
]
@
property
def
schema_version
(
self
)
->
str
:
return
self
.
detail_type
.
split
(
":"
)[
1
]
@
property
def
model_name
(
self
)
->
str
:
return
self
.
detail_type
.
split
(
"/"
)[
1
].
split
(
":"
)[
0
]
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment