-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨(models) clean xAPI pydantic models naming convention
The naming convention used in xAPI Pydantic modelisation was confusing for users. Furthermore, some models are being cross used between several profiles. A new naming convention has been applied for more clarity and to factorize common vocabulary usable in all profiles.
- Loading branch information
1 parent
8af6a84
commit 0d1a748
Showing
79 changed files
with
2,263 additions
and
1,405 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
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
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
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
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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
"""Base xAPI `Agent` definitions.""" | ||
|
||
from typing import Optional, Union | ||
|
||
try: | ||
from typing import Literal | ||
except ImportError: | ||
from typing_extensions import Literal | ||
|
||
from pydantic import AnyUrl, StrictStr, constr | ||
|
||
from ..config import BaseModelWithConfig | ||
from .common import IRI, MailtoEmail | ||
|
||
|
||
class BaseXapiAgentAccount(BaseModelWithConfig): | ||
"""Pydantic model for `Agent` type account` property. | ||
Attributes: | ||
homePage (IRI): Consists of the home page of the account's service provider. | ||
name (str): Consists of the unique id or name of the Actor's account. | ||
""" | ||
|
||
homePage: IRI | ||
name: StrictStr | ||
|
||
|
||
class BaseXapiAgentCommonProperties(BaseModelWithConfig): | ||
"""Pydantic model for core `Agent` type property. | ||
It defines who performed the action. | ||
Attributes: | ||
objectType (str): Consists of the value `Agent`. | ||
name (str): Consists of the full name of the Agent. | ||
""" | ||
|
||
objectType: Optional[Literal["Agent"]] | ||
name: Optional[StrictStr] | ||
|
||
|
||
class BaseXapiAgentWithMboxIFI(BaseXapiAgentCommonProperties): | ||
"""Pydantic model for `Agent` type property. | ||
It defines a mailto Inverse Functional Identifier. | ||
Attributes: | ||
mbox (MailtoEmail): Consists of the Agent's email address. | ||
""" | ||
|
||
mbox: MailtoEmail | ||
|
||
|
||
class BaseXapiAgentWithMboxSha1SumIFI(BaseXapiAgentCommonProperties): | ||
"""Pydantic model for `Agent` type property. | ||
It defines a hash Inverse Functional Identifier. | ||
Attributes: | ||
mbox_sha1sum (str): Consists of the SHA1 hash of the Agent's email address. | ||
""" | ||
|
||
mbox_sha1sum: constr(regex=r"^[0-9a-f]{40}$") # noqa:F722 | ||
|
||
|
||
class BaseXapiAgentWithOpenIdIFI(BaseXapiAgentCommonProperties): | ||
"""Pydantic model for `Agent` type property. | ||
It defines an OpenID Inverse Functional Identifier. | ||
Attributes: | ||
openid (URI): Consists of an openID that uniquely identifies the Agent. | ||
""" | ||
|
||
openid: AnyUrl | ||
|
||
|
||
class BaseXapiAgentWithAccountIFI(BaseXapiAgentCommonProperties): | ||
"""Pydantic model for `Agent` type property. | ||
It defines an account Inverse Functional Identifier. | ||
Attributes: | ||
account (dict): See BaseXapiAgentAccount. | ||
""" | ||
|
||
account: BaseXapiAgentAccount | ||
|
||
|
||
BaseXapiAgent = Union[ | ||
BaseXapiAgentWithMboxIFI, | ||
BaseXapiAgentWithMboxSha1SumIFI, | ||
BaseXapiAgentWithOpenIdIFI, | ||
BaseXapiAgentWithAccountIFI, | ||
] |
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
2 changes: 1 addition & 1 deletion
2
src/ralph/models/xapi/fields/common.py → src/ralph/models/xapi/base/common.py
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,4 +1,4 @@ | ||
"""Common xAPI field definitions.""" | ||
"""Common for xAPI base definitions.""" | ||
|
||
from typing import Dict | ||
|
||
|
Oops, something went wrong.