Module activitypubdantic.models.object
OBJECT PYDANTIC MODELS FOR VALIDATION
Documentation: https://www.w3.org/TR/activitystreams-vocabulary/#object-types
Expand source code
# -*- coding: utf-8 -*-
"""
OBJECT PYDANTIC MODELS FOR VALIDATION \n
Documentation: https://www.w3.org/TR/activitystreams-vocabulary/#object-types
"""
# Import Pydantic models and types
from datetime import datetime
from pydantic import field_validator
from typing import List, Literal, Union
# Import core models that are required for the actor definition
# Not all will be directly called
from activitypubdantic.models.core import (
DocumentModel,
ImageModel,
LinkModel,
ObjectModel,
PlaceModel,
validate_list_links_or_objects,
validate_list_objects,
)
"""
OBJECT TYPES
"""
class RelationshipModel(ObjectModel):
"""
Describes a relationship between two individuals.
"""
# Type
type: Literal["Relationship"] = "Relationship"
# Properties
subject: Union[None, List[Union[None, LinkModel, ObjectModel]]] = None
object: Union[None, List[Union[None, LinkModel, ObjectModel]]] = None
relationship: Union[None, List[Union[None, ObjectModel]]] = None
# Validators
_relationship_list_links_or_objects = field_validator(
"subject", "object", mode="before"
)(validate_list_links_or_objects)
_relationship_list_objects = field_validator("relationship", mode="before")(
validate_list_objects
)
class ArticleModel(ObjectModel):
"""
Represents any kind of multi-paragraph written work.
"""
# Type
type: Literal["Article"] = "Article"
class AudioModel(DocumentModel):
"""
Represents an audio document of any kind.
"""
# Type
type: Literal["Audio"] = "Audio"
class VideoModel(DocumentModel):
"""
Represents a video document of any kind.
"""
# Type
type: Literal["Video"] = "Video"
class NoteModel(ObjectModel):
"""
Represents a short written work typically less than a single paragraph in length.
"""
# Type
type: Literal["Note"] = "Note"
class PageModel(DocumentModel):
"""
Represents a Web Page.
"""
# Type
type: Literal["Page"] = "Page"
class EventModel(ObjectModel):
"""
Represents any kind of event.
"""
# Type
type: Literal["Event"] = "Event"
class ProfileModel(ObjectModel):
"""
A Profile is a content object that describes another Object.
Typically used to describe Actor Type objects.
"""
# Type
type: Literal["Profile"] = "Profile"
# Properties
describes: Union[None, ObjectModel] = None
class TombstoneModel(ObjectModel):
"""
A Tombstone represents a content object that has been deleted.
"""
# Type
type: Literal["Tombstone"] = "Tombstone"
# Properties
former_type: Union[None, ObjectModel] = None
deleted: Union[None, datetime] = None
Classes
class ArticleModel (id: HttpUrl = None, **kwargs)
-
Represents any kind of multi-paragraph written work.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class ArticleModel(ObjectModel): """ Represents any kind of multi-paragraph written work. """ # Type type: Literal["Article"] = "Article"
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Article']
class AudioModel (id: HttpUrl = None, **kwargs)
-
Represents an audio document of any kind.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class AudioModel(DocumentModel): """ Represents an audio document of any kind. """ # Type type: Literal["Audio"] = "Audio"
Ancestors
- DocumentModel
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Audio']
class EventModel (id: HttpUrl = None, **kwargs)
-
Represents any kind of event.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class EventModel(ObjectModel): """ Represents any kind of event. """ # Type type: Literal["Event"] = "Event"
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Event']
class NoteModel (id: HttpUrl = None, **kwargs)
-
Represents a short written work typically less than a single paragraph in length.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class NoteModel(ObjectModel): """ Represents a short written work typically less than a single paragraph in length. """ # Type type: Literal["Note"] = "Note"
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Note']
class PageModel (id: HttpUrl = None, **kwargs)
-
Represents a Web Page.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class PageModel(DocumentModel): """ Represents a Web Page. """ # Type type: Literal["Page"] = "Page"
Ancestors
- DocumentModel
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Page']
class ProfileModel (id: HttpUrl = None, **kwargs)
-
A Profile is a content object that describes another Object. Typically used to describe Actor Type objects.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class ProfileModel(ObjectModel): """ A Profile is a content object that describes another Object. Typically used to describe Actor Type objects. """ # Type type: Literal["Profile"] = "Profile" # Properties describes: Union[None, ObjectModel] = None
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var describes : Optional[None]
var model_config
var model_fields
var type : Literal['Profile']
class RelationshipModel (id: HttpUrl = None, **kwargs)
-
Describes a relationship between two individuals.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class RelationshipModel(ObjectModel): """ Describes a relationship between two individuals. """ # Type type: Literal["Relationship"] = "Relationship" # Properties subject: Union[None, List[Union[None, LinkModel, ObjectModel]]] = None object: Union[None, List[Union[None, LinkModel, ObjectModel]]] = None relationship: Union[None, List[Union[None, ObjectModel]]] = None # Validators _relationship_list_links_or_objects = field_validator( "subject", "object", mode="before" )(validate_list_links_or_objects) _relationship_list_objects = field_validator("relationship", mode="before")( validate_list_objects )
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var object : Optional[None]
var relationship : Optional[None]
var subject : Optional[None]
var type : Literal['Relationship']
class TombstoneModel (id: HttpUrl = None, **kwargs)
-
A Tombstone represents a content object that has been deleted.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class TombstoneModel(ObjectModel): """ A Tombstone represents a content object that has been deleted. """ # Type type: Literal["Tombstone"] = "Tombstone" # Properties former_type: Union[None, ObjectModel] = None deleted: Union[None, datetime] = None
Ancestors
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var deleted : Optional[None]
var former_type : Optional[None]
var model_config
var model_fields
var type : Literal['Tombstone']
class VideoModel (id: HttpUrl = None, **kwargs)
-
Represents a video document of any kind.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Uses
__pydantic_self__
instead of the more commonself
for the first arg to allowself
as a field name.Expand source code
class VideoModel(DocumentModel): """ Represents a video document of any kind. """ # Type type: Literal["Video"] = "Video"
Ancestors
- DocumentModel
- ObjectModel
- CoreModel
- pydantic.main.BaseModel
Class variables
var model_config
var model_fields
var type : Literal['Video']