diff --git a/manager.spec.yaml b/manager.spec.yaml index 06595feb7..b07a6e785 100644 --- a/manager.spec.yaml +++ b/manager.spec.yaml @@ -864,6 +864,24 @@ paths: - $ref: '#/components/parameters/mssql' /feature/cves_without_errata: + get: + summary: Get a feature flag status for CVEs without errata + description: > + Use this endpoint to get an enablement status of reporting CVEs that do not have advisories + (errata) for your customer account. If the feature is disabled, CVEs without advisories + will be hidden in outputs of all endpoints. + operationId: manager.feature_handler.GetCvesWithoutErrata.get + x-methodName: getCvesWithoutErrata + security: + - ApiKeyAuth: [] + - BasicAuth: [] + responses: + 200: + description: CVEs without Errata feature enablement status. + content: + application/vnd.api+json: + schema: + $ref: '#/components/schemas/CvesWithoutErrataOut' patch: summary: Set a feature flag for CVEs without errata description: > @@ -889,7 +907,7 @@ paths: content: application/vnd.api+json: schema: - $ref: '#/components/schemas/CvesWithoutErrataOut' + $ref: '#/components/schemas/CvesWithoutErrataPatchOut' /notifications: delete: @@ -3932,6 +3950,18 @@ components: type: number CvesWithoutErrataOut: + type: object + properties: + cves_without_errata: + type: object + properties: + enabled: + type: boolean + required: + - cves_without_errata + - org_id + + CvesWithoutErrataPatchOut: type: object properties: updated: diff --git a/manager/feature_handler.py b/manager/feature_handler.py index ecf80d249..a6cc0af0b 100644 --- a/manager/feature_handler.py +++ b/manager/feature_handler.py @@ -7,6 +7,7 @@ from common.peewee_model import RHAccount from manager.base import ApplicationException from manager.base import DeleteRequest +from manager.base import GetRequest from manager.base import PatchRequest from manager.base import get_account_data from manager.rbac_manager import RbacManager as RBAC @@ -28,6 +29,22 @@ def handle_patch(cls, **kwargs): return {"updated": {"org_id": org_id, "cves_without_errata": {"enabled": enable}}} +class GetCvesWithoutErrata(GetRequest): + """GET to /feature/cves_without_errata""" + + _endpoint_name = r"/v1/feature/cves_without_errata" + + @classmethod + def handle_get(cls, **kwargs): + """Get cves_without_errata DB flag for account.""" + org_id = context.context["user"]["org_id"] + result = RHAccount.get_or_none(RHAccount.org_id == org_id) + cves_without_errata = True + if result is not None: + cves_without_errata = result.cves_without_errata + return {"cves_without_errata": {"enabled": cves_without_errata}, "org_id": org_id} + + class DeleteNotifications(DeleteRequest): """DELETE to /notifications"""