Beispiel #1
0
def _submit_scheduled_job(api: CustomObjectsApi, name: str, resource: dict,
                          namespace: str):
    try:
        api.get_namespaced_custom_object(**_scheduled_crd_args(namespace),
                                         name=name)
    except client.ApiException as e:
        if e.status == 404:
            api.create_namespaced_custom_object(**_scheduled_crd_args(
                namespace),
                                                body=resource)
            return
        else:
            raise e
    api.patch_namespaced_custom_object(
        **_scheduled_crd_args(namespace),
        name=name,
        body=resource,
    )
Beispiel #2
0
def _get_job_by_id(api: CustomObjectsApi, namespace: str,
                   job_id: str) -> Optional[JobInfo]:
    try:
        response = api.get_namespaced_custom_object(
            **_crd_args(namespace), name=_job_id_to_resource_name(job_id))

        return _resource_to_job_info(response)
    except client.ApiException as e:
        if e.status == 404:
            return None
        else:
            raise