From cdc1f4b2df9880cb5efd1b5bd804d5026a6fff68 Mon Sep 17 00:00:00 2001 From: KnucklesSG1 Date: Mon, 21 Oct 2024 14:19:14 -0500 Subject: [PATCH] Added support for latest fields in gitlab api. --- gitlab_api/gitlab_api.py | 2 ++ gitlab_api/gitlab_db_models.py | 9 ++++++++- gitlab_api/gitlab_response_models.py | 18 +++++++++++++----- test/test_gitlab_api.py | 10 ++++------ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/gitlab_api/gitlab_api.py b/gitlab_api/gitlab_api.py index b876294..72b1a8c 100644 --- a/gitlab_api/gitlab_api.py +++ b/gitlab_api/gitlab_api.py @@ -2147,11 +2147,13 @@ def get_nested_projects_by_group( if project.group_id is None: raise MissingParameterError project_group = self.get_group(group_id=project.group_id) + print(f"\n\nPROJECT GROUP: {project_group}\n\n") if project_group.data: all_groups.append(project_group.data) groups = self.get_group_descendant_groups(group_id=project.group_id) if groups.data: all_groups.extend(groups.data) + print(f"ALL GROUPS: {all_groups}") for group in all_groups: pages_response = self.get_total_projects_in_group( group_id=project.group_id, per_page=project.per_page diff --git a/gitlab_api/gitlab_db_models.py b/gitlab_api/gitlab_db_models.py index c82357f..8bc07a4 100644 --- a/gitlab_api/gitlab_db_models.py +++ b/gitlab_api/gitlab_db_models.py @@ -1192,7 +1192,7 @@ def __ne__(self, other): BaseDBModel.metadata, Column("project_id", Integer, ForeignKey("projects.id")), Column("group_id", Integer, ForeignKey("groups.id")), - Column("id", Integer, primary_key=True, autoincrement=True) + Column("id", Integer, primary_key=True, autoincrement=True), ) @@ -1805,6 +1805,13 @@ def __ne__(self, other): operations_access_level: Mapped[str] = mapped_column(String, nullable=True) ci_dockerfile: Mapped[str] = mapped_column(String, nullable=True) public: Mapped[bool] = mapped_column(Boolean, nullable=True) + ci_id_token_sub_claim_components = mapped_column(ARRAY(String), nullable=True) + ci_pipeline_variables_minimum_override_role: Mapped[str] = mapped_column( + String, nullable=True + ) + ci_push_repository_for_job_token_allowed: Mapped[bool] = mapped_column( + Boolean, nullable=True + ) tag_list_id: Mapped[int] = mapped_column( Integer, ForeignKey(column="tags.id"), nullable=True diff --git a/gitlab_api/gitlab_response_models.py b/gitlab_api/gitlab_response_models.py index d9fc95c..48bb520 100644 --- a/gitlab_api/gitlab_response_models.py +++ b/gitlab_api/gitlab_response_models.py @@ -1,6 +1,5 @@ #!/usr/bin/python # coding: utf-8 -import logging from typing import Union, List, Dict, Optional, Any from pydantic import ( @@ -1682,6 +1681,15 @@ class Meta: public: Optional[bool] = Field( default=None, description="Whether project is allowed to be public." ) + ci_id_token_sub_claim_components: Optional[List[str]] = Field( + default=None, description="CI ID Token Sub Claim Components" + ) + ci_pipeline_variables_minimum_override_role: Optional[str] = Field( + default=None, description="CI Pipeline Variables minimum override role" + ) + ci_push_repository_for_job_token_allowed: Optional[bool] = Field( + default=None, description="CI Push repository for Job token allowed" + ) @field_validator("tag_list", mode="before") def validate_tags(cls, v): @@ -3603,10 +3611,10 @@ def determine_model_type(cls, value): model(**item) if isinstance(item, dict) else item for item in value ] - logging.debug(f"{model_name} Validation Success: {temp_value}") + print(f"{model_name} Validation Success: {temp_value}") return temp_value except Exception as e: - logging.debug( + print( f"\n\n\n {model_name} Validation Failed: {value}\nError: {e}" ) return value @@ -3614,10 +3622,10 @@ def determine_model_type(cls, value): for model_name, model in single_models.items(): try: temp_value = model(**value) - logging.debug(f"{model_name} Model Validation Success: {value}") + print(f"{model_name} Model Validation Success: {value}") return temp_value except Exception as e: - logging.debug( + print( f"\n\n\n {model_name} Dict Validation Failed for - {value}\nError: {e}" ) return value diff --git a/test/test_gitlab_api.py b/test/test_gitlab_api.py index 77f51b8..af66fb9 100644 --- a/test/test_gitlab_api.py +++ b/test/test_gitlab_api.py @@ -32,14 +32,12 @@ def test_get_nested_projects(): # Get nested projects group_id = 2 projects = client.get_nested_projects_by_group(group_id=group_id, per_page=3) - assert projects.data.base_type == "Projects" - assert isinstance(projects.data.projects, list) - assert len(projects.data.projects) > 3 + assert len(projects.data) > 0 + assert isinstance(projects.data, list) group_id = 6 projects = client.get_nested_projects_by_group(group_id=group_id, per_page=3) - assert projects.data.base_type == "Projects" - assert isinstance(projects.data.projects, list) - assert len(projects.data.projects) > 3 + assert len(projects.data) > 0 + assert isinstance(projects.data, list) @pytest.mark.skipif(