-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
12 changed files
with
500 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from spaceone.api.inventory_v2.v1 import job_task_pb2, job_task_pb2_grpc | ||
from spaceone.core.pygrpc import BaseAPI | ||
|
||
from spaceone.inventory_v2.service.job_task_service import JobTaskService | ||
|
||
|
||
class JobTask(BaseAPI, job_task_pb2_grpc.JobTaskServicer): | ||
pb2 = job_task_pb2 | ||
pb2_grpc = job_task_pb2_grpc | ||
|
||
def delete(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
job_task_svc = JobTaskService(metadata) | ||
job_task_svc.delete(params) | ||
return self.empty() | ||
|
||
def get(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
job_task_svc = JobTaskService(metadata) | ||
response = job_task_svc.get(params) | ||
return self.dict_to_message(response) | ||
|
||
def get_detail(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
job_task_svc = JobTaskService(metadata) | ||
response = job_task_svc.get_detail(params) | ||
return self.dict_to_message(response) | ||
|
||
def list(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
job_task_svc = JobTaskService(metadata) | ||
response = job_task_svc.list(params) | ||
return self.dict_to_message(response) | ||
|
||
def stat(self, request, context): | ||
params, metadata = self.parse_request(request, context) | ||
job_task_svc = JobTaskService(metadata) | ||
response = job_task_svc.stat(params) | ||
return self.dict_to_message(response) |
60 changes: 60 additions & 0 deletions
60
src/spaceone/inventory_v2/manager/job_task_detail_manager.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import logging | ||
from typing import Tuple | ||
|
||
from spaceone.core.manager import BaseManager | ||
from spaceone.core.model.mongo_model import QuerySet | ||
|
||
from spaceone.inventory_v2.model.job_task.database import JobTask, JobTaskDetail | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class JobTaskDetailManager(BaseManager): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.job_task_detail_model = JobTaskDetail | ||
self.job_task_model = JobTask | ||
|
||
def create_job_task_detail_by_task_vo(self, job_task_vo: JobTask) -> JobTaskDetail: | ||
def _rollback(vo: JobTaskDetail): | ||
_LOGGER.info(f"[ROLLBACK] Delete job task detail: {vo.job_task_id}") | ||
vo.delete() | ||
|
||
params = { | ||
"job_task_id": job_task_vo.job_task_id, | ||
"job_id": job_task_vo.job_id, | ||
} | ||
job_task_detail_vo: JobTaskDetail = self.job_task_detail_model.create(params) | ||
|
||
self.transaction.add_rollback(_rollback, job_task_vo) | ||
|
||
return job_task_detail_vo | ||
|
||
def get_job_task_detail( | ||
self, | ||
job_task_id: str, | ||
domain_id: str, | ||
workspace_id: str = None, | ||
user_projects: list = None, | ||
) -> JobTaskDetail: | ||
conditions = { | ||
"job_task_id": job_task_id, | ||
"domain_id": domain_id, | ||
} | ||
|
||
if workspace_id: | ||
conditions["workspace_id"] = workspace_id | ||
|
||
if user_projects: | ||
conditions["project_id"] = user_projects | ||
|
||
return self.job_task_detail_model.get(**conditions) | ||
|
||
def filter_job_task_details(self, **conditions) -> QuerySet: | ||
return self.job_task_detail_model.filter(**conditions) | ||
|
||
def list_job_task_details(self, query: dict) -> Tuple[QuerySet, int]: | ||
return self.job_task_detail_model.query(**query) | ||
|
||
def stat_job_task_details(self, query: dict) -> dict: | ||
return self.job_task_detail_model.stat(**query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from typing import Union, Literal, List | ||
from pydantic import BaseModel | ||
|
||
__all__ = [ | ||
"JobTaskDeleteRequest", | ||
"JobTaskGetRequest", | ||
"JobTaskGetDetailRequest", | ||
"JobTaskSearchQueryRequest", | ||
"JobTaskStatQueryRequest", | ||
"Status", | ||
] | ||
|
||
Status = Literal["PENDING", "IN_PROGRESS", "SUCCESS", "FAILURE", "CANCELLED"] | ||
|
||
|
||
class JobTaskDeleteRequest(BaseModel): | ||
job_task_id: str | ||
workspace_id: Union[str, None] | ||
domain_id: str | ||
|
||
|
||
class JobTaskGetRequest(BaseModel): | ||
job_task_id: str | ||
workspace_id: Union[str, None] | ||
domain_id: str | ||
user_projects: Union[List[str], None] | ||
|
||
|
||
class JobTaskGetDetailRequest(BaseModel): | ||
job_task_id: str | ||
workspace_id: Union[str, None] | ||
domain_id: str | ||
user_projects: Union[List[str], None] | ||
|
||
|
||
class JobTaskSearchQueryRequest(BaseModel): | ||
query: dict | ||
job_task_id: Union[str, None] | ||
status: Union[Status, None] | ||
provider: Union[str, None] | ||
job_id: Union[str, None] | ||
secret_id: Union[str, None] | ||
service_account_id: Union[str, None] | ||
project_id: Union[str, None] | ||
workspace_id: Union[str, None] | ||
domain_id: str | ||
|
||
|
||
class JobTaskStatQueryRequest(BaseModel): | ||
query: dict | ||
workspace_id: Union[str, None] = None | ||
domain_id: str | ||
user_projects: Union[List[str], None] = None |
Oops, something went wrong.