def _submit_job(api: CustomObjectsApi, resource, namespace: str) -> JobInfo: # create the resource response = api.create_namespaced_custom_object( **_crd_args(namespace), body=resource, ) return _resource_to_job_info(response)
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, )