-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made models compatible to pydantic 2
- Loading branch information
Showing
22 changed files
with
334 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from typing import Optional, List, Dict | ||
|
||
from pydantic import BaseModel | ||
|
||
from typing import Optional, List | ||
from pydantic import BaseModel, Field | ||
|
||
class CustomPayload(BaseModel): | ||
url: Optional[List[str]] | ||
ontology: Optional[List[str]] | ||
url: Optional[List[str]] = Field(default=None) | ||
ontology: Optional[List[str]] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from typing import Optional, List | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class AddOntologyPayload(BaseModel): | ||
url: Optional[List[str]] | ||
url: Optional[List[str]] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
from typing import Optional, List | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class AddTemplatePayload(BaseModel): | ||
url: Optional[List[str]] | ||
url: Optional[List[str]] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} | ||
|
||
class DeleteTemplatePayload(BaseModel): | ||
ids: Optional[List[str]] | ||
ids: Optional[List[str]] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
from typing import Optional, List | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class DeleteOntologyPayload(BaseModel): | ||
ontology: Optional[List[str]] | ||
ontology: Optional[List[str]] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} | ||
|
||
class DeleteOntologyResponse(BaseModel): | ||
deleted: int | ||
deleted: int = Field(default=0) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
from typing import Optional, List, Dict | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class Neo4j(BaseModel): | ||
status: str | ||
version: str | ||
status: str = Field(default="") | ||
version: str = Field(default="") | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} | ||
|
||
class Services(BaseModel): | ||
neo4j: Neo4j | ||
swate: str | ||
rabbitmq: str | ||
swate: str = Field(default="") | ||
rabbitmq: str = Field(default="") | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} | ||
|
||
class Health(BaseModel): | ||
services: Services | ||
status: str | ||
status: str = Field(default="") | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from typing import Optional, List | ||
|
||
from pydantic import BaseModel | ||
|
||
from typing import Optional | ||
from pydantic import BaseModel, Field | ||
|
||
class NotificationPayload(BaseModel): | ||
mail_address: Optional[str] | ||
mail_address: Optional[str] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
from typing import Optional, List, Dict | ||
|
||
from pydantic import BaseModel, validator | ||
from typing import Optional, List | ||
from pydantic import BaseModel, Field, validator | ||
|
||
class MainOntology(BaseModel): | ||
name: str | ||
version: str | ||
lastUpdated: str | ||
name: str = Field(default="") | ||
version: str = Field(default="") | ||
lastUpdated: str = Field(default="") | ||
|
||
@validator("version", "name", "lastUpdated", pre=True) | ||
@validator("version", "name", "lastUpdated", pre=True, always=True) | ||
def rewrite_name(cls, value): | ||
if value is None: | ||
value = "" | ||
return value | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} | ||
|
||
class Status(BaseModel): | ||
number_terms: int | ||
number_ontologies: int | ||
number_templates: int | ||
number_relationships: int | ||
main_ontologies : List[MainOntology] | ||
|
||
|
||
main_ontologies: List[MainOntology] | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class Author(BaseModel): | ||
name: Optional[str] | ||
email: Optional[str] | ||
username: Optional[str] | ||
name: Optional[str] = Field(default=None) | ||
email: Optional[str] = Field(default=None) | ||
username: Optional[str] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
from typing import Optional, List | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
from app.github.models.author import Author | ||
|
||
|
||
class Commit(BaseModel): | ||
id: Optional[str] | ||
timestamp: Optional[str] | ||
message: Optional[str] | ||
author: Optional[Author] | ||
url: Optional[str] | ||
distinct: Optional[bool] | ||
added: Optional[List[str]] | ||
modified: Optional[List[str]] | ||
removed: Optional[List[str]] | ||
id: Optional[str] = Field(default=None) | ||
timestamp: Optional[str] = Field(default=None) | ||
message: Optional[str] = Field(default=None) | ||
author: Optional[Author] = Field(default=None) | ||
url: Optional[str] = Field(default=None) | ||
distinct: Optional[bool] = Field(default=None) | ||
added: Optional[List[str]] = Field(default_factory=list) | ||
modified: Optional[List[str]] = Field(default_factory=list) | ||
removed: Optional[List[str]] = Field(default_factory=list) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
from app.github.models.user import User | ||
from app.github.models.author import Author | ||
|
||
|
||
class Repository(BaseModel): | ||
id: Optional[int] | ||
node_id: Optional[str] | ||
name: Optional[str] | ||
full_name: Optional[str] | ||
html_url: Optional[str] | ||
stargazers_count: int | ||
watchers_count: int | ||
language: Optional[str] | ||
private: Optional[bool] | ||
owner: Optional[User] | ||
default_branch: Optional[str] | ||
ref: Optional[str] | ||
id: Optional[int] = Field(default=None) | ||
node_id: Optional[str] = Field(default=None) | ||
name: Optional[str] = Field(default=None) | ||
full_name: Optional[str] = Field(default=None) | ||
html_url: Optional[str] = Field(default=None) | ||
stargazers_count: int = Field(default=0) | ||
watchers_count: int = Field(default=0) | ||
language: Optional[str] = Field(default=None) | ||
private: Optional[bool] = Field(default=None) | ||
owner: Optional[User] = Field(default=None) | ||
default_branch: Optional[str] = Field(default=None) | ||
ref: Optional[str] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
class User(BaseModel): | ||
login: Optional[str] | ||
name: Optional[str] | ||
email: Optional[str] | ||
id: Optional[int] | ||
html_url: Optional[str] | ||
login: Optional[str] = Field(default=None) | ||
name: Optional[str] = Field(default=None) | ||
email: Optional[str] = Field(default=None) | ||
id: Optional[int] = Field(default=None) | ||
html_url: Optional[str] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
from typing import Optional, List, Dict | ||
|
||
from pydantic import BaseModel | ||
from typing import Optional, List | ||
from pydantic import BaseModel, Field | ||
|
||
from app.github.models.commit import Commit | ||
from app.github.models.author import Author | ||
from app.github.models.repository import Repository | ||
from app.github.models.user import User | ||
|
||
|
||
class PushWebhookPayload(BaseModel): | ||
ref: Optional[str] | ||
before: Optional[str] | ||
after: Optional[str] | ||
commits: Optional[List[Commit]] | ||
# commits: Optional[Dict(Commit)] | ||
pusher: Optional[Author] | ||
repository: Optional[Repository] | ||
sender: Optional[User] | ||
ref: Optional[str] = Field(default=None) | ||
before: Optional[str] = Field(default=None) | ||
after: Optional[str] = Field(default=None) | ||
commits: Optional[List[Commit]] = Field(default_factory=list) | ||
pusher: Optional[Author] = Field(default=None) | ||
repository: Optional[Repository] = Field(default=None) | ||
sender: Optional[User] = Field(default=None) | ||
|
||
model_config = { | ||
'validate_assignment': True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.