Skip to content

Commit

Permalink
Merge pull request #113 from stat-kwon/master
Browse files Browse the repository at this point in the history
Remove list projects method in Bigquery service
  • Loading branch information
stat-kwon authored Apr 8, 2024
2 parents 165521b + 2531f84 commit 67dbef8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
26 changes: 13 additions & 13 deletions src/spaceone/inventory/connector/bigquery/sql_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
24 changes: 12 additions & 12 deletions src/spaceone/inventory/manager/bigquery/sql_workspace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
BigQueryWorkSpace,
SQLWorkSpaceResource,
SQLWorkSpaceResponse,
ProjectModel,
# ProjectModel,
)
from spaceone.inventory.model.bigquery.sql_workspace.cloud_service_type import (
CLOUD_SERVICE_TYPES,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -93,7 +93,7 @@
[
workspace_dataset_meta,
workspace_table_meta,
workspace_matching_project_meta,
# workspace_matching_project_meta,
workspace_labels_meta,
]
)
Expand Down
22 changes: 11 additions & 11 deletions src/spaceone/inventory/model/bigquery/sql_workspace/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
)
Expand Down

0 comments on commit 67dbef8

Please sign in to comment.