Skip to content

Commit

Permalink
refactor: change dashboard to public_dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
stat-kwon committed Dec 19, 2023
1 parent e45fea4 commit 75229b8
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 380 deletions.
4 changes: 2 additions & 2 deletions src/spaceone/dashboard/info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from spaceone.dashboard.info.dashboard_info import *
from spaceone.dashboard.info.dashboard_version_info import *
from spaceone.dashboard.info.public_dashboard_info import *
from spaceone.dashboard.info.public_dashboard_version_info import *
from spaceone.dashboard.info.common_info import *
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import functools
from spaceone.api.dashboard.v1 import dashboard_pb2
from spaceone.api.dashboard.v1 import public_dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model.dashboard_model import Dashboard
from spaceone.dashboard.model.public_dashboard_model import PublicDashboard

__all__ = ["DashboardInfo", "DashboardsInfo"]
__all__ = ["PublicDashboardInfo", "PublicDashboardsInfo"]


def DashboardInfo(dashboard_vo: Dashboard, minimal=False):
def PublicDashboardInfo(dashboard_vo: PublicDashboard, minimal=False):
info = {
"dashboard_id": dashboard_vo.dashboard_id,
"public_dashboard_id": dashboard_vo.public_dashboard_id,
"name": dashboard_vo.name,
"dashboard_type": dashboard_vo.dashboard_type,
"version": dashboard_vo.version,
"labels": change_list_value_type(dashboard_vo.labels),
"resource_group": dashboard_vo.resource_group,
"user_id": dashboard_vo.user_id,
"project_id": dashboard_vo.project_id,
"workspace_id": dashboard_vo.workspace_id,
"domain_id": dashboard_vo.domain_id,
Expand All @@ -36,11 +34,13 @@ def DashboardInfo(dashboard_vo: Dashboard, minimal=False):
}
)

return dashboard_pb2.DashboardInfo(**info)
return public_dashboard_pb2.PublicDashboardInfo(**info)


