diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 23b995f8e4..5454c62245 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -20,7 +20,7 @@ jobs: juju-channel: 3.6/stable provider: lxd test-tox-env: integration-juju3.6 - modules: '["test_charm_metrics_failure", "test_charm_metrics_success", "test_charm_fork_repo", "test_charm_fork_path_change", "test_charm_no_runner", "test_charm_runner", "test_debug_ssh", "test_charm_upgrade", "test_reactive", "test_jobmanager_prespawned", "test_jobmanager_reactive"]' + modules: '["test_charm_metrics_failure", "test_charm_metrics_success", "test_charm_fork_repo", "test_charm_fork_path_change", "test_charm_no_runner", "test_charm_runner", "test_debug_ssh", "test_charm_upgrade", "test_reactive"]' extra-arguments: '-m openstack --log-format="%(asctime)s %(levelname)s %(message)s"' self-hosted-runner: true self-hosted-runner-label: pfe-ci diff --git a/.licenserc.yaml b/.licenserc.yaml index cfa1ae4123..cfeb77f4ee 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -27,6 +27,5 @@ header: - '.woke.yaml' - 'lib/**' - 'github-runner-manager/**' - - 'jobmanager/**' - '.lycheeignore' comment: on-failure diff --git a/.vale/styles/config/vocabularies/local/accept.txt b/.vale/styles/config/vocabularies/local/accept.txt index 8eedc924e6..8af4b37a9d 100644 --- a/.vale/styles/config/vocabularies/local/accept.txt +++ b/.vale/styles/config/vocabularies/local/accept.txt @@ -1,5 +1,4 @@ aproxy Aproxy iptables -jobmanager Tmate \ No newline at end of file diff --git a/.woke.yaml b/.woke.yaml index 487bafcac4..8e96adc91c 100644 --- a/.woke.yaml +++ b/.woke.yaml @@ -1,6 +1,4 @@ -ignore_files: - # This is autogenerated code - - jobmanager/** +ignore_files: [] rules: # Ignore whitelist - we are using it to ignore pydantic in pyproject.toml and pylintrc - name: whitelist diff --git a/docs/changelog.md b/docs/changelog.md index c7301bdc6d..f34b3543fa 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,10 @@ This changelog documents user-relevant changes to the GitHub runner charm. - Added Grafana dashboard using Prometheus data source. +## 2025-11-12 + +- Removed the jobmanager platform provider and related integration tests as they are no longer used and not part of any public API. + ## 2025-08-27 - Updated the documentation workflow to be fully integrated with the Vale GitHub Action. diff --git a/github-runner-manager/pyproject.toml b/github-runner-manager/pyproject.toml index e01bbb8327..36e9476832 100644 --- a/github-runner-manager/pyproject.toml +++ b/github-runner-manager/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "github-runner-manager" -version = "0.6.3" +version = "0.7.0" authors = [ { name = "Canonical IS DevOps", email = "is-devops-team@canonical.com" }, ] diff --git a/github-runner-manager/src/github_runner_manager/configuration/base.py b/github-runner-manager/src/github_runner_manager/configuration/base.py index 978cfb4b8e..5183ddb569 100644 --- a/github-runner-manager/src/github_runner_manager/configuration/base.py +++ b/github-runner-manager/src/github_runner_manager/configuration/base.py @@ -10,7 +10,7 @@ import yaml from pydantic import AnyHttpUrl, BaseModel, Field, IPvAnyAddress, MongoDsn, root_validator -from github_runner_manager.configuration import github, jobmanager +from github_runner_manager.configuration import github from github_runner_manager.openstack_cloud.configuration import OpenStackConfiguration logger = logging.getLogger(__name__) @@ -40,7 +40,6 @@ class ApplicationConfiguration(BaseModel): Attributes: name: Name to identify the manager. Used for metrics. extra_labels: Extra labels to add to the runner. - jobmanager_config: Configuration for the jobmanager platform. github_config: GitHub configuration. service_config: The configuration for supporting services. non_reactive_configuration: Configuration for non-reactive mode. @@ -51,7 +50,6 @@ class ApplicationConfiguration(BaseModel): name: str extra_labels: list[str] - jobmanager_config: jobmanager.JobManagerConfiguration | None github_config: github.GitHubConfiguration | None service_config: "SupportServiceConfig" non_reactive_configuration: "NonReactiveConfiguration" diff --git a/github-runner-manager/src/github_runner_manager/configuration/jobmanager.py b/github-runner-manager/src/github_runner_manager/configuration/jobmanager.py deleted file mode 100644 index 098785ce5d..0000000000 --- a/github-runner-manager/src/github_runner_manager/configuration/jobmanager.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Module containing JobManager Configuration.""" -from pydantic import BaseModel, HttpUrl - - -class JobManagerConfiguration(BaseModel): - """JobManager configuration for the application. - - Attributes: - url: Base url of the job manager API. - token: Token to authenticate with the job manager API. - """ - - url: HttpUrl - token: str diff --git a/github-runner-manager/src/github_runner_manager/jobmanager_api.py b/github-runner-manager/src/github_runner_manager/jobmanager_api.py deleted file mode 100644 index 7008bcf1c8..0000000000 --- a/github-runner-manager/src/github_runner_manager/jobmanager_api.py +++ /dev/null @@ -1,184 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Module containing logic to handle calls to the jobmanager api.""" -from enum import Enum - -import jobmanager_client -from jobmanager_client.exceptions import ApiException, NotFoundException -from pydantic import BaseModel -from urllib3.exceptions import RequestError - - -class JobManagerAPIError(Exception): - """Base exception for JobManager API errors.""" - - -class JobManagerAPINotFoundError(JobManagerAPIError): - """Exception raised when a runner is not found in the JobManager API.""" - - -class JobStatus(str, Enum): - """Status of a job on the JobManager. - - Attributes: - IN_PROGRESS: Represents a job that is in progress. - PENDING: Represents a job that is pending. - """ - - IN_PROGRESS = "IN_PROGRESS" - PENDING = "PENDING" - - -class Job(BaseModel): - """Represents a job on the JobManagerAPI. - - Attributes: - status: The status of the job. - """ - - status: str | None - - -class RunnerStatus(str, Enum): - """Status of a runner on the JobManager. - - Attributes: - IN_PROGRESS: Represents a runner that is in progress. - PENDING: Represents a runner that is pending. - """ - - IN_PROGRESS = "IN_PROGRESS" - PENDING = "PENDING" - - -class RunnerRegistration(BaseModel): - """Represents a runner registration response from the JobManagerAPI. - - Attributes: - id: The ID of the registered runner. - token: The token for the registered runner. - """ - - id: int - token: str - - -class RunnerHealth(BaseModel): - """Represents the health status of a runner on the JobManagerAPI. - - Attributes: - status: The health status of the runner. - deletable: Indicates if the runner can be deleted. - """ - - status: str - deletable: bool - - -class JobManagerAPI: - """Handles interactions with the JobManager API.""" - - # The job manager api uses an autogenerated api client that uses urllib3 connection pools - # that are not multiprocessing safe: https://github.com/urllib3/urllib3/issues/850 - # Therefore, we create a new ApiClient for each request and close resources - # to avoid issues with multiprocessing in the application. - - def __init__(self, token: str, url: str): - """Initialize the JobManagerAPI with a token and URL. - - Args: - token: The authentication token for the JobManager API. - url: The base URL for the JobManager API. - """ - self._token = token - self.url = url - - def get_runner_health(self, runner_id: int) -> RunnerHealth: - """Fetch the health status of a runner by its ID from the JobManager API. - - Args: - runner_id: The ID of the runner to fetch health status for. - - Raises: - JobManagerAPINotFoundError: If the runner with the given ID is not found. - JobManagerAPIError: If there is an error fetching the runner health. - - Returns: - RunnerHealth: The health status of the runner. - """ - with self._create_api_client() as api_client: - runners_api = jobmanager_client.RunnersApi(api_client=api_client) - try: - response = runners_api.get_runner_health_v1_runners_runner_id_health_get(runner_id) - except NotFoundException as err: - raise JobManagerAPINotFoundError( - f"Health for runner with ID {runner_id} not found in JobManager API." - ) from err - except (ApiException, RequestError, ValueError) as exc: - raise JobManagerAPIError( - f"Error fetching runner health for ID {runner_id}: {exc}" - ) from exc - return RunnerHealth(status=response.status, deletable=response.deletable) - - def register_runner(self, name: str, labels: list[str]) -> RunnerRegistration: - """Register a new runner with the JobManager API. - - Args: - name: The name of the runner to register. - labels: A list of labels to associate with the runner. - - Returns: - RunnerRegistration: The registration details of the runner, including ID and token. - - Raises: - JobManagerAPIError: If there is an error registering the runner. - """ - with self._create_api_client() as api_client: - runners_api = jobmanager_client.RunnersApi(api_client=api_client) - runner_register_request = jobmanager_client.RunnerCreate(name=name, labels=labels) - - try: - response = runners_api.register_runner_v1_runners_register_post( - runner_register_request - ) - except (ApiException, RequestError, ValueError) as exc: - raise JobManagerAPIError(f"Error registering runner: {exc}") from exc - return RunnerRegistration(id=response.id, token=response.token) - - def get_job(self, job_id: int) -> Job: - """Fetch a job by its ID from the JobManager API. - - Args: - job_id: The ID of the job to fetch. - - Returns: - Job: The job object containing its status. - - Raises: - JobManagerAPINotFoundError: If the job with the given ID is not found. - JobManagerAPIError: If there is an error fetching the job. - """ - with self._create_api_client() as api_client: - jobs_api = jobmanager_client.JobsApi(api_client=api_client) - try: - response = jobs_api.get_job_v1_jobs_job_id_get(job_id) - except NotFoundException as err: - raise JobManagerAPINotFoundError( - f"Job with ID {job_id} not found in JobManager API." - ) from err - except (ApiException, RequestError, ValueError) as exc: - raise JobManagerAPIError(f"Error fetching job with ID {job_id}: {exc}") from exc - return Job(status=response.status) - - def _create_api_client(self) -> jobmanager_client.ApiClient: - """Create a new API client for the JobManager API. - - Returns: - jobmanager_client.ApiClient: A new API client configured with the JobManager - API URL and token. - """ - config = jobmanager_client.Configuration(host=self.url) - api_client = jobmanager_client.ApiClient(configuration=config) - api_client.set_default_header("Authorization", f"Bearer {self._token}") - return api_client diff --git a/github-runner-manager/src/github_runner_manager/manager/models.py b/github-runner-manager/src/github_runner_manager/manager/models.py index fe4b591aee..a5e1bfce1a 100644 --- a/github-runner-manager/src/github_runner_manager/manager/models.py +++ b/github-runner-manager/src/github_runner_manager/manager/models.py @@ -163,7 +163,7 @@ class RunnerMetadata: platform ones. Attributes: - platform_name: Platform name where the runner resides (github, jobmanager...) + platform_name: Platform name where the runner resides (currently only github) runner_id: Id of the runner in the platform url: URL for the runner. """ diff --git a/github-runner-manager/src/github_runner_manager/manager/runner_scaler.py b/github-runner-manager/src/github_runner_manager/manager/runner_scaler.py index 456b63e219..448c0d4265 100644 --- a/github-runner-manager/src/github_runner_manager/manager/runner_scaler.py +++ b/github-runner-manager/src/github_runner_manager/manager/runner_scaler.py @@ -144,7 +144,6 @@ def build( # pylint: disable-msg=too-many-locals platform_provider = platform_factory( vm_prefix=application_configuration.openstack_configuration.vm_prefix, github_config=application_configuration.github_config, - jobmanager_config=application_configuration.jobmanager_config, ) runner_manager = RunnerManager( @@ -167,7 +166,6 @@ def build( # pylint: disable-msg=too-many-locals queue=reactive_config.queue, manager_name=application_configuration.name, github_configuration=application_configuration.github_config, - jobmanager_configuration=application_configuration.jobmanager_config, cloud_runner_manager=openstack_runner_manager_config, supported_labels=supported_labels, labels=labels, @@ -179,9 +177,7 @@ def build( # pylint: disable-msg=too-many-locals user=user, base_quantity=base_quantity, max_quantity=max_quantity, - platform_name=( - Platform.GITHUB if application_configuration.github_config else Platform.JOBMANAGER - ), + platform_name=Platform.GITHUB, python_path=python_path, ) diff --git a/github-runner-manager/src/github_runner_manager/platform/factory.py b/github-runner-manager/src/github_runner_manager/platform/factory.py index 0450e37245..70e5ec6390 100644 --- a/github-runner-manager/src/github_runner_manager/platform/factory.py +++ b/github-runner-manager/src/github_runner_manager/platform/factory.py @@ -3,23 +3,19 @@ """Factory for instantiating platform provider.""" from github_runner_manager.configuration.github import GitHubConfiguration -from github_runner_manager.configuration.jobmanager import JobManagerConfiguration from github_runner_manager.platform.github_provider import GitHubRunnerPlatform -from github_runner_manager.platform.jobmanager_provider import JobManagerPlatform from github_runner_manager.platform.platform_provider import PlatformProvider def platform_factory( vm_prefix: str, github_config: GitHubConfiguration | None, - jobmanager_config: JobManagerConfiguration | None, ) -> PlatformProvider: """Instantiate a concrete Platform Provider. Args: vm_prefix: The prefix for the virtual machines to be created. github_config: Configuration of the GitHub instance. - jobmanager_config: Configuration of the job manager. Raises: ValueError: If an invalid configuration has been passed. @@ -27,10 +23,6 @@ def platform_factory( Returns: A concrete platform provider. """ - if github_config and jobmanager_config: - raise ValueError("Multiple configuration provided.") - if github_config: - return GitHubRunnerPlatform.build(prefix=vm_prefix, github_configuration=github_config) - if jobmanager_config: - return JobManagerPlatform.build(jobmanager_configuration=jobmanager_config) - raise ValueError("Missing configuration.") + if not github_config: + raise ValueError("Missing configuration.") + return GitHubRunnerPlatform.build(prefix=vm_prefix, github_configuration=github_config) diff --git a/github-runner-manager/src/github_runner_manager/platform/jobmanager_provider.py b/github-runner-manager/src/github_runner_manager/platform/jobmanager_provider.py deleted file mode 100644 index 91c4f4c5fa..0000000000 --- a/github-runner-manager/src/github_runner_manager/platform/jobmanager_provider.py +++ /dev/null @@ -1,271 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""JobManager platform provider.""" - -import logging - -from pydantic import HttpUrl - -from github_runner_manager.configuration.jobmanager import JobManagerConfiguration -from github_runner_manager.jobmanager_api import ( - JobManagerAPI, - JobManagerAPIError, - JobManagerAPINotFoundError, - JobStatus, - RunnerStatus, -) -from github_runner_manager.manager.models import ( - InstanceID, - RunnerContext, - RunnerIdentity, - RunnerMetadata, -) -from github_runner_manager.platform.platform_provider import ( - JobInfo, - PlatformApiError, - PlatformProvider, - PlatformRunnerHealth, - RunnersHealthResponse, -) -from github_runner_manager.types_.github import GitHubRunnerStatus, SelfHostedRunner - -logger = logging.getLogger(__name__) - - -class JobManagerPlatform(PlatformProvider): - """Manage self-hosted runner on the JobManager.""" - - def __init__(self, jobmanager_api: JobManagerAPI): - """Construct the object. - - Args: - jobmanager_api: The jobmanager API client to use. - """ - self._jobmanager_api = jobmanager_api - - @classmethod - def build(cls, jobmanager_configuration: JobManagerConfiguration) -> "JobManagerPlatform": - """Build a new instance of the JobManagerPlatform. - - Args: - jobmanager_configuration: Configuration for the jobmanager. - - Returns: - New JobManagerPlatform. - """ - return cls( - jobmanager_api=JobManagerAPI( - url=jobmanager_configuration.url, token=jobmanager_configuration.token - ), - ) - - def get_runner_health( - self, - runner_identity: RunnerIdentity, - ) -> PlatformRunnerHealth: - """Get health information on jobmanager runner. - - Args: - runner_identity: Identity of the runner. - - Raises: - PlatformApiError: If there was an error calling the jobmanager client. - - Returns: - The health of the runner in the jobmanager. - """ - try: - response = self._jobmanager_api.get_runner_health( - int(runner_identity.metadata.runner_id) - ) - except JobManagerAPINotFoundError: - return PlatformRunnerHealth( - identity=runner_identity, - online=False, - deletable=False, - busy=False, - ) - except JobManagerAPIError as exc: - logger.exception( - "Error calling jobmanager api for runner %s. %s", runner_identity, exc - ) - raise PlatformApiError("API error") from exc - - online = response.status != RunnerStatus.PENDING - # busy is complex in the jobmanager, as a completed job that is not deletable is really - # busy. As so, every job that is not deletable is considered busy. - busy = not response.deletable - deletable = response.deletable - - return PlatformRunnerHealth( - identity=runner_identity, - online=online, - deletable=deletable, - busy=busy, - ) - - def get_runners_health(self, requested_runners: list[RunnerIdentity]) -> RunnersHealthResponse: - """Get the health of a list of requested runners. - - Args: - requested_runners: List of requested runners. - - Returns: - Health information on the runners. - """ - runners_health = [] - failed_runners = [] - for identity in requested_runners: - try: - health = self.get_runner_health(identity) - except PlatformApiError as exc: - logger.warning( - "Failed to get information for the runner %s in the jobmanager. %s", - identity, - exc, - ) - failed_runners.append(identity) - continue - runners_health.append(health) - return RunnersHealthResponse( - requested_runners=runners_health, - failed_requested_runners=failed_runners, - ) - - def delete_runners(self, runner_ids: list[str]) -> list[str]: - """Delete a runner from jobmanager. - - This method does nothing, as the jobmanager does not implement it. - - Args: - runner_ids: The runner IDs to delete. - - Returns: - The runner IDs requested for deletion. - """ - logger.debug("No need to delete runners in the jobmanager.") - return runner_ids - - def get_runner_context( - self, metadata: RunnerMetadata, instance_id: InstanceID, labels: list[str] - ) -> tuple[RunnerContext, SelfHostedRunner]: - """Get the runner context for a self-hosted runner. - - This token is used for registering self-hosted runners. - - Args: - instance_id: Instance ID of the runner. - metadata: Metadata for the runner. - labels: Labels for the runner. - - Raises: - PlatformApiError: Problem with the underlying API. - - Returns: - A tuple containing the runner context and the self-hosted runner. - """ - try: - response = self._jobmanager_api.register_runner(name=instance_id.name, labels=labels) - jobmanager_base_url = self._jobmanager_api.url.rstrip("/") - updated_metadata = RunnerMetadata( - platform_name=metadata.platform_name, url=jobmanager_base_url - ) - updated_metadata.runner_id = str(response.id) - if token := response.token: - jobmanager_endpoint = ( - f"{jobmanager_base_url}/v1/runners/{updated_metadata.runner_id}/health" - ) - # For now, use the first label - label = "undefined" if not labels else labels[0] - command_to_run = ( - f"BUILDER_LABEL={label} JOB_MANAGER_BEARER_TOKEN={token} " - f"JOB_MANAGER_API_ENDPOINT={jobmanager_endpoint} " - "builder-agent" - ) - return ( - RunnerContext( - shell_run_script=command_to_run, - ingress_tcp_ports=[8080], - ), - SelfHostedRunner( - identity=RunnerIdentity( - instance_id=instance_id, - metadata=metadata, - ), - busy=False, - id=int(updated_metadata.runner_id), - labels=labels, - status=GitHubRunnerStatus.OFFLINE, - ), - ) - raise PlatformApiError("Empty token from jobmanager API") - except JobManagerAPIError as exc: - logger.exception("Error calling jobmanager api.") - raise PlatformApiError("API error") from exc - - def check_job_been_picked_up(self, metadata: RunnerMetadata, job_url: HttpUrl) -> bool: - """Check if the job has already been picked up. - - Args: - job_url: The URL of the job. - metadata: Metadata for the runner. - - Raises: - PlatformApiError: Problem with the underlying client. - ValueError: Raised when the job_url is malformed. - - Returns: - True if the job has been picked up, False otherwise. - """ - # job_url has the path: - # "/v1/jobs/" - job_path_prefix = "/v1/jobs/" - - path = job_url.path - if not (path and path.startswith(job_path_prefix)): - logger.error( - "Job URL path does not start with '%s'. Received %s", job_path_prefix, path - ) - raise ValueError(f'Job URL path does not start with "{job_path_prefix}"') - try: - job_id = int(path[len(job_path_prefix) :]) # Extract job_id from the path - except ValueError as exc: - logger.error( - "Job URL path %s does not contain a valid job_id after '%s'", - path, - job_path_prefix, - ) - raise ValueError( - f"Job URL path does not contain a valid job_id after '{job_path_prefix}'" - ) from exc - logging.debug( - "Parsed job_id: %s from job_url path %s", - job_id, - path, - ) - - try: - job = self._jobmanager_api.get_job(job_id) - if job.status != JobStatus.PENDING: - return True - except JobManagerAPIError as exc: - logger.exception("Error calling jobmanager api to get job information.") - raise PlatformApiError("API error") from exc - return False - - def get_job_info( - self, metadata: RunnerMetadata, repository: str, workflow_run_id: str, runner: InstanceID - ) -> JobInfo: - """Get the Job info from the provider. - - Args: - metadata: Metadata for the runner. - repository: repository to get the job from. - workflow_run_id: workflow run id of the job. - runner: runner to get the job from. - - Raises: - PlatformApiError: This is not provided by this interface yet. - """ - raise PlatformApiError("get_job_info not provided by the jobmanager") diff --git a/github-runner-manager/src/github_runner_manager/platform/platform_provider.py b/github-runner-manager/src/github_runner_manager/platform/platform_provider.py index 7b5d21fb21..a7192a1086 100644 --- a/github-runner-manager/src/github_runner_manager/platform/platform_provider.py +++ b/github-runner-manager/src/github_runner_manager/platform/platform_provider.py @@ -20,7 +20,6 @@ from github_runner_manager.types_.github import GitHubRunnerStatus, SelfHostedRunner _GITHUB_PLATFORM_KEY = "github" -_JOBMANAGER_PLATFORM_KEY = "jobmanager" class Platform(str, Enum): @@ -28,11 +27,9 @@ class Platform(str, Enum): Attributes: GITHUB: GitHub platform. - JOBMANAGER: JobManager platform. """ GITHUB = _GITHUB_PLATFORM_KEY - JOBMANAGER = _JOBMANAGER_PLATFORM_KEY class PlatformError(Exception): diff --git a/github-runner-manager/src/github_runner_manager/reactive/consumer.py b/github-runner-manager/src/github_runner_manager/reactive/consumer.py index 5e9b79b97d..93601bbca4 100644 --- a/github-runner-manager/src/github_runner_manager/reactive/consumer.py +++ b/github-runner-manager/src/github_runner_manager/reactive/consumer.py @@ -4,7 +4,6 @@ """Module responsible for consuming jobs from the message queue.""" import contextlib import logging -import re import signal import sys from contextlib import closing @@ -197,21 +196,24 @@ def consume( # noqa: C901 def _build_runner_metadata(job_url: str) -> RunnerMetadata: - """Build runner metadata from the job url.""" + """Build runner metadata from the job url. + + Args: + job_url: The job URL. + + Returns: + RunnerMetadata for GitHub. + + Raises: + ValueError: If the URL is not a GitHub URL. + """ parsed_url = urlparse(job_url) - # We expect the netloc to contain github.com, otherwise this function will fail, - # as will use jobmanager code to handle github runners. + # We only support github.com URLs now if "github.com" in parsed_url.netloc: return RunnerMetadata() - # From here on jobmanager. For now we just regex on the url to check if it is the url - # of a runner. - match_result = re.match(r"^(.*)/v1/jobs/(\d+)$", parsed_url.path) - if not match_result: - logger.error("Invalid URL for a job. url: %s", job_url) - raise ValueError(f"Invalid format for job url {job_url}") - base_url = parsed_url._replace(path=match_result.group(1)).geturl() - return RunnerMetadata(platform_name="jobmanager", url=base_url) + logger.error("Invalid URL for a job. Only GitHub URLs are supported. url: %s", job_url) + raise ValueError(f"Invalid job url {job_url}. Only GitHub URLs are supported.") def _parse_job_details(msg: Message) -> JobDetails: diff --git a/github-runner-manager/src/github_runner_manager/reactive/runner.py b/github-runner-manager/src/github_runner_manager/reactive/runner.py index 6ccf3d0a2f..b8be206729 100644 --- a/github-runner-manager/src/github_runner_manager/reactive/runner.py +++ b/github-runner-manager/src/github_runner_manager/reactive/runner.py @@ -54,7 +54,6 @@ def main() -> None: platform_provider = platform_factory( vm_prefix=runner_config.cloud_runner_manager.prefix, github_config=runner_config.github_configuration, - jobmanager_config=runner_config.jobmanager_configuration, ) runner_manager = RunnerManager( manager_name=runner_config.manager_name, diff --git a/github-runner-manager/src/github_runner_manager/reactive/types_.py b/github-runner-manager/src/github_runner_manager/reactive/types_.py index afdc18bab3..0487aa9113 100644 --- a/github-runner-manager/src/github_runner_manager/reactive/types_.py +++ b/github-runner-manager/src/github_runner_manager/reactive/types_.py @@ -7,7 +7,6 @@ from github_runner_manager.configuration.base import QueueConfig from github_runner_manager.configuration.github import GitHubConfiguration -from github_runner_manager.configuration.jobmanager import JobManagerConfiguration from github_runner_manager.openstack_cloud.openstack_runner_manager import ( OpenStackRunnerManagerConfig, ) @@ -19,7 +18,6 @@ class ReactiveProcessConfig(BaseModel): Attributes: queue: The queue configuration. manager_name: Name of the manager. - jobmanager_configuration: Configuration for JobManager. github_configuration: Configuration for GitHub. cloud_runner_manager: The OpenStack runner manager configuration. supported_labels: The supported labels for the runner. @@ -29,7 +27,6 @@ class ReactiveProcessConfig(BaseModel): queue: QueueConfig manager_name: str github_configuration: GitHubConfiguration | None - jobmanager_configuration: JobManagerConfiguration | None cloud_runner_manager: OpenStackRunnerManagerConfig supported_labels: set[str] labels: list[str] diff --git a/github-runner-manager/tests/unit/factories/runner_instance_factory.py b/github-runner-manager/tests/unit/factories/runner_instance_factory.py index 06bdf3223b..1601ffe825 100644 --- a/github-runner-manager/tests/unit/factories/runner_instance_factory.py +++ b/github-runner-manager/tests/unit/factories/runner_instance_factory.py @@ -48,7 +48,7 @@ class Meta: model = RunnerMetadata - platform_name = factory.Faker("word", ext_word_list=["github", "jobmanager"]) + platform_name = factory.Faker("word", ext_word_list=["github"]) runner_id = str(factory.Faker("random_int", min=1, max=10000)) url = factory.Faker("url") diff --git a/github-runner-manager/tests/unit/platform/test_factory.py b/github-runner-manager/tests/unit/platform/test_factory.py index 7635305220..d5c7d3d675 100644 --- a/github-runner-manager/tests/unit/platform/test_factory.py +++ b/github-runner-manager/tests/unit/platform/test_factory.py @@ -9,50 +9,38 @@ from github_runner_manager.platform.factory import platform_factory from github_runner_manager.platform.github_provider import GitHubRunnerPlatform -from github_runner_manager.platform.jobmanager_provider import JobManagerPlatform @pytest.mark.parametrize( - "github_config, jobmanager_config, expected_error", + "github_config, expected_error", [ - pytest.param(None, None, "Missing configuration.", id="No configurations"), - pytest.param( - MagicMock(), - MagicMock(), - "Multiple configuration provided.", - id="Multiple configurations", - ), + pytest.param(None, "Missing configuration.", id="No configurations"), ], ) -def test_platform_factory_invalid_configurations(github_config, jobmanager_config, expected_error): +def test_platform_factory_invalid_configurations(github_config, expected_error): """ - arrange: mock github client and job manager configuration. + arrange: mock github client configuration. act: call platform_factory with invalid configurations. assert: check that ValueError is raised. """ with pytest.raises(ValueError) as exc_info: - platform_factory( - vm_prefix="test", github_config=github_config, jobmanager_config=jobmanager_config - ) + platform_factory(vm_prefix="test", github_config=github_config) assert str(exc_info.value) == expected_error @pytest.mark.parametrize( - "github_config, jobmanager_config, expected_platform", + "github_config, expected_platform", [ - pytest.param(MagicMock(), None, GitHubRunnerPlatform, id="GitHub configuration"), - pytest.param(None, MagicMock(), JobManagerPlatform, id="Jobmanager configuration"), + pytest.param(MagicMock(), GitHubRunnerPlatform, id="GitHub configuration"), ], ) -def test_platform_factory(github_config, jobmanager_config, expected_platform): +def test_platform_factory(github_config, expected_platform): """ - arrange: mock github client and job manager configuration. + arrange: mock github client configuration. act: call platform_factory with mock objects. assert: check that expected platform provider is returned. """ assert isinstance( - platform_factory( - vm_prefix="test", github_config=github_config, jobmanager_config=jobmanager_config - ), + platform_factory(vm_prefix="test", github_config=github_config), expected_platform, ) diff --git a/github-runner-manager/tests/unit/platform/test_jobmanager_provider.py b/github-runner-manager/tests/unit/platform/test_jobmanager_provider.py deleted file mode 100644 index 9dbc2b95a7..0000000000 --- a/github-runner-manager/tests/unit/platform/test_jobmanager_provider.py +++ /dev/null @@ -1,437 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Test for the jobmanager provider module.""" -import random -from typing import Any - -import pytest -from pydantic import BaseModel, HttpUrl - -from github_runner_manager.jobmanager_api import ( - Job, - JobManagerAPIError, - JobManagerAPINotFoundError, - JobStatus, - RunnerHealth, - RunnerRegistration, - RunnerStatus, -) -from github_runner_manager.manager.models import InstanceID, RunnerIdentity, RunnerMetadata -from github_runner_manager.platform.jobmanager_provider import JobManagerPlatform -from github_runner_manager.platform.platform_provider import ( - PlatformApiError, - PlatformRunnerHealth, - RunnersHealthResponse, -) -from github_runner_manager.types_.github import GitHubRunnerStatus - -TEST_JOB_MANAGER_TOKEN = "token" - -TEST_JOB_MANAGER_URL = "http://jobmanager.example.com" - - -class JobManagerAPIStub: - """Stub for the JobManagerAPI to use in tests.""" - - def __init__(self, url: str, token: str): - """Initialize the stub with a URL and token.""" - self.url = url - self.token = token - self._register_runner_response = RunnerRegistration( - id=random.randint(1, 1000), token=token - ) - self._job_response = Job(status=JobStatus.PENDING.value) - self._runner_health_responses = [ - RunnerHealth( - status=RunnerStatus.PENDING.value, - deletable=False, - ) - ] - - def set_register_runner_response(self, response: RunnerRegistration | Exception): - """Set the response for the register_runner method.""" - self._register_runner_response = response - - def register_runner(self, *args, **kwargs): - """Stub register_runner_method.""" - if isinstance(self._register_runner_response, Exception): - raise self._register_runner_response - return self._register_runner_response - - def set_job_response(self, job: Job | Exception): - """Set the response for the get_job method.""" - self._job_response = job - - def get_job(self, *args, **kwargs) -> Job: - """Stub get_job method.""" - if isinstance(self._job_response, Exception): - raise self._job_response - return self._job_response - - def set_get_runner_health_responses(self, responses: list[RunnerHealth | Exception]): - """Set the responses for the get_runner_health method.""" - self._runner_health_responses = responses - - def get_runner_health(self, *args, **kwargs) -> RunnerHealth: - """Stub get_runner_health method.""" - try: - response = self._runner_health_responses.pop(0) - except IndexError: - assert False, "No more responses available for get_runner_health" - if isinstance(response, Exception): - raise response - return response - - -def test_get_runner_context_succeeds(monkeypatch: pytest.MonkeyPatch): - """ - arrange: Mock the client api to return a token. - act: Call get_runner_context. - assert: The correct token and the correct runner are returned. - """ - metadata = RunnerMetadata(platform_name="jobmanager", runner_id=None, url=None) - instance_id = InstanceID.build(prefix="unit-0") - labels = ["label"] - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - - context, runner = platform.get_runner_context(metadata, instance_id, labels) - - assert "builder-agent" in context.shell_run_script - assert runner.labels == ["label"] - assert runner.identity.metadata == metadata - assert runner.status == GitHubRunnerStatus.OFFLINE - assert not runner.busy - - -@pytest.mark.parametrize( - "api_return_value, error_message", - [ - pytest.param( - RunnerRegistration(id=random.randint(1, 10), token=""), - "Empty token", - id="Empty token", - ), - pytest.param(JobManagerAPIError(), "API error", id="Exception from api"), - ], -) -def test_get_runner_context_fails( - monkeypatch: pytest.MonkeyPatch, api_return_value, error_message -): - """ - arrange: Mock the jobmanager client to return different error conditions. - act: Call get_runner_context. - assert: PlatformApiError should be raised with the expected message. - """ - metadata = RunnerMetadata( - platform_name="jobmanager", runner_id="3", url="http://jobmanager.example.com" - ) - instance_id = InstanceID.build(prefix="unit-0") - labels = ["label"] - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_register_runner_response(api_return_value) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - - with pytest.raises(PlatformApiError) as exc: - _context, _runner = platform.get_runner_context(metadata, instance_id, labels) - - assert error_message in str(exc.value) - - -@pytest.mark.parametrize( - "api_return_value, picked_up", - [ - pytest.param( - Job( - status=JobStatus.IN_PROGRESS.value, - ), - True, - id="in progress job", - ), - pytest.param( - Job( - status=JobStatus.PENDING.value, - ), - False, - id="pending job", - ), - ], -) -def test_check_job_been_picked_up(monkeypatch: pytest.MonkeyPatch, api_return_value, picked_up): - """ - arrange: Prepare a job return for the jobmanager client. - act: call check_job_been_picked_up. - assert: Depending on the state of the job, it will be picked or not accordingly. - """ - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_job_response(api_return_value) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - metadata = RunnerMetadata( - platform_name="jobmanager", runner_id="3", url="http://jobmanager.example.com" - ) - - # we use a BaseModel to convert a url string to a HttpUrl - class JobUrlModel(BaseModel): - """Model for job URL. - - Attributes: - url: The URL of the job. - """ - - url: HttpUrl - - # we can pass a string here, mypy doesn't understand it - job_url = JobUrlModel(url="http://jobmanager.com/v1/jobs/1234").url # type: ignore - - assert platform.check_job_been_picked_up(metadata, job_url) == picked_up - - -def test_check_job_been_picked_fails(monkeypatch: pytest.MonkeyPatch): - """ - arrange: The jobmanager client raises an exception when called. - act: call check_job_been_picked_up. - assert: The PlatformApiError exception is raised from the jobmanager provider. - """ - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_job_response(JobManagerAPIError()) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - metadata = RunnerMetadata( - platform_name="jobmanager", runner_id="3", url="http://jobmanager.example.com" - ) - - # we use a BaseModel to convert a url string to a HttpUrl - class JobUrlModel(BaseModel): - """Model for job URL. - - Attributes: - url: The URL of the job. - """ - - url: HttpUrl - - # we can pass a string here, mypy doesn't understand it - job_url = JobUrlModel(url="http://jobmanager.com/v1/jobs/1234").url # type: ignore - - with pytest.raises(PlatformApiError): - platform.check_job_been_picked_up(metadata, job_url) - - -@pytest.mark.parametrize( - "job_url, expected_msg", - [ - pytest.param( - "http://jobmanager.com/v1/runner", - 'Job URL path does not start with "/v1/jobs/"', - id="wrong path", - ), - pytest.param( - "http://jobmanager.com/", - 'Job URL path does not start with "/v1/jobs/"', - id="no path", - ), - pytest.param( - "http://jobmanager.com", - 'Job URL path does not start with "/v1/jobs/"', - id="no path and no trailing slash", - ), - pytest.param( - "http://jobmanager.com/v1/jobs/", - "Job URL path does not contain a valid job_id after '/v1/jobs/'", - id="job id missing", - ), - pytest.param( - "http://jobmanager.com/v1/jobs/", - "Job URL path does not contain a valid job_id after '/v1/jobs/'", - id="job id non-int", - ), - ], -) -def test_check_job_been_picked_up_job_url_validation_err( - job_url: str, expected_msg: str, monkeypatch: pytest.MonkeyPatch -): - - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_job_response(Job(status=JobStatus.IN_PROGRESS)) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - metadata = RunnerMetadata(platform_name="jobmanager", runner_id="3", url=job_url) - - # we use a BaseModel to convert a url string to a HttpUrl - class JobUrlModel(BaseModel): - """Model for job URL. - - Attributes: - url: The URL of the job. - """ - - url: HttpUrl - - # we can pass a string here, mypy doesn't understand it - job_url = JobUrlModel(url=job_url).url # type: ignore - - with pytest.raises(ValueError) as exc_info: - platform.check_job_been_picked_up(metadata, job_url) - - assert expected_msg in str(exc_info.value) - - -@pytest.mark.parametrize( - "job_status,job_deletable,expected_online,expected_busy,expected_deletable", - [ - pytest.param("PENDING", False, False, True, False, id="pending runner"), - pytest.param("IN_PROGRESS", False, True, True, False, id="in progress runner"), - pytest.param("COMPLETED", False, True, True, False, id="completed not deletabule runner"), - pytest.param("COMPLETED", True, True, False, True, id="completed and deletable runner"), - ], -) -def test_get_runner_health( - monkeypatch: pytest.MonkeyPatch, - job_status: str, - job_deletable: bool, - expected_online: bool, - expected_busy: bool, - expected_deletable: bool, -): - """ - arrange: Given job health information from the jobmanager. - act: Call JobManagerPlatform.get_runner_health. - assert: Assert the correct health state is reported. - """ - api_return_value = RunnerHealth( - status=job_status, - deletable=job_deletable, - ) - - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_get_runner_health_responses([api_return_value]) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - - instance_id = InstanceID.build(prefix="unit-0") - metadata = RunnerMetadata( - platform_name="jobmanager", runner_id="3", url="http://jobmanager.example.com" - ) - identity = RunnerIdentity(instance_id=instance_id, metadata=metadata) - runner_health = platform.get_runner_health(identity) - - assert runner_health - assert runner_health.online is expected_online - assert runner_health.busy is expected_busy - assert runner_health.deletable is expected_deletable - - -@pytest.mark.parametrize( - "requested_runners,jobmanager_side_effects,expected_health_response", - [ - pytest.param( - [], - [], - RunnersHealthResponse(), - id="Nothing requested, nothing in jobmanager, nothing replied.", - ), - pytest.param( - [ - identity_1 := RunnerIdentity( - instance_id=InstanceID.build(prefix="unit-0"), - metadata=RunnerMetadata( - platform_name="jobmanager", - runner_id="1", - url="http://jobmanager.example.com", - ), - ), - identity_2 := RunnerIdentity( - instance_id=InstanceID.build(prefix="unit-0"), - metadata=RunnerMetadata( - platform_name="jobmanager", - runner_id="2", - url="http://jobmanager.example.com", - ), - ), - ], - [ - RunnerHealth( - status="IN_PROGRESS", - deletable=False, - ), - JobManagerAPIError(), - ], - RunnersHealthResponse( - requested_runners=[ - PlatformRunnerHealth( - identity=identity_1, - online=True, - busy=True, - deletable=False, - ), - ], - failed_requested_runners=[ - identity_2, - ], - ), - id="Two requested. One of the request failed.", - ), - pytest.param( - [ - identity_1 := RunnerIdentity( - instance_id=InstanceID.build(prefix="unit-0"), - metadata=RunnerMetadata( - platform_name="jobmanager", - runner_id="1", - url="http://jobmanager.example.com", - ), - ), - identity_2 := RunnerIdentity( - instance_id=InstanceID.build(prefix="unit-0"), - metadata=RunnerMetadata( - platform_name="jobmanager", - runner_id="2", - url="http://jobmanager.example.com", - ), - ), - ], - [ - RunnerHealth( - status="FAILED", - deletable=True, - ), - JobManagerAPINotFoundError(), - ], - RunnersHealthResponse( - requested_runners=[ - PlatformRunnerHealth( - identity=identity_1, - online=True, - busy=False, - deletable=True, - ), - PlatformRunnerHealth( - identity=identity_2, - online=False, - busy=False, - deletable=False, - ), - ], - ), - id="Two requested. One deletable, one not found in jobmanager.", - ), - ], -) -def test_get_runners_health( - monkeypatch: pytest.MonkeyPatch, - requested_runners: list[RunnerIdentity], - jobmanager_side_effects: Any, - expected_health_response: RunnersHealthResponse, -): - """ - arrange: Given some requested runner identities, and replies from the jobmanager. - act: Call get_runners_health. - assert: The expected health response with the correct requested_runners and - runners with failed requests. - """ - jobmanager_api = JobManagerAPIStub(TEST_JOB_MANAGER_URL, TEST_JOB_MANAGER_TOKEN) - jobmanager_api.set_get_runner_health_responses(jobmanager_side_effects) - platform = JobManagerPlatform(jobmanager_api=jobmanager_api) - - runners_health_response = platform.get_runners_health(requested_runners) - - expected_health_response = expected_health_response - assert runners_health_response == expected_health_response diff --git a/github-runner-manager/tests/unit/reactive/test_consumer.py b/github-runner-manager/tests/unit/reactive/test_consumer.py index a666671f32..7ea21d0954 100644 --- a/github-runner-manager/tests/unit/reactive/test_consumer.py +++ b/github-runner-manager/tests/unit/reactive/test_consumer.py @@ -86,44 +86,6 @@ def test_consume(labels: Labels, supported_labels: Labels, queue_config: QueueCo mock_sleep.assert_called_once_with(WAIT_TIME_IN_SEC) -def test_consume_job_manager(queue_config: QueueConfig): - """ - arrange: New Job created in the queue with a format matching the jobmanager. - act: Call consume. - assert: A runner in created with the correct metadata - """ - labels = {"label1"} - - job_id = "5" - job_url = f"https://jobmanager.example.com/subpath/v1/jobs/{job_id}" - - job_details = consumer.JobDetails( - labels=labels, - url=job_url, - ) - _put_in_queue(job_details.json(), queue_config.queue_name) - - runner_manager_mock = MagicMock(spec=consumer.RunnerManager) - platform_mock = MagicMock(spec=PlatformProvider) - platform_mock.check_job_been_picked_up.side_effect = [False, True] - - consumer.consume( - queue_config=queue_config, - runner_manager=runner_manager_mock, - platform_provider=platform_mock, - supported_labels=labels, - ) - - expected_metadata = RunnerMetadata( - platform_name="jobmanager", url="https://jobmanager.example.com/subpath" - ) - runner_manager_mock.create_runners.assert_called_once_with( - 1, metadata=expected_metadata, reactive=True - ) - - _assert_queue_is_empty(queue_config.queue_name) - - def test_consume_after_in_progress(queue_config: QueueConfig): """ arrange: Two jobs, the first one in progress and the second one queued. diff --git a/github-runner-manager/tests/unit/test_jobmanager_api.py b/github-runner-manager/tests/unit/test_jobmanager_api.py deleted file mode 100644 index 2f822c489e..0000000000 --- a/github-runner-manager/tests/unit/test_jobmanager_api.py +++ /dev/null @@ -1,258 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Test for jobmanager client.""" -import secrets -from unittest.mock import MagicMock - -import pytest -from jobmanager_client import ( - JobRead, - RunnerHealthResponse, - RunnerRegisterResponse, -) -from jobmanager_client.exceptions import ApiException, NotFoundException -from urllib3.exceptions import RequestError - -from github_runner_manager.jobmanager_api import ( - Job, - JobManagerAPI, - JobManagerAPIError, - JobManagerAPINotFoundError, - JobStatus, - RunnerHealth, - RunnerRegistration, - RunnerStatus, -) - - -@pytest.fixture(name="token") -def token_fixture(): - return secrets.token_hex(8) - - -@pytest.fixture(name="url") -def url_fixture(): - return "http://jobmanager.internal" - - -@pytest.fixture(name="jobmanager_api") -def jobmanager_api(token, url): - jobmanager_api = JobManagerAPI(token=token, url=url) - return jobmanager_api - - -def test_jobmanager_api_sets_token_in_default_headers(token: str, url: str): - """ - arrange: Create a jobmanager api object. - act: Check if the generated api client has the token in default headers. - assert: The default headers contain the token. - """ - jobmanager_api = JobManagerAPI(token=token, url=url) - - api_client = jobmanager_api._create_api_client() - assert "Authorization" in api_client.default_headers - assert api_client.default_headers["Authorization"] == f"Bearer {token}" - - -def test_jobmanager_api_sets_url_in_configuration(token: str, url: str): - """ - arrange: Create a jobmanager api object. - act: Check if the generated api client has the url in configuration. - assert: The configuration host is set to the provided url. - """ - jobmanager_api = JobManagerAPI(token=token, url=url) - - api_client = jobmanager_api._create_api_client() - assert api_client.configuration.host == url - - -def test_jobmanager_api_get_runner_health( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI -): - """ - arrange: Create a jobmanager api object and stub the api client method. - act: Call get_runner_health method. - assert: The method returns a RunnerHealth object. - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.RunnersApi.get_runner_health_v1_runners_runner_id_health_get", - MagicMock( - return_value=RunnerHealthResponse( - label="label", - status=RunnerStatus.IN_PROGRESS.value, - deletable=True, - cpu_usage="10%", - ram_usage="20%", - disk_usage="30%", - ), - ), - ) - response = jobmanager_api.get_runner_health(runner_id=123) - assert RunnerHealth(status=RunnerStatus.IN_PROGRESS, deletable=True) == response - - -def test_jobmanager_api_get_runner_health_not_found( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI -): - """ - arrange: Create a jobmanager api object and stub the api client method to return a 404. - act: Call get_runner_health method. - assert: The method returns a JobManagerNotFound exception - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.RunnersApi.get_runner_health_v1_runners_runner_id_health_get", - MagicMock(side_effect=NotFoundException("Runner not found")), - ) - - with pytest.raises(JobManagerAPINotFoundError): - jobmanager_api.get_runner_health(runner_id=123) - - -@pytest.mark.parametrize( - "exception", - [ - pytest.param(ApiException(), id="ApiException"), - pytest.param(RequestError(MagicMock(), MagicMock(), MagicMock()), id="RequestError"), - pytest.param(ValueError(), id="ValueError"), - ], -) -def test_jobmanager_api_get_runner_health_error( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI, exception: Exception -): - """ - arrange: Create a jobmanager api object and stub the api client method to raise an exception. - act: Call get_runner_health method. - assert: The method raises the exception - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.RunnersApi.get_runner_health_v1_runners_runner_id_health_get", - MagicMock(side_effect=exception), - ) - - with pytest.raises(JobManagerAPIError): - jobmanager_api.get_runner_health(runner_id=123) - - -def test_jobmanager_api_register_runner( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI -): - """ - arrange: Create a jobmanager api object and stub the api client method. - act: Call register_runner method. - assert: The method returns a RunnerRegistration object. - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.RunnersApi.register_runner_v1_runners_register_post", - MagicMock(return_value=RunnerRegisterResponse(id=123, token="token")), - ) - - response = jobmanager_api.register_runner(name="test-runner", labels=["label1", "label2"]) - assert response == RunnerRegistration(id=123, token="token") - - -@pytest.mark.parametrize( - "exception", - [ - pytest.param(ApiException(), id="ApiException"), - pytest.param(RequestError(MagicMock(), MagicMock(), MagicMock()), id="RequestError"), - pytest.param(ValueError(), id="ValueError"), - ], -) -def test_jobmanager_api_register_runner_error( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI, exception: Exception -): - """ - arrange: Create a jobmanager api object and stub the api client method to raise an exception. - act: Call get_runner_health method. - assert: The method raises the exception - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.RunnersApi.register_runner_v1_runners_register_post", - MagicMock(side_effect=exception), - ) - - with pytest.raises(JobManagerAPIError): - jobmanager_api.register_runner(name="test-runner", labels=["label1", "label2"]) - - -@pytest.mark.parametrize( - "status", - [ - pytest.param(JobStatus.PENDING.value, id="PENDING"), - pytest.param(JobStatus.IN_PROGRESS.value, id="IN_PROGRESS"), - pytest.param(None, id="None"), - ], -) -def test_jobmanager_api_get_job( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI, status: str -): - """ - arrange: Create a jobmanager api object and stub the api client method. - act: Call get_runner_health method. - assert: The method returns a Job object. - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.JobsApi.get_job_v1_jobs_job_id_get", - MagicMock( - return_value=JobRead( - status=status, - architecture="arm64", - base_series="jammy", - id=1, - requested_by="foobar", - ) - ), - ) - - response = jobmanager_api.get_job(job_id=123) - assert Job(status=status) == response - - -def test_jobmanager_api_get_job_not_found( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI -): - """ - arrange: Create a jobmanager api object and stub the api client method to return a 404. - act: Call get_job method. - assert: The method returns a JobManagerNotFound exception - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.JobsApi.get_job_v1_jobs_job_id_get", - MagicMock(side_effect=NotFoundException("Job not found")), - ) - - with pytest.raises(JobManagerAPINotFoundError): - jobmanager_api.get_job(job_id=123) - - -@pytest.mark.parametrize( - "exception", - [ - pytest.param(ApiException(), id="ApiException"), - pytest.param(RequestError(MagicMock(), MagicMock(), MagicMock()), id="RequestError"), - pytest.param(ValueError(), id="ValueError"), - ], -) -def test_jobmanager_api_get_job_error( - monkeypatch: pytest.MonkeyPatch, jobmanager_api: JobManagerAPI, exception: Exception -): - """ - arrange: Create a jobmanager api object and stub the api client method to raise an exception. - act: Call get_job method. - assert: The method raises the exception - """ - monkeypatch.setattr(JobManagerAPI, "_create_api_client", MagicMock()) - monkeypatch.setattr( - "jobmanager_client.JobsApi.get_job_v1_jobs_job_id_get", MagicMock(side_effect=exception) - ) - - with pytest.raises(JobManagerAPIError): - jobmanager_api.get_job(job_id=123) diff --git a/github-runner-manager/tox.ini b/github-runner-manager/tox.ini index a9701b96f9..83811fac8f 100644 --- a/github-runner-manager/tox.ini +++ b/github-runner-manager/tox.ini @@ -56,7 +56,6 @@ deps = types-requests types-paramiko -r{toxinidir}/requirements.txt - ../jobmanager/client commands = pydocstyle {[vars]src_path} # uncomment the following line if this charm owns a lib @@ -78,7 +77,6 @@ deps = pytest -r{toxinidir}/requirements.txt -r{toxinidir}/tests/unit/requirements.txt - ../jobmanager/client commands = coverage run --source={[vars]src_path} \ -m pytest --ignore={[vars]tst_path}integration -v --tb native -s {posargs} diff --git a/jobmanager/client/.github/workflows/python.yml b/jobmanager/client/.github/workflows/python.yml deleted file mode 100644 index 1eb34b9707..0000000000 --- a/jobmanager/client/.github/workflows/python.yml +++ /dev/null @@ -1,38 +0,0 @@ -# NOTE: This file is auto generated by OpenAPI Generator. -# URL: https://openapi-generator.tech -# -# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: jobmanager_client Python package - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest diff --git a/jobmanager/client/.gitignore b/jobmanager/client/.gitignore deleted file mode 100644 index 41b073441b..0000000000 --- a/jobmanager/client/.gitignore +++ /dev/null @@ -1,67 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ -venv/ -.venv/ -.python-version -.pytest_cache - -# Translations -*.mo -*.pot - -# Django stuff: -*.log - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -#Ipython Notebook -.ipynb_checkpoints - diff --git a/jobmanager/client/.gitlab-ci.yml b/jobmanager/client/.gitlab-ci.yml deleted file mode 100644 index 9d16eb9d09..0000000000 --- a/jobmanager/client/.gitlab-ci.yml +++ /dev/null @@ -1,31 +0,0 @@ -# NOTE: This file is auto generated by OpenAPI Generator. -# URL: https://openapi-generator.tech -# -# ref: https://docs.gitlab.com/ee/ci/README.html -# ref: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Python.gitlab-ci.yml - -stages: - - test - -.pytest: - stage: test - script: - - pip install -r requirements.txt - - pip install -r test-requirements.txt - - pytest --cov=jobmanager_client - -pytest-3.7: - extends: .pytest - image: python:3.7-alpine -pytest-3.8: - extends: .pytest - image: python:3.8-alpine -pytest-3.9: - extends: .pytest - image: python:3.9-alpine -pytest-3.10: - extends: .pytest - image: python:3.10-alpine -pytest-3.11: - extends: .pytest - image: python:3.11-alpine diff --git a/jobmanager/client/.openapi-generator-ignore b/jobmanager/client/.openapi-generator-ignore deleted file mode 100644 index 7484ee590a..0000000000 --- a/jobmanager/client/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/jobmanager/client/.openapi-generator/FILES b/jobmanager/client/.openapi-generator/FILES deleted file mode 100644 index c7d56fc133..0000000000 --- a/jobmanager/client/.openapi-generator/FILES +++ /dev/null @@ -1,68 +0,0 @@ -.github/workflows/python.yml -.gitignore -.gitlab-ci.yml -.openapi-generator-ignore -.travis.yml -README.md -docs/DefaultApi.md -docs/HTTPValidationError.md -docs/JobCreate.md -docs/JobRead.md -docs/JobUpdate.md -docs/JobsApi.md -docs/RunnerCreate.md -docs/RunnerHealthResponse.md -docs/RunnerHealthUpdateResponse.md -docs/RunnerRegisterResponse.md -docs/RunnersApi.md -docs/TokensApi.md -docs/ValidationError.md -docs/ValidationErrorLocInner.md -docs/VmDependencies.md -git_push.sh -jobmanager_client/__init__.py -jobmanager_client/api/__init__.py -jobmanager_client/api/default_api.py -jobmanager_client/api/jobs_api.py -jobmanager_client/api/runners_api.py -jobmanager_client/api/tokens_api.py -jobmanager_client/api_client.py -jobmanager_client/api_response.py -jobmanager_client/configuration.py -jobmanager_client/exceptions.py -jobmanager_client/models/__init__.py -jobmanager_client/models/http_validation_error.py -jobmanager_client/models/job_create.py -jobmanager_client/models/job_read.py -jobmanager_client/models/job_update.py -jobmanager_client/models/runner_create.py -jobmanager_client/models/runner_health_response.py -jobmanager_client/models/runner_health_update_response.py -jobmanager_client/models/runner_register_response.py -jobmanager_client/models/validation_error.py -jobmanager_client/models/validation_error_loc_inner.py -jobmanager_client/models/vm_dependencies.py -jobmanager_client/py.typed -jobmanager_client/rest.py -pyproject.toml -requirements.txt -setup.cfg -setup.py -test-requirements.txt -test/__init__.py -test/test_default_api.py -test/test_http_validation_error.py -test/test_job_create.py -test/test_job_read.py -test/test_job_update.py -test/test_jobs_api.py -test/test_runner_create.py -test/test_runner_health_response.py -test/test_runner_health_update_response.py -test/test_runner_register_response.py -test/test_runners_api.py -test/test_tokens_api.py -test/test_validation_error.py -test/test_validation_error_loc_inner.py -test/test_vm_dependencies.py -tox.ini diff --git a/jobmanager/client/.openapi-generator/VERSION b/jobmanager/client/.openapi-generator/VERSION deleted file mode 100644 index 4c631cf217..0000000000 --- a/jobmanager/client/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.14.0-SNAPSHOT diff --git a/jobmanager/client/.travis.yml b/jobmanager/client/.travis.yml deleted file mode 100644 index d7e4f2dd53..0000000000 --- a/jobmanager/client/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -# ref: https://docs.travis-ci.com/user/languages/python -language: python -python: - - "3.7" - - "3.8" - - "3.9" - - "3.10" - - "3.11" - # uncomment the following if needed - #- "3.11-dev" # 3.11 development branch - #- "nightly" # nightly build -# command to install dependencies -install: - - "pip install -r requirements.txt" - - "pip install -r test-requirements.txt" -# command to run tests -script: pytest --cov=jobmanager_client diff --git a/jobmanager/client/README.md b/jobmanager/client/README.md deleted file mode 100644 index 0b26eaeffc..0000000000 --- a/jobmanager/client/README.md +++ /dev/null @@ -1,130 +0,0 @@ -# jobmanager-client -A modern job management system - -This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - -- API version: 2.0.0 -- Package version: 1.0.0 -- Generator version: 7.14.0-SNAPSHOT -- Build package: org.openapitools.codegen.languages.PythonPydanticV1ClientCodegen - -## Requirements. - -Python 3.7+ - -## Installation & Usage -### pip install - -If the python package is hosted on a repository, you can install directly using: - -```sh -pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git -``` -(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`) - -Then import the package: -```python -import jobmanager_client -``` - -### Setuptools - -Install via [Setuptools](http://pypi.python.org/pypi/setuptools). - -```sh -python setup.py install --user -``` -(or `sudo python setup.py install` to install the package for all users) - -Then import the package: -```python -import jobmanager_client -``` - -### Tests - -Execute `pytest` to run the tests. - -## Getting Started - -Please follow the [installation procedure](#installation--usage) and then run the following: - -```python - -import time -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.DefaultApi(api_client) - - try: - # Health Check - api_response = api_instance.health_check_health_get() - print("The response of DefaultApi->health_check_health_get:\n") - pprint(api_response) - except ApiException as e: - print("Exception when calling DefaultApi->health_check_health_get: %s\n" % e) - -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://localhost* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultApi* | [**health_check_health_get**](docs/DefaultApi.md#health_check_health_get) | **GET** /health | Health Check -*DefaultApi* | [**root_get**](docs/DefaultApi.md#root_get) | **GET** / | Root -*JobsApi* | [**create_job_v1_jobs_post**](docs/JobsApi.md#create_job_v1_jobs_post) | **POST** /v1/jobs | Create Job -*JobsApi* | [**download_object_v1_jobs_job_id_object_object_name_get**](docs/JobsApi.md#download_object_v1_jobs_job_id_object_object_name_get) | **GET** /v1/jobs/{job_id}/object/{object_name} | Download Object -*JobsApi* | [**generate_token_v1_jobs_job_id_token_post**](docs/JobsApi.md#generate_token_v1_jobs_job_id_token_post) | **POST** /v1/jobs/{job_id}/token | Generate Token -*JobsApi* | [**get_health_v1_jobs_job_id_health_get**](docs/JobsApi.md#get_health_v1_jobs_job_id_health_get) | **GET** /v1/jobs/{job_id}/health | Get Health -*JobsApi* | [**get_job_v1_jobs_job_id_get**](docs/JobsApi.md#get_job_v1_jobs_job_id_get) | **GET** /v1/jobs/{job_id} | Get Job -*JobsApi* | [**get_jobs_v1_jobs_get**](docs/JobsApi.md#get_jobs_v1_jobs_get) | **GET** /v1/jobs | Get Jobs -*JobsApi* | [**update_health_v1_jobs_job_id_health_put**](docs/JobsApi.md#update_health_v1_jobs_job_id_health_put) | **PUT** /v1/jobs/{job_id}/health | Update Health -*JobsApi* | [**update_job_v1_jobs_job_id_put**](docs/JobsApi.md#update_job_v1_jobs_job_id_put) | **PUT** /v1/jobs/{job_id} | Update Job -*RunnersApi* | [**get_runner_health_v1_runners_runner_id_health_get**](docs/RunnersApi.md#get_runner_health_v1_runners_runner_id_health_get) | **GET** /v1/runners/{runner_id}/health | Get Runner Health -*RunnersApi* | [**register_runner_v1_runners_register_post**](docs/RunnersApi.md#register_runner_v1_runners_register_post) | **POST** /v1/runners/register | Register Runner -*RunnersApi* | [**update_runner_health_v1_runners_runner_id_health_put**](docs/RunnersApi.md#update_runner_health_v1_runners_runner_id_health_put) | **PUT** /v1/runners/{runner_id}/health | Update Runner Health -*TokensApi* | [**create_api_access_token_v1_api_access_token_post**](docs/TokensApi.md#create_api_access_token_v1_api_access_token_post) | **POST** /v1/api_access_token | Create Api Access Token -*TokensApi* | [**revoke_api_access_token_v1_api_access_token_delete**](docs/TokensApi.md#revoke_api_access_token_v1_api_access_token_delete) | **DELETE** /v1/api_access_token | Revoke Api Access Token - - -## Documentation For Models - - - [HTTPValidationError](docs/HTTPValidationError.md) - - [JobCreate](docs/JobCreate.md) - - [JobRead](docs/JobRead.md) - - [JobUpdate](docs/JobUpdate.md) - - [RunnerCreate](docs/RunnerCreate.md) - - [RunnerHealthResponse](docs/RunnerHealthResponse.md) - - [RunnerHealthUpdateResponse](docs/RunnerHealthUpdateResponse.md) - - [RunnerRegisterResponse](docs/RunnerRegisterResponse.md) - - [ValidationError](docs/ValidationError.md) - - [ValidationErrorLocInner](docs/ValidationErrorLocInner.md) - - [VmDependencies](docs/VmDependencies.md) - - - -## Documentation For Authorization - -Endpoints do not require authorization. - - -## Author - - - - diff --git a/jobmanager/client/docs/DefaultApi.md b/jobmanager/client/docs/DefaultApi.md deleted file mode 100644 index 5bccd1ac92..0000000000 --- a/jobmanager/client/docs/DefaultApi.md +++ /dev/null @@ -1,146 +0,0 @@ -# jobmanager_client.DefaultApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**health_check_health_get**](DefaultApi.md#health_check_health_get) | **GET** /health | Health Check -[**root_get**](DefaultApi.md#root_get) | **GET** / | Root - - -# **health_check_health_get** -> object health_check_health_get() - -Health Check - -Health check endpoint for monitoring service status. - -This endpoint can be used by monitoring tools and load balancers to -verify the service is operational. - -Returns: - dict: Contains status indicating service health - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.DefaultApi(api_client) - - try: - # Health Check - api_response = api_instance.health_check_health_get() - print("The response of DefaultApi->health_check_health_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling DefaultApi->health_check_health_get: %s\n" % e) -``` - - - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **root_get** -> object root_get() - -Root - -Root endpoint providing basic API information. - -Returns: - dict: Basic API information including: - - message: API identification - - version: Current API version - - status: Running status - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.DefaultApi(api_client) - - try: - # Root - api_response = api_instance.root_get() - print("The response of DefaultApi->root_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling DefaultApi->root_get: %s\n" % e) -``` - - - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/jobmanager/client/docs/HTTPValidationError.md b/jobmanager/client/docs/HTTPValidationError.md deleted file mode 100644 index 165613dac5..0000000000 --- a/jobmanager/client/docs/HTTPValidationError.md +++ /dev/null @@ -1,28 +0,0 @@ -# HTTPValidationError - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**detail** | [**List[ValidationError]**](ValidationError.md) | | [optional] - -## Example - -```python -from jobmanager_client.models.http_validation_error import HTTPValidationError - -# TODO update the JSON string below -json = "{}" -# create an instance of HTTPValidationError from a JSON string -http_validation_error_instance = HTTPValidationError.from_json(json) -# print the JSON string representation of the object -print HTTPValidationError.to_json() - -# convert the object into a dict -http_validation_error_dict = http_validation_error_instance.to_dict() -# create an instance of HTTPValidationError from a dict -http_validation_error_from_dict = HTTPValidationError.from_dict(http_validation_error_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/JobCreate.md b/jobmanager/client/docs/JobCreate.md deleted file mode 100644 index e9eb051fcf..0000000000 --- a/jobmanager/client/docs/JobCreate.md +++ /dev/null @@ -1,44 +0,0 @@ -# JobCreate - -Job creation model. - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**requested_by** | **str** | | -**repository_url** | **str** | | [optional] -**repository_ref** | **str** | | [optional] -**architecture** | **str** | | -**base_series** | **str** | | -**vm_dependencies** | [**VmDependencies**](VmDependencies.md) | | [optional] -**commands** | **List[object]** | | [optional] -**secrets** | **Dict[str, object]** | | [optional] -**environment** | **Dict[str, object]** | | [optional] -**artifacts_dir** | **str** | | [optional] -**topology** | **str** | | [optional] -**vm_ip** | **str** | | [optional] -**vm_size** | **str** | | [optional] -**status** | **str** | | [optional] -**artifact_urls** | **List[object]** | | [optional] -**log_urls** | **List[object]** | | [optional] - -## Example - -```python -from jobmanager_client.models.job_create import JobCreate - -# TODO update the JSON string below -json = "{}" -# create an instance of JobCreate from a JSON string -job_create_instance = JobCreate.from_json(json) -# print the JSON string representation of the object -print JobCreate.to_json() - -# convert the object into a dict -job_create_dict = job_create_instance.to_dict() -# create an instance of JobCreate from a dict -job_create_from_dict = JobCreate.from_dict(job_create_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/JobRead.md b/jobmanager/client/docs/JobRead.md deleted file mode 100644 index 07e6608468..0000000000 --- a/jobmanager/client/docs/JobRead.md +++ /dev/null @@ -1,49 +0,0 @@ -# JobRead - -Job read model with all fields. - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**requested_by** | **str** | | -**repository_url** | **str** | | [optional] -**repository_ref** | **str** | | [optional] -**architecture** | **str** | | -**base_series** | **str** | | -**vm_dependencies** | [**VmDependencies**](VmDependencies.md) | | [optional] -**commands** | **List[object]** | | [optional] -**secrets** | **Dict[str, object]** | | [optional] -**environment** | **Dict[str, object]** | | [optional] -**artifacts_dir** | **str** | | [optional] -**topology** | **str** | | [optional] -**vm_ip** | **str** | | [optional] -**vm_size** | **str** | | [optional] -**status** | **str** | | [optional] -**artifact_urls** | **List[object]** | | [optional] -**log_urls** | **List[object]** | | [optional] -**id** | **int** | | -**created_at** | **datetime** | | [optional] -**updated_at** | **datetime** | | [optional] -**started_at** | **datetime** | | [optional] -**completed_at** | **datetime** | | [optional] - -## Example - -```python -from jobmanager_client.models.job_read import JobRead - -# TODO update the JSON string below -json = "{}" -# create an instance of JobRead from a JSON string -job_read_instance = JobRead.from_json(json) -# print the JSON string representation of the object -print JobRead.to_json() - -# convert the object into a dict -job_read_dict = job_read_instance.to_dict() -# create an instance of JobRead from a dict -job_read_from_dict = JobRead.from_dict(job_read_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/JobUpdate.md b/jobmanager/client/docs/JobUpdate.md deleted file mode 100644 index 98b62d83fc..0000000000 --- a/jobmanager/client/docs/JobUpdate.md +++ /dev/null @@ -1,34 +0,0 @@ -# JobUpdate - -Job update model. - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**status** | **str** | | [optional] -**vm_ip** | **str** | | [optional] -**artifact_urls** | **List[object]** | | [optional] -**log_urls** | **List[object]** | | [optional] -**started_at** | **datetime** | | [optional] -**completed_at** | **datetime** | | [optional] - -## Example - -```python -from jobmanager_client.models.job_update import JobUpdate - -# TODO update the JSON string below -json = "{}" -# create an instance of JobUpdate from a JSON string -job_update_instance = JobUpdate.from_json(json) -# print the JSON string representation of the object -print JobUpdate.to_json() - -# convert the object into a dict -job_update_dict = job_update_instance.to_dict() -# create an instance of JobUpdate from a dict -job_update_from_dict = JobUpdate.from_dict(job_update_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/JobsApi.md b/jobmanager/client/docs/JobsApi.md deleted file mode 100644 index 3b83915331..0000000000 --- a/jobmanager/client/docs/JobsApi.md +++ /dev/null @@ -1,645 +0,0 @@ -# jobmanager_client.JobsApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_job_v1_jobs_post**](JobsApi.md#create_job_v1_jobs_post) | **POST** /v1/jobs | Create Job -[**download_object_v1_jobs_job_id_object_object_name_get**](JobsApi.md#download_object_v1_jobs_job_id_object_object_name_get) | **GET** /v1/jobs/{job_id}/object/{object_name} | Download Object -[**generate_token_v1_jobs_job_id_token_post**](JobsApi.md#generate_token_v1_jobs_job_id_token_post) | **POST** /v1/jobs/{job_id}/token | Generate Token -[**get_health_v1_jobs_job_id_health_get**](JobsApi.md#get_health_v1_jobs_job_id_health_get) | **GET** /v1/jobs/{job_id}/health | Get Health -[**get_job_v1_jobs_job_id_get**](JobsApi.md#get_job_v1_jobs_job_id_get) | **GET** /v1/jobs/{job_id} | Get Job -[**get_jobs_v1_jobs_get**](JobsApi.md#get_jobs_v1_jobs_get) | **GET** /v1/jobs | Get Jobs -[**update_health_v1_jobs_job_id_health_put**](JobsApi.md#update_health_v1_jobs_job_id_health_put) | **PUT** /v1/jobs/{job_id}/health | Update Health -[**update_job_v1_jobs_job_id_put**](JobsApi.md#update_job_v1_jobs_job_id_put) | **PUT** /v1/jobs/{job_id} | Update Job - - -# **create_job_v1_jobs_post** -> JobRead create_job_v1_jobs_post(job_create) - -Create Job - -Create a new job in the system. - -Args: - job_in: Job creation model containing all required job parameters - db: Database session dependency - token: API access token for authorization - -Returns: - JobRead: The created job object - -Raises: - HTTPException 502: If webhook notification fails - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.job_create import JobCreate -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_create = jobmanager_client.JobCreate() # JobCreate | - - try: - # Create Job - api_response = api_instance.create_job_v1_jobs_post(job_create) - print("The response of JobsApi->create_job_v1_jobs_post:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->create_job_v1_jobs_post: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_create** | [**JobCreate**](JobCreate.md)| | - -### Return type - -[**JobRead**](JobRead.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**201** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **download_object_v1_jobs_job_id_object_object_name_get** -> object download_object_v1_jobs_job_id_object_object_name_get(job_id, object_name) - -Download Object - -Download an artifact or object associated with a job. - -Args: - job_id: Unique identifier of the job - object_name: Name of the object/artifact to download - db: Database session dependency - -Returns: - StreamingResponse: Stream of the requested object data with appropriate - headers - -Raises: - HTTPException 404: If job is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - object_name = 'object_name_example' # str | - - try: - # Download Object - api_response = api_instance.download_object_v1_jobs_job_id_object_object_name_get(job_id, object_name) - print("The response of JobsApi->download_object_v1_jobs_job_id_object_object_name_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->download_object_v1_jobs_job_id_object_object_name_get: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - **object_name** | **str**| | - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **generate_token_v1_jobs_job_id_token_post** -> object generate_token_v1_jobs_job_id_token_post(job_id) - -Generate Token - -Generate a JWT token for job authentication and set up SSH keys. - -Args: - job_id: Unique identifier of the job - request: FastAPI request object potentially containing SSH keys - db: Database session dependency - token: API access token for authorization - -Returns: - dict: Contains the generated JWT token - -Raises: - HTTPException 404: If job is not found - HTTPException 500: If SSH key generation fails - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - - try: - # Generate Token - api_response = api_instance.generate_token_v1_jobs_job_id_token_post(job_id) - print("The response of JobsApi->generate_token_v1_jobs_job_id_token_post:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->generate_token_v1_jobs_job_id_token_post: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_health_v1_jobs_job_id_health_get** -> object get_health_v1_jobs_job_id_health_get(job_id) - -Get Health - -Retrieve the current health status of a job. - -Args: - job_id: Unique identifier of the job - db: Database session dependency - -Returns: - dict: Health status information including CPU, RAM, disk usage, and job - status - -Raises: - HTTPException 404: If job is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - - try: - # Get Health - api_response = api_instance.get_health_v1_jobs_job_id_health_get(job_id) - print("The response of JobsApi->get_health_v1_jobs_job_id_health_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->get_health_v1_jobs_job_id_health_get: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_job_v1_jobs_job_id_get** -> JobRead get_job_v1_jobs_job_id_get(job_id) - -Get Job - -Retrieve a specific job by its ID. - -Args: - job_id: Unique identifier of the job - db: Database session dependency - -Returns: - JobRead: The requested job object - -Raises: - HTTPException 404: If job is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - - try: - # Get Job - api_response = api_instance.get_job_v1_jobs_job_id_get(job_id) - print("The response of JobsApi->get_job_v1_jobs_job_id_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->get_job_v1_jobs_job_id_get: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - -### Return type - -[**JobRead**](JobRead.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **get_jobs_v1_jobs_get** -> List[JobRead] get_jobs_v1_jobs_get() - -Get Jobs - -Retrieve a list of all jobs in the system. - -Args: - db: Database session dependency - token: API access token for authorization - -Returns: - List[JobRead]: List of all jobs - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - - try: - # Get Jobs - api_response = api_instance.get_jobs_v1_jobs_get() - print("The response of JobsApi->get_jobs_v1_jobs_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->get_jobs_v1_jobs_get: %s\n" % e) -``` - - - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**List[JobRead]**](JobRead.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **update_health_v1_jobs_job_id_health_put** -> object update_health_v1_jobs_job_id_health_put(job_id) - -Update Health - -Update the health status of a running job. - -Args: - job_id: Unique identifier of the job - db: Database session dependency - token: Builder token for authorization - request: FastAPI request object containing health data - -Returns: - dict: The updated health status data - -Raises: - HTTPException 404: If job is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - - try: - # Update Health - api_response = api_instance.update_health_v1_jobs_job_id_health_put(job_id) - print("The response of JobsApi->update_health_v1_jobs_job_id_health_put:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->update_health_v1_jobs_job_id_health_put: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **update_job_v1_jobs_job_id_put** -> JobRead update_job_v1_jobs_job_id_put(job_id, job_update) - -Update Job - -Update an existing job's information. - -Args: - job_id: Unique identifier of the job to update - job_in: Job update model containing fields to update - db: Database session dependency - token: API access token for authorization - -Returns: - JobRead: The updated job object - -Raises: - HTTPException 404: If job is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.models.job_update import JobUpdate -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.JobsApi(api_client) - job_id = 56 # int | - job_update = jobmanager_client.JobUpdate() # JobUpdate | - - try: - # Update Job - api_response = api_instance.update_job_v1_jobs_job_id_put(job_id, job_update) - print("The response of JobsApi->update_job_v1_jobs_job_id_put:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling JobsApi->update_job_v1_jobs_job_id_put: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **job_id** | **int**| | - **job_update** | [**JobUpdate**](JobUpdate.md)| | - -### Return type - -[**JobRead**](JobRead.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/jobmanager/client/docs/RunnersApi.md b/jobmanager/client/docs/RunnersApi.md deleted file mode 100644 index 96a6e4d075..0000000000 --- a/jobmanager/client/docs/RunnersApi.md +++ /dev/null @@ -1,249 +0,0 @@ -# jobmanager_client.RunnersApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**get_runner_health_v1_runners_runner_id_health_get**](RunnersApi.md#get_runner_health_v1_runners_runner_id_health_get) | **GET** /v1/runners/{runner_id}/health | Get Runner Health -[**register_runner_v1_runners_register_post**](RunnersApi.md#register_runner_v1_runners_register_post) | **POST** /v1/runners/register | Register Runner -[**update_runner_health_v1_runners_runner_id_health_put**](RunnersApi.md#update_runner_health_v1_runners_runner_id_health_put) | **PUT** /v1/runners/{runner_id}/health | Update Runner Health - - -# **get_runner_health_v1_runners_runner_id_health_get** -> RunnerHealthResponse get_runner_health_v1_runners_runner_id_health_get(runner_id) - -Get Runner Health - -Get runner health status. - -Args: - runner_id: Unique identifier of the runner - db: Database session dependency - -Returns: - dict: Runner health metrics including CPU, RAM, disk usage and status - -Raises: - HTTPException 404: If runner is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.runner_health_response import RunnerHealthResponse -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.RunnersApi(api_client) - runner_id = 56 # int | - - try: - # Get Runner Health - api_response = api_instance.get_runner_health_v1_runners_runner_id_health_get(runner_id) - print("The response of RunnersApi->get_runner_health_v1_runners_runner_id_health_get:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling RunnersApi->get_runner_health_v1_runners_runner_id_health_get: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **runner_id** | **int**| | - -### Return type - -[**RunnerHealthResponse**](RunnerHealthResponse.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **register_runner_v1_runners_register_post** -> RunnerRegisterResponse register_runner_v1_runners_register_post(runner_create) - -Register Runner - -Register a new runner. - -Args: - runner_in: Runner registration data including name and labels - db: Database session dependency - token: API access token for authorization - -Returns: - dict: Contains the runner ID and its authentication token - -Raises: - HTTPException 500: If token generation fails - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.runner_create import RunnerCreate -from jobmanager_client.models.runner_register_response import RunnerRegisterResponse -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.RunnersApi(api_client) - runner_create = jobmanager_client.RunnerCreate() # RunnerCreate | - - try: - # Register Runner - api_response = api_instance.register_runner_v1_runners_register_post(runner_create) - print("The response of RunnersApi->register_runner_v1_runners_register_post:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling RunnersApi->register_runner_v1_runners_register_post: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **runner_create** | [**RunnerCreate**](RunnerCreate.md)| | - -### Return type - -[**RunnerRegisterResponse**](RunnerRegisterResponse.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: application/json - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **update_runner_health_v1_runners_runner_id_health_put** -> RunnerHealthUpdateResponse update_runner_health_v1_runners_runner_id_health_put(runner_id) - -Update Runner Health - -Update runner health metrics. - -Args: - runner_id: Unique identifier of the runner - request: FastAPI request object containing health metrics - db: Database session dependency - token: Runner token for authorization - -Returns: - dict: Success indicator - -Raises: - HTTPException 404: If runner is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.models.runner_health_update_response import RunnerHealthUpdateResponse -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.RunnersApi(api_client) - runner_id = 56 # int | - - try: - # Update Runner Health - api_response = api_instance.update_runner_health_v1_runners_runner_id_health_put(runner_id) - print("The response of RunnersApi->update_runner_health_v1_runners_runner_id_health_put:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling RunnersApi->update_runner_health_v1_runners_runner_id_health_put: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **runner_id** | **int**| | - -### Return type - -[**RunnerHealthUpdateResponse**](RunnerHealthUpdateResponse.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/jobmanager/client/docs/TokensApi.md b/jobmanager/client/docs/TokensApi.md deleted file mode 100644 index 9355207adb..0000000000 --- a/jobmanager/client/docs/TokensApi.md +++ /dev/null @@ -1,166 +0,0 @@ -# jobmanager_client.TokensApi - -All URIs are relative to *http://localhost* - -Method | HTTP request | Description -------------- | ------------- | ------------- -[**create_api_access_token_v1_api_access_token_post**](TokensApi.md#create_api_access_token_v1_api_access_token_post) | **POST** /v1/api_access_token | Create Api Access Token -[**revoke_api_access_token_v1_api_access_token_delete**](TokensApi.md#revoke_api_access_token_v1_api_access_token_delete) | **DELETE** /v1/api_access_token | Revoke Api Access Token - - -# **create_api_access_token_v1_api_access_token_post** -> object create_api_access_token_v1_api_access_token_post() - -Create Api Access Token - -Create a new API access token for service authentication. - -Args: - request: FastAPI request object with identity and optional expiration - db: Database session dependency - _: Internal-only access check dependency - -Returns: - JSONResponse: Contains the generated token and identity - -Raises: - HTTPException 400: If identity is missing from request - HTTPException 403: If request is not from internal network - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.TokensApi(api_client) - - try: - # Create Api Access Token - api_response = api_instance.create_api_access_token_v1_api_access_token_post() - print("The response of TokensApi->create_api_access_token_v1_api_access_token_post:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling TokensApi->create_api_access_token_v1_api_access_token_post: %s\n" % e) -``` - - - -### Parameters -This endpoint does not need any parameter. - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - -# **revoke_api_access_token_v1_api_access_token_delete** -> object revoke_api_access_token_v1_api_access_token_delete(identity, token) - -Revoke Api Access Token - -Revoke an existing API access token. - -Args: - identity: Service identity associated with the token - token: The token value to revoke - db: Database session dependency - _: Internal-only access check dependency - -Returns: - dict: Contains the revoked token and identity - -Raises: - HTTPException 403: If request is not from internal network - HTTPException 404: If token is not found - -### Example - -```python -import time -import os -import jobmanager_client -from jobmanager_client.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to http://localhost -# See configuration.py for a list of all supported configuration parameters. -configuration = jobmanager_client.Configuration( - host = "http://localhost" -) - - -# Enter a context with an instance of the API client -with jobmanager_client.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = jobmanager_client.TokensApi(api_client) - identity = 'identity_example' # str | - token = 'token_example' # str | - - try: - # Revoke Api Access Token - api_response = api_instance.revoke_api_access_token_v1_api_access_token_delete(identity, token) - print("The response of TokensApi->revoke_api_access_token_v1_api_access_token_delete:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling TokensApi->revoke_api_access_token_v1_api_access_token_delete: %s\n" % e) -``` - - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **identity** | **str**| | - **token** | **str**| | - -### Return type - -**object** - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | Successful Response | - | -**422** | Validation Error | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - diff --git a/jobmanager/client/docs/ValidationError.md b/jobmanager/client/docs/ValidationError.md deleted file mode 100644 index 08b4d2aa34..0000000000 --- a/jobmanager/client/docs/ValidationError.md +++ /dev/null @@ -1,30 +0,0 @@ -# ValidationError - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**loc** | [**List[ValidationErrorLocInner]**](ValidationErrorLocInner.md) | | -**msg** | **str** | | -**type** | **str** | | - -## Example - -```python -from jobmanager_client.models.validation_error import ValidationError - -# TODO update the JSON string below -json = "{}" -# create an instance of ValidationError from a JSON string -validation_error_instance = ValidationError.from_json(json) -# print the JSON string representation of the object -print ValidationError.to_json() - -# convert the object into a dict -validation_error_dict = validation_error_instance.to_dict() -# create an instance of ValidationError from a dict -validation_error_from_dict = ValidationError.from_dict(validation_error_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/ValidationErrorLocInner.md b/jobmanager/client/docs/ValidationErrorLocInner.md deleted file mode 100644 index b43916739d..0000000000 --- a/jobmanager/client/docs/ValidationErrorLocInner.md +++ /dev/null @@ -1,27 +0,0 @@ -# ValidationErrorLocInner - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - -## Example - -```python -from jobmanager_client.models.validation_error_loc_inner import ValidationErrorLocInner - -# TODO update the JSON string below -json = "{}" -# create an instance of ValidationErrorLocInner from a JSON string -validation_error_loc_inner_instance = ValidationErrorLocInner.from_json(json) -# print the JSON string representation of the object -print ValidationErrorLocInner.to_json() - -# convert the object into a dict -validation_error_loc_inner_dict = validation_error_loc_inner_instance.to_dict() -# create an instance of ValidationErrorLocInner from a dict -validation_error_loc_inner_from_dict = ValidationErrorLocInner.from_dict(validation_error_loc_inner_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/docs/VmDependencies.md b/jobmanager/client/docs/VmDependencies.md deleted file mode 100644 index 786662cb90..0000000000 --- a/jobmanager/client/docs/VmDependencies.md +++ /dev/null @@ -1,27 +0,0 @@ -# VmDependencies - - -## Properties -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - -## Example - -```python -from jobmanager_client.models.vm_dependencies import VmDependencies - -# TODO update the JSON string below -json = "{}" -# create an instance of VmDependencies from a JSON string -vm_dependencies_instance = VmDependencies.from_json(json) -# print the JSON string representation of the object -print VmDependencies.to_json() - -# convert the object into a dict -vm_dependencies_dict = vm_dependencies_instance.to_dict() -# create an instance of VmDependencies from a dict -vm_dependencies_from_dict = VmDependencies.from_dict(vm_dependencies_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/jobmanager/client/git_push.sh b/jobmanager/client/git_push.sh deleted file mode 100644 index 26b9737a9c..0000000000 --- a/jobmanager/client/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="GIT_USER_ID" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="GIT_REPO_ID" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin "https://${git_host}/${git_user_id}/${git_repo_id}.git" - else - git remote add origin "https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git" - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/jobmanager/client/jobmanager_client/__init__.py b/jobmanager/client/jobmanager_client/__init__.py deleted file mode 100644 index b65f704ae2..0000000000 --- a/jobmanager/client/jobmanager_client/__init__.py +++ /dev/null @@ -1,75 +0,0 @@ -# coding: utf-8 - -# flake8: noqa - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -__version__ = "1.0.0" - -# Define package exports -__all__ = [ - "DefaultApi", - "JobsApi", - "RunnersApi", - "TokensApi", - "ApiResponse", - "ApiClient", - "Configuration", - "OpenApiException", - "ApiTypeError", - "ApiValueError", - "ApiKeyError", - "ApiAttributeError", - "ApiException", - "HTTPValidationError", - "JobCreate", - "JobRead", - "JobUpdate", - "RunnerCreate", - "RunnerHealthResponse", - "RunnerHealthUpdateResponse", - "RunnerRegisterResponse", - "ValidationError", - "ValidationErrorLocInner", - "VmDependencies", -] - -# import apis into sdk package -from jobmanager_client.api.default_api import DefaultApi as DefaultApi -from jobmanager_client.api.jobs_api import JobsApi as JobsApi -from jobmanager_client.api.runners_api import RunnersApi as RunnersApi -from jobmanager_client.api.tokens_api import TokensApi as TokensApi - -# import ApiClient -from jobmanager_client.api_response import ApiResponse as ApiResponse -from jobmanager_client.api_client import ApiClient as ApiClient -from jobmanager_client.configuration import Configuration as Configuration -from jobmanager_client.exceptions import OpenApiException as OpenApiException -from jobmanager_client.exceptions import ApiTypeError as ApiTypeError -from jobmanager_client.exceptions import ApiValueError as ApiValueError -from jobmanager_client.exceptions import ApiKeyError as ApiKeyError -from jobmanager_client.exceptions import ApiAttributeError as ApiAttributeError -from jobmanager_client.exceptions import ApiException as ApiException - -# import models into sdk package -from jobmanager_client.models.http_validation_error import HTTPValidationError as HTTPValidationError -from jobmanager_client.models.job_create import JobCreate as JobCreate -from jobmanager_client.models.job_read import JobRead as JobRead -from jobmanager_client.models.job_update import JobUpdate as JobUpdate -from jobmanager_client.models.runner_create import RunnerCreate as RunnerCreate -from jobmanager_client.models.runner_health_response import RunnerHealthResponse as RunnerHealthResponse -from jobmanager_client.models.runner_health_update_response import RunnerHealthUpdateResponse as RunnerHealthUpdateResponse -from jobmanager_client.models.runner_register_response import RunnerRegisterResponse as RunnerRegisterResponse -from jobmanager_client.models.validation_error import ValidationError as ValidationError -from jobmanager_client.models.validation_error_loc_inner import ValidationErrorLocInner as ValidationErrorLocInner -from jobmanager_client.models.vm_dependencies import VmDependencies as VmDependencies diff --git a/jobmanager/client/jobmanager_client/api/__init__.py b/jobmanager/client/jobmanager_client/api/__init__.py deleted file mode 100644 index 98969d5d01..0000000000 --- a/jobmanager/client/jobmanager_client/api/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# flake8: noqa - -# import apis into api package -from jobmanager_client.api.default_api import DefaultApi -from jobmanager_client.api.jobs_api import JobsApi -from jobmanager_client.api.runners_api import RunnersApi -from jobmanager_client.api.tokens_api import TokensApi - diff --git a/jobmanager/client/jobmanager_client/api/default_api.py b/jobmanager/client/jobmanager_client/api/default_api.py deleted file mode 100644 index d6c9404a9e..0000000000 --- a/jobmanager/client/jobmanager_client/api/default_api.py +++ /dev/null @@ -1,306 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import re # noqa: F401 -import io -import warnings - -from pydantic import validate_arguments, ValidationError - -from typing import Any - - -from jobmanager_client.api_client import ApiClient -from jobmanager_client.api_response import ApiResponse -from jobmanager_client.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError -) - - -class DefaultApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_arguments - def health_check_health_get(self, **kwargs) -> object: # noqa: E501 - """Health Check # noqa: E501 - - Health check endpoint for monitoring service status. This endpoint can be used by monitoring tools and load balancers to verify the service is operational. Returns: dict: Contains status indicating service health # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.health_check_health_get(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the health_check_health_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.health_check_health_get_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def health_check_health_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """Health Check # noqa: E501 - - Health check endpoint for monitoring service status. This endpoint can be used by monitoring tools and load balancers to verify the service is operational. Returns: dict: Contains status indicating service health # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.health_check_health_get_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method health_check_health_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - } - - return self.api_client.call_api( - '/health', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def root_get(self, **kwargs) -> object: # noqa: E501 - """Root # noqa: E501 - - Root endpoint providing basic API information. Returns: dict: Basic API information including: - message: API identification - version: Current API version - status: Running status # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.root_get(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the root_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.root_get_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def root_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """Root # noqa: E501 - - Root endpoint providing basic API information. Returns: dict: Basic API information including: - message: API identification - version: Current API version - status: Running status # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.root_get_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method root_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - } - - return self.api_client.call_api( - '/', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) diff --git a/jobmanager/client/jobmanager_client/api/jobs_api.py b/jobmanager/client/jobmanager_client/api/jobs_api.py deleted file mode 100644 index 5698b92f64..0000000000 --- a/jobmanager/client/jobmanager_client/api/jobs_api.py +++ /dev/null @@ -1,1196 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import re # noqa: F401 -import io -import warnings - -from pydantic import validate_arguments, ValidationError - -from pydantic import StrictInt, StrictStr - -from typing import Any, List - -from jobmanager_client.models.job_create import JobCreate -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.models.job_update import JobUpdate - -from jobmanager_client.api_client import ApiClient -from jobmanager_client.api_response import ApiResponse -from jobmanager_client.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError -) - - -class JobsApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_arguments - def create_job_v1_jobs_post(self, job_create : JobCreate, **kwargs) -> JobRead: # noqa: E501 - """Create Job # noqa: E501 - - Create a new job in the system. Args: job_in: Job creation model containing all required job parameters db: Database session dependency token: API access token for authorization Returns: JobRead: The created job object Raises: HTTPException 502: If webhook notification fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.create_job_v1_jobs_post(job_create, async_req=True) - >>> result = thread.get() - - :param job_create: (required) - :type job_create: JobCreate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: JobRead - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the create_job_v1_jobs_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.create_job_v1_jobs_post_with_http_info(job_create, **kwargs) # noqa: E501 - - @validate_arguments - def create_job_v1_jobs_post_with_http_info(self, job_create : JobCreate, **kwargs) -> ApiResponse: # noqa: E501 - """Create Job # noqa: E501 - - Create a new job in the system. Args: job_in: Job creation model containing all required job parameters db: Database session dependency token: API access token for authorization Returns: JobRead: The created job object Raises: HTTPException 502: If webhook notification fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.create_job_v1_jobs_post_with_http_info(job_create, async_req=True) - >>> result = thread.get() - - :param job_create: (required) - :type job_create: JobCreate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(JobRead, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_create' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_job_v1_jobs_post" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - if _params['job_create'] is not None: - _body_params = _params['job_create'] - - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # set the HTTP header `Content-Type` - _content_types_list = _params.get('_content_type', - self.api_client.select_header_content_type( - ['application/json'])) - if _content_types_list: - _header_params['Content-Type'] = _content_types_list - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '201': "JobRead", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs', 'POST', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def download_object_v1_jobs_job_id_object_object_name_get(self, job_id : StrictInt, object_name : StrictStr, **kwargs) -> object: # noqa: E501 - """Download Object # noqa: E501 - - Download an artifact or object associated with a job. Args: job_id: Unique identifier of the job object_name: Name of the object/artifact to download db: Database session dependency Returns: StreamingResponse: Stream of the requested object data with appropriate headers Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.download_object_v1_jobs_job_id_object_object_name_get(job_id, object_name, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param object_name: (required) - :type object_name: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the download_object_v1_jobs_job_id_object_object_name_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.download_object_v1_jobs_job_id_object_object_name_get_with_http_info(job_id, object_name, **kwargs) # noqa: E501 - - @validate_arguments - def download_object_v1_jobs_job_id_object_object_name_get_with_http_info(self, job_id : StrictInt, object_name : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 - """Download Object # noqa: E501 - - Download an artifact or object associated with a job. Args: job_id: Unique identifier of the job object_name: Name of the object/artifact to download db: Database session dependency Returns: StreamingResponse: Stream of the requested object data with appropriate headers Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.download_object_v1_jobs_job_id_object_object_name_get_with_http_info(job_id, object_name, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param object_name: (required) - :type object_name: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id', - 'object_name' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method download_object_v1_jobs_job_id_object_object_name_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - if _params['object_name'] is not None: - _path_params['object_name'] = _params['object_name'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}/object/{object_name}', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def generate_token_v1_jobs_job_id_token_post(self, job_id : StrictInt, **kwargs) -> object: # noqa: E501 - """Generate Token # noqa: E501 - - Generate a JWT token for job authentication and set up SSH keys. Args: job_id: Unique identifier of the job request: FastAPI request object potentially containing SSH keys db: Database session dependency token: API access token for authorization Returns: dict: Contains the generated JWT token Raises: HTTPException 404: If job is not found HTTPException 500: If SSH key generation fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.generate_token_v1_jobs_job_id_token_post(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the generate_token_v1_jobs_job_id_token_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.generate_token_v1_jobs_job_id_token_post_with_http_info(job_id, **kwargs) # noqa: E501 - - @validate_arguments - def generate_token_v1_jobs_job_id_token_post_with_http_info(self, job_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Generate Token # noqa: E501 - - Generate a JWT token for job authentication and set up SSH keys. Args: job_id: Unique identifier of the job request: FastAPI request object potentially containing SSH keys db: Database session dependency token: API access token for authorization Returns: dict: Contains the generated JWT token Raises: HTTPException 404: If job is not found HTTPException 500: If SSH key generation fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.generate_token_v1_jobs_job_id_token_post_with_http_info(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method generate_token_v1_jobs_job_id_token_post" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}/token', 'POST', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def get_health_v1_jobs_job_id_health_get(self, job_id : StrictInt, **kwargs) -> object: # noqa: E501 - """Get Health # noqa: E501 - - Retrieve the current health status of a job. Args: job_id: Unique identifier of the job db: Database session dependency Returns: dict: Health status information including CPU, RAM, disk usage, and job status Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_health_v1_jobs_job_id_health_get(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the get_health_v1_jobs_job_id_health_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.get_health_v1_jobs_job_id_health_get_with_http_info(job_id, **kwargs) # noqa: E501 - - @validate_arguments - def get_health_v1_jobs_job_id_health_get_with_http_info(self, job_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Get Health # noqa: E501 - - Retrieve the current health status of a job. Args: job_id: Unique identifier of the job db: Database session dependency Returns: dict: Health status information including CPU, RAM, disk usage, and job status Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_health_v1_jobs_job_id_health_get_with_http_info(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_health_v1_jobs_job_id_health_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}/health', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def get_job_v1_jobs_job_id_get(self, job_id : StrictInt, **kwargs) -> JobRead: # noqa: E501 - """Get Job # noqa: E501 - - Retrieve a specific job by its ID. Args: job_id: Unique identifier of the job db: Database session dependency Returns: JobRead: The requested job object Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_job_v1_jobs_job_id_get(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: JobRead - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the get_job_v1_jobs_job_id_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.get_job_v1_jobs_job_id_get_with_http_info(job_id, **kwargs) # noqa: E501 - - @validate_arguments - def get_job_v1_jobs_job_id_get_with_http_info(self, job_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Get Job # noqa: E501 - - Retrieve a specific job by its ID. Args: job_id: Unique identifier of the job db: Database session dependency Returns: JobRead: The requested job object Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_job_v1_jobs_job_id_get_with_http_info(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(JobRead, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_job_v1_jobs_job_id_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "JobRead", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def get_jobs_v1_jobs_get(self, **kwargs) -> List[JobRead]: # noqa: E501 - """Get Jobs # noqa: E501 - - Retrieve a list of all jobs in the system. Args: db: Database session dependency token: API access token for authorization Returns: List[JobRead]: List of all jobs # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_jobs_v1_jobs_get(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: List[JobRead] - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the get_jobs_v1_jobs_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.get_jobs_v1_jobs_get_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def get_jobs_v1_jobs_get_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """Get Jobs # noqa: E501 - - Retrieve a list of all jobs in the system. Args: db: Database session dependency token: API access token for authorization Returns: List[JobRead]: List of all jobs # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_jobs_v1_jobs_get_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(List[JobRead], status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_jobs_v1_jobs_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "List[JobRead]", - } - - return self.api_client.call_api( - '/v1/jobs', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def update_health_v1_jobs_job_id_health_put(self, job_id : StrictInt, **kwargs) -> object: # noqa: E501 - """Update Health # noqa: E501 - - Update the health status of a running job. Args: job_id: Unique identifier of the job db: Database session dependency token: Builder token for authorization request: FastAPI request object containing health data Returns: dict: The updated health status data Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_health_v1_jobs_job_id_health_put(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the update_health_v1_jobs_job_id_health_put_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.update_health_v1_jobs_job_id_health_put_with_http_info(job_id, **kwargs) # noqa: E501 - - @validate_arguments - def update_health_v1_jobs_job_id_health_put_with_http_info(self, job_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Update Health # noqa: E501 - - Update the health status of a running job. Args: job_id: Unique identifier of the job db: Database session dependency token: Builder token for authorization request: FastAPI request object containing health data Returns: dict: The updated health status data Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_health_v1_jobs_job_id_health_put_with_http_info(job_id, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_health_v1_jobs_job_id_health_put" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}/health', 'PUT', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def update_job_v1_jobs_job_id_put(self, job_id : StrictInt, job_update : JobUpdate, **kwargs) -> JobRead: # noqa: E501 - """Update Job # noqa: E501 - - Update an existing job's information. Args: job_id: Unique identifier of the job to update job_in: Job update model containing fields to update db: Database session dependency token: API access token for authorization Returns: JobRead: The updated job object Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_job_v1_jobs_job_id_put(job_id, job_update, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param job_update: (required) - :type job_update: JobUpdate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: JobRead - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the update_job_v1_jobs_job_id_put_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.update_job_v1_jobs_job_id_put_with_http_info(job_id, job_update, **kwargs) # noqa: E501 - - @validate_arguments - def update_job_v1_jobs_job_id_put_with_http_info(self, job_id : StrictInt, job_update : JobUpdate, **kwargs) -> ApiResponse: # noqa: E501 - """Update Job # noqa: E501 - - Update an existing job's information. Args: job_id: Unique identifier of the job to update job_in: Job update model containing fields to update db: Database session dependency token: API access token for authorization Returns: JobRead: The updated job object Raises: HTTPException 404: If job is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_job_v1_jobs_job_id_put_with_http_info(job_id, job_update, async_req=True) - >>> result = thread.get() - - :param job_id: (required) - :type job_id: int - :param job_update: (required) - :type job_update: JobUpdate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(JobRead, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'job_id', - 'job_update' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_job_v1_jobs_job_id_put" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['job_id'] is not None: - _path_params['job_id'] = _params['job_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - if _params['job_update'] is not None: - _body_params = _params['job_update'] - - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # set the HTTP header `Content-Type` - _content_types_list = _params.get('_content_type', - self.api_client.select_header_content_type( - ['application/json'])) - if _content_types_list: - _header_params['Content-Type'] = _content_types_list - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "JobRead", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/jobs/{job_id}', 'PUT', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) diff --git a/jobmanager/client/jobmanager_client/api/runners_api.py b/jobmanager/client/jobmanager_client/api/runners_api.py deleted file mode 100644 index 235d004e38..0000000000 --- a/jobmanager/client/jobmanager_client/api/runners_api.py +++ /dev/null @@ -1,476 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import re # noqa: F401 -import io -import warnings - -from pydantic import validate_arguments, ValidationError - -from pydantic import StrictInt - -from jobmanager_client.models.runner_create import RunnerCreate -from jobmanager_client.models.runner_health_response import RunnerHealthResponse -from jobmanager_client.models.runner_health_update_response import RunnerHealthUpdateResponse -from jobmanager_client.models.runner_register_response import RunnerRegisterResponse - -from jobmanager_client.api_client import ApiClient -from jobmanager_client.api_response import ApiResponse -from jobmanager_client.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError -) - - -class RunnersApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_arguments - def get_runner_health_v1_runners_runner_id_health_get(self, runner_id : StrictInt, **kwargs) -> RunnerHealthResponse: # noqa: E501 - """Get Runner Health # noqa: E501 - - Get runner health status. Args: runner_id: Unique identifier of the runner db: Database session dependency Returns: dict: Runner health metrics including CPU, RAM, disk usage and status Raises: HTTPException 404: If runner is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_runner_health_v1_runners_runner_id_health_get(runner_id, async_req=True) - >>> result = thread.get() - - :param runner_id: (required) - :type runner_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: RunnerHealthResponse - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the get_runner_health_v1_runners_runner_id_health_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.get_runner_health_v1_runners_runner_id_health_get_with_http_info(runner_id, **kwargs) # noqa: E501 - - @validate_arguments - def get_runner_health_v1_runners_runner_id_health_get_with_http_info(self, runner_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Get Runner Health # noqa: E501 - - Get runner health status. Args: runner_id: Unique identifier of the runner db: Database session dependency Returns: dict: Runner health metrics including CPU, RAM, disk usage and status Raises: HTTPException 404: If runner is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_runner_health_v1_runners_runner_id_health_get_with_http_info(runner_id, async_req=True) - >>> result = thread.get() - - :param runner_id: (required) - :type runner_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(RunnerHealthResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'runner_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method get_runner_health_v1_runners_runner_id_health_get" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['runner_id'] is not None: - _path_params['runner_id'] = _params['runner_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "RunnerHealthResponse", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/runners/{runner_id}/health', 'GET', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def register_runner_v1_runners_register_post(self, runner_create : RunnerCreate, **kwargs) -> RunnerRegisterResponse: # noqa: E501 - """Register Runner # noqa: E501 - - Register a new runner. Args: runner_in: Runner registration data including name and labels db: Database session dependency token: API access token for authorization Returns: dict: Contains the runner ID and its authentication token Raises: HTTPException 500: If token generation fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.register_runner_v1_runners_register_post(runner_create, async_req=True) - >>> result = thread.get() - - :param runner_create: (required) - :type runner_create: RunnerCreate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: RunnerRegisterResponse - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the register_runner_v1_runners_register_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.register_runner_v1_runners_register_post_with_http_info(runner_create, **kwargs) # noqa: E501 - - @validate_arguments - def register_runner_v1_runners_register_post_with_http_info(self, runner_create : RunnerCreate, **kwargs) -> ApiResponse: # noqa: E501 - """Register Runner # noqa: E501 - - Register a new runner. Args: runner_in: Runner registration data including name and labels db: Database session dependency token: API access token for authorization Returns: dict: Contains the runner ID and its authentication token Raises: HTTPException 500: If token generation fails # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.register_runner_v1_runners_register_post_with_http_info(runner_create, async_req=True) - >>> result = thread.get() - - :param runner_create: (required) - :type runner_create: RunnerCreate - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(RunnerRegisterResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'runner_create' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method register_runner_v1_runners_register_post" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - if _params['runner_create'] is not None: - _body_params = _params['runner_create'] - - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # set the HTTP header `Content-Type` - _content_types_list = _params.get('_content_type', - self.api_client.select_header_content_type( - ['application/json'])) - if _content_types_list: - _header_params['Content-Type'] = _content_types_list - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "RunnerRegisterResponse", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/runners/register', 'POST', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def update_runner_health_v1_runners_runner_id_health_put(self, runner_id : StrictInt, **kwargs) -> RunnerHealthUpdateResponse: # noqa: E501 - """Update Runner Health # noqa: E501 - - Update runner health metrics. Args: runner_id: Unique identifier of the runner request: FastAPI request object containing health metrics db: Database session dependency token: Runner token for authorization Returns: dict: Success indicator Raises: HTTPException 404: If runner is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_runner_health_v1_runners_runner_id_health_put(runner_id, async_req=True) - >>> result = thread.get() - - :param runner_id: (required) - :type runner_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: RunnerHealthUpdateResponse - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the update_runner_health_v1_runners_runner_id_health_put_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.update_runner_health_v1_runners_runner_id_health_put_with_http_info(runner_id, **kwargs) # noqa: E501 - - @validate_arguments - def update_runner_health_v1_runners_runner_id_health_put_with_http_info(self, runner_id : StrictInt, **kwargs) -> ApiResponse: # noqa: E501 - """Update Runner Health # noqa: E501 - - Update runner health metrics. Args: runner_id: Unique identifier of the runner request: FastAPI request object containing health metrics db: Database session dependency token: Runner token for authorization Returns: dict: Success indicator Raises: HTTPException 404: If runner is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.update_runner_health_v1_runners_runner_id_health_put_with_http_info(runner_id, async_req=True) - >>> result = thread.get() - - :param runner_id: (required) - :type runner_id: int - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(RunnerHealthUpdateResponse, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'runner_id' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method update_runner_health_v1_runners_runner_id_health_put" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - if _params['runner_id'] is not None: - _path_params['runner_id'] = _params['runner_id'] - - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "RunnerHealthUpdateResponse", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/runners/{runner_id}/health', 'PUT', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) diff --git a/jobmanager/client/jobmanager_client/api/tokens_api.py b/jobmanager/client/jobmanager_client/api/tokens_api.py deleted file mode 100644 index 257e488175..0000000000 --- a/jobmanager/client/jobmanager_client/api/tokens_api.py +++ /dev/null @@ -1,325 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import re # noqa: F401 -import io -import warnings - -from pydantic import validate_arguments, ValidationError - -from pydantic import StrictStr - -from typing import Any - - -from jobmanager_client.api_client import ApiClient -from jobmanager_client.api_response import ApiResponse -from jobmanager_client.exceptions import ( # noqa: F401 - ApiTypeError, - ApiValueError -) - - -class TokensApi: - """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - def __init__(self, api_client=None) -> None: - if api_client is None: - api_client = ApiClient.get_default() - self.api_client = api_client - - @validate_arguments - def create_api_access_token_v1_api_access_token_post(self, **kwargs) -> object: # noqa: E501 - """Create Api Access Token # noqa: E501 - - Create a new API access token for service authentication. Args: request: FastAPI request object with identity and optional expiration db: Database session dependency _: Internal-only access check dependency Returns: JSONResponse: Contains the generated token and identity Raises: HTTPException 400: If identity is missing from request HTTPException 403: If request is not from internal network # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.create_api_access_token_v1_api_access_token_post(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the create_api_access_token_v1_api_access_token_post_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.create_api_access_token_v1_api_access_token_post_with_http_info(**kwargs) # noqa: E501 - - @validate_arguments - def create_api_access_token_v1_api_access_token_post_with_http_info(self, **kwargs) -> ApiResponse: # noqa: E501 - """Create Api Access Token # noqa: E501 - - Create a new API access token for service authentication. Args: request: FastAPI request object with identity and optional expiration db: Database session dependency _: Internal-only access check dependency Returns: JSONResponse: Contains the generated token and identity Raises: HTTPException 400: If identity is missing from request HTTPException 403: If request is not from internal network # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.create_api_access_token_v1_api_access_token_post_with_http_info(async_req=True) - >>> result = thread.get() - - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method create_api_access_token_v1_api_access_token_post" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - } - - return self.api_client.call_api( - '/v1/api_access_token', 'POST', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) - - @validate_arguments - def revoke_api_access_token_v1_api_access_token_delete(self, identity : StrictStr, token : StrictStr, **kwargs) -> object: # noqa: E501 - """Revoke Api Access Token # noqa: E501 - - Revoke an existing API access token. Args: identity: Service identity associated with the token token: The token value to revoke db: Database session dependency _: Internal-only access check dependency Returns: dict: Contains the revoked token and identity Raises: HTTPException 403: If request is not from internal network HTTPException 404: If token is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.revoke_api_access_token_v1_api_access_token_delete(identity, token, async_req=True) - >>> result = thread.get() - - :param identity: (required) - :type identity: str - :param token: (required) - :type token: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _request_timeout: timeout setting for this request. - If one number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: object - """ - kwargs['_return_http_data_only'] = True - if '_preload_content' in kwargs: - message = "Error! Please call the revoke_api_access_token_v1_api_access_token_delete_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501 - raise ValueError(message) - return self.revoke_api_access_token_v1_api_access_token_delete_with_http_info(identity, token, **kwargs) # noqa: E501 - - @validate_arguments - def revoke_api_access_token_v1_api_access_token_delete_with_http_info(self, identity : StrictStr, token : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 - """Revoke Api Access Token # noqa: E501 - - Revoke an existing API access token. Args: identity: Service identity associated with the token token: The token value to revoke db: Database session dependency _: Internal-only access check dependency Returns: dict: Contains the revoked token and identity Raises: HTTPException 403: If request is not from internal network HTTPException 404: If token is not found # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.revoke_api_access_token_v1_api_access_token_delete_with_http_info(identity, token, async_req=True) - >>> result = thread.get() - - :param identity: (required) - :type identity: str - :param token: (required) - :type token: str - :param async_req: Whether to execute the request asynchronously. - :type async_req: bool, optional - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :type _preload_content: bool, optional - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :type _return_http_data_only: bool, optional - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_auth: dict, optional - :type _content_type: string, optional: force content-type for the request - :return: Returns the result object. - If the method is called asynchronously, - returns the request thread. - :rtype: tuple(object, status_code(int), headers(HTTPHeaderDict)) - """ - - _params = locals() - - _all_params = [ - 'identity', - 'token' - ] - _all_params.extend( - [ - 'async_req', - '_return_http_data_only', - '_preload_content', - '_request_timeout', - '_request_auth', - '_content_type', - '_headers' - ] - ) - - # validate the arguments - for _key, _val in _params['kwargs'].items(): - if _key not in _all_params: - raise ApiTypeError( - "Got an unexpected keyword argument '%s'" - " to method revoke_api_access_token_v1_api_access_token_delete" % _key - ) - _params[_key] = _val - del _params['kwargs'] - - _collection_formats = {} - - # process the path parameters - _path_params = {} - - # process the query parameters - _query_params = [] - if _params.get('identity') is not None: # noqa: E501 - _query_params.append(('identity', _params['identity'])) - - if _params.get('token') is not None: # noqa: E501 - _query_params.append(('token', _params['token'])) - - # process the header parameters - _header_params = dict(_params.get('_headers', {})) - # process the form parameters - _form_params = [] - _files = {} - # process the body parameter - _body_params = None - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 - - # authentication setting - _auth_settings = [] # noqa: E501 - - _response_types_map = { - '200': "object", - '422': "HTTPValidationError", - } - - return self.api_client.call_api( - '/v1/api_access_token', 'DELETE', - _path_params, - _query_params, - _header_params, - body=_body_params, - post_params=_form_params, - files=_files, - response_types_map=_response_types_map, - auth_settings=_auth_settings, - async_req=_params.get('async_req'), - _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=_params.get('_preload_content', True), - _request_timeout=_params.get('_request_timeout'), - collection_formats=_collection_formats, - _request_auth=_params.get('_request_auth')) diff --git a/jobmanager/client/jobmanager_client/api_client.py b/jobmanager/client/jobmanager_client/api_client.py deleted file mode 100644 index 0bdbfa44e8..0000000000 --- a/jobmanager/client/jobmanager_client/api_client.py +++ /dev/null @@ -1,766 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import atexit -import datetime -from dateutil.parser import parse -import json -import mimetypes -from multiprocessing.pool import ThreadPool -import os -import re -import tempfile - -from urllib.parse import quote -from pydantic import SecretStr - -from jobmanager_client.configuration import Configuration -from jobmanager_client.api_response import ApiResponse -import jobmanager_client.models -from jobmanager_client import rest -from jobmanager_client.exceptions import ApiValueError, ApiException - - -class ApiClient: - """Generic API client for OpenAPI client library builds. - - OpenAPI generic API client. This client handles the client- - server communication, and is invariant across implementations. Specifics of - the methods and models for each application are generated from the OpenAPI - templates. - - :param configuration: .Configuration object for this client - :param header_name: a header to pass when making calls to the API. - :param header_value: a header value to pass when making calls to - the API. - :param cookie: a cookie to include in the header when making calls - to the API - :param pool_threads: The number of threads to use for async requests - to the API. More threads means more concurrent API requests. - """ - - PRIMITIVE_TYPES = (float, bool, bytes, str, int) - NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int, # TODO remove as only py3 is supported? - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, - } - _pool = None - - def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=1) -> None: - # use default configuration if none is provided - if configuration is None: - configuration = Configuration.get_default() - self.configuration = configuration - self.pool_threads = pool_threads - - self.rest_client = rest.RESTClientObject(configuration) - self.default_headers = {} - if header_name is not None: - self.default_headers[header_name] = header_value - self.cookie = cookie - # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.0.0/python' - self.client_side_validation = configuration.client_side_validation - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def close(self): - if self._pool: - self._pool.close() - self._pool.join() - self._pool = None - if hasattr(atexit, 'unregister'): - atexit.unregister(self.close) - - @property - def pool(self): - """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. - """ - if self._pool is None: - atexit.register(self.close) - self._pool = ThreadPool(self.pool_threads) - return self._pool - - @property - def user_agent(self): - """User agent for this API client""" - return self.default_headers['User-Agent'] - - @user_agent.setter - def user_agent(self, value): - self.default_headers['User-Agent'] = value - - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - - - _default = None - - @classmethod - def get_default(cls): - """Return new instance of ApiClient. - - This method returns newly created, based on default constructor, - object of ApiClient class or returns a copy of default - ApiClient. - - :return: The ApiClient object. - """ - if cls._default is None: - cls._default = ApiClient() - return cls._default - - @classmethod - def set_default(cls, default): - """Set default instance of ApiClient. - - It stores default ApiClient. - - :param default: object of ApiClient. - """ - cls._default = default - - def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_types_map=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None, - _request_auth=None): - - config = self.configuration - - # header parameters - header_params = header_params or {} - header_params.update(self.default_headers) - if self.cookie: - header_params['Cookie'] = self.cookie - if header_params: - header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) - - # path parameters - if path_params: - path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) - for k, v in path_params: - # specified safe chars, encode everything - resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) - ) - - # post parameters - if post_params or files: - post_params = post_params if post_params else [] - post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) - post_params.extend(self.files_parameters(files)) - - # auth setting - self.update_params_for_auth( - header_params, query_params, auth_settings, - resource_path, method, body, - request_auth=_request_auth) - - # body - if body: - body = self.sanitize_for_serialization(body) - - # request url - if _host is None: - url = self.configuration.host + resource_path - else: - # use server/host defined in path or operation instead - url = _host + resource_path - - # query parameters - if query_params: - query_params = self.sanitize_for_serialization(query_params) - url_query = self.parameters_to_url_query(query_params, - collection_formats) - url += "?" + url_query - - try: - # perform request and return response - response_data = self.request( - method, url, - query_params=query_params, - headers=header_params, - post_params=post_params, body=body, - _preload_content=_preload_content, - _request_timeout=_request_timeout) - except ApiException as e: - if e.body: - e.body = e.body.decode('utf-8') - raise e - - self.last_response = response_data - - return_data = None # assuming deserialization is not needed - # data needs deserialization or returns HTTP data (deserialized) only - if _preload_content or _return_http_data_only: - response_type = response_types_map.get(str(response_data.status), None) - if not response_type and isinstance(response_data.status, int) and 100 <= response_data.status <= 599: - # if not found, look for '1XX', '2XX', etc. - response_type = response_types_map.get(str(response_data.status)[0] + "XX", None) - - if response_type == "bytearray": - response_data.data = response_data.data - else: - match = None - content_type = response_data.getheader('content-type') - if content_type is not None: - match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type) - encoding = match.group(1) if match else "utf-8" - response_data.data = response_data.data.decode(encoding) - - # deserialize response data - if response_type == "bytearray": - return_data = response_data.data - elif response_type: - return_data = self.deserialize(response_data, response_type) - else: - return_data = None - - if _return_http_data_only: - return return_data - else: - return ApiResponse(status_code = response_data.status, - data = return_data, - headers = response_data.getheaders(), - raw_data = response_data.data) - - def sanitize_for_serialization(self, obj): - """Builds a JSON POST object. - - If obj is None, return None. - If obj is SecretStr, return obj.get_secret_value() - If obj is str, int, long, float, bool, return directly. - If obj is datetime.datetime, datetime.date - convert to string in iso8601 format. - If obj is list, sanitize each element in the list. - If obj is dict, return the dict. - If obj is OpenAPI model, return the properties dict. - - :param obj: The data to serialize. - :return: The serialized form of data. - """ - if obj is None: - return None - elif isinstance(obj, SecretStr): - return obj.get_secret_value() - elif isinstance(obj, self.PRIMITIVE_TYPES): - return obj - elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] - elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) - elif isinstance(obj, (datetime.datetime, datetime.date)): - return obj.isoformat() - - if isinstance(obj, dict): - obj_dict = obj - else: - # Convert model obj to dict except - # attributes `openapi_types`, `attribute_map` - # and attributes which value is not None. - # Convert attribute name to json key in - # model definition for request. - if hasattr(obj, 'to_dict') and callable(getattr(obj, 'to_dict')): - obj_dict = obj.to_dict() - else: - obj_dict = obj.__dict__ - - return {key: self.sanitize_for_serialization(val) - for key, val in obj_dict.items()} - - def deserialize(self, response, response_type): - """Deserializes response into an object. - - :param response: RESTResponse object to be deserialized. - :param response_type: class literal for - deserialized object, or string of class name. - - :return: deserialized object. - """ - # handle file downloading - # save response body into a tmp file and return the instance - if response_type == "file": - return self.__deserialize_file(response) - - # fetch data from response object - try: - data = json.loads(response.data) - except ValueError: - data = response.data - - return self.__deserialize(data, response_type) - - def __deserialize(self, data, klass): - """Deserializes dict, list, str into an object. - - :param data: dict, list or str. - :param klass: class literal, or string of class name. - - :return: object. - """ - if data is None: - return None - - if isinstance(klass, str): - if klass.startswith('List['): - sub_kls = re.match(r'List\[(.*)]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] - - if klass.startswith('Dict['): - sub_kls = re.match(r'Dict\[([^,]*), (.*)]', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in data.items()} - - # convert str to class - if klass in self.NATIVE_TYPES_MAPPING: - klass = self.NATIVE_TYPES_MAPPING[klass] - else: - klass = getattr(jobmanager_client.models, klass) - - if klass in self.PRIMITIVE_TYPES: - return self.__deserialize_primitive(data, klass) - elif klass == object: - return self.__deserialize_object(data) - elif klass == datetime.date: - return self.__deserialize_date(data) - elif klass == datetime.datetime: - return self.__deserialize_datetime(data) - else: - return self.__deserialize_model(data, klass) - - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_types_map=None, auth_settings=None, - async_req=None, _return_http_data_only=None, - collection_formats=None, _preload_content=True, - _request_timeout=None, _host=None, _request_auth=None): - """Makes the HTTP request (synchronous) and returns deserialized data. - - To make an async_req request, set the async_req parameter. - - :param resource_path: Path to method endpoint. - :param method: Method to call. - :param path_params: Path parameters in the url. - :param query_params: Query parameters in the url. - :param header_params: Header parameters to be - placed in the request header. - :param body: Request body. - :param post_params dict: Request post form parameters, - for `application/x-www-form-urlencoded`, `multipart/form-data`. - :param auth_settings list: Auth Settings names for the request. - :param response: Response data type. - :param files dict: key -> filename, value -> filepath, - for `multipart/form-data`. - :param async_req bool: execute request asynchronously - :param _return_http_data_only: response data instead of ApiResponse - object with status code, headers, etc - :param _preload_content: if False, the ApiResponse.data will - be set to none and raw_data will store the - HTTP response body without reading/decoding. - Default is True. - :param collection_formats: dict of collection formats for path, query, - header, and post parameters. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the authentication - in the spec for a single request. - :type _request_token: dict, optional - :return: - If async_req parameter is True, - the request will be called asynchronously. - The method will return the request thread. - If parameter async_req is False or missing, - then the method will return the response directly. - """ - args = ( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_types_map, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - _request_auth, - ) - if not async_req: - return self.__call_api(*args) - - return self.pool.apply_async(self.__call_api, args) - - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None): - """Makes the HTTP request using RESTClient.""" - if method == "GET": - return self.rest_client.get_request(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "HEAD": - return self.rest_client.head_request(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) - elif method == "OPTIONS": - return self.rest_client.options_request(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout) - elif method == "POST": - return self.rest_client.post_request(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PUT": - return self.rest_client.put_request(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "PATCH": - return self.rest_client.patch_request(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - elif method == "DELETE": - return self.rest_client.delete_request(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - else: - raise ApiValueError( - "http method must be `GET`, `HEAD`, `OPTIONS`," - " `POST`, `PATCH`, `PUT` or `DELETE`." - ) - - def parameters_to_tuples(self, params, collection_formats): - """Get parameters as list of tuples, formatting collections. - - :param params: Parameters as dict or list of two-tuples - :param dict collection_formats: Parameter collection formats - :return: Parameters as list of tuples, collections formatted - """ - new_params = [] - if collection_formats is None: - collection_formats = {} - for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, value) for value in v) - else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' - else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) - else: - new_params.append((k, v)) - return new_params - - def parameters_to_url_query(self, params, collection_formats): - """Get parameters as list of tuples, formatting collections. - - :param params: Parameters as dict or list of two-tuples - :param dict collection_formats: Parameter collection formats - :return: URL query string (e.g. a=Hello%20World&b=123) - """ - new_params = [] - if collection_formats is None: - collection_formats = {} - for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 - if isinstance(v, bool): - v = str(v).lower() - if isinstance(v, (int, float)): - v = str(v) - if isinstance(v, dict): - v = json.dumps(v) - - if k in collection_formats: - collection_format = collection_formats[k] - if collection_format == 'multi': - new_params.extend((k, quote(str(value))) for value in v) - else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' - else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(quote(str(value)) for value in v))) - else: - new_params.append((k, quote(str(v)))) - - return "&".join(["=".join(map(str, item)) for item in new_params]) - - def files_parameters(self, files=None): - """Builds form parameters. - - :param files: File parameters. - :return: Form parameters with files. - """ - params = [] - - if files: - for k, v in files.items(): - if not v: - continue - file_names = v if type(v) is list else [v] - for n in file_names: - with open(n, 'rb') as f: - filename = os.path.basename(f.name) - filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) - - return params - - def select_header_accept(self, accepts): - """Returns `Accept` based on an array of accepts provided. - - :param accepts: List of headers. - :return: Accept (e.g. application/json). - """ - if not accepts: - return - - for accept in accepts: - if re.search('json', accept, re.IGNORECASE): - return accept - - return accepts[0] - - def select_header_content_type(self, content_types): - """Returns `Content-Type` based on an array of content_types provided. - - :param content_types: List of content-types. - :return: Content-Type (e.g. application/json). - """ - if not content_types: - return None - - for content_type in content_types: - if re.search('json', content_type, re.IGNORECASE): - return content_type - - return content_types[0] - - def update_params_for_auth(self, headers, queries, auth_settings, - resource_path, method, body, - request_auth=None): - """Updates header and query params based on authentication setting. - - :param headers: Header parameters dict to be updated. - :param queries: Query parameters tuple list to be updated. - :param auth_settings: Authentication setting identifiers list. - :resource_path: A string representation of the HTTP request resource path. - :method: A string representation of the HTTP request method. - :body: A object representing the body of the HTTP request. - The object type is the return value of sanitize_for_serialization(). - :param request_auth: if set, the provided settings will - override the token in the configuration. - """ - if not auth_settings: - return - - if request_auth: - self._apply_auth_params(headers, queries, - resource_path, method, body, - request_auth) - return - - for auth in auth_settings: - auth_setting = self.configuration.auth_settings().get(auth) - if auth_setting: - self._apply_auth_params(headers, queries, - resource_path, method, body, - auth_setting) - - def _apply_auth_params(self, headers, queries, - resource_path, method, body, - auth_setting): - """Updates the request parameters based on a single auth_setting - - :param headers: Header parameters dict to be updated. - :param queries: Query parameters tuple list to be updated. - :resource_path: A string representation of the HTTP request resource path. - :method: A string representation of the HTTP request method. - :body: A object representing the body of the HTTP request. - The object type is the return value of sanitize_for_serialization(). - :param auth_setting: auth settings for the endpoint - """ - if auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - if auth_setting['type'] != 'http-signature': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - queries.append((auth_setting['key'], auth_setting['value'])) - else: - raise ApiValueError( - 'Authentication token must be in `query` or `header`' - ) - - def __deserialize_file(self, response): - """Deserializes body to file - - Saves response body into a file in a temporary folder, - using the filename from the `Content-Disposition` header if provided. - - :param response: RESTResponse. - :return: file path. - """ - fd, path = tempfile.mkstemp(dir=self.configuration.temp_folder_path) - os.close(fd) - os.remove(path) - - content_disposition = response.getheader("Content-Disposition") - if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) - path = os.path.join(os.path.dirname(path), filename) - - with open(path, "wb") as f: - f.write(response.data) - - return path - - def __deserialize_primitive(self, data, klass): - """Deserializes string to primitive type. - - :param data: str. - :param klass: class literal. - - :return: int, long, float, str, bool. - """ - try: - return klass(data) - except UnicodeEncodeError: - return str(data) - except TypeError: - return data - - def __deserialize_object(self, value): - """Return an original value. - - :return: object. - """ - return value - - def __deserialize_date(self, string): - """Deserializes string to date. - - :param string: str. - :return: date. - """ - try: - return parse(string).date() - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) - ) - - def __deserialize_datetime(self, string): - """Deserializes string to datetime. - - The string should be in iso8601 datetime format. - - :param string: str. - :return: datetime. - """ - try: - return parse(string) - except ImportError: - return string - except ValueError: - raise rest.ApiException( - status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) - ) - - def __deserialize_model(self, data, klass): - """Deserializes list or dict to model. - - :param data: dict, list. - :param klass: class literal. - :return: model object. - """ - - return klass.from_dict(data) diff --git a/jobmanager/client/jobmanager_client/api_response.py b/jobmanager/client/jobmanager_client/api_response.py deleted file mode 100644 index a0b62b9524..0000000000 --- a/jobmanager/client/jobmanager_client/api_response.py +++ /dev/null @@ -1,25 +0,0 @@ -"""API response object.""" - -from __future__ import annotations -from typing import Any, Dict, Optional -from pydantic import Field, StrictInt, StrictStr - -class ApiResponse: - """ - API response object - """ - - status_code: Optional[StrictInt] = Field(None, description="HTTP status code") - headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers") - data: Optional[Any] = Field(None, description="Deserialized data given the data type") - raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)") - - def __init__(self, - status_code=None, - headers=None, - data=None, - raw_data=None) -> None: - self.status_code = status_code - self.headers = headers - self.data = data - self.raw_data = raw_data diff --git a/jobmanager/client/jobmanager_client/configuration.py b/jobmanager/client/jobmanager_client/configuration.py deleted file mode 100644 index b008349536..0000000000 --- a/jobmanager/client/jobmanager_client/configuration.py +++ /dev/null @@ -1,434 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import copy -import logging -import multiprocessing -import sys -import urllib3 - -import http.client as httplib - -JSON_SCHEMA_VALIDATION_KEYWORDS = { - 'multipleOf', 'maximum', 'exclusiveMaximum', - 'minimum', 'exclusiveMinimum', 'maxLength', - 'minLength', 'pattern', 'maxItems', 'minItems' -} - -class Configuration: - """This class contains various settings of the API client. - - :param host: Base url. - :param api_key: Dict to store API key(s). - Each entry in the dict specifies an API key. - The dict key is the name of the security scheme in the OAS specification. - The dict value is the API key secret. - :param api_key_prefix: Dict to store API prefix (e.g. Bearer). - The dict key is the name of the security scheme in the OAS specification. - The dict value is an API key prefix when generating the auth data. - :param username: Username for HTTP basic authentication. - :param password: Password for HTTP basic authentication. - :param access_token: Access token. - :param server_index: Index to servers configuration. - :param server_variables: Mapping with string values to replace variables in - templated server configuration. The validation of enums is performed for - variables with defined enum values before. - :param server_operation_index: Mapping from operation ID to an index to server - configuration. - :param server_operation_variables: Mapping from operation ID to a mapping with - string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum - values before. - :param ssl_ca_cert: str - the path to a file of concatenated CA certificates - in PEM format. - - """ - - _default = None - - def __init__(self, host=None, - api_key=None, api_key_prefix=None, - username=None, password=None, - access_token=None, - server_index=None, server_variables=None, - server_operation_index=None, server_operation_variables=None, - ssl_ca_cert=None, - ) -> None: - """Constructor - """ - self._base_path = "http://localhost" if host is None else host - """Default Base url - """ - self.server_index = 0 if server_index is None and host is None else server_index - self.server_operation_index = server_operation_index or {} - """Default server index - """ - self.server_variables = server_variables or {} - self.server_operation_variables = server_operation_variables or {} - """Default server variables - """ - self.temp_folder_path = None - """Temp file folder for downloading files - """ - # Authentication Settings - self.api_key = {} - if api_key: - self.api_key = api_key - """dict to store API key(s) - """ - self.api_key_prefix = {} - if api_key_prefix: - self.api_key_prefix = api_key_prefix - """dict to store API prefix (e.g. Bearer) - """ - self.refresh_api_key_hook = None - """function hook to refresh API key if expired - """ - self.username = username - """Username for HTTP basic authentication - """ - self.password = password - """Password for HTTP basic authentication - """ - self.access_token = access_token - """Access token - """ - self.logger = {} - """Logging Settings - """ - self.logger["package_logger"] = logging.getLogger("jobmanager_client") - self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = '%(asctime)s %(levelname)s %(message)s' - """Log format - """ - self.logger_stream_handler = None - """Log stream handler - """ - self.logger_file_handler = None - """Log file handler - """ - self.logger_file = None - """Debug file location - """ - self.debug = False - """Debug switch - """ - - self.verify_ssl = True - """SSL/TLS verification - Set this to false to skip verifying SSL certificate when calling API - from https server. - """ - self.ssl_ca_cert = ssl_ca_cert - """Set this to customize the certificate file to verify the peer. - """ - self.cert_file = None - """client certificate file - """ - self.key_file = None - """client key file - """ - self.assert_hostname = None - """Set this to True/False to enable/disable SSL hostname verification. - """ - self.tls_server_name = None - """SSL/TLS Server Name Indication (SNI) - Set this to the SNI value expected by the server. - """ - - self.connection_pool_maxsize = multiprocessing.cpu_count() * 5 - """urllib3 connection pool's maximum number of connections saved - per pool. urllib3 uses 1 connection as default value, but this is - not the best value when you are making a lot of possibly parallel - requests to the same host, which is often the case here. - cpu_count * 5 is used as default value to increase performance. - """ - - self.proxy = None - """Proxy URL - """ - self.proxy_headers = None - """Proxy headers - """ - self.safe_chars_for_path_param = '' - """Safe chars for path_param - """ - self.retries = None - """Adding retries to override urllib3 default value 3 - """ - # Enable client side validation - self.client_side_validation = True - - self.socket_options = None - """Options to pass down to the underlying urllib3 socket - """ - - self.datetime_format = "%Y-%m-%dT%H:%M:%S.%f%z" - """datetime format - """ - - self.date_format = "%Y-%m-%d" - """date format - """ - - def __deepcopy__(self, memo): - cls = self.__class__ - result = cls.__new__(cls) - memo[id(self)] = result - for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): - setattr(result, k, copy.deepcopy(v, memo)) - # shallow copy of loggers - result.logger = copy.copy(self.logger) - # use setters to configure loggers - result.logger_file = self.logger_file - result.debug = self.debug - return result - - def __setattr__(self, name, value): - object.__setattr__(self, name, value) - - @classmethod - def set_default(cls, default): - """Set default instance of configuration. - - It stores default configuration, which can be - returned by get_default_copy method. - - :param default: object of Configuration - """ - cls._default = default - - @classmethod - def get_default_copy(cls): - """Deprecated. Please use `get_default` instead. - - Deprecated. Please use `get_default` instead. - - :return: The configuration object. - """ - return cls.get_default() - - @classmethod - def get_default(cls): - """Return the default configuration. - - This method returns newly created, based on default constructor, - object of Configuration class or returns a copy of default - configuration. - - :return: The configuration object. - """ - if cls._default is None: - cls._default = Configuration() - return cls._default - - @property - def logger_file(self): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - return self.__logger_file - - @logger_file.setter - def logger_file(self, value): - """The logger file. - - If the logger_file is None, then add stream handler and remove file - handler. Otherwise, add file handler and remove stream handler. - - :param value: The logger_file path. - :type: str - """ - self.__logger_file = value - if self.__logger_file: - # If set logging file, - # then add file handler and remove stream handler. - self.logger_file_handler = logging.FileHandler(self.__logger_file) - self.logger_file_handler.setFormatter(self.logger_formatter) - for _, logger in self.logger.items(): - logger.addHandler(self.logger_file_handler) - - @property - def debug(self): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - return self.__debug - - @debug.setter - def debug(self, value): - """Debug status - - :param value: The debug status, True or False. - :type: bool - """ - self.__debug = value - if self.__debug: - # if debug status is True, turn on debug logging - for _, logger in self.logger.items(): - logger.setLevel(logging.DEBUG) - # turn on httplib debug - httplib.HTTPConnection.debuglevel = 1 - else: - # if debug status is False, turn off debug logging, - # setting log level to default `logging.WARNING` - for _, logger in self.logger.items(): - logger.setLevel(logging.WARNING) - # turn off httplib debug - httplib.HTTPConnection.debuglevel = 0 - - @property - def logger_format(self): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - return self.__logger_format - - @logger_format.setter - def logger_format(self, value): - """The logger format. - - The logger_formatter will be updated when sets logger_format. - - :param value: The format string. - :type: str - """ - self.__logger_format = value - self.logger_formatter = logging.Formatter(self.__logger_format) - - def get_api_key_with_prefix(self, identifier, alias=None): - """Gets API key (with prefix if set). - - :param identifier: The identifier of apiKey. - :param alias: The alternative identifier of apiKey. - :return: The token for api key authentication. - """ - if self.refresh_api_key_hook is not None: - self.refresh_api_key_hook(self) - key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None) - if key: - prefix = self.api_key_prefix.get(identifier) - if prefix: - return "%s %s" % (prefix, key) - else: - return key - - def get_basic_auth_token(self): - """Gets HTTP basic authentication header (string). - - :return: The token for basic HTTP authentication. - """ - username = "" - if self.username is not None: - username = self.username - password = "" - if self.password is not None: - password = self.password - return urllib3.util.make_headers( - basic_auth=username + ':' + password - ).get('authorization') - - def auth_settings(self): - """Gets Auth Settings dict for api client. - - :return: The Auth Settings information dict. - """ - auth = {} - return auth - - def to_debug_report(self): - """Gets the essential information for debugging. - - :return: The report for debugging. - """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: 2.0.0\n"\ - "SDK Package Version: 1.0.0".\ - format(env=sys.platform, pyversion=sys.version) - - def get_host_settings(self): - """Gets an array of host settings - - :return: An array of host settings - """ - return [ - { - 'url': "", - 'description': "No description provided", - } - ] - - def get_host_from_settings(self, index, variables=None, servers=None): - """Gets host URL based on the index and variables - :param index: array index of the host settings - :param variables: hash of variable and the corresponding value - :param servers: an array of host settings or None - :return: URL based on host settings - """ - if index is None: - return self._base_path - - variables = {} if variables is None else variables - servers = self.get_host_settings() if servers is None else servers - - try: - server = servers[index] - except IndexError: - raise ValueError( - "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers))) - - url = server['url'] - - # go through variables and replace placeholders - for variable_name, variable in server.get('variables', {}).items(): - used_value = variables.get( - variable_name, variable['default_value']) - - if 'enum_values' in variable \ - and used_value not in variable['enum_values']: - raise ValueError( - "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format( - variable_name, variables[variable_name], - variable['enum_values'])) - - url = url.replace("{" + variable_name + "}", used_value) - - return url - - @property - def host(self): - """Return generated host.""" - return self.get_host_from_settings(self.server_index, variables=self.server_variables) - - @host.setter - def host(self, value): - """Fix base path.""" - self._base_path = value - self.server_index = None diff --git a/jobmanager/client/jobmanager_client/exceptions.py b/jobmanager/client/jobmanager_client/exceptions.py deleted file mode 100644 index 3ad5937292..0000000000 --- a/jobmanager/client/jobmanager_client/exceptions.py +++ /dev/null @@ -1,166 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -class OpenApiException(Exception): - """The base exception class for all OpenAPIExceptions""" - - -class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None) -> None: - """ Raises an exception for TypeErrors - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list): a list of keys an indices to get to the - current_item - None if unset - valid_classes (tuple): the primitive classes that current item - should be an instance of - None if unset - key_type (bool): False if our value is a value in a dict - True if it is a key in a dict - False if our item is an item in a list - None if unset - """ - self.path_to_item = path_to_item - self.valid_classes = valid_classes - self.key_type = key_type - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiTypeError, self).__init__(full_msg) - - -class ApiValueError(OpenApiException, ValueError): - def __init__(self, msg, path_to_item=None) -> None: - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (list) the path to the exception in the - received_data dict. None if unset - """ - - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiValueError, self).__init__(full_msg) - - -class ApiAttributeError(OpenApiException, AttributeError): - def __init__(self, msg, path_to_item=None) -> None: - """ - Raised when an attribute reference or assignment fails. - - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiAttributeError, self).__init__(full_msg) - - -class ApiKeyError(OpenApiException, KeyError): - def __init__(self, msg, path_to_item=None) -> None: - """ - Args: - msg (str): the exception message - - Keyword Args: - path_to_item (None/list) the path to the exception in the - received_data dict - """ - self.path_to_item = path_to_item - full_msg = msg - if path_to_item: - full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) - super(ApiKeyError, self).__init__(full_msg) - - -class ApiException(OpenApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - if http_resp: - self.status = http_resp.status - self.reason = http_resp.reason - self.body = http_resp.data - self.headers = http_resp.getheaders() - else: - self.status = status - self.reason = reason - self.body = None - self.headers = None - - def __str__(self): - """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) - if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) - - if self.body: - error_message += "HTTP response body: {0}\n".format(self.body) - - return error_message - -class BadRequestException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(BadRequestException, self).__init__(status, reason, http_resp) - -class NotFoundException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(NotFoundException, self).__init__(status, reason, http_resp) - - -class UnauthorizedException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(UnauthorizedException, self).__init__(status, reason, http_resp) - - -class ForbiddenException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ForbiddenException, self).__init__(status, reason, http_resp) - - -class ServiceException(ApiException): - - def __init__(self, status=None, reason=None, http_resp=None) -> None: - super(ServiceException, self).__init__(status, reason, http_resp) - - -def render_path(path_to_item): - """Returns a string representation of a path""" - result = "" - for pth in path_to_item: - if isinstance(pth, int): - result += "[{0}]".format(pth) - else: - result += "['{0}']".format(pth) - return result diff --git a/jobmanager/client/jobmanager_client/models/__init__.py b/jobmanager/client/jobmanager_client/models/__init__.py deleted file mode 100644 index 7f405b0cbb..0000000000 --- a/jobmanager/client/jobmanager_client/models/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# coding: utf-8 - -# flake8: noqa -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -# import models into model package -from jobmanager_client.models.http_validation_error import HTTPValidationError -from jobmanager_client.models.job_create import JobCreate -from jobmanager_client.models.job_read import JobRead -from jobmanager_client.models.job_update import JobUpdate -from jobmanager_client.models.runner_create import RunnerCreate -from jobmanager_client.models.runner_health_response import RunnerHealthResponse -from jobmanager_client.models.runner_health_update_response import RunnerHealthUpdateResponse -from jobmanager_client.models.runner_register_response import RunnerRegisterResponse -from jobmanager_client.models.validation_error import ValidationError -from jobmanager_client.models.validation_error_loc_inner import ValidationErrorLocInner -from jobmanager_client.models.vm_dependencies import VmDependencies diff --git a/jobmanager/client/jobmanager_client/models/http_validation_error.py b/jobmanager/client/jobmanager_client/models/http_validation_error.py deleted file mode 100644 index 8ff3220260..0000000000 --- a/jobmanager/client/jobmanager_client/models/http_validation_error.py +++ /dev/null @@ -1,79 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - -from typing import List, Optional -from pydantic import BaseModel, conlist -from jobmanager_client.models.validation_error import ValidationError - -class HTTPValidationError(BaseModel): - """ - HTTPValidationError - """ - detail: Optional[conlist(ValidationError)] = None - __properties = ["detail"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> HTTPValidationError: - """Create an instance of HTTPValidationError from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of each item in detail (list) - _items = [] - if self.detail: - for _item in self.detail: - if _item: - _items.append(_item.to_dict()) - _dict['detail'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> HTTPValidationError: - """Create an instance of HTTPValidationError from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return HTTPValidationError.parse_obj(obj) - - _obj = HTTPValidationError.parse_obj({ - "detail": [ValidationError.from_dict(_item) for _item in obj.get("detail")] if obj.get("detail") is not None else None - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/job_create.py b/jobmanager/client/jobmanager_client/models/job_create.py deleted file mode 100644 index ba7039df5b..0000000000 --- a/jobmanager/client/jobmanager_client/models/job_create.py +++ /dev/null @@ -1,170 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - -from typing import Any, Dict, List, Optional -from pydantic import BaseModel, Field, StrictStr, conlist -from jobmanager_client.models.vm_dependencies import VmDependencies - -class JobCreate(BaseModel): - """ - Job creation model. # noqa: E501 - """ - requested_by: StrictStr = Field(...) - repository_url: Optional[StrictStr] = None - repository_ref: Optional[StrictStr] = None - architecture: StrictStr = Field(...) - base_series: StrictStr = Field(...) - vm_dependencies: Optional[VmDependencies] = None - commands: Optional[conlist(Any)] = None - secrets: Optional[Dict[str, Any]] = None - environment: Optional[Dict[str, Any]] = None - artifacts_dir: Optional[StrictStr] = None - topology: Optional[StrictStr] = None - vm_ip: Optional[StrictStr] = None - vm_size: Optional[StrictStr] = None - status: Optional[StrictStr] = None - artifact_urls: Optional[conlist(Any)] = None - log_urls: Optional[conlist(Any)] = None - __properties = ["requested_by", "repository_url", "repository_ref", "architecture", "base_series", "vm_dependencies", "commands", "secrets", "environment", "artifacts_dir", "topology", "vm_ip", "vm_size", "status", "artifact_urls", "log_urls"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> JobCreate: - """Create an instance of JobCreate from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of vm_dependencies - if self.vm_dependencies: - _dict['vm_dependencies'] = self.vm_dependencies.to_dict() - # set to None if repository_url (nullable) is None - # and __fields_set__ contains the field - if self.repository_url is None and "repository_url" in self.__fields_set__: - _dict['repository_url'] = None - - # set to None if repository_ref (nullable) is None - # and __fields_set__ contains the field - if self.repository_ref is None and "repository_ref" in self.__fields_set__: - _dict['repository_ref'] = None - - # set to None if vm_dependencies (nullable) is None - # and __fields_set__ contains the field - if self.vm_dependencies is None and "vm_dependencies" in self.__fields_set__: - _dict['vm_dependencies'] = None - - # set to None if commands (nullable) is None - # and __fields_set__ contains the field - if self.commands is None and "commands" in self.__fields_set__: - _dict['commands'] = None - - # set to None if secrets (nullable) is None - # and __fields_set__ contains the field - if self.secrets is None and "secrets" in self.__fields_set__: - _dict['secrets'] = None - - # set to None if environment (nullable) is None - # and __fields_set__ contains the field - if self.environment is None and "environment" in self.__fields_set__: - _dict['environment'] = None - - # set to None if artifacts_dir (nullable) is None - # and __fields_set__ contains the field - if self.artifacts_dir is None and "artifacts_dir" in self.__fields_set__: - _dict['artifacts_dir'] = None - - # set to None if topology (nullable) is None - # and __fields_set__ contains the field - if self.topology is None and "topology" in self.__fields_set__: - _dict['topology'] = None - - # set to None if vm_ip (nullable) is None - # and __fields_set__ contains the field - if self.vm_ip is None and "vm_ip" in self.__fields_set__: - _dict['vm_ip'] = None - - # set to None if vm_size (nullable) is None - # and __fields_set__ contains the field - if self.vm_size is None and "vm_size" in self.__fields_set__: - _dict['vm_size'] = None - - # set to None if status (nullable) is None - # and __fields_set__ contains the field - if self.status is None and "status" in self.__fields_set__: - _dict['status'] = None - - # set to None if artifact_urls (nullable) is None - # and __fields_set__ contains the field - if self.artifact_urls is None and "artifact_urls" in self.__fields_set__: - _dict['artifact_urls'] = None - - # set to None if log_urls (nullable) is None - # and __fields_set__ contains the field - if self.log_urls is None and "log_urls" in self.__fields_set__: - _dict['log_urls'] = None - - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> JobCreate: - """Create an instance of JobCreate from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return JobCreate.parse_obj(obj) - - _obj = JobCreate.parse_obj({ - "requested_by": obj.get("requested_by"), - "repository_url": obj.get("repository_url"), - "repository_ref": obj.get("repository_ref"), - "architecture": obj.get("architecture"), - "base_series": obj.get("base_series"), - "vm_dependencies": VmDependencies.from_dict(obj.get("vm_dependencies")) if obj.get("vm_dependencies") is not None else None, - "commands": obj.get("commands"), - "secrets": obj.get("secrets"), - "environment": obj.get("environment"), - "artifacts_dir": obj.get("artifacts_dir"), - "topology": obj.get("topology"), - "vm_ip": obj.get("vm_ip"), - "vm_size": obj.get("vm_size"), - "status": obj.get("status"), - "artifact_urls": obj.get("artifact_urls"), - "log_urls": obj.get("log_urls") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/job_read.py b/jobmanager/client/jobmanager_client/models/job_read.py deleted file mode 100644 index 9929aa87df..0000000000 --- a/jobmanager/client/jobmanager_client/models/job_read.py +++ /dev/null @@ -1,200 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from datetime import datetime -from typing import Any, Dict, List, Optional -from pydantic import BaseModel, Field, StrictInt, StrictStr, conlist -from jobmanager_client.models.vm_dependencies import VmDependencies - -class JobRead(BaseModel): - """ - Job read model with all fields. # noqa: E501 - """ - requested_by: StrictStr = Field(...) - repository_url: Optional[StrictStr] = None - repository_ref: Optional[StrictStr] = None - architecture: StrictStr = Field(...) - base_series: StrictStr = Field(...) - vm_dependencies: Optional[VmDependencies] = None - commands: Optional[conlist(Any)] = None - secrets: Optional[Dict[str, Any]] = None - environment: Optional[Dict[str, Any]] = None - artifacts_dir: Optional[StrictStr] = None - topology: Optional[StrictStr] = None - vm_ip: Optional[StrictStr] = None - vm_size: Optional[StrictStr] = None - status: Optional[StrictStr] = None - artifact_urls: Optional[conlist(Any)] = None - log_urls: Optional[conlist(Any)] = None - id: StrictInt = Field(...) - created_at: Optional[datetime] = None - updated_at: Optional[datetime] = None - started_at: Optional[datetime] = None - completed_at: Optional[datetime] = None - __properties = ["requested_by", "repository_url", "repository_ref", "architecture", "base_series", "vm_dependencies", "commands", "secrets", "environment", "artifacts_dir", "topology", "vm_ip", "vm_size", "status", "artifact_urls", "log_urls", "id", "created_at", "updated_at", "started_at", "completed_at"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> JobRead: - """Create an instance of JobRead from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of vm_dependencies - if self.vm_dependencies: - _dict['vm_dependencies'] = self.vm_dependencies.to_dict() - # set to None if repository_url (nullable) is None - # and __fields_set__ contains the field - if self.repository_url is None and "repository_url" in self.__fields_set__: - _dict['repository_url'] = None - - # set to None if repository_ref (nullable) is None - # and __fields_set__ contains the field - if self.repository_ref is None and "repository_ref" in self.__fields_set__: - _dict['repository_ref'] = None - - # set to None if vm_dependencies (nullable) is None - # and __fields_set__ contains the field - if self.vm_dependencies is None and "vm_dependencies" in self.__fields_set__: - _dict['vm_dependencies'] = None - - # set to None if commands (nullable) is None - # and __fields_set__ contains the field - if self.commands is None and "commands" in self.__fields_set__: - _dict['commands'] = None - - # set to None if secrets (nullable) is None - # and __fields_set__ contains the field - if self.secrets is None and "secrets" in self.__fields_set__: - _dict['secrets'] = None - - # set to None if environment (nullable) is None - # and __fields_set__ contains the field - if self.environment is None and "environment" in self.__fields_set__: - _dict['environment'] = None - - # set to None if artifacts_dir (nullable) is None - # and __fields_set__ contains the field - if self.artifacts_dir is None and "artifacts_dir" in self.__fields_set__: - _dict['artifacts_dir'] = None - - # set to None if topology (nullable) is None - # and __fields_set__ contains the field - if self.topology is None and "topology" in self.__fields_set__: - _dict['topology'] = None - - # set to None if vm_ip (nullable) is None - # and __fields_set__ contains the field - if self.vm_ip is None and "vm_ip" in self.__fields_set__: - _dict['vm_ip'] = None - - # set to None if vm_size (nullable) is None - # and __fields_set__ contains the field - if self.vm_size is None and "vm_size" in self.__fields_set__: - _dict['vm_size'] = None - - # set to None if status (nullable) is None - # and __fields_set__ contains the field - if self.status is None and "status" in self.__fields_set__: - _dict['status'] = None - - # set to None if artifact_urls (nullable) is None - # and __fields_set__ contains the field - if self.artifact_urls is None and "artifact_urls" in self.__fields_set__: - _dict['artifact_urls'] = None - - # set to None if log_urls (nullable) is None - # and __fields_set__ contains the field - if self.log_urls is None and "log_urls" in self.__fields_set__: - _dict['log_urls'] = None - - # set to None if created_at (nullable) is None - # and __fields_set__ contains the field - if self.created_at is None and "created_at" in self.__fields_set__: - _dict['created_at'] = None - - # set to None if updated_at (nullable) is None - # and __fields_set__ contains the field - if self.updated_at is None and "updated_at" in self.__fields_set__: - _dict['updated_at'] = None - - # set to None if started_at (nullable) is None - # and __fields_set__ contains the field - if self.started_at is None and "started_at" in self.__fields_set__: - _dict['started_at'] = None - - # set to None if completed_at (nullable) is None - # and __fields_set__ contains the field - if self.completed_at is None and "completed_at" in self.__fields_set__: - _dict['completed_at'] = None - - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> JobRead: - """Create an instance of JobRead from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return JobRead.parse_obj(obj) - - _obj = JobRead.parse_obj({ - "requested_by": obj.get("requested_by"), - "repository_url": obj.get("repository_url"), - "repository_ref": obj.get("repository_ref"), - "architecture": obj.get("architecture"), - "base_series": obj.get("base_series"), - "vm_dependencies": VmDependencies.from_dict(obj.get("vm_dependencies")) if obj.get("vm_dependencies") is not None else None, - "commands": obj.get("commands"), - "secrets": obj.get("secrets"), - "environment": obj.get("environment"), - "artifacts_dir": obj.get("artifacts_dir"), - "topology": obj.get("topology"), - "vm_ip": obj.get("vm_ip"), - "vm_size": obj.get("vm_size"), - "status": obj.get("status"), - "artifact_urls": obj.get("artifact_urls"), - "log_urls": obj.get("log_urls"), - "id": obj.get("id"), - "created_at": obj.get("created_at"), - "updated_at": obj.get("updated_at"), - "started_at": obj.get("started_at"), - "completed_at": obj.get("completed_at") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/job_update.py b/jobmanager/client/jobmanager_client/models/job_update.py deleted file mode 100644 index ddeaee057e..0000000000 --- a/jobmanager/client/jobmanager_client/models/job_update.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from datetime import datetime -from typing import Any, List, Optional -from pydantic import BaseModel, StrictStr, conlist - -class JobUpdate(BaseModel): - """ - Job update model. # noqa: E501 - """ - status: Optional[StrictStr] = None - vm_ip: Optional[StrictStr] = None - artifact_urls: Optional[conlist(Any)] = None - log_urls: Optional[conlist(Any)] = None - started_at: Optional[datetime] = None - completed_at: Optional[datetime] = None - __properties = ["status", "vm_ip", "artifact_urls", "log_urls", "started_at", "completed_at"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> JobUpdate: - """Create an instance of JobUpdate from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # set to None if status (nullable) is None - # and __fields_set__ contains the field - if self.status is None and "status" in self.__fields_set__: - _dict['status'] = None - - # set to None if vm_ip (nullable) is None - # and __fields_set__ contains the field - if self.vm_ip is None and "vm_ip" in self.__fields_set__: - _dict['vm_ip'] = None - - # set to None if artifact_urls (nullable) is None - # and __fields_set__ contains the field - if self.artifact_urls is None and "artifact_urls" in self.__fields_set__: - _dict['artifact_urls'] = None - - # set to None if log_urls (nullable) is None - # and __fields_set__ contains the field - if self.log_urls is None and "log_urls" in self.__fields_set__: - _dict['log_urls'] = None - - # set to None if started_at (nullable) is None - # and __fields_set__ contains the field - if self.started_at is None and "started_at" in self.__fields_set__: - _dict['started_at'] = None - - # set to None if completed_at (nullable) is None - # and __fields_set__ contains the field - if self.completed_at is None and "completed_at" in self.__fields_set__: - _dict['completed_at'] = None - - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> JobUpdate: - """Create an instance of JobUpdate from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return JobUpdate.parse_obj(obj) - - _obj = JobUpdate.parse_obj({ - "status": obj.get("status"), - "vm_ip": obj.get("vm_ip"), - "artifact_urls": obj.get("artifact_urls"), - "log_urls": obj.get("log_urls"), - "started_at": obj.get("started_at"), - "completed_at": obj.get("completed_at") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/runner_create.py b/jobmanager/client/jobmanager_client/models/runner_create.py deleted file mode 100644 index a5bb971f0a..0000000000 --- a/jobmanager/client/jobmanager_client/models/runner_create.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - -from typing import List -from pydantic import BaseModel, Field, StrictStr, conlist - -class RunnerCreate(BaseModel): - """ - Runner creation model. # noqa: E501 - """ - name: StrictStr = Field(...) - labels: conlist(StrictStr) = Field(...) - __properties = ["name", "labels"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> RunnerCreate: - """Create an instance of RunnerCreate from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> RunnerCreate: - """Create an instance of RunnerCreate from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return RunnerCreate.parse_obj(obj) - - _obj = RunnerCreate.parse_obj({ - "name": obj.get("name"), - "labels": obj.get("labels") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/runner_health_response.py b/jobmanager/client/jobmanager_client/models/runner_health_response.py deleted file mode 100644 index ffeeab8eb7..0000000000 --- a/jobmanager/client/jobmanager_client/models/runner_health_response.py +++ /dev/null @@ -1,81 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - -from pydantic import BaseModel, Field, StrictBool, StrictStr - -class RunnerHealthResponse(BaseModel): - """ - RunnerHealthResponse - """ - label: StrictStr = Field(...) - cpu_usage: StrictStr = Field(...) - ram_usage: StrictStr = Field(...) - disk_usage: StrictStr = Field(...) - status: StrictStr = Field(...) - deletable: StrictBool = Field(...) - __properties = ["label", "cpu_usage", "ram_usage", "disk_usage", "status", "deletable"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> RunnerHealthResponse: - """Create an instance of RunnerHealthResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> RunnerHealthResponse: - """Create an instance of RunnerHealthResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return RunnerHealthResponse.parse_obj(obj) - - _obj = RunnerHealthResponse.parse_obj({ - "label": obj.get("label"), - "cpu_usage": obj.get("cpu_usage"), - "ram_usage": obj.get("ram_usage"), - "disk_usage": obj.get("disk_usage"), - "status": obj.get("status"), - "deletable": obj.get("deletable") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/runner_health_update_response.py b/jobmanager/client/jobmanager_client/models/runner_health_update_response.py deleted file mode 100644 index 3eaaaeaf8b..0000000000 --- a/jobmanager/client/jobmanager_client/models/runner_health_update_response.py +++ /dev/null @@ -1,71 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - -from pydantic import BaseModel, Field, StrictStr - -class RunnerHealthUpdateResponse(BaseModel): - """ - RunnerHealthUpdateResponse - """ - message: StrictStr = Field(...) - __properties = ["message"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> RunnerHealthUpdateResponse: - """Create an instance of RunnerHealthUpdateResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> RunnerHealthUpdateResponse: - """Create an instance of RunnerHealthUpdateResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return RunnerHealthUpdateResponse.parse_obj(obj) - - _obj = RunnerHealthUpdateResponse.parse_obj({ - "message": obj.get("message") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/runner_register_response.py b/jobmanager/client/jobmanager_client/models/runner_register_response.py deleted file mode 100644 index 7ad0e61b80..0000000000 --- a/jobmanager/client/jobmanager_client/models/runner_register_response.py +++ /dev/null @@ -1,73 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - - -from pydantic import BaseModel, Field, StrictInt, StrictStr - -class RunnerRegisterResponse(BaseModel): - """ - RunnerRegisterResponse - """ - id: StrictInt = Field(...) - token: StrictStr = Field(...) - __properties = ["id", "token"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> RunnerRegisterResponse: - """Create an instance of RunnerRegisterResponse from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> RunnerRegisterResponse: - """Create an instance of RunnerRegisterResponse from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return RunnerRegisterResponse.parse_obj(obj) - - _obj = RunnerRegisterResponse.parse_obj({ - "id": obj.get("id"), - "token": obj.get("token") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/validation_error.py b/jobmanager/client/jobmanager_client/models/validation_error.py deleted file mode 100644 index 36cb8034d1..0000000000 --- a/jobmanager/client/jobmanager_client/models/validation_error.py +++ /dev/null @@ -1,83 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - - -from typing import List -from pydantic import BaseModel, Field, StrictStr, conlist -from jobmanager_client.models.validation_error_loc_inner import ValidationErrorLocInner - -class ValidationError(BaseModel): - """ - ValidationError - """ - loc: conlist(ValidationErrorLocInner) = Field(...) - msg: StrictStr = Field(...) - type: StrictStr = Field(...) - __properties = ["loc", "msg", "type"] - - class Config: - """Pydantic configuration""" - allow_population_by_field_name = True - validate_assignment = True - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.dict(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> ValidationError: - """Create an instance of ValidationError from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self): - """Returns the dictionary representation of the model using alias""" - _dict = self.dict(by_alias=True, - exclude={ - }, - exclude_none=True) - # override the default output from pydantic by calling `to_dict()` of each item in loc (list) - _items = [] - if self.loc: - for _item in self.loc: - if _item: - _items.append(_item.to_dict()) - _dict['loc'] = _items - return _dict - - @classmethod - def from_dict(cls, obj: dict) -> ValidationError: - """Create an instance of ValidationError from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return ValidationError.parse_obj(obj) - - _obj = ValidationError.parse_obj({ - "loc": [ValidationErrorLocInner.from_dict(_item) for _item in obj.get("loc")] if obj.get("loc") is not None else None, - "msg": obj.get("msg"), - "type": obj.get("type") - }) - return _obj - - diff --git a/jobmanager/client/jobmanager_client/models/validation_error_loc_inner.py b/jobmanager/client/jobmanager_client/models/validation_error_loc_inner.py deleted file mode 100644 index 0b55392b61..0000000000 --- a/jobmanager/client/jobmanager_client/models/validation_error_loc_inner.py +++ /dev/null @@ -1,139 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -from inspect import getfullargspec -import json -import pprint -import re # noqa: F401 - -from typing import Optional -from pydantic import BaseModel, Field, StrictInt, StrictStr, ValidationError, validator -from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field - -VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS = ["int", "str"] - -class ValidationErrorLocInner(BaseModel): - """ - ValidationErrorLocInner - """ - - # data type: str - anyof_schema_1_validator: Optional[StrictStr] = None - # data type: int - anyof_schema_2_validator: Optional[StrictInt] = None - if TYPE_CHECKING: - actual_instance: Union[int, str] - else: - actual_instance: Any - any_of_schemas: List[str] = Field(VALIDATIONERRORLOCINNER_ANY_OF_SCHEMAS, const=True) - - class Config: - validate_assignment = True - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - instance = ValidationErrorLocInner.construct() - error_messages = [] - # validate data type: str - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: int - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return v - - @classmethod - def from_dict(cls, obj: dict) -> ValidationErrorLocInner: - return cls.from_json(json.dumps(obj)) - - @classmethod - def from_json(cls, json_str: str) -> ValidationErrorLocInner: - """Returns the object represented by the json string""" - instance = ValidationErrorLocInner.construct() - error_messages = [] - # deserialize data into str - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into int - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into ValidationErrorLocInner with anyOf schemas: int, str. Details: " + ", ".join(error_messages)) - else: - return instance - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> dict: - """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) - - diff --git a/jobmanager/client/jobmanager_client/models/vm_dependencies.py b/jobmanager/client/jobmanager_client/models/vm_dependencies.py deleted file mode 100644 index 5c9f8438c3..0000000000 --- a/jobmanager/client/jobmanager_client/models/vm_dependencies.py +++ /dev/null @@ -1,145 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -from inspect import getfullargspec -import json -import pprint -import re # noqa: F401 - -from typing import Any, Dict, List, Optional -from pydantic import BaseModel, Field, StrictStr, ValidationError, conlist, validator -from typing import Union, Any, List, TYPE_CHECKING -from pydantic import StrictStr, Field - -VMDEPENDENCIES_ANY_OF_SCHEMAS = ["Dict[str, object]", "List[object]"] - -class VmDependencies(BaseModel): - """ - VmDependencies - """ - - # data type: Dict[str, object] - anyof_schema_1_validator: Optional[Dict[str, Any]] = None - # data type: List[object] - anyof_schema_2_validator: Optional[conlist(Any)] = None - if TYPE_CHECKING: - actual_instance: Union[Dict[str, object], List[object]] - else: - actual_instance: Any - any_of_schemas: List[str] = Field(VMDEPENDENCIES_ANY_OF_SCHEMAS, const=True) - - class Config: - validate_assignment = True - - def __init__(self, *args, **kwargs) -> None: - if args: - if len(args) > 1: - raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`") - if kwargs: - raise ValueError("If a position argument is used, keyword arguments cannot be used.") - super().__init__(actual_instance=args[0]) - else: - super().__init__(**kwargs) - - @validator('actual_instance') - def actual_instance_must_validate_anyof(cls, v): - if v is None: - return v - - instance = VmDependencies.construct() - error_messages = [] - # validate data type: Dict[str, object] - try: - instance.anyof_schema_1_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # validate data type: List[object] - try: - instance.anyof_schema_2_validator = v - return v - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - if error_messages: - # no match - raise ValueError("No match found when setting the actual_instance in VmDependencies with anyOf schemas: Dict[str, object], List[object]. Details: " + ", ".join(error_messages)) - else: - return v - - @classmethod - def from_dict(cls, obj: dict) -> VmDependencies: - return cls.from_json(json.dumps(obj)) - - @classmethod - def from_json(cls, json_str: str) -> VmDependencies: - """Returns the object represented by the json string""" - instance = VmDependencies.construct() - if json_str is None: - return instance - - error_messages = [] - # deserialize data into Dict[str, object] - try: - # validation - instance.anyof_schema_1_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_1_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into List[object] - try: - # validation - instance.anyof_schema_2_validator = json.loads(json_str) - # assign value to actual_instance - instance.actual_instance = instance.anyof_schema_2_validator - return instance - except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - - if error_messages: - # no match - raise ValueError("No match found when deserializing the JSON string into VmDependencies with anyOf schemas: Dict[str, object], List[object]. Details: " + ", ".join(error_messages)) - else: - return instance - - def to_json(self) -> str: - """Returns the JSON representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_json() - else: - return json.dumps(self.actual_instance) - - def to_dict(self) -> dict: - """Returns the dict representation of the actual instance""" - if self.actual_instance is None: - return "null" - - to_json = getattr(self.actual_instance, "to_json", None) - if callable(to_json): - return self.actual_instance.to_dict() - else: - # primitive type - return self.actual_instance - - def to_str(self) -> str: - """Returns the string representation of the actual instance""" - return pprint.pformat(self.dict()) - - diff --git a/jobmanager/client/jobmanager_client/py.typed b/jobmanager/client/jobmanager_client/py.typed deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/jobmanager/client/jobmanager_client/rest.py b/jobmanager/client/jobmanager_client/rest.py deleted file mode 100644 index aed7daebd7..0000000000 --- a/jobmanager/client/jobmanager_client/rest.py +++ /dev/null @@ -1,329 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import io -import json -import logging -import re -import ssl - -from urllib.parse import urlencode, quote_plus -import urllib3 - -from jobmanager_client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException - - -logger = logging.getLogger(__name__) - -SUPPORTED_SOCKS_PROXIES = {"socks5", "socks5h", "socks4", "socks4a"} - - -def is_socks_proxy_url(url): - if url is None: - return False - split_section = url.split("://") - if len(split_section) < 2: - return False - else: - return split_section[0].lower() in SUPPORTED_SOCKS_PROXIES - - -class RESTResponse(io.IOBase): - - def __init__(self, resp) -> None: - self.urllib3_response = resp - self.status = resp.status - self.reason = resp.reason - self.data = resp.data - - def getheaders(self): - """Returns a dictionary of the response headers.""" - return self.urllib3_response.headers - - def getheader(self, name, default=None): - """Returns a given response header.""" - return self.urllib3_response.headers.get(name, default) - - -class RESTClientObject: - - def __init__(self, configuration, pools_size=4, maxsize=None) -> None: - # urllib3.PoolManager will pass all kw parameters to connectionpool - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 - # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/connectionpool.py#L680 # noqa: E501 - # maxsize is the number of requests to host that are allowed in parallel # noqa: E501 - # Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501 - - # cert_reqs - if configuration.verify_ssl: - cert_reqs = ssl.CERT_REQUIRED - else: - cert_reqs = ssl.CERT_NONE - - addition_pool_args = {} - if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 - - if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries - - if configuration.tls_server_name: - addition_pool_args['server_hostname'] = configuration.tls_server_name - - - if configuration.socket_options is not None: - addition_pool_args['socket_options'] = configuration.socket_options - - if maxsize is None: - if configuration.connection_pool_maxsize is not None: - maxsize = configuration.connection_pool_maxsize - else: - maxsize = 4 - - # https pool manager - if configuration.proxy: - if is_socks_proxy_url(configuration.proxy): - from urllib3.contrib.socks import SOCKSProxyManager - self.pool_manager = SOCKSProxyManager( - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - headers=configuration.proxy_headers, - **addition_pool_args - ) - else: - self.pool_manager = urllib3.ProxyManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - proxy_url=configuration.proxy, - proxy_headers=configuration.proxy_headers, - **addition_pool_args - ) - else: - self.pool_manager = urllib3.PoolManager( - num_pools=pools_size, - maxsize=maxsize, - cert_reqs=cert_reqs, - ca_certs=configuration.ssl_ca_cert, - cert_file=configuration.cert_file, - key_file=configuration.key_file, - **addition_pool_args - ) - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): - """Perform requests. - - :param method: http request method - :param url: http request url - :param query_params: query parameters in the url - :param headers: http request headers - :param body: request json body, for `application/json` - :param post_params: request post parameters, - `application/x-www-form-urlencoded` - and `multipart/form-data` - :param _preload_content: if False, the urllib3.HTTPResponse object will - be returned without reading/decoding response - data. Default is True. - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - """ - method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] - - if post_params and body: - raise ApiValueError( - "body parameter cannot be used with post_params parameter." - ) - - post_params = post_params or {} - headers = headers or {} - # url already contains the URL query string - # so reset query_params to empty dict - query_params = {} - - timeout = None - if _request_timeout: - if isinstance(_request_timeout, (int,float)): # noqa: E501,F821 - timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): - timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) - - try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - - # no content type provided or payload is json - if not headers.get('Content-Type') or re.search('json', headers['Content-Type'], re.IGNORECASE): - request_body = None - if body is not None: - request_body = json.dumps(body) - r = self.pool_manager.request( - method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 - r = self.pool_manager.request( - method, url, - fields=post_params, - encode_multipart=False, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': - # must del headers['Content-Type'], or the correct - # Content-Type which generated by urllib3 will be - # overwritten. - del headers['Content-Type'] - # Ensures that dict objects are serialized - post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a,b) for a, b in post_params] - r = self.pool_manager.request( - method, url, - fields=post_params, - encode_multipart=True, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - # Pass a `string` parameter directly in the body to support - # other content types than Json when `body` argument is - # provided in serialized form - elif isinstance(body, str) or isinstance(body, bytes): - request_body = body - r = self.pool_manager.request( - method, url, - body=request_body, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - else: - # Cannot generate the request from given parameters - msg = """Cannot prepare a request message for provided - arguments. Please check that your arguments match - declared content type.""" - raise ApiException(status=0, reason=msg) - # For `GET`, `HEAD` - else: - r = self.pool_manager.request(method, url, - fields={}, - preload_content=_preload_content, - timeout=timeout, - headers=headers) - except urllib3.exceptions.SSLError as e: - msg = "{0}\n{1}".format(type(e).__name__, str(e)) - raise ApiException(status=0, reason=msg) - - if _preload_content: - r = RESTResponse(r) - - # log response body - logger.debug("response body: %s", r.data) - - if not 200 <= r.status <= 299: - if r.status == 400: - raise BadRequestException(http_resp=r) - - if r.status == 401: - raise UnauthorizedException(http_resp=r) - - if r.status == 403: - raise ForbiddenException(http_resp=r) - - if r.status == 404: - raise NotFoundException(http_resp=r) - - if 500 <= r.status <= 599: - raise ServiceException(http_resp=r) - - raise ApiException(http_resp=r) - - return r - - def get_request(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def head_request(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def options_request(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def delete_request(self, url, headers=None, query_params=None, body=None, - _preload_content=True, _request_timeout=None): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def post_request(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("POST", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def put_request(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def patch_request(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) diff --git a/jobmanager/client/pyproject.toml b/jobmanager/client/pyproject.toml deleted file mode 100644 index b869637df6..0000000000 --- a/jobmanager/client/pyproject.toml +++ /dev/null @@ -1,30 +0,0 @@ -[tool.poetry] -name = "jobmanager_client" -version = "1.0.0" -description = "Job Manager API" -authors = ["OpenAPI Generator Community "] -license = "NoLicense" -readme = "README.md" -repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID" -keywords = ["OpenAPI", "OpenAPI-Generator", "Job Manager API"] -include = ["jobmanager_client/py.typed"] - -[tool.poetry.dependencies] -python = "^3.8" - -urllib3 = ">= 1.25.3" -python-dateutil = ">=2.8.2" -pydantic = "^1.10.5, <2" -aenum = ">=3.1.11" - -[tool.poetry.dev-dependencies] -pytest = ">=7.2.1" -tox = ">=3.9.0" -flake8 = ">=4.0.0" - -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" - -[tool.pylint.'MESSAGES CONTROL'] -extension-pkg-whitelist = "pydantic" diff --git a/jobmanager/client/requirements.txt b/jobmanager/client/requirements.txt deleted file mode 100644 index 0a8bf96cad..0000000000 --- a/jobmanager/client/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -python_dateutil >= 2.5.3 -setuptools >= 21.0.0 -urllib3 >= 1.25.3, < 3.0.0 -pydantic >= 1.10.5, < 2 -aenum >= 3.1.11 diff --git a/jobmanager/client/setup.cfg b/jobmanager/client/setup.cfg deleted file mode 100644 index 11433ee875..0000000000 --- a/jobmanager/client/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length=99 diff --git a/jobmanager/client/setup.py b/jobmanager/client/setup.py deleted file mode 100644 index caa220b911..0000000000 --- a/jobmanager/client/setup.py +++ /dev/null @@ -1,49 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from setuptools import setup, find_packages # noqa: H301 - -# To install the library, run the following -# -# python setup.py install -# -# prerequisite: setuptools -# http://pypi.python.org/pypi/setuptools -NAME = "jobmanager-client" -VERSION = "1.0.0" -PYTHON_REQUIRES = ">=3.7" -REQUIRES = [ - "urllib3 >= 1.25.3, < 3.0.0", - "python-dateutil", - "pydantic >= 1.10.5, < 2", - "aenum" -] - -setup( - name=NAME, - version=VERSION, - description="Job Manager API", - author="OpenAPI Generator community", - author_email="team@openapitools.org", - url="", - keywords=["OpenAPI", "OpenAPI-Generator", "Job Manager API"], - install_requires=REQUIRES, - packages=find_packages(exclude=["test", "tests"]), - include_package_data=True, - long_description_content_type='text/markdown', - long_description="""\ - A modern job management system - """, # noqa: E501 - package_data={"jobmanager_client": ["py.typed"]}, -) diff --git a/jobmanager/client/test-requirements.txt b/jobmanager/client/test-requirements.txt deleted file mode 100644 index 3a0d0b939a..0000000000 --- a/jobmanager/client/test-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest~=7.1.3 -pytest-cov>=2.8.1 -pytest-randomly>=3.12.0 diff --git a/jobmanager/client/test/__init__.py b/jobmanager/client/test/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/jobmanager/client/test/test_default_api.py b/jobmanager/client/test/test_default_api.py deleted file mode 100644 index c0f2746b5b..0000000000 --- a/jobmanager/client/test/test_default_api.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from jobmanager_client.api.default_api import DefaultApi # noqa: E501 - - -class TestDefaultApi(unittest.TestCase): - """DefaultApi unit test stubs""" - - def setUp(self) -> None: - self.api = DefaultApi() - - def tearDown(self) -> None: - self.api.api_client.close() - - def test_health_check_health_get(self) -> None: - """Test case for health_check_health_get - - Health Check # noqa: E501 - """ - pass - - def test_root_get(self) -> None: - """Test case for root_get - - Root # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_http_validation_error.py b/jobmanager/client/test/test_http_validation_error.py deleted file mode 100644 index 11401807ec..0000000000 --- a/jobmanager/client/test/test_http_validation_error.py +++ /dev/null @@ -1,59 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.http_validation_error import HTTPValidationError # noqa: E501 - -class TestHTTPValidationError(unittest.TestCase): - """HTTPValidationError unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> HTTPValidationError: - """Test HTTPValidationError - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `HTTPValidationError` - """ - model = HTTPValidationError() # noqa: E501 - if include_optional: - return HTTPValidationError( - detail = [ - jobmanager_client.models.validation_error.ValidationError( - loc = [ - null - ], - msg = '', - type = '', ) - ] - ) - else: - return HTTPValidationError( - ) - """ - - def testHTTPValidationError(self): - """Test HTTPValidationError""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_job_create.py b/jobmanager/client/test/test_job_create.py deleted file mode 100644 index 70ef1a9eed..0000000000 --- a/jobmanager/client/test/test_job_create.py +++ /dev/null @@ -1,76 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.job_create import JobCreate # noqa: E501 - -class TestJobCreate(unittest.TestCase): - """JobCreate unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> JobCreate: - """Test JobCreate - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `JobCreate` - """ - model = JobCreate() # noqa: E501 - if include_optional: - return JobCreate( - requested_by = '', - repository_url = '', - repository_ref = '', - architecture = '', - base_series = '', - vm_dependencies = None, - commands = [ - null - ], - secrets = { }, - environment = { }, - artifacts_dir = '', - topology = '', - vm_ip = '', - vm_size = '', - status = '', - artifact_urls = [ - null - ], - log_urls = [ - null - ] - ) - else: - return JobCreate( - requested_by = '', - architecture = '', - base_series = '', - ) - """ - - def testJobCreate(self): - """Test JobCreate""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_job_read.py b/jobmanager/client/test/test_job_read.py deleted file mode 100644 index 5933b5c2fc..0000000000 --- a/jobmanager/client/test/test_job_read.py +++ /dev/null @@ -1,82 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.job_read import JobRead # noqa: E501 - -class TestJobRead(unittest.TestCase): - """JobRead unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> JobRead: - """Test JobRead - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `JobRead` - """ - model = JobRead() # noqa: E501 - if include_optional: - return JobRead( - requested_by = '', - repository_url = '', - repository_ref = '', - architecture = '', - base_series = '', - vm_dependencies = None, - commands = [ - null - ], - secrets = { }, - environment = { }, - artifacts_dir = '', - topology = '', - vm_ip = '', - vm_size = '', - status = '', - artifact_urls = [ - null - ], - log_urls = [ - null - ], - id = 56, - created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - started_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - completed_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f') - ) - else: - return JobRead( - requested_by = '', - architecture = '', - base_series = '', - id = 56, - ) - """ - - def testJobRead(self): - """Test JobRead""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_job_update.py b/jobmanager/client/test/test_job_update.py deleted file mode 100644 index a0864427c5..0000000000 --- a/jobmanager/client/test/test_job_update.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.job_update import JobUpdate # noqa: E501 - -class TestJobUpdate(unittest.TestCase): - """JobUpdate unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> JobUpdate: - """Test JobUpdate - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `JobUpdate` - """ - model = JobUpdate() # noqa: E501 - if include_optional: - return JobUpdate( - status = '', - vm_ip = '', - artifact_urls = [ - null - ], - log_urls = [ - null - ], - started_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), - completed_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f') - ) - else: - return JobUpdate( - ) - """ - - def testJobUpdate(self): - """Test JobUpdate""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_jobs_api.py b/jobmanager/client/test/test_jobs_api.py deleted file mode 100644 index 812fba07e1..0000000000 --- a/jobmanager/client/test/test_jobs_api.py +++ /dev/null @@ -1,87 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from jobmanager_client.api.jobs_api import JobsApi # noqa: E501 - - -class TestJobsApi(unittest.TestCase): - """JobsApi unit test stubs""" - - def setUp(self) -> None: - self.api = JobsApi() - - def tearDown(self) -> None: - self.api.api_client.close() - - def test_create_job_v1_jobs_post(self) -> None: - """Test case for create_job_v1_jobs_post - - Create Job # noqa: E501 - """ - pass - - def test_download_object_v1_jobs_job_id_object_object_name_get(self) -> None: - """Test case for download_object_v1_jobs_job_id_object_object_name_get - - Download Object # noqa: E501 - """ - pass - - def test_generate_token_v1_jobs_job_id_token_post(self) -> None: - """Test case for generate_token_v1_jobs_job_id_token_post - - Generate Token # noqa: E501 - """ - pass - - def test_get_health_v1_jobs_job_id_health_get(self) -> None: - """Test case for get_health_v1_jobs_job_id_health_get - - Get Health # noqa: E501 - """ - pass - - def test_get_job_v1_jobs_job_id_get(self) -> None: - """Test case for get_job_v1_jobs_job_id_get - - Get Job # noqa: E501 - """ - pass - - def test_get_jobs_v1_jobs_get(self) -> None: - """Test case for get_jobs_v1_jobs_get - - Get Jobs # noqa: E501 - """ - pass - - def test_update_health_v1_jobs_job_id_health_put(self) -> None: - """Test case for update_health_v1_jobs_job_id_health_put - - Update Health # noqa: E501 - """ - pass - - def test_update_job_v1_jobs_job_id_put(self) -> None: - """Test case for update_job_v1_jobs_job_id_put - - Update Job # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_runners_api.py b/jobmanager/client/test/test_runners_api.py deleted file mode 100644 index 6bc2767117..0000000000 --- a/jobmanager/client/test/test_runners_api.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from jobmanager_client.api.runners_api import RunnersApi # noqa: E501 - - -class TestRunnersApi(unittest.TestCase): - """RunnersApi unit test stubs""" - - def setUp(self) -> None: - self.api = RunnersApi() - - def tearDown(self) -> None: - self.api.api_client.close() - - def test_get_runner_health_v1_runners_runner_id_health_get(self) -> None: - """Test case for get_runner_health_v1_runners_runner_id_health_get - - Get Runner Health # noqa: E501 - """ - pass - - def test_register_runner_v1_runners_register_post(self) -> None: - """Test case for register_runner_v1_runners_register_post - - Register Runner # noqa: E501 - """ - pass - - def test_update_runner_health_v1_runners_runner_id_health_put(self) -> None: - """Test case for update_runner_health_v1_runners_runner_id_health_put - - Update Runner Health # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_tokens_api.py b/jobmanager/client/test/test_tokens_api.py deleted file mode 100644 index 14665e33c2..0000000000 --- a/jobmanager/client/test/test_tokens_api.py +++ /dev/null @@ -1,45 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest - -from jobmanager_client.api.tokens_api import TokensApi # noqa: E501 - - -class TestTokensApi(unittest.TestCase): - """TokensApi unit test stubs""" - - def setUp(self) -> None: - self.api = TokensApi() - - def tearDown(self) -> None: - self.api.api_client.close() - - def test_create_api_access_token_v1_api_access_token_post(self) -> None: - """Test case for create_api_access_token_v1_api_access_token_post - - Create Api Access Token # noqa: E501 - """ - pass - - def test_revoke_api_access_token_v1_api_access_token_delete(self) -> None: - """Test case for revoke_api_access_token_v1_api_access_token_delete - - Revoke Api Access Token # noqa: E501 - """ - pass - - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_validation_error.py b/jobmanager/client/test/test_validation_error.py deleted file mode 100644 index 6a939093f0..0000000000 --- a/jobmanager/client/test/test_validation_error.py +++ /dev/null @@ -1,61 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.validation_error import ValidationError # noqa: E501 - -class TestValidationError(unittest.TestCase): - """ValidationError unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ValidationError: - """Test ValidationError - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ValidationError` - """ - model = ValidationError() # noqa: E501 - if include_optional: - return ValidationError( - loc = [ - null - ], - msg = '', - type = '' - ) - else: - return ValidationError( - loc = [ - null - ], - msg = '', - type = '', - ) - """ - - def testValidationError(self): - """Test ValidationError""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_validation_error_loc_inner.py b/jobmanager/client/test/test_validation_error_loc_inner.py deleted file mode 100644 index 5bad0cb13c..0000000000 --- a/jobmanager/client/test/test_validation_error_loc_inner.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.validation_error_loc_inner import ValidationErrorLocInner # noqa: E501 - -class TestValidationErrorLocInner(unittest.TestCase): - """ValidationErrorLocInner unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> ValidationErrorLocInner: - """Test ValidationErrorLocInner - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `ValidationErrorLocInner` - """ - model = ValidationErrorLocInner() # noqa: E501 - if include_optional: - return ValidationErrorLocInner( - ) - else: - return ValidationErrorLocInner( - ) - """ - - def testValidationErrorLocInner(self): - """Test ValidationErrorLocInner""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/test/test_vm_dependencies.py b/jobmanager/client/test/test_vm_dependencies.py deleted file mode 100644 index 1a093ab299..0000000000 --- a/jobmanager/client/test/test_vm_dependencies.py +++ /dev/null @@ -1,51 +0,0 @@ -# coding: utf-8 - -""" - Job Manager API - - A modern job management system - - The version of the OpenAPI document: 2.0.0 - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -import unittest -import datetime - -from jobmanager_client.models.vm_dependencies import VmDependencies # noqa: E501 - -class TestVmDependencies(unittest.TestCase): - """VmDependencies unit test stubs""" - - def setUp(self): - pass - - def tearDown(self): - pass - - def make_instance(self, include_optional) -> VmDependencies: - """Test VmDependencies - include_option is a boolean, when False only required - params are included, when True both required and - optional params are included """ - # uncomment below to create an instance of `VmDependencies` - """ - model = VmDependencies() # noqa: E501 - if include_optional: - return VmDependencies( - ) - else: - return VmDependencies( - ) - """ - - def testVmDependencies(self): - """Test VmDependencies""" - # inst_req_only = self.make_instance(include_optional=False) - # inst_req_and_optional = self.make_instance(include_optional=True) - -if __name__ == '__main__': - unittest.main() diff --git a/jobmanager/client/tox.ini b/jobmanager/client/tox.ini deleted file mode 100644 index f62558314b..0000000000 --- a/jobmanager/client/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py3 - -[testenv] -deps=-r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements.txt - -commands= - pytest --cov=jobmanager_client diff --git a/jobmanager/openapi-generate-jobmanager.sh b/jobmanager/openapi-generate-jobmanager.sh deleted file mode 100644 index c2e8b6397c..0000000000 --- a/jobmanager/openapi-generate-jobmanager.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -rm -rf ./client -curl -o openapi.yaml https://git.launchpad.net/job-manager/plain/openapi/openapi.yaml?h=main -docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/openapi.yaml --package-name jobmanager_client -g python-pydantic-v1 -o /local/client -sudo chown -R "$USER" ./client diff --git a/requirements.txt b/requirements.txt index f5a8d4f620..5d4d06fa66 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ -r base_requirements.txt ./github-runner-manager -./jobmanager/client diff --git a/src/charm_state.py b/src/charm_state.py index 6f21b575dc..d779e78a25 100644 --- a/src/charm_state.py +++ b/src/charm_state.py @@ -106,13 +106,6 @@ def from_charm(cls, charm: CharmBase) -> "GithubConfig | None": if not path_str: raise CharmConfigInvalidError(f"Missing {PATH_CONFIG_NAME} configuration") - if path_str.startswith("http://") or path_str.startswith("https://"): - logger.info( - "Detected URL in %s configuration, will use experimental jobmanager mode", - PATH_CONFIG_NAME, - ) - return None - try: path = parse_github_path(cast(str, path_str), cast(str, runner_group)) except ValueError as e: @@ -124,46 +117,6 @@ def from_charm(cls, charm: CharmBase) -> "GithubConfig | None": return cls(token=cast(str, token), path=path) -class JobManagerConfig(BaseModel): - """Configuration for the job manager. - - Attributes: - url: The job manager base URL. - token: The job manager API token. - """ - - url: AnyHttpUrl - token: str - - @classmethod - def from_charm(cls, charm: CharmBase) -> "JobManagerConfig | None": - """Initialize the config from charm. - - Args: - charm: The charm instance. - - Returns: - Current job manager config of the charm. - - Raises: - CharmConfigInvalidError: If an invalid configuration was set. - """ - url_str = cast(str, charm.config.get(PATH_CONFIG_NAME, "")) - if not url_str: - raise CharmConfigInvalidError(f"Missing {PATH_CONFIG_NAME} configuration") - - token_str = cast(str, charm.config.get(TOKEN_CONFIG_NAME)) - if not token_str: - raise CharmConfigInvalidError(f"Missing {TOKEN_CONFIG_NAME} configuration") - - try: - # pydantic allows string to be passed as AnyHttpUrl, mypy complains about it - return cls(url=url_str, token=token_str) # type: ignore - except ValidationError as e: - logger.info("Path is not a URL, will not use it as jobmanager url: %s", e) - return None - - class CharmConfigInvalidError(Exception): """Raised when charm config is invalid. @@ -270,8 +223,6 @@ class CharmConfig(BaseModel): aproxy_exclude_addresses: a list of addresses to exclude from the aproxy proxy. aproxy_redirect_ports: a list of ports to redirect to the aproxy proxy. custom_pre_job_script: Custom pre-job script to run before the job. - jobmanager_url: Base URL of the job manager service. - jobmanager_token: Token for authentication with the job manager service. runner_manager_log_level: The log level of the runner manager application. """ @@ -287,8 +238,6 @@ class CharmConfig(BaseModel): aproxy_exclude_addresses: list[str] = [] aproxy_redirect_ports: list[str] = [] custom_pre_job_script: str | None - jobmanager_url: AnyHttpUrl | None - jobmanager_token: str | None runner_manager_log_level: LogLevel @classmethod @@ -524,8 +473,6 @@ def from_charm(cls, charm: CharmBase) -> "CharmConfig": except CharmConfigInvalidError as exc: raise CharmConfigInvalidError(f"Invalid Github config, {str(exc)}") from exc - jobmanager_config = JobManagerConfig.from_charm(charm) if not github_config else None - try: reconcile_interval = int(charm.config[RECONCILE_INTERVAL_CONFIG_NAME]) except ValueError as err: @@ -583,8 +530,6 @@ def from_charm(cls, charm: CharmBase) -> "CharmConfig": ), custom_pre_job_script=custom_pre_job_script, runner_manager_log_level=runner_manager_log_level, - jobmanager_url=jobmanager_config.url if jobmanager_config else None, - jobmanager_token=jobmanager_config.token if jobmanager_config else None, ) diff --git a/src/factories.py b/src/factories.py index a925854341..94eb6d100b 100644 --- a/src/factories.py +++ b/src/factories.py @@ -18,7 +18,6 @@ UserInfo, ) from github_runner_manager.configuration.github import GitHubConfiguration -from github_runner_manager.configuration.jobmanager import JobManagerConfiguration from github_runner_manager.manager.runner_scaler import RunnerScaler from github_runner_manager.openstack_cloud.configuration import ( OpenStackConfiguration, @@ -72,13 +71,6 @@ def create_application_configuration( if state.charm_config.path else None ) - jobmanager_configuration = ( - JobManagerConfiguration( - url=state.charm_config.jobmanager_url, token=state.charm_config.jobmanager_token - ) - if state.charm_config.jobmanager_url - else None - ) service_config = SupportServiceConfig( manager_proxy_command=state.charm_config.manager_proxy_command, @@ -99,7 +91,6 @@ def create_application_configuration( name=app_name, extra_labels=extra_labels, github_config=github_configuration, - jobmanager_config=jobmanager_configuration, service_config=service_config, non_reactive_configuration=non_reactive_configuration, reactive_configuration=reactive_configuration, diff --git a/src/manager_service.py b/src/manager_service.py index 1427c6c28f..e5e43a9d4a 100644 --- a/src/manager_service.py +++ b/src/manager_service.py @@ -33,9 +33,7 @@ SYSTEMD_SERVICE_PATH / GITHUB_RUNNER_MANAGER_SYSTEMD_SERVICE ) GITHUB_RUNNER_MANAGER_PACKAGE = "github_runner_manager" -JOB_MANAGER_PACKAGE = "jobmanager_client" GITHUB_RUNNER_MANAGER_PACKAGE_PATH = "./github-runner-manager" -JOB_MANAGER_PACKAGE_PATH = "./jobmanager/client" GITHUB_RUNNER_MANAGER_SERVICE_NAME = "github-runner-manager" GITHUB_RUNNER_MANAGER_SERVICE_LOG_DIR = Path("/var/log/github-runner-manager") GITHUB_RUNNER_MANAGER_SERVICE_EXECUTABLE_PATH = "/usr/local/bin/github-runner-manager" @@ -112,16 +110,6 @@ def install_package() -> None: execute_command( ["pipx", "install", "--global", "--force", GITHUB_RUNNER_MANAGER_PACKAGE_PATH] ) - execute_command( - [ - "pipx", - "inject", - "--global", - "--force", - GITHUB_RUNNER_MANAGER_PACKAGE, - JOB_MANAGER_PACKAGE_PATH, - ] - ) except SubprocessError as err: raise RunnerManagerApplicationInstallError(_INSTALL_ERROR_MESSAGE) from err diff --git a/tests/integration/jobmanager/__init__.py b/tests/integration/jobmanager/__init__.py deleted file mode 100644 index 97bca57b0b..0000000000 --- a/tests/integration/jobmanager/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. diff --git a/tests/integration/jobmanager/conftest.py b/tests/integration/jobmanager/conftest.py deleted file mode 100644 index 8f795164fa..0000000000 --- a/tests/integration/jobmanager/conftest.py +++ /dev/null @@ -1,122 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -import logging -import secrets -import socket -from typing import AsyncIterator - -import pytest -import pytest_asyncio -from juju.application import Application -from pytest_httpserver import HTTPServer - -from charm_state import ( - BASE_VIRTUAL_MACHINES_CONFIG_NAME, - PATH_CONFIG_NAME, - RECONCILE_INTERVAL_CONFIG_NAME, - TOKEN_CONFIG_NAME, -) -from tests.integration.conftest import DEFAULT_RECONCILE_INTERVAL -from tests.integration.helpers.common import wait_for_reconcile -from tests.integration.helpers.openstack import PrivateEndpointConfigs - -logger = logging.getLogger(__name__) -pytestmark = pytest.mark.openstack - - -@pytest_asyncio.fixture(scope="module", name="image_builder_config") -async def image_builder_config_fixture( - private_endpoint_config: PrivateEndpointConfigs | None, - flavor_name: str, - network_name: str, -): - """The image builder application default for OpenStack runners.""" - if not private_endpoint_config: - raise ValueError("Private endpoints are required for testing OpenStack runners.") - return { - "build-interval": "12", - "revision-history-limit": "2", - "openstack-auth-url": private_endpoint_config["auth_url"], - # Bandit thinks this is a hardcoded password - "openstack-password": private_endpoint_config["password"], # nosec: B105 - "openstack-project-domain-name": private_endpoint_config["project_domain_name"], - "openstack-project-name": private_endpoint_config["project_name"], - "openstack-user-domain-name": private_endpoint_config["user_domain_name"], - "openstack-user-name": private_endpoint_config["username"], - "build-flavor": flavor_name, - "build-network": network_name, - "architecture": "amd64", - "script-url": "https://git.launchpad.net/job-manager/plain/scripts/post-image-build.sh?h=main", # noqa - } - - -@pytest.fixture(scope="session") -def httpserver_listen_port() -> int: - # Do not use the listening port of the builder-agent, as it - # will interfere with the tunnel from the runner to the mock jobmanager. - return 8000 - - -@pytest.fixture(scope="session") -def httpserver_listen_address(httpserver_listen_port: int): - return ("0.0.0.0", httpserver_listen_port) - - -@pytest.fixture(scope="session", name="jobmanager_ip_address") -def jb_ip_address_fixture() -> str: - """IP address for the jobmanager tests.""" - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect(("8.8.8.8", 80)) - ip_address = s.getsockname()[0] - logger.info("IP Address to use as the fake jobmanager: %s", ip_address) - s.close() - return ip_address - - -@pytest.fixture(scope="session", name="jobmanager_base_url") -def jobmanager_base_url_fixture( - jobmanager_ip_address: str, - httpserver_listen_port: int, -) -> str: - """Jobmanager base URL for the tests.""" - return f"http://{jobmanager_ip_address}:{httpserver_listen_port}" - - -@pytest.fixture(scope="session", name="jobmanager_token") -def jobmanager_token_fixture() -> str: - """Token for the jobmanager tests.""" - return secrets.token_hex(8) - - -@pytest_asyncio.fixture(name="app") -async def app_fixture( - app_no_runner: Application, - jobmanager_base_url: str, - jobmanager_token: str, - httpserver: HTTPServer, -) -> AsyncIterator[Application]: - """Setup and tear down for app.""" - app_for_jobmanager = app_no_runner - - await app_for_jobmanager.set_config( - { - RECONCILE_INTERVAL_CONFIG_NAME: str(DEFAULT_RECONCILE_INTERVAL), - TOKEN_CONFIG_NAME: jobmanager_token, - PATH_CONFIG_NAME: jobmanager_base_url, - } - ) - await wait_for_reconcile(app_for_jobmanager) - - httpserver.clear_all_handlers() - - yield app_for_jobmanager - - # cleanup of any runner spawned - await app_for_jobmanager.set_config( - { - BASE_VIRTUAL_MACHINES_CONFIG_NAME: "0", - RECONCILE_INTERVAL_CONFIG_NAME: str(DEFAULT_RECONCILE_INTERVAL), - } - ) - await wait_for_reconcile(app_for_jobmanager) diff --git a/tests/integration/jobmanager/helpers.py b/tests/integration/jobmanager/helpers.py deleted file mode 100644 index 783bf0e82e..0000000000 --- a/tests/integration/jobmanager/helpers.py +++ /dev/null @@ -1,222 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -import asyncio -import logging - -from juju.application import Application -from pytest_httpserver import HTTPServer, RequestHandler - -from jobmanager.client.jobmanager_client.models.runner_health_response import RunnerHealthResponse -from jobmanager.client.jobmanager_client.models.runner_register_response import ( - RunnerRegisterResponse, -) - -logger = logging.getLogger(__name__) - - -def add_builder_agent_health_endpoint_response( - app: Application, - httpserver: HTTPServer, - runner_health_path: str, - runner_token: str, - status="IDLE", - oneshot=False, -): - """Add a response to the builder-agent health endpoint for given status. - - Args: - app: The application to which the builder-agent belongs. - httpserver: The HTTP server to use for the endpoint. - runner_health_path: The path for the runner health endpoint. - runner_token: The token for the runner. - status: The status of the runner, e.g., "IDLE", "IN_PROGRESS", "COMPLETED". - oneshot: If True, the request will be expected only once. - """ - base_builder_agent_health_request = { - "uri": runner_health_path, - "method": "PUT", - "headers": {"Authorization": f"Bearer {runner_token}"}, - } - json_data = {"json": {"label": app.name, "status": status}} - builder_agent_request_parms = base_builder_agent_health_request | json_data - if oneshot: - httpserver.expect_oneshot_request(**builder_agent_request_parms).respond_with_data("OK") - else: - httpserver.expect_request(**builder_agent_request_parms).respond_with_data("OK") - - -async def _assert_runners(app: Application, online: int, busy: int, offline: int, unknown: int): - """Assert the number of runners with given status in the application. - - Args: - app: The application to check the runners in. - online: The expected number of online runners. - busy: The expected number of busy runners. - offline: The expected number of offline runners. - unknown: The expected number of unknown runners. - """ - action = await app.units[0].run_action("check-runners") - await action.wait() - logger.info("check-runners: %s", action.results) - assert action.status == "completed" - assert action.results["online"] == str(online), f"{online} Runner(s) should be online" - assert action.results["busy"] == str(busy), f"{busy} Runner(s) should be busy" - assert action.results["offline"] == str(offline), f"{offline} Runner(s) should be offline" - assert action.results["unknown"] == str(unknown), f"{unknown} Runner(s) should be unknown" - - -class GetRunnerHealthEndpoint: - """Class modelling the runner health endpoint.""" - - def __init__(self, httpserver: HTTPServer, runner_health_path: str, jobmanager_token: str): - """Initialize the GetRunnerHealthEndpoint. - - Args: - httpserver: The HTTP server to use for the endpoint. - runner_health_path: The path for the runner health endpoint. - jobmanager_token: The token for the jobmanager for authentication. - """ - self.httpserver = httpserver - self.runner_health_path = runner_health_path - self._handler: RequestHandler | None = None - self._jobmanager_token = jobmanager_token - - def set(self, status="PENDING", deletable=False): - """Set the runner health endpoint. - - Args: - status: The status of the runner, e.g., "PENDING", "IDLE", "IN_PROGRESS", "COMPLETED". - deletable: Whether the runner is deletable or not. - """ - # '/v1/runners//health', 'GET', - # Returns GetRunnerHealthV1RunnerRunnerIdHealthGet200Response - health_response = RunnerHealthResponse( - label="label", - cpu_usage="1", - ram_usage="1", - disk_usage="1", - status=status, - deletable=deletable, - ) - if not self._handler: - self._handler = self.httpserver.expect_request( - uri=self.runner_health_path, - method="GET", - headers={"Authorization": f"Bearer {self._jobmanager_token}"}, - ) - self._handler.respond_with_json(health_response.to_dict()) - logger.info("handler health %s", self._handler) - - -async def wait_for_runner_to_be_registered( - httpserver: HTTPServer, runner_id: int, runner_token: str, jobmanager_token: str -): - """Wait for the runner to be registered in the jobmanager. - - Args: - httpserver: The HTTP server to use for the request. - runner_id: The ID of the runner. - runner_token: The token of the runner. - jobmanager_token: The token for authentication with the jobmanager. - """ - runner_register = "/v1/runners/register" - returned_token = RunnerRegisterResponse(id=runner_id, token=runner_token) - httpserver.expect_oneshot_request( - uri=runner_register, - method="POST", - headers={ - "Authorization": f"Bearer {jobmanager_token}", - }, - ).respond_with_json(returned_token.to_dict()) - with httpserver.wait(raise_assertions=False, stop_on_nohandler=False, timeout=30) as waiting: - logger.info("Waiting for runner to be registered.") - logger.info("server log: %s ", (httpserver.log)) - assert waiting.result, "Failed waiting for get token in the jobmanager." - - -async def prepare_runner_tunnel_for_builder_agent( - instance_helper, unit, jobmanager_address, jobmanager_port -) -> bool: - """Prepare the runner tunner so the builder-agent can access the fake jobmanager. - - This function will change the address of the traffic going to the jobmanager_address - and jobmanager_port to the jobmanager_port in the address 127.0.0.1 inside the runner. - A reverse tunnel will be then created that will listen in the runner in the - address 127.0.0.1 and the port jobmanager_port and will send the traffic to the - fake jobmanager http server. This is required as the runner may be unable to send traffic - directly to the fake http server running in this test. - - This function return False if the tunnel could not be prepared and - retrying is possible. - - Args: - instance_helper: An instance helper to run commands in the unit. - unit: The unit where the runner is running. - jobmanager_address: The address of the jobmanager. - jobmanager_port: The port of the jobmanager. - - Returns: - bool: True if the tunnel was prepared successfully, False otherwise. - """ - logger.info("trying to prepare tunnel for builder agent") - try: - server = instance_helper.get_single_runner(unit) - except AssertionError: - logger.info("no runner or two or more runners in unit, return False") - return False - network_address_list = server.addresses.values() - if not network_address_list: - logger.info("no addresses yet, return False") - return False - - exit_code, stdout, _ = await instance_helper.run_in_instance( - unit, - "'echo hello'", - timeout=10, - ) - if exit_code != 0 or not stdout or "hello" not in stdout: - logger.info("cannot ssh yet, return False") - return False - - # Not sure about this. We should check if the nftables interfere with the iptables rules. - # For now, a sleep for a bit of time so we the runner has time to flush and apply the - # nftables rules. We may also check this issue in other tests. - await asyncio.sleep(60) - - dnat_comman_in_runner = f"sudo iptables -t nat -A OUTPUT -p tcp -d {jobmanager_address} --dport {jobmanager_port} -j DNAT --to-destination 127.0.0.1:{jobmanager_port}" # noqa # pylint: disable=line-too-long - exit_code, _, _ = await instance_helper.run_in_instance( - unit, - dnat_comman_in_runner, - timeout=10, - ) - assert exit_code == 0, "could not apply iptables" - await instance_helper.expose_to_instance( - unit=unit, port=jobmanager_port, host=jobmanager_address - ) - logger.info("prepared tunnel for builder agent") - return True - - -async def execute_command_with_builder_agent(instance_helper, unit, command) -> None: - """Execute a command in the builder-agent. - - Args: - instance_helper: Helper class to manage interactions with OpenStack instances. - unit: The Juju unit to operate on. - command: The command to run. - """ - execute_command = ( - "'curl http://127.0.0.1:8080/execute -X POST " - '--header "Content-Type: application/json" ' - '--data "' - f'{{\\"commands\\":[\\"{command}\\"]}}"' - "'" - ) - _, _, _ = await instance_helper.run_in_instance( - unit=unit, - command=execute_command, - assert_on_failure=True, - timeout=10, - assert_msg="Failed executing commands in builder-agent", - ) diff --git a/tests/integration/jobmanager/test_jobmanager_prespawned.py b/tests/integration/jobmanager/test_jobmanager_prespawned.py deleted file mode 100644 index 1f03df532b..0000000000 --- a/tests/integration/jobmanager/test_jobmanager_prespawned.py +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Testing for jobmanager platform.""" - -import logging - -import pytest -from juju.application import Application -from pytest_httpserver import HTTPServer - -from charm_state import ( - BASE_VIRTUAL_MACHINES_CONFIG_NAME, - MAX_TOTAL_VIRTUAL_MACHINES_CONFIG_NAME, - RECONCILE_INTERVAL_CONFIG_NAME, -) -from tests.integration.conftest import DEFAULT_RECONCILE_INTERVAL -from tests.integration.helpers.common import wait_for, wait_for_reconcile, wait_for_runner_ready -from tests.integration.helpers.openstack import OpenStackInstanceHelper -from tests.integration.jobmanager.helpers import ( - GetRunnerHealthEndpoint, - _assert_runners, - add_builder_agent_health_endpoint_response, - execute_command_with_builder_agent, - prepare_runner_tunnel_for_builder_agent, - wait_for_runner_to_be_registered, -) - -logger = logging.getLogger(__name__) -pytestmark = pytest.mark.openstack - - -@pytest.mark.abort_on_fail -async def test_jobmanager( - instance_helper: OpenStackInstanceHelper, - app: Application, - httpserver: HTTPServer, - jobmanager_base_url: str, - jobmanager_ip_address: str, - jobmanager_token: str, -): - """ - This is a full test for the happy path of the jobmanager. - - A fake http server will simulate all interactions with the jobmanager. - - The main steps in this test are: - 1. Change config to spawn a runner. - 2. The github-runner manager will register a runner on the jobmanager. - 3. The jobmanager will return a health response with "PENDING" status and not deletable. - 4. A tunnel will be prepared in the test so the reactive runner can get to the jobmanager. - This is specific to this test and in production it should not be needed. - 5. After some time, the runner will hit the jobmanager health endpoint indicating - IDLE status. - 6. The jobmanager will change the health response to "IN_PROGRESS" and will send a job - to the builder-agent. The job will be a sleep 30 seconds. - 7. The builder-agent will run the job. While running the job it will send the status - EXECUTING and after it is finished it will send the status FINISHED. - 8. Run reconcile in the github-runner manager. As the jobmanager fake health response is - still "IN_PROGRESS" and not deletable, the runner should not be deleted. - 9. Change the health response from the fake jobmanager to reply COMPLETED and deletable. - 10. Run reconcile in the github-runner manager. The runner should be deleted at this point. - """ - # The http server simulates the jobmanager. Both the github-runner application - # and the builder-agent will interact with the jobmanager. An alternative is - # to create a test with a real jobmanager, and this could be done in the future. - runner_id = 1234 - runner_token = "token" - runner_health_path = f"/v1/runners/{runner_id}/health" - - # The builder-agent can get to us at any point after runner is spawned, so we already - # register the health endpoint. - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="IDLE" - ) - - unit = app.units[0] - - # 1. Change config to spawn a runner. - await app.set_config( - { - BASE_VIRTUAL_MACHINES_CONFIG_NAME: "1", - MAX_TOTAL_VIRTUAL_MACHINES_CONFIG_NAME: "0", - } - ) - - # 2. The github-runner manager will register a runner on the jobmanager. - await wait_for_runner_to_be_registered(httpserver, runner_id, runner_token, jobmanager_token) - - # 3. The jobmanager will return a health response with "PENDING" status and not deletable. - runner_health_endpoint = GetRunnerHealthEndpoint( - httpserver, runner_health_path, jobmanager_token - ) - runner_health_endpoint.set(status="PENDING", deletable=False) - - # 4. A tunnel will be prepared in the test so the reactive runner can get to the jobmanager. - # This is specific to this test and in production it should not be needed. - async def _prepare_runner() -> bool: - """Prepare the tunner so the runner builder-agent can get to the jobmanager.""" - return await prepare_runner_tunnel_for_builder_agent( - instance_helper, unit, jobmanager_ip_address, httpserver.port - ) - - await wait_for(_prepare_runner, check_interval=10, timeout=600) - - # 5. After some time, the runner will hit the jobmanager health endpoint indicating - # IDLE status. - # httpserver.wait will only check for oneshot requests, so we register as oneshot handler. - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="IDLE", oneshot=True - ) - - with httpserver.wait(raise_assertions=True, stop_on_nohandler=False, timeout=120) as waiting: - logger.info("Waiting for builder-agent to contact us.") - logger.info("server log after executing: %s ", (httpserver.log)) - assert waiting.result, "builder-agent did not contact us with IDLE status." - - # 6. The jobmanager will change the health response to "IN_PROGRESS" and will send a job - # to the builder-agent. The job will be a sleep 30 seconds. - runner_health_endpoint.set(status="IN_PROGRESS", deletable=False) - - # Ok, at this point, we want to tell the builder-agent to execute some command, - # specifically a sleep so we can check that it goes over executing and finished statuses. - await execute_command_with_builder_agent(instance_helper, unit, "sleep 30") - - # 7. The builder-agent will run the job. While running the job it will send the status - # EXECUTING and after it is finished it will send the status FINISHED. - # We need oneshot for httpserver.wait - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="EXECUTING", oneshot=True - ) - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="EXECUTING", oneshot=False - ) - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="FINISHED", oneshot=True - ) - add_builder_agent_health_endpoint_response( - app, httpserver, runner_health_path, runner_token, status="FINISHED", oneshot=False - ) - - with httpserver.wait(raise_assertions=True, stop_on_nohandler=False, timeout=120) as waiting: - logger.info("Waiting for builder-agent to contact us.") - logger.info("server log after executing: %s ", (httpserver.log)) - assert waiting.result, "builder-agent did not execute or finished." - - # 8. Run reconcile in the github-runner manager. As the jobmanager fake health response is - # still "IN_PROGRESS" and not deletable, the runner should not be deleted. - logger.info("First reconcile that should not delete the runner, as it is still healthy.") - # TMP: hack to trigger reconcile by changing the configuration, which cause config_changed hook - # to restart the reconcile service. - await app.set_config({RECONCILE_INTERVAL_CONFIG_NAME: str(DEFAULT_RECONCILE_INTERVAL + 1)}) - await wait_for_runner_ready(app) - - # At this point there should be a runner - await _assert_runners(app, online=1, busy=1, offline=0, unknown=0) - - # 9. Change the health response from the fake jobmanager to reply COMPLETED and deletable. - runner_health_endpoint.set(status="COMPLETED", deletable=True) - - # 10. Run reconcile in the github-runner manager. The runner should be deleted at this point. - # TMP: hack to trigger reconcile by changing the configuration, which cause config_changed hook - # to restart the reconcile service. - await app.set_config({RECONCILE_INTERVAL_CONFIG_NAME: str(DEFAULT_RECONCILE_INTERVAL + 2)}) - await wait_for_reconcile(app) - - await _assert_runners(app, online=0, busy=0, offline=0, unknown=0) diff --git a/tests/integration/jobmanager/test_jobmanager_reactive.py b/tests/integration/jobmanager/test_jobmanager_reactive.py deleted file mode 100644 index ad93c6d55f..0000000000 --- a/tests/integration/jobmanager/test_jobmanager_reactive.py +++ /dev/null @@ -1,224 +0,0 @@ -# Copyright 2025 Canonical Ltd. -# See LICENSE file for licensing details. - -"""Testing for jobmanager platform.""" - -import json -import logging -from typing import AsyncIterator - -import jubilant -import pytest -import pytest_asyncio -from github_runner_manager.platform.jobmanager_provider import JobStatus -from github_runner_manager.reactive.consumer import JobDetails -from juju.application import Application -from pytest_httpserver import HTTPServer - -from charm_state import ( - BASE_VIRTUAL_MACHINES_CONFIG_NAME, - MAX_TOTAL_VIRTUAL_MACHINES_CONFIG_NAME, - RECONCILE_INTERVAL_CONFIG_NAME, -) -from jobmanager.client.jobmanager_client.models.job_read import JobRead -from tests.integration.conftest import DEFAULT_RECONCILE_INTERVAL -from tests.integration.helpers.common import wait_for, wait_for_reconcile -from tests.integration.helpers.openstack import OpenStackInstanceHelper -from tests.integration.jobmanager.helpers import ( - GetRunnerHealthEndpoint, - add_builder_agent_health_endpoint_response, - prepare_runner_tunnel_for_builder_agent, - wait_for_runner_to_be_registered, -) -from tests.integration.utils_reactive import ( - add_to_queue, - assert_queue_is_empty, - clear_queue, - get_mongodb_uri, -) - -logger = logging.getLogger(__name__) -pytestmark = pytest.mark.openstack - -# This is tied to the wait time in reactive processes. -REACTIVE_WAIT_TIME = 60 -# Set to a higher reconcile time, due to flush on empty queue in reconcile can affect the tests. -RECONCILE_INTERVAL = 15 - - -@pytest_asyncio.fixture(name="app_for_reactive") -async def app_for_reactive_fixture( - ops_test, - juju: jubilant.Juju, - app: Application, - mongodb: Application, - jobmanager_base_url: str, - existing_app_suffix: str, -) -> AsyncIterator[Application]: - """Setup the reactive charm with 1 virtual machine and tear down afterwards.""" - app_for_reactive = app - - if not existing_app_suffix: - relation = (f"{app_for_reactive.name}:mongodb", f"{mongodb.name}:database") - juju.integrate(*relation) - - juju.wait( - lambda status: jubilant.all_active(status, app_for_reactive.name, mongodb.name) - and jubilant.all_agents_idle(status, app_for_reactive.name, mongodb.name) - ) - - mongodb_uri = await get_mongodb_uri(ops_test, app_for_reactive) - clear_queue(mongodb_uri, app_for_reactive.name) - assert_queue_is_empty(mongodb_uri, app_for_reactive.name) - - await app_for_reactive.set_config( - { - BASE_VIRTUAL_MACHINES_CONFIG_NAME: "0", - MAX_TOTAL_VIRTUAL_MACHINES_CONFIG_NAME: "1", - RECONCILE_INTERVAL_CONFIG_NAME: str(RECONCILE_INTERVAL), - } - ) - await wait_for_reconcile(app_for_reactive) - - yield app_for_reactive - - await app_for_reactive.set_config( - { - MAX_TOTAL_VIRTUAL_MACHINES_CONFIG_NAME: "0", - RECONCILE_INTERVAL_CONFIG_NAME: str(DEFAULT_RECONCILE_INTERVAL), - } - ) - await wait_for_reconcile(app_for_reactive) - - -@pytest.mark.abort_on_fail -async def test_jobmanager_reactive( - ops_test, - instance_helper: OpenStackInstanceHelper, - app_for_reactive: Application, - httpserver: HTTPServer, - jobmanager_base_url: str, - jobmanager_ip_address: str, - jobmanager_token: str, -): - """ - Test reactive mode together with jobmanager. - - Test that after putting a job in the queue that the runner is registered and the - job is picked up. - - So, - 1. Put job in the queue - 2. Wait for runner to be registered - 3. Wait for reactive process to ask for job status - 4. Mark job deletable - 5. Reconcile - 6. Assert queue is empty - """ - runner_id = 1234 - runner_token = "token" - runner_health_path = f"/v1/runners/{runner_id}/health" - - # The builder-agent can get to us at any point. - add_builder_agent_health_endpoint_response( - app_for_reactive, httpserver, runner_health_path, runner_token, status="IDLE" - ) - add_builder_agent_health_endpoint_response( - app_for_reactive, httpserver, runner_health_path, runner_token, status="EXECUTING" - ) - add_builder_agent_health_endpoint_response( - app_for_reactive, httpserver, runner_health_path, runner_token, status="FINISHED" - ) - - # 1. Put job in the queue - mongodb_uri = await get_mongodb_uri(ops_test, app_for_reactive) - labels = {app_for_reactive.name, "x64"} - - job_id = 99 - job_path = f"/v1/jobs/{job_id}" - job_url = f"{jobmanager_base_url}{job_path}" - - job = JobDetails( - labels=labels, - url=job_url, - ) - - # The first interaction with the jobmanager after the runner manager gets - # a message in the queue is to check if the job has been picked up. If it is pending, - # the github-runner will spawn a reactive runner. - returned_job = JobRead( - id=job_id, - status=JobStatus.PENDING.value, - architecture="x64", - base_series="jammy", - requested_by="foobar", - ) - httpserver.expect_oneshot_request(job_path).respond_with_json(returned_job.to_dict()) - - with httpserver.wait( - raise_assertions=True, stop_on_nohandler=False, timeout=60 * 2 - ) as waiting: - add_to_queue( - json.dumps(json.loads(job.json()) | {"ignored_noise": "foobar"}), - mongodb_uri, - app_for_reactive.name, - ) - logger.info("Waiting for first check job status.") - logger.info("server log: %s ", (httpserver.log)) - assert waiting.result, "Failed Waiting for first check job status." - - # From this point, the github-runner reactive process will check if the job has been picked - # up. The jobmanager will return pending until the builder-agent is alive (that is, - # the server is alive and running). - job_get_handler = httpserver.expect_request(job_path) - job_get_handler.respond_with_json(returned_job.to_dict()) - - # 2. Wait for runner to be registered - await wait_for_runner_to_be_registered(httpserver, runner_id, runner_token, jobmanager_token) - - # For the github runner manager, at this point, the jobmanager will return - # that the runner health is pending and not deletable - runner_health_endpoint = GetRunnerHealthEndpoint( - httpserver, runner_health_path, jobmanager_token - ) - runner_health_endpoint.set(status="PENDING", deletable=False) - - unit = app_for_reactive.units[0] - - async def _prepare_runner() -> bool: - """Prepare the tunner so the runner builder-agent can get to the jobmanager.""" - return await prepare_runner_tunnel_for_builder_agent( - instance_helper, unit, jobmanager_ip_address, httpserver.port - ) - - await wait_for(_prepare_runner, check_interval=10, timeout=600) - - # 3. Wait for reactive process to ask for job status - runner_health_endpoint.set(status="IN_PROGRESS", deletable=False) - - returned_job.status = JobStatus.IN_PROGRESS.value - job_get_handler = httpserver.expect_oneshot_request( - uri=job_path, method="GET", headers={"Authorization": f"Bearer {jobmanager_token}"} - ) - job_get_handler.respond_with_json(returned_job.to_dict()) - - with httpserver.wait( - raise_assertions=True, stop_on_nohandler=False, timeout=REACTIVE_WAIT_TIME + 30 - ) as waiting: - logger.info("Waiting for job status to be queried.") - logger.info("server log: %s ", (httpserver.log)) - assert waiting.result, "Failed waiting for job status to be queried." - - # 4. Mark runner deletable - runner_health_endpoint.set(status="COMPLETED", deletable=True) - - # 5. Reconcile - # TMP: hack to trigger reconcile by changing the configuration, which cause config_changed hook - # to restart the reconcile service. - await app_for_reactive.set_config( - {RECONCILE_INTERVAL_CONFIG_NAME: str(RECONCILE_INTERVAL + 1)} - ) - await wait_for_reconcile(app_for_reactive) - - # 6. Assert queue is empty - assert_queue_is_empty(mongodb_uri, app_for_reactive.name) diff --git a/tests/unit/test_charm_state.py b/tests/unit/test_charm_state.py index f0011133db..7a33bfd8bd 100644 --- a/tests/unit/test_charm_state.py +++ b/tests/unit/test_charm_state.py @@ -65,14 +65,7 @@ def test_github_config_from_charm_invalid_path(): GithubConfig.from_charm(mock_charm) -@pytest.mark.parametrize( - "config_cls", - [ - pytest.param(GithubConfig, id="GithubConfig"), - pytest.param(charm_state.JobManagerConfig, id="JobManagerConfig"), - ], -) -def test_github_jobmanager_config_from_charm_empty_path(config_cls): +def test_github_config_from_charm_empty_path(): """ arrange: Create an empty path configuration and prepare the config class to test. act: Call from_charm method with the mock CharmBase instance. @@ -82,7 +75,7 @@ def test_github_jobmanager_config_from_charm_empty_path(config_cls): mock_charm.config[PATH_CONFIG_NAME] = "" with pytest.raises(CharmConfigInvalidError): - config_cls.from_charm(mock_charm) + GithubConfig.from_charm(mock_charm) def test_github_config_from_charm_invalid_token(): @@ -98,48 +91,6 @@ def test_github_config_from_charm_invalid_token(): GithubConfig.from_charm(mock_charm) -def test_jobmanager_config_from_charm_empty_token(): - """ - arrange: Create a mock CharmBase instance with an empty token configuration. - act: Call from_charm method with the mock CharmBase instance. - assert: - """ - mock_charm = MockGithubRunnerCharmFactory() - mock_charm.config[PATH_CONFIG_NAME] = "https://jobmanager/" - mock_charm.config[TOKEN_CONFIG_NAME] = "" - - with pytest.raises(CharmConfigInvalidError): - charm_state.JobManagerConfig.from_charm(mock_charm) - - -def test_github_config_from_charm_url_path_returns_none(): - """ - arrange: Create a mock CharmBase instance with an empty path and token configuration. - act: Call from_charm method with the mock CharmBase instance. - assert: Verify that the method returns None. - """ - mock_charm = MockGithubRunnerCharmFactory() - mock_charm.config[PATH_CONFIG_NAME] = "https://jobmanager/" - - result = GithubConfig.from_charm(mock_charm) - - assert result is None - - -def test_jobmanager_config_from_charm_non_http_path_returns_none(): - """ - arrange: Create a mock CharmBase instance with a non-HTTP path configuration. - act: Call from_charm method with the mock CharmBase instance. - assert: Verify that the method returns None. - """ - mock_charm = MockGithubRunnerCharmFactory() - mock_charm.config[PATH_CONFIG_NAME] = "owner/repo" - - result = charm_state.JobManagerConfig.from_charm(mock_charm) - - assert result is None - - @pytest.mark.parametrize( "path_str, runner_group, expected_type, expected_attrs", [ @@ -382,26 +333,6 @@ def test_charm_config_from_charm_invalid_labels(): assert "Invalid labels config" in str(exc_info.value) -def test_charm_config_from_charm_sets_jobmanager_config(): - """ - arrange: Create a mock CharmBase instance with a path being equal to a url. - act: Call from_charm method with the mock CharmBase instance. - assert: Verify that job manager setting is set and github configs not. - """ - jobmanager_url = "http://jobmanager.url:80" - jobmanager_token = secrets.token_hex(4) - mock_charm = MockGithubRunnerCharmFactory() - mock_charm.config[PATH_CONFIG_NAME] = jobmanager_url - mock_charm.config[TOKEN_CONFIG_NAME] = jobmanager_token - - config = CharmConfig.from_charm(mock_charm) - - assert config.jobmanager_url == jobmanager_url - assert config.jobmanager_token == jobmanager_token - assert config.token is None - assert config.path is None - - def test_charm_config_from_charm_valid(): """ arrange: Create a mock CharmBase instance with valid configuration. diff --git a/tests/unit/test_factories.py b/tests/unit/test_factories.py index e13e34b67d..a32e2a8e0b 100644 --- a/tests/unit/test_factories.py +++ b/tests/unit/test_factories.py @@ -1,6 +1,5 @@ # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. -import pytest from github_runner_manager.configuration import ( ApplicationConfiguration, Flavor, @@ -15,7 +14,6 @@ SupportServiceConfig, ) from github_runner_manager.configuration.github import GitHubConfiguration, GitHubOrg -from github_runner_manager.configuration.jobmanager import JobManagerConfiguration from github_runner_manager.openstack_cloud.configuration import ( OpenStackConfiguration, OpenStackCredentials, @@ -27,33 +25,8 @@ import factories -@pytest.mark.parametrize( - "with_github_config, expected_github_config, expected_jobmanager_config", - [ - pytest.param( - True, - GitHubConfiguration( - token="githubtoken", path=GitHubOrg(org="canonical", group="group") - ), - None, - id="with_github_config", - ), - pytest.param( - False, - None, - JobManagerConfiguration( - url="http://jobmanager.internal", - token="jobmanagertoken", - ), - id="with_jobmanager_config", - ), - ], -) def test_create_application_configuration( complete_charm_state: charm_state.CharmState, - with_github_config: bool, - expected_github_config: GitHubConfiguration | None, - expected_jobmanager_config: JobManagerConfiguration | None, ): """ arrange: Prepare a fully populated CharmState. @@ -62,19 +35,14 @@ def test_create_application_configuration( """ state = complete_charm_state - if not with_github_config: - state.charm_config.path = None - state.charm_config.token = None - state.charm_config.jobmanager_url = "http://jobmanager.internal" - state.charm_config.jobmanager_token = "jobmanagertoken" - app_configuration = factories.create_application_configuration(state, "app_name", "unit_name") assert app_configuration == ApplicationConfiguration( name="app_name", extra_labels=["label1", "label2"], - github_config=expected_github_config, - jobmanager_config=expected_jobmanager_config, + github_config=GitHubConfiguration( + token="githubtoken", path=GitHubOrg(org="canonical", group="group") + ), service_config=SupportServiceConfig( manager_proxy_command="ssh -W %h:%p example.com", proxy_config=ProxyConfig(