models¶
Model definition for the domain.
API Reference¶
Shared models.
- class byte_bot.server.domain.db.models.AllowedUsersConfig(**kwargs)[source]¶
Bases:
UUIDAuditBase
SQLAlchemy association model for a guild’s allowed users’ config.
A guild normally has a set of users to perform administrative actions, but sometimes we don’t want to give full administrative access to a user.
This model allows us to configure which users are allowed to perform administrative actions on Byte specifically without giving them full administrative access to the Discord guild.
Todo
More preferably, this should be more generalized to a user OR role ID.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class byte_bot.server.domain.db.models.ForumConfig(**kwargs)[source]¶
Bases:
UUIDAuditBase
Forum configuration.
- A guild will be able to set whether they want help and/or showcase forums.
If they already have them set up, they can configure the channel IDs for them.
If they don’t have them set up, they can configure the category and channel names for them Byte will then create the channels for them.
If they don’t want them, they can disable them.
- Help forum settings include:
Respond with help embed, including a link to ‘Open a GitHub Issue’ if the GitHubConfig:github_organization and GitHubConfig:github_repository are set. Also includes Solve button to mark as solved and close the thread.
Automatic thread closing after a certain period of inactivity.
Uploading of threads into GitHub discussions.
Pinging of defined roles when a thread has not received a response from someone with those roles after a certain period of time.
- Showcase forum settings include:
Respond with showcase embed, including a link to ‘Add to awesome-$repo’ if the GitHubConfig:github_organization and GitHubConfig:github_awesome are set.
Automatic thread closing after a certain period of inactivity.
Uploading of threads into GitHub discussions.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- help_thread_sync: AssociationProxy[bool] = AmbiguousAssociationProxyInstance(AssociationProxy('guild', 'github_config.discussion_sync'))¶
Showcase forum settings.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class byte_bot.server.domain.db.models.GitHubConfig(**kwargs)[source]¶
Bases:
UUIDAuditBase
GitHub configuration.
A guild will be able to configure which organization or user they want as a default base, which repository they want as a default, and whether they would like to sync discussions with forum posts.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class byte_bot.server.domain.db.models.Guild(**kwargs)[source]¶
Bases:
UUIDAuditBase
Guild configuration.
A single guild will contain base defaults (e.g.,
prefix
, boolean flags for linking, etc.) with configurable options that can be set by the guild owner orallowed_users
.Part of the feature set of Byte is that you have interactivity with your git repositories, StackOverflow, Discord forums, and other external services.
Here, a guild should be able to configure their own GitHub organization, StackOverflow tags, etc.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class byte_bot.server.domain.db.models.SOTagsConfig(**kwargs)[source]¶
Bases:
UUIDAuditBase
SQLAlchemy association model for a guild’s Stack Overflow tags config.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
- class byte_bot.server.domain.db.models.User(**kwargs)[source]¶
Bases:
UUIDAuditBase
SQLAlchemy model representing a user.
Todo
This may not really be needed?
Currently, a user in the Byte context is an individual user assigned to the guild’s allowed users config.
In the future we may want to expand this to allow for more granular permissions.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- created_at: Mapped[datetime.datetime]¶
Date/time of instance creation.
- id: Mapped[UUID]¶
UUID Primary key column.
- updated_at: Mapped[datetime.datetime]¶
Date/time of instance last update.
Model Reference¶
- byte_bot.server.domain.db.models.Guild (guild)
Guild configuration.
A single guild will contain base defaults (e.g.,
prefix
, boolean flags for linking, etc.) with configurable options that can be set by the guild owner orallowed_users
.Part of the feature set of Byte is that you have interactivity with your git repositories, StackOverflow, Discord forums, and other external services.
Here, a guild should be able to configure their own GitHub organization, StackOverflow tags, etc.
Columns:
guild_id*
BIGINT
guild_name
VARCHAR(100)
prefix
VARCHAR(5)
help_channel_id
BIGINT?
showcase_channel_id
BIGINT?
sync_label
VARCHAR?
issue_linking
BOOLEAN
comment_linking
BOOLEAN
pep_linking
BOOLEAN
id*
BINARY(16)
sa_orm_sentinel
INTEGER?
created_at
DATETIME
updated_at
DATETIME
Constraints:
PRIMARY KEY (id)
Indexes:
ix_guild_guild_id (guild_id)
- byte_bot.server.domain.db.models.GitHubConfig (github_config)
GitHub configuration.
A guild will be able to configure which organization or user they want as a default base, which repository they want as a default, and whether they would like to sync discussions with forum posts.
Columns:
→ guild_id
BIGINT
discussion_sync
BOOLEAN
github_organization
VARCHAR?
github_repository
VARCHAR?
id*
BINARY(16)
sa_orm_sentinel
INTEGER?
created_at
DATETIME
updated_at
DATETIME
Constraints:
FOREIGN KEY (guild.guild_id → guild_id)
PRIMARY KEY (id)
- byte_bot.server.domain.db.models.SOTagsConfig (so_tags_config)
SQLAlchemy association model for a guild’s Stack Overflow tags config.
Columns:
→ guild_id
BIGINT
tag_name
VARCHAR(50)
id*
BINARY(16)
sa_orm_sentinel
INTEGER?
created_at
DATETIME
updated_at
DATETIME
Constraints:
FOREIGN KEY (guild.guild_id → guild_id)
PRIMARY KEY (id)
UNIQUE (guild_id, tag_name)
- byte_bot.server.domain.db.models.AllowedUsersConfig (allowed_users)
SQLAlchemy association model for a guild’s allowed users’ config.
A guild normally has a set of users to perform administrative actions, but sometimes we don’t want to give full administrative access to a user.
This model allows us to configure which users are allowed to perform administrative actions on Byte specifically without giving them full administrative access to the Discord guild.
Todo
More preferably, this should be more generalized to a user OR role ID.
Columns:
→ guild_id
BIGINT
→ user_id
BINARY(16)
id*
BINARY(16)
sa_orm_sentinel
INTEGER?
created_at
DATETIME
updated_at
DATETIME
Constraints:
FOREIGN KEY (guild.guild_id → guild_id)
FOREIGN KEY (user.id → user_id)
PRIMARY KEY (id)
UNIQUE (guild_id, user_id)
- byte_bot.server.domain.db.models.User (user)
SQLAlchemy model representing a user.
Todo
This may not really be needed?
Currently, a user in the Byte context is an individual user assigned to the guild’s allowed users config.
In the future we may want to expand this to allow for more granular permissions.
Columns:
name
VARCHAR(100)
avatar_url
VARCHAR?
discriminator
VARCHAR(4)
id*
BINARY(16)
sa_orm_sentinel
INTEGER?
created_at
DATETIME
updated_at
DATETIME
Constraints:
PRIMARY KEY (id)
Mermaid Diagram¶
classDiagram AdvancedDeclarativeBase <|-- UUIDAuditBase AsyncAttrs <|-- UUIDAuditBase AuditColumns <|-- UUIDAuditBase ColumnCollectionConstraint <|-- UniqueConstraint CommonTableAttributes <|-- UUIDAuditBase Concatenable <|-- String DDLConstraintColumnRole <|-- Mapped DialectKWArgs <|-- ForeignKey InspectionAttrInfo <|-- AssociationProxy Integer <|-- BigInteger ORMDescriptor <|-- AssociationProxy ORMDescriptor <|-- Mapped SQLORMExpression <|-- Mapped SchemaItem <|-- ForeignKey TypeEngine <|-- String UUIDAuditBase <|-- AllowedUsersConfig UUIDAuditBase <|-- ForumConfig UUIDAuditBase <|-- GitHubConfig UUIDAuditBase <|-- Guild UUIDAuditBase <|-- SOTagsConfig UUIDAuditBase <|-- User UUIDPrimaryKey <|-- UUIDAuditBase _AssociationProxyProtocol <|-- AssociationProxy _DCAttributeOptions <|-- AssociationProxy _MappedAnnotationBase <|-- Mapped