def DashboardsInfo(dashboard_vos, total_count, **kwargs):
return dashboard_pb2.DashboardsInfo(
results=list(map(functools.partial(DashboardInfo, **kwargs), dashboard_vos)),
def PublicDashboardsInfo(dashboard_vos, total_count, **kwargs):
return public_dashboard_pb2.PublicDashboardsInfo(
results=list(
map(functools.partial(PublicDashboardInfo, **kwargs), dashboard_vos)
),
total_count=total_count,
)
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import functools
from spaceone.api.dashboard.v1 import dashboard_pb2
from spaceone.api.dashboard.v1 import public_dashboard_pb2
from spaceone.core.pygrpc.message_type import *
from spaceone.core import utils
from spaceone.dashboard.model import DashboardVersion
from spaceone.dashboard.model import PublicDashboardVersion

__all__ = ["DashboardVersionInfo", "DashboardVersionsInfo"]
__all__ = ["PublicDashboardVersionInfo", "PublicDashboardVersionsInfo"]


def DashboardVersionInfo(
dashboard_version_vo: DashboardVersion, minimal=False, latest_version=None
def PublicDashboardVersionInfo(
dashboard_version_vo: PublicDashboardVersion, minimal=False, latest_version=None
):
info = {
"dashboard_id": dashboard_version_vo.dashboard_id,
"public_dashboard_id": dashboard_version_vo.public_dashboard_id,
"version": dashboard_version_vo.version,
"created_at": utils.datetime_to_iso8601(dashboard_version_vo.created_at),
"domain_id": dashboard_version_vo.domain_id,
Expand All @@ -37,14 +37,14 @@ def DashboardVersionInfo(
}
)

return dashboard_pb2.DashboardVersionInfo(**info)
return public_dashboard_pb2.PublicDashboardVersionInfo(**info)


def DashboardVersionsInfo(dashboard_version_vos, total_count, **kwargs):
return dashboard_pb2.DashboardVersionsInfo(
def PublicDashboardVersionsInfo(dashboard_version_vos, total_count, **kwargs):
return public_dashboard_pb2.PublicDashboardVersionsInfo(
results=list(
map(
functools.partial(DashboardVersionInfo, **kwargs),
functools.partial(PublicDashboardVersionInfo, **kwargs),
dashboard_version_vos,
)
),
Expand Down
4 changes: 2 additions & 2 deletions src/spaceone/dashboard/interface/grpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from spaceone.core.pygrpc.server import GRPCServer
from spaceone.dashboard.interface.grpc.dashboard import Dashboard
from spaceone.dashboard.interface.grpc.public_dashboard import PublicDashboard

__all__ = ["app"]

app = GRPCServer()
app.add_service(Dashboard)
app.add_service(PublicDashboard)
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
from spaceone.api.dashboard.v1 import dashboard_pb2, dashboard_pb2_grpc
from spaceone.api.dashboard.v1 import public_dashboard_pb2, public_dashboard_pb2_grpc
from spaceone.core.pygrpc import BaseAPI


class Dashboard(BaseAPI, dashboard_pb2_grpc.DashboardServicer):
pb2 = dashboard_pb2
pb2_grpc = dashboard_pb2_grpc
class PublicDashboard(BaseAPI, public_dashboard_pb2_grpc.PublicDashboardServicer):
pb2 = public_dashboard_pb2
pb2_grpc = public_dashboard_pb2_grpc

def create(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info(
"DashboardInfo", dashboard_service.create(params)
"PublicDashboardInfo", dashboard_service.create(params)
)

def update(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info(
"DashboardInfo", dashboard_service.update(params)
"PublicDashboardInfo", dashboard_service.update(params)
)

def delete(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
dashboard_service.delete(params)
return self.locator.get_info("EmptyInfo")
Expand All @@ -39,15 +39,17 @@ def get(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info("DashboardInfo", dashboard_service.get(params))
return self.locator.get_info(
"PublicDashboardInfo", dashboard_service.get(params)
)

def delete_version(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
dashboard_service.delete_version(params)
return self.locator.get_info("EmptyInfo")
Expand All @@ -56,51 +58,52 @@ def revert_version(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info(
"DashboardInfo", dashboard_service.revert_version(params)
"PublicDashboardInfo", dashboard_service.revert_version(params)
)

def get_version(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info(
"DashboardVersionInfo", dashboard_service.get_version(params)
"PublicDashboardVersionInfo",
dashboard_service.get_version(params),
)

def list_versions(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
(
dashboard_version_vos,
public_dashboard_version_vos,
total_count,
dashboard_version,
public_dashboard_version,
) = dashboard_service.list_versions(params)
return self.locator.get_info(
"DashboardVersionsInfo",
dashboard_version_vos,
"PublicDashboardVersionsInfo",
public_dashboard_version_vos,
total_count,
minimal=self.get_minimal(params),
latest_version=dashboard_version,
latest_version=public_dashboard_version,
)

def list(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
dashboard_vos, total_count = dashboard_service.list(params)
public_dashboard_vos, total_count = dashboard_service.list(params)
return self.locator.get_info(
"DashboardsInfo",
dashboard_vos,
"PublicDashboardsInfo",
public_dashboard_vos,
total_count,
minimal=self.get_minimal(params),
)
Expand All @@ -109,7 +112,7 @@ def stat(self, request, context):
params, metadata = self.parse_request(request, context)

with self.locator.get_service(
"DashboardService", metadata
"PublicDashboardService", metadata
) as dashboard_service:
return self.locator.get_info(
"StatisticsInfo", dashboard_service.stat(params)
Expand Down
6 changes: 4 additions & 2 deletions src/spaceone/dashboard/manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from spaceone.dashboard.manager.dashboard_manager import DashboardManager
from spaceone.dashboard.manager.dashboard_version_manager import DashboardVersionManager
from spaceone.dashboard.manager.public_dashboard_manager import PublicDashboardManager
from spaceone.dashboard.manager.public_dashboard_version_manager import (
PublicDashboardVersionManager,
)
from spaceone.dashboard.manager.identity_manager import IdentityManager
87 changes: 0 additions & 87 deletions src/spaceone/dashboard/manager/dashboard_manager.py

This file was deleted.

Loading

0 comments on commit 75229b8

Please sign in to comment.