base
konigle.models.base
¶
Base model classes and mixins for the Konigle SDK.
This module provides the foundation for all resource models, including Active Record functionality, state tracking, and common model patterns.
BaseResource
¶
Bases: BaseModel
Base class providing Active Record functionality to all resources.
This class enables resources to have methods like save(), delete(), and reload() by maintaining a reference to their manager and tracking field modifications.
dirty_fields
property
¶
Get the names of fields that have been modified.
is_dirty
property
¶
Check if the object has unsaved changes.
__setattr__(name, value)
¶
Track field modifications for dirty checking.
adelete()
async
¶
Async version of delete() - Delete this resource from the API.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if deletion was successful |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with an async manager |
APIError
|
If the API request fails |
aload_detail()
async
¶
Async version of load_detail() - Load full detail from API.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Self with updated data from the detail API |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with an async manager |
APIError
|
If the API request fails |
areload()
async
¶
Async version of reload() - Reload fresh data from the API.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Self with updated data from the server |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with an async manager |
APIError
|
If the API request fails |
asave()
async
¶
Async version of save() - Save changes back to the API.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Updated resource instance with fresh data from the server |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with an async manager |
APIError
|
If the API request fails |
delete()
¶
Delete this resource from the API.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if deletion was successful |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with a manager |
APIError
|
If the API request fails |
is_detail_loaded()
¶
Check if detail data is loaded.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if this resource was loaded from a detail endpoint, |
bool
|
or if there are no detail-only fields or foreign key fields. |
bool
|
False if loaded from a list endpoint and has detail-only/foreign key fields. |
is_foreign_key_loaded(field_name)
¶
Check if a foreign key field is fully loaded (not just IDs).
| PARAMETER | DESCRIPTION |
|---|---|
field_name
|
Name of the foreign key field to check
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the field contains full objects, False if just IDs |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If field_name is not a defined foreign key field |
load_detail()
¶
Load full detail from API and update this instance.
Fetches the complete resource from the detail endpoint and updates all fields, including detail-only fields and full foreign key objects.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Self with updated data from the detail API |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with a manager |
APIError
|
If the API request fails |
reload()
¶
Reload fresh data from the API.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Self with updated data from the server |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with a manager |
APIError
|
If the API request fails |
reset_changes()
¶
Reset all changes to original values.
save()
¶
Save changes back to the API.
| RETURNS | DESCRIPTION |
|---|---|
BaseResource
|
Updated resource instance with fresh data from the server |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If resource is not associated with a manager |
APIError
|
If the API request fails |
CreateModel
¶
Bases: BaseModel
Base class for creation models.
Used for models that define fields required/allowed when creating new resources.
Resource
¶
Bases: BaseResource, IDMixin
Standard resource model for resources that have an ID but no timestamps.
Combines BaseResource (Active Record) with IDMixin (id field). Use this for simple resources that don't have created_at/updated_at fields.
SEOMeta
¶
Bases: BaseModel
SEO metadata model for all resource types.
Provides comprehensive SEO and social media metadata fields that can be used across website, commerce, and marketing resources.
description = Field(default='', title='SEO Description', description='Description for SEO purposes, max 160 characters.')
class-attribute
instance-attribute
¶
Description for SEO purposes, max 160 characters.
keywords = Field(default=None, title='SEO Keywords', description='Comma-separated keywords for SEO.')
class-attribute
instance-attribute
¶
Comma-separated keywords for SEO.
og_description = Field(default=None, title='Open Graph Description', description='Description for social sharing, max 160 characters.')
class-attribute
instance-attribute
¶
Description for social sharing, max 160 characters.
og_image = Field(default=None, title='Open Graph Image URL', description='URL of the image for social sharing.')
class-attribute
instance-attribute
¶
URL of the image for social sharing.
og_title = Field(default=None, title='Open Graph Title', description='Title for social sharing, max 70 characters.')
class-attribute
instance-attribute
¶
Title for social sharing, max 70 characters.
title = Field(default=None, title='SEO Title', description='Title for SEO purposes, max 70 characters.')
class-attribute
instance-attribute
¶
Title for SEO purposes, max 70 characters.
TimestampedResource
¶
Bases: BaseResource, IDMixin, TimestampMixin
Resource model for resources that have ID and timestamp fields.
Combines BaseResource (Active Record), IDMixin (id field), and TimestampMixin (created_at, updated_at) for resources that include full timestamp tracking.
UpdateModel
¶
Bases: BaseModel
Base class for update models.
Used for models that define fields allowed when updating existing resources. All fields are optional.