Skip to content

Commit

Permalink
enable 6 document types of the sync-job to be called from the managem…
Browse files Browse the repository at this point in the history
…ent api
  • Loading branch information
Gregory-Pereira committed Apr 22, 2022
1 parent fc385a5 commit 49d6b66
Show file tree
Hide file tree
Showing 2 changed files with 252 additions and 0 deletions.
150 changes: 150 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,156 @@ paths:
"401":
description: On invalid secret.

/graph/sync-job/solver:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_solver_documents
summary: Trigger the Sync job for solver documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

/graph/sync-job/adviser:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_adviser_documents
summary: Trigger the Sync job for adviser documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

/graph/sync-job/revsolver:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_revsolver_documents
summary: Trigger the Sync job for revsolver documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

/graph/sync-job/package-extract:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_analysis_documents
summary: Trigger the Sync job for analysis documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

/graph/sync-job/provenance-checker:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_provenance_checker_documents
summary: Trigger the Sync job for provenance-checker documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

/graph/sync-job/security-indicators:
post:
tags: [Graph]
x-openapi-router-controller: thoth.management_api.api_v1
operationId: post_sync_job_secutiry_indicators_documents
summary: Trigger the Sync job for security-indicators documents
parameters:
- name: force
in: query
required: false
description: Perform force sync of documents.
schema:
type: string
- name: graceful
in: query
required: false
description: Continue on any error during the sync.
schema:
type: string
responses:
"201":
description: The Sync Job was triggerred successfully.
"400":
description: On invalid request.

components:
schemas:
Info:
Expand Down
102 changes: 102 additions & 0 deletions thoth/management_api/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
from thoth.storages import DependencyMonkeyRequestsStore
from thoth.storages import DependencyMonkeyReportsStore
from thoth.storages.exceptions import NotFoundError
from thoth.storages.sync import sync_adviser_documents
from thoth.storages.sync import sync_solver_documents
from thoth.storages.sync import sync_revsolver_documents
from thoth.storages.sync import sync_analysis_documents
from thoth.storages.sync import sync_provenance_checker_documents
from thoth.storages.sync import sync_security_indicators_documents

from .configuration import Configuration

Expand Down Expand Up @@ -61,6 +67,102 @@ def get_info(secret: str):
}


def post_sync_job_solver_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Solver documents."""
from .openapi_server import GRAPH

try:
sync_solver_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync adviser documents"}, 400


def post_sync_job_adviser_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Adviser documents."""
from .openapi_server import GRAPH

try:
sync_adviser_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync Adviser documents"}, 400


def post_sync_job_revsolver_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Revsolver documents."""
from .openapi_server import GRAPH

try:
sync_revsolver_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync revsolver documents"}, 400


def post_sync_job_analysis_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Analysis documents."""
from .openapi_server import GRAPH

try:
sync_analysis_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync Analysis documents"}, 400


def post_sync_job_provenance_checker_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Provenance Checker documents."""
from .openapi_server import GRAPH

try:
sync_provenance_checker_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync Provenance Checker documents"}, 400


def post_sync_job_secutiry_indicators_documents(
force: bool = False,
graceful: bool = False,
) -> tuple:
"""Tringger the Sync Job for Secutiry Indicators documents."""
from .openapi_server import GRAPH

try:
sync_security_indicators_documents(
force=force, graph=GRAPH, graceful=graceful, is_local=False
)
return {}, 201
except Exception:
return {"error": "Failed to sync Secutiry Indicators documents"}, 400


def post_register_python_package_index(
secret: str, index: dict, enabled: bool = False
) -> tuple:
Expand Down

0 comments on commit 49d6b66

Please sign in to comment.