#!/usr/bin/env python3
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

import sys
from logging import getLogger
from typing import Sequence

from cmk.gui.openapi.spec_generator_job import trigger_spec_generation_in_background


def main(args: Sequence[str]) -> int:
    logger = getLogger("api-spec")
    try:
        trigger_spec_generation_in_background(user_id=None)
    except Exception as e:
        logger.error("ERROR: Failed to initialize background job for regenerating openapi spec")
        logger.error(e)
    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
