Skip to content

Commit f5d602e

Browse files
committed
refactor: move GenericResourceBase to core.models.base for platform-wide use
1 parent 3ebd74b commit f5d602e

4 files changed

Lines changed: 17 additions & 27 deletions

File tree

src/itl_controlplane_sdk/core/models/base/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
)
5555

5656
__all__ = [
57+
# Generic resource base
58+
"GenericResourceBase",
5759
# HTTP Models
5860
"CoreBaseModel",
5961
"CoreRequestBaseModel",

src/itl_controlplane_sdk/core/models/base/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
from typing import Any, Dict, Optional
2+
from pydantic import BaseModel, Field, ConfigDict
3+
4+
# --- GenericResourceBase (voor alle providers) ---
5+
class GenericResourceBase(BaseModel):
6+
"""
7+
Base class for generic resource models with common fields and configuration.
8+
Provides common schema fields (location, tags) en shared Pydantic config.
9+
"""
10+
location: str = Field(..., description="Location or region")
11+
tags: Optional[Dict[str, str]] = Field(None, description="Resource tags for categorization")
12+
model_config = ConfigDict(
13+
str_strip_whitespace=True,
14+
arbitrary_types_allowed=True,
15+
)
116
"""
217
Base HTTP models for the ITL ControlPlane SDK.
318

src/itl_controlplane_sdk/fastapi/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from .config import FastAPIConfig
1010
from .crud_routes import create_crud_routes
1111
from .generic_routes import setup_generic_routes
12-
from .models import GenericResourceBase
1312
from .observability_routes import setup_observability_routes
1413
from .provider_server import BaseProviderServer
1514
from .provider_setup import (
@@ -28,7 +27,6 @@
2827
"add_audit_middleware",
2928
"BaseProviderServer",
3029
"create_crud_routes",
31-
"GenericResourceBase",
3230
"register_resource_types",
3331
"setup_generic_routes",
3432
"setup_observability_routes",

src/itl_controlplane_sdk/fastapi/models.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,3 @@
1010
from pydantic import BaseModel, Field, ConfigDict
1111

1212

13-
class GenericResourceBase(BaseModel):
14-
"""
15-
Base class for generic resource models with common fields and configuration.
16-
17-
Provides common schema fields (location, tags) and shared Pydantic configuration
18-
that can be inherited by request and response models across all providers.
19-
20-
This base class ensures consistency across the platform while allowing
21-
providers to extend with their own specific fields.
22-
23-
Example:
24-
class MyProviderRequest(GenericResourceBase):
25-
subscription_id: str
26-
resource_group: str
27-
resource_name: str
28-
# Additional provider-specific fields here
29-
"""
30-
31-
location: str = Field(..., description="Location or region")
32-
tags: Optional[Dict[str, str]] = Field(None, description="Resource tags for categorization")
33-
34-
model_config = ConfigDict(
35-
str_strip_whitespace=True,
36-
arbitrary_types_allowed=True,
37-
)

0 commit comments

Comments
 (0)