Skip to content

Commit

Permalink
Merge pull request #9 from stat-kwon/master
Browse files Browse the repository at this point in the history
refactor: change all APIs for SpaceONE 2.0
  • Loading branch information
stat-kwon authored Dec 19, 2023
2 parents 2eddfb3 + d070a4a commit b70cd2f
Show file tree
Hide file tree
Showing 21 changed files with 141 additions and 498 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ build
test
*.egg-info
__pycache__
.idea
.idea/src/spaceone/board/service/post_service.py
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cloudforet/python-core:1.12
FROM cloudforet/python-core:2.0
ARG PACKAGE_VERSION
ENV PYTHONUNBUFFERED 1
ENV SPACEONE_PORT 50051
Expand All @@ -9,7 +9,8 @@ ENV PACKAGE_VERSION=$PACKAGE_VERSION

COPY pkg/pip_requirements.txt pip_requirements.txt

RUN pip install --upgrade -r pip_requirements.txt
RUN pip install --upgrade pip && \
pip install --upgrade -r pip_requirements.txt

COPY src ${SRC_DIR}
WORKDIR ${SRC_DIR}
Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.3.11
version: 1.3.12

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
1 change: 0 additions & 1 deletion src/spaceone/board/conf/board_conf.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/spaceone/board/conf/global_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# Connector Settings
CONNECTORS = {
"SpaceConnector": {
"backend": "spaceone.core.connector.space_connector.SpaceConnector",
"backend": "spaceone.core.connector.space_connector:SpaceConnector",
"endpoints": {
"identity": "grpc://identity:50051",
"file_manager": "grpc://file-manager:50051",
Expand Down
1 change: 0 additions & 1 deletion src/spaceone/board/error/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from spaceone.board.error.board import *
from spaceone.board.error.post import *
5 changes: 0 additions & 5 deletions src/spaceone/board/error/board.py

This file was deleted.

14 changes: 0 additions & 14 deletions src/spaceone/board/error/post.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
from spaceone.core.error import *


class ERROR_SETTING_CATEGORIES(ERROR_BASE):
_message = "First, you need to set the categories of the board."


class ERROR_INVALID_CATEGORY(ERROR_BASE):
_message = (
"Invalid category (category = {category}), you must choose one of {categories}"
)


class ERROR_INVALID_KEY_IN_OPTIONS(ERROR_BASE):
_message = "Invalid key in options"


class ERROR_NOT_FOUND_FILE(ERROR_BASE):
_message = "{file_id} does not exist in {domain_id}"


class ERROR_INVALID_FILE_STATE(ERROR_BASE):
_message = "file state is invalid (file_id = {file_id}, state = {state})"
1 change: 0 additions & 1 deletion src/spaceone/board/info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from spaceone.board.info.common_info import *
from spaceone.board.info.board_info import *
from spaceone.board.info.post_info import *
31 changes: 0 additions & 31 deletions src/spaceone/board/info/board_info.py

This file was deleted.

5 changes: 2 additions & 3 deletions src/spaceone/board/info/post_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

def PostInfo(post_vo: Post, minimal=False, files_info=None):
info = {
"board_id": post_vo.board_id,
"board_type": post_vo.board_type,
"post_id": post_vo.post_id,
"category": post_vo.category,
"title": post_vo.title,
"permission_group": post_vo.permission_group,
"resource_group": post_vo.resource_group,
"domain_id": post_vo.domain_id,
}

Expand All @@ -27,7 +27,6 @@ def PostInfo(post_vo: Post, minimal=False, files_info=None):
"writer": post_vo.writer,
"options": change_struct_type(post_vo.options),
"user_id": post_vo.user_id,
"user_domain_id": post_vo.user_domain_id,
"created_at": utils.datetime_to_iso8601(post_vo.created_at),
"updated_at": utils.datetime_to_iso8601(post_vo.updated_at),
}
Expand Down
2 changes: 0 additions & 2 deletions src/spaceone/board/interface/grpc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from spaceone.core.pygrpc.server import GRPCServer
from spaceone.board.interface.grpc.board import Board
from spaceone.board.interface.grpc.post import Post

_all_ = ["app"]

app = GRPCServer()
app.add_service(Board)
app.add_service(Post)
58 changes: 0 additions & 58 deletions src/spaceone/board/interface/grpc/board.py

This file was deleted.

61 changes: 0 additions & 61 deletions src/spaceone/board/manager/board_manager.py

This file was deleted.

22 changes: 9 additions & 13 deletions src/spaceone/board/manager/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,20 @@ def __init__(self, *args, **kwargs):
SpaceConnector, service="file_manager"
)

def get_file(self, file_id: str, domain_id: str) -> dict:
return self.file_manager_connector.dispatch(
"File.get", {"file_id": file_id, "domain_id": domain_id}
)
def get_file(self, file_id: str) -> dict:
return self.file_manager_connector.dispatch("File.get", {"file_id": file_id})

def update_file_reference(self, file_id: str, reference: dict, domain_id: str) -> dict:
def update_file_reference(self, file_id: str, reference: dict) -> dict:
return self.file_manager_connector.dispatch(
"File.update",
{"file_id": file_id, "reference": reference, "domain_id": domain_id},
{"file_id": file_id, "reference": reference},
)

def delete_file(self, file_id: str, domain_id: str) -> None:
return self.file_manager_connector.dispatch(
"File.delete", {"file_id": file_id, "domain_id": domain_id}
)
def delete_file(self, file_id: str) -> None:
return self.file_manager_connector.dispatch("File.delete", {"file_id": file_id})

@cache.cacheable(key="board:file-download-url:{domain_id}:{file_id}", expire=600)
def get_download_url(self, file_id: str, domain_id: str) -> dict:
@cache.cacheable(key="board:file-download-url:{file_id}", expire=600)
def get_download_url(self, file_id: str) -> dict:
return self.file_manager_connector.dispatch(
"File.get_download_url", {"file_id": file_id, "domain_id": domain_id}
"File.get_download_url", {"file_id": file_id}
)
17 changes: 0 additions & 17 deletions src/spaceone/board/manager/identity_manager.py

This file was deleted.

13 changes: 9 additions & 4 deletions src/spaceone/board/manager/post_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.post_model: Post = self.locator.get_model(Post)

def create_board(self, params: dict) -> Post:
def _rollback(vo):
def create_post(self, params: dict) -> Post:
def _rollback(vo: Post):
_LOGGER.info(f"[create_post._rollback] " f"Delete post : {vo.name}")
vo.delete()

Expand All @@ -37,8 +37,13 @@ def _rollback(old_data: dict):

return post_vo.update(params)

def get_post(self, board_id: str, post_id: str) -> Post:
return self.post_model.get(board_id=board_id, post_id=post_id)
def get_post(self, post_id: str, domain_id: str = None) -> Post:
conditions = {"post_id": post_id}

if domain_id:
conditions["domain_id"] = domain_id

return self.post_model.get(**conditions)

def list_boards(self, query: Union[dict, None] = None):
if query is None:
Expand Down
22 changes: 0 additions & 22 deletions src/spaceone/board/model/board_model.py

This file was deleted.

Loading

0 comments on commit b70cd2f

Please sign in to comment.