tba-storage-operator 0.4.0.dev2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tba_storage_operator-0.4.0.dev2/PKG-INFO +22 -0
- tba_storage_operator-0.4.0.dev2/README.md +3 -0
- tba_storage_operator-0.4.0.dev2/pyproject.toml +20 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/__init__.py +7 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/component.toml +41 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/manifest.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/migrations/__init__.py +0 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/migrations/versions/469839b2_d339_544a_b747_fd68b6a5f235_initial_schema.py +33 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/migrations/versions/__init__.py +0 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/py.typed +0 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/__init__.py +20 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_activity/__init__.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_activity/_table.py +29 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_audit_event/__init__.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_audit_event/_table.py +29 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_metadata/__init__.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_metadata/_table.py +19 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_record/__init__.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_record/_table.py +44 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_transaction/__init__.py +9 -0
- tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_transaction/_table.py +33 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-storage-operator
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Owned operator identity database tables and migrations.
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.15
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Dist: tba-primitives-identity[storage] (>=0.4.0.dev2)
|
|
15
|
+
Requires-Dist: tigrbl (>=0.4.4.dev1,<0.5)
|
|
16
|
+
Requires-Dist: tigrbl-migrations (>=0.4.5.dev4)
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# tba-storage-operator
|
|
20
|
+
|
|
21
|
+
Owns the `tigrbl.identity.storage.operator` schema component.
|
|
22
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-storage-operator"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Owned operator identity database tables and migrations."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
license = { text = "Apache-2.0" }
|
|
8
|
+
dependencies = [
|
|
9
|
+
"tigrbl>=0.4.4.dev1,<0.5",
|
|
10
|
+
"tigrbl-migrations>=0.4.5.dev4",
|
|
11
|
+
"tba-primitives-identity[storage]>=0.4.0.dev2",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[build-system]
|
|
15
|
+
requires = ["poetry-core>=1.0.0"]
|
|
16
|
+
build-backend = "poetry.core.masonry.api"
|
|
17
|
+
|
|
18
|
+
[tool.poetry]
|
|
19
|
+
packages = [{ include = "tba_storage_operator", from = "src" }]
|
|
20
|
+
include = ["src/tba_storage_operator/component.toml"]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Standalone identity storage component."""
|
|
2
|
+
|
|
3
|
+
from .manifest import MANIFEST, load_manifest
|
|
4
|
+
from .tables import * # noqa: F401,F403
|
|
5
|
+
from .tables import TABLE_MODEL_BY_NAME, TABLE_MODEL_BY_TABLENAME, TABLE_MODELS
|
|
6
|
+
|
|
7
|
+
__all__ = ["MANIFEST", "load_manifest", "TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME"] + [model.__name__ for model in TABLE_MODELS]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
manifest_version = "1.0.0"
|
|
2
|
+
|
|
3
|
+
[component]
|
|
4
|
+
id = "tigrbl.identity.storage.operator"
|
|
5
|
+
distribution = "tba-storage-operator"
|
|
6
|
+
import_root = "tba_storage_operator"
|
|
7
|
+
|
|
8
|
+
[schema]
|
|
9
|
+
contract = "1.0.0"
|
|
10
|
+
migration_head = "469839b2-d339-544a-b747-fd68b6a5f235"
|
|
11
|
+
migrations_package = "tba_storage_operator.migrations.versions"
|
|
12
|
+
|
|
13
|
+
[[schema.objects]]
|
|
14
|
+
id = "tigrbl.identity.storage.operator:table:operator_metadata"
|
|
15
|
+
kind = "table"
|
|
16
|
+
physical_name = "operator_metadata"
|
|
17
|
+
model = "tba_storage_operator.tables:OperatorMetadata"
|
|
18
|
+
|
|
19
|
+
[[schema.objects]]
|
|
20
|
+
id = "tigrbl.identity.storage.operator:table:operator_records"
|
|
21
|
+
kind = "table"
|
|
22
|
+
physical_name = "operator_records"
|
|
23
|
+
model = "tba_storage_operator.tables:OperatorRecord"
|
|
24
|
+
|
|
25
|
+
[[schema.objects]]
|
|
26
|
+
id = "tigrbl.identity.storage.operator:table:operator_transactions"
|
|
27
|
+
kind = "table"
|
|
28
|
+
physical_name = "operator_transactions"
|
|
29
|
+
model = "tba_storage_operator.tables:OperatorTransaction"
|
|
30
|
+
|
|
31
|
+
[[schema.objects]]
|
|
32
|
+
id = "tigrbl.identity.storage.operator:table:operator_audit_events"
|
|
33
|
+
kind = "table"
|
|
34
|
+
physical_name = "operator_audit_events"
|
|
35
|
+
model = "tba_storage_operator.tables:OperatorAuditEvent"
|
|
36
|
+
|
|
37
|
+
[[schema.objects]]
|
|
38
|
+
id = "tigrbl.identity.storage.operator:table:operator_activity"
|
|
39
|
+
kind = "table"
|
|
40
|
+
physical_name = "operator_activity"
|
|
41
|
+
model = "tba_storage_operator.tables:OperatorActivity"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Installed component manifest access."""
|
|
2
|
+
from importlib.resources import as_file, files
|
|
3
|
+
from tigrbl_migrations import StorageManifest
|
|
4
|
+
|
|
5
|
+
def load_manifest() -> StorageManifest:
|
|
6
|
+
with as_file(files(__package__).joinpath("component.toml")) as path:
|
|
7
|
+
return StorageManifest.from_toml(path)
|
|
8
|
+
|
|
9
|
+
MANIFEST = load_manifest()
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Initial owned schema for tigrbl.identity.storage.operator."""
|
|
2
|
+
from sqlalchemy.schema import CreateIndex, CreateTable
|
|
3
|
+
|
|
4
|
+
from tigrbl_migrations import Migration
|
|
5
|
+
from tba_storage_operator.tables import TABLE_MODELS
|
|
6
|
+
|
|
7
|
+
REVISION = "469839b2-d339-544a-b747-fd68b6a5f235"
|
|
8
|
+
|
|
9
|
+
def upgrade(connection):
|
|
10
|
+
for model in TABLE_MODELS:
|
|
11
|
+
table = model.__table__
|
|
12
|
+
connection.execute(CreateTable(table, if_not_exists=True))
|
|
13
|
+
for index in sorted(table.indexes, key=lambda item: item.name or ""):
|
|
14
|
+
statement = str(
|
|
15
|
+
CreateIndex(index, if_not_exists=True).compile(
|
|
16
|
+
dialect=connection.dialect
|
|
17
|
+
)
|
|
18
|
+
)
|
|
19
|
+
connection.exec_driver_sql(statement)
|
|
20
|
+
|
|
21
|
+
def downgrade(connection):
|
|
22
|
+
for model in reversed(TABLE_MODELS):
|
|
23
|
+
model.__table__.drop(bind=connection, checkfirst=True)
|
|
24
|
+
|
|
25
|
+
MIGRATION = Migration(
|
|
26
|
+
component="tigrbl.identity.storage.operator",
|
|
27
|
+
revision=REVISION,
|
|
28
|
+
parents=(),
|
|
29
|
+
kind="standard",
|
|
30
|
+
reversible=True,
|
|
31
|
+
upgrade=upgrade,
|
|
32
|
+
downgrade=downgrade,
|
|
33
|
+
)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Owned mapped-table inventory."""
|
|
2
|
+
|
|
3
|
+
from .operator_activity import OperatorActivity
|
|
4
|
+
from .operator_audit_event import OperatorAuditEvent
|
|
5
|
+
from .operator_metadata import OperatorMetadata
|
|
6
|
+
from .operator_record import OperatorRecord
|
|
7
|
+
from .operator_transaction import OperatorTransaction
|
|
8
|
+
|
|
9
|
+
TABLE_MODELS = (
|
|
10
|
+
OperatorMetadata,
|
|
11
|
+
OperatorRecord,
|
|
12
|
+
OperatorTransaction,
|
|
13
|
+
OperatorAuditEvent,
|
|
14
|
+
OperatorActivity,
|
|
15
|
+
)
|
|
16
|
+
TABLE_MODEL_BY_NAME = {model.__name__: model for model in TABLE_MODELS}
|
|
17
|
+
TABLE_MODEL_BY_TABLENAME = {model.__tablename__: model for model in TABLE_MODELS}
|
|
18
|
+
__all__ = [model.__name__ for model in TABLE_MODELS] + [
|
|
19
|
+
"TABLE_MODELS", "TABLE_MODEL_BY_NAME", "TABLE_MODEL_BY_TABLENAME",
|
|
20
|
+
]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Table-owned operator activity log."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from tba_primitives_identity.orm import (
|
|
6
|
+
RestOltpTable,
|
|
7
|
+
Integer,
|
|
8
|
+
Mapped,
|
|
9
|
+
S,
|
|
10
|
+
String,
|
|
11
|
+
acol,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class OperatorActivity(RestOltpTable):
|
|
16
|
+
__tablename__ = "operator_activity"
|
|
17
|
+
|
|
18
|
+
id: Mapped[int] = acol(
|
|
19
|
+
storage=S(Integer, primary_key=True, autoincrement=True, nullable=False)
|
|
20
|
+
)
|
|
21
|
+
ts: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
|
|
22
|
+
kind: Mapped[str] = acol(storage=S(String(255), nullable=False))
|
|
23
|
+
resource: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
24
|
+
record_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
25
|
+
status: Mapped[str | None] = acol(storage=S(String(64), nullable=True))
|
|
26
|
+
transaction_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
__all__ = ["OperatorActivity"]
|
tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_audit_event/_table.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""Table-owned operator audit log."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from tba_primitives_identity.orm import RestOltpTable, Mapped, S, String, acol
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OperatorAuditEvent(RestOltpTable):
|
|
9
|
+
__tablename__ = "operator_audit_events"
|
|
10
|
+
|
|
11
|
+
id: Mapped[str] = acol(storage=S(String(255), primary_key=True, nullable=False))
|
|
12
|
+
tenant_id: Mapped[str | None] = acol(
|
|
13
|
+
storage=S(String(255), nullable=True, index=True)
|
|
14
|
+
)
|
|
15
|
+
actor_user_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
16
|
+
actor_client_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
17
|
+
session_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
18
|
+
event_type: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
19
|
+
target_type: Mapped[str] = acol(storage=S(String(128), nullable=False))
|
|
20
|
+
target_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
21
|
+
outcome: Mapped[str] = acol(storage=S(String(64), nullable=False))
|
|
22
|
+
request_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
23
|
+
occurred_at: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
|
|
24
|
+
details_json: Mapped[str] = acol(
|
|
25
|
+
storage=S(String(20000), nullable=False, default="{}")
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
__all__ = ["OperatorAuditEvent"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Table-owned operator store metadata."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from tba_primitives_identity.orm import RestOltpTable, Mapped, S, String, TZDateTime, acol
|
|
8
|
+
from tba_primitives_identity.clock import utc_now
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class OperatorMetadata(RestOltpTable):
|
|
12
|
+
__tablename__ = "operator_metadata"
|
|
13
|
+
|
|
14
|
+
key: Mapped[str] = acol(storage=S(String(255), primary_key=True, nullable=False))
|
|
15
|
+
value_json: Mapped[str] = acol(storage=S(String(8000), nullable=False, default="null"))
|
|
16
|
+
updated_at: Mapped[Any] = acol(storage=S(TZDateTime, nullable=False, default=utc_now))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
__all__ = ["OperatorMetadata"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Table-owned operator resource records."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import copy
|
|
6
|
+
from typing import Any, Mapping
|
|
7
|
+
|
|
8
|
+
from tba_primitives_identity.orm import RestOltpTable, Boolean, Mapped, S, String, acol
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _default_status(resource: str) -> str:
|
|
13
|
+
return "staged" if resource in {"keys"} else "active"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class OperatorRecord(RestOltpTable):
|
|
17
|
+
__tablename__ = "operator_records"
|
|
18
|
+
|
|
19
|
+
id: Mapped[str] = acol(storage=S(String(512), primary_key=True, nullable=False))
|
|
20
|
+
resource: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
21
|
+
record_id: Mapped[str] = acol(storage=S(String(255), nullable=False, index=True))
|
|
22
|
+
status: Mapped[str] = acol(storage=S(String(64), nullable=False, default="active", index=True))
|
|
23
|
+
enabled: Mapped[bool] = acol(storage=S(Boolean, nullable=False, default=True))
|
|
24
|
+
created_at: Mapped[str] = acol(storage=S(String(64), nullable=False))
|
|
25
|
+
updated_at: Mapped[str] = acol(storage=S(String(64), nullable=False))
|
|
26
|
+
actor: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
27
|
+
profile: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
28
|
+
tenant: Mapped[str | None] = acol(storage=S(String(255), nullable=True, index=True))
|
|
29
|
+
issuer: Mapped[str | None] = acol(storage=S(String(512), nullable=True))
|
|
30
|
+
revision: Mapped[int] = acol(storage=S(nullable=False, default=1))
|
|
31
|
+
data_json: Mapped[str] = acol(storage=S(String(20000), nullable=False, default="{}"))
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def store_id(resource: str, record_id: str) -> str:
|
|
35
|
+
return f"{resource}:{record_id}"
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _without_revision(record: Mapping[str, Any]) -> dict[str, Any]:
|
|
39
|
+
cleaned = copy.deepcopy(dict(record))
|
|
40
|
+
cleaned.pop("revision", None)
|
|
41
|
+
return cleaned
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
__all__ = ["OperatorRecord"]
|
tba_storage_operator-0.4.0.dev2/src/tba_storage_operator/tables/operator_transaction/_table.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""Table-owned operator transaction log."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from tba_primitives_identity.orm import RestOltpTable, Mapped, S, String, acol
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OperatorTransaction(RestOltpTable):
|
|
9
|
+
__tablename__ = "operator_transactions"
|
|
10
|
+
|
|
11
|
+
transaction_id: Mapped[str] = acol(
|
|
12
|
+
storage=S(String(255), primary_key=True, nullable=False)
|
|
13
|
+
)
|
|
14
|
+
ts: Mapped[str] = acol(storage=S(String(64), nullable=False, index=True))
|
|
15
|
+
command: Mapped[str] = acol(storage=S(String(255), nullable=False))
|
|
16
|
+
resource: Mapped[str] = acol(storage=S(String(128), nullable=False, index=True))
|
|
17
|
+
status: Mapped[str] = acol(storage=S(String(64), nullable=False))
|
|
18
|
+
record_id: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
19
|
+
changed_ids_json: Mapped[str] = acol(
|
|
20
|
+
storage=S(String(8000), nullable=False, default="[]")
|
|
21
|
+
)
|
|
22
|
+
summary_json: Mapped[str] = acol(
|
|
23
|
+
storage=S(String(20000), nullable=False, default="{}")
|
|
24
|
+
)
|
|
25
|
+
actor: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
26
|
+
profile: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
27
|
+
tenant: Mapped[str | None] = acol(storage=S(String(255), nullable=True))
|
|
28
|
+
issuer: Mapped[str | None] = acol(storage=S(String(512), nullable=True))
|
|
29
|
+
before_checksum: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
30
|
+
after_checksum: Mapped[str | None] = acol(storage=S(String(128), nullable=True))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
__all__ = ["OperatorTransaction"]
|