From 2d7a500d74cd41a148a89745cf8a9f8ec92c88c6 Mon Sep 17 00:00:00 2001 From: seolmin Date: Mon, 8 Apr 2024 19:08:04 +0900 Subject: [PATCH 1/2] fix: remove list projects method in Bigquery service --- .../connector/bigquery/sql_workspace.py | 26 +++++++++---------- .../manager/bigquery/sql_workspace_manager.py | 22 ++++++++-------- .../bigquery/sql_workspace/cloud_service.py | 22 ++++++++-------- .../model/bigquery/sql_workspace/data.py | 22 ++++++++-------- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/spaceone/inventory/connector/bigquery/sql_workspace.py b/src/spaceone/inventory/connector/bigquery/sql_workspace.py index 11d2d33..c6ee463 100644 --- a/src/spaceone/inventory/connector/bigquery/sql_workspace.py +++ b/src/spaceone/inventory/connector/bigquery/sql_workspace.py @@ -34,19 +34,19 @@ def get_dataset(self, dataset_id, **query): return response - def list_projects(self, **query): - project_list = [] - request = self.client.projects().list(**query) - - while request is not None: - response = request.execute() - for project in response.get("projects", []): - project_list.append(project) - request = self.client.projects().list_next( - previous_request=request, previous_response=response - ) - - return project_list + # def list_projects(self, **query): + # project_list = [] + # request = self.client.projects().list(**query) + # + # while request is not None: + # response = request.execute() + # for project in response.get("projects", []): + # project_list.append(project) + # request = self.client.projects().list_next( + # previous_request=request, previous_response=response + # ) + # + # return project_list def list_tables(self, dataset_id, **query): table_list = [] diff --git a/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py b/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py index 449173a..450c903 100644 --- a/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py +++ b/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py @@ -51,7 +51,7 @@ def collect_cloud_service(self, params): self.connector_name, **params ) data_sets = big_query_conn.list_dataset() - projects = big_query_conn.list_projects() + # projects = big_query_conn.list_projects() for data_set in data_sets: try: @@ -90,9 +90,9 @@ def collect_cloud_service(self, params): "project": project_id, "tables": updated_bq_tables, "region": region, - "matching_project": self._get_matching_project( - dataset_project_id, projects - ), + # "matching_project": self._get_matching_project( + # dataset_project_id, projects + # ), "creationTime": self._convert_unix_timestamp(creation_time), "lastModifiedTime": self._convert_unix_timestamp( last_modified_time @@ -180,13 +180,13 @@ def _preprocess_bigquery_tables_info(self, bq_tables): return preprocessed_bq_tables - @staticmethod - def _get_matching_project(project_id, projects): - _projects = [] - for project in projects: - if project_id == project.get("id"): - _projects.append(ProjectModel(project, strict=False)) - return _projects + # @staticmethod + # def _get_matching_project(project_id, projects): + # _projects = [] + # for project in projects: + # if project_id == project.get("id"): + # _projects.append(ProjectModel(project, strict=False)) + # return _projects @staticmethod def _convert_milliseconds_to_minutes(milliseconds): diff --git a/src/spaceone/inventory/model/bigquery/sql_workspace/cloud_service.py b/src/spaceone/inventory/model/bigquery/sql_workspace/cloud_service.py index 4319d76..d7fb230 100644 --- a/src/spaceone/inventory/model/bigquery/sql_workspace/cloud_service.py +++ b/src/spaceone/inventory/model/bigquery/sql_workspace/cloud_service.py @@ -54,16 +54,16 @@ ) -workspace_matching_project_meta = TableDynamicLayout.set_fields( - "Project", - root_path="data.matching_project", - fields=[ - TextDyField.data_source("ID", "id"), - TextDyField.data_source("Numeric Id", "numeric_id"), - TextDyField.data_source("kind", "kind"), - TextDyField.data_source("Friendly Name", "friendly_name"), - ], -) +# workspace_matching_project_meta = TableDynamicLayout.set_fields( +# "Project", +# root_path="data.matching_project", +# fields=[ +# TextDyField.data_source("ID", "id"), +# TextDyField.data_source("Numeric Id", "numeric_id"), +# TextDyField.data_source("kind", "kind"), +# TextDyField.data_source("Friendly Name", "friendly_name"), +# ], +# ) workspace_table_meta = TableDynamicLayout.set_fields( @@ -93,7 +93,7 @@ [ workspace_dataset_meta, workspace_table_meta, - workspace_matching_project_meta, + # workspace_matching_project_meta, workspace_labels_meta, ] ) diff --git a/src/spaceone/inventory/model/bigquery/sql_workspace/data.py b/src/spaceone/inventory/model/bigquery/sql_workspace/data.py index b09375a..a556ff6 100644 --- a/src/spaceone/inventory/model/bigquery/sql_workspace/data.py +++ b/src/spaceone/inventory/model/bigquery/sql_workspace/data.py @@ -88,16 +88,16 @@ class DatasetReference(Model): project_id = StringType(deserialize_from="projectId", serialize_when_none=False) -class ProjectModel(Model): - id = StringType() - kind = StringType() - numeric_id = StringType(deserialize_from="numericId") - project_reference = ModelType( - ProjectReference, deserialize_from="projectReference", serialize_when_none=False - ) - friendly_name = StringType( - deserialize_from="friendlyName", serialize_when_none=False - ) +# class ProjectModel(Model): +# id = StringType() +# kind = StringType() +# numeric_id = StringType(deserialize_from="numericId") +# project_reference = ModelType( +# ProjectReference, deserialize_from="projectReference", serialize_when_none=False +# ) +# friendly_name = StringType( +# deserialize_from="friendlyName", serialize_when_none=False +# ) class Access(Model): @@ -111,7 +111,7 @@ class Access(Model): class BigQueryWorkSpace(BaseResource): - matching_project = ListType(ModelType(ProjectModel), default=[]) + # matching_project = ListType(ModelType(ProjectModel), default=[]) dataset_reference = ModelType( DatasetReference, deserialize_from="datasetReference", serialize_when_none=False ) From 2531f842fa20eb5d5a2b2543b50fd658369dc4a4 Mon Sep 17 00:00:00 2001 From: seolmin Date: Mon, 8 Apr 2024 19:09:29 +0900 Subject: [PATCH 2/2] fix: fix typo --- .../inventory/manager/bigquery/sql_workspace_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py b/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py index 450c903..2dcf358 100644 --- a/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py +++ b/src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py @@ -8,7 +8,7 @@ BigQueryWorkSpace, SQLWorkSpaceResource, SQLWorkSpaceResponse, - ProjectModel, + # ProjectModel, ) from spaceone.inventory.model.bigquery.sql_workspace.cloud_service_type import ( CLOUD_SERVICE_TYPES,