diff --git a/.github/workflows/tox-test.yml b/.github/workflows/tox-test.yml index 5586258..c398769 100644 --- a/.github/workflows/tox-test.yml +++ b/.github/workflows/tox-test.yml @@ -172,7 +172,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.9 - name: Install Tox run: pip install tox 'virtualenv<20.21.1' - name: Run Tox diff --git a/starmap_client/models.py b/starmap_client/models.py index 03a5b3f..c251786 100644 --- a/starmap_client/models.py +++ b/starmap_client/models.py @@ -21,6 +21,26 @@ ] +class PaginationMetadata(TypedDict): + """Datastructure of the metadata about the paginated query.""" + + first: str + last: str + next: Optional[str] + page: int + per_page: int + previous: Optional[str] + total: int + total_pages: int + + +class PaginatedRawData(TypedDict): + """Represent a paginated StArMap data in its raw format (Dict).""" + + items: List[Any] + nav: PaginationMetadata + + class Workflow(str, Enum): """Define the valid workflows for StArMap.""" @@ -85,14 +105,8 @@ def from_json(cls, json: Any): @frozen -class StarmapBaseData: - """Represent the common data present in StArMap entities.""" - - id: Optional[str] = field(validator=optional(instance_of(str))) - """ - The unique ID for a StArMap model. - This field is never set on :class:`~starmap_client.models.QueryResponse`. - """ +class MetaMixin: + """Mixin for defining the meta attribute and its validator.""" meta: Optional[Dict[str, Any]] = field() """Dictionary with additional information related to a VM image.""" @@ -109,7 +123,18 @@ def _is_meta_dict_of_str_any(self, attribute: Attribute, value: Any): @frozen -class Destination(StarmapBaseData, StarmapJSONDecodeMixin): +class StarmapBaseData(MetaMixin, StarmapJSONDecodeMixin): + """Represent the common data present in StArMap entities.""" + + id: Optional[str] = field(validator=optional(instance_of(str))) + """ + The unique ID for a StArMap model. + This field is never set on :class:`~starmap_client.models.QueryResponse`. + """ + + +@frozen +class Destination(StarmapBaseData): """Represent a destination entry from Mapping.""" architecture: Optional[str] = field(validator=optional(instance_of(str))) @@ -146,7 +171,7 @@ class Destination(StarmapBaseData, StarmapJSONDecodeMixin): @frozen -class Mapping(StarmapBaseData, StarmapJSONDecodeMixin): +class Mapping(StarmapBaseData): """Represent a marketplace Mapping from Policy.""" destinations: List[Destination] = field( @@ -176,7 +201,7 @@ class Mapping(StarmapBaseData, StarmapJSONDecodeMixin): @frozen -class Policy(StarmapBaseData, StarmapJSONDecodeMixin): +class Policy(StarmapBaseData): """Represent a StArMap policy.""" mappings: List[Mapping] = field( @@ -237,23 +262,3 @@ def _preprocess_json(cls, json: Any) -> Dict[str, Any]: mappings[c] = dst json["clouds"] = mappings return json - - -class PaginationMetadata(TypedDict): - """Datastructure of the metadata about the paginated query.""" - - first: str - last: str - next: Optional[str] - page: int - per_page: int - previous: Optional[str] - total: int - total_pages: int - - -class PaginatedRawData(TypedDict): - """Represent a paginated StArMap data in its raw format (Dict).""" - - items: List[Any] - nav: PaginationMetadata diff --git a/tox.ini b/tox.ini index 767bdd2..e91ce00 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ commands = pip-compile -U --generate-hashes --reuse-hashes --output-file=requirements-test.txt setup.py requirements-test.in [testenv:docs] +basepython = python3.9 use_develop=true commands= sphinx-build -M html docs docs/_build