Skip to content

Commit

Permalink
change BatchV1beta1Api to BatchV1Api
Browse files Browse the repository at this point in the history
  • Loading branch information
xg0719 committed Jul 9, 2022
1 parent ab58e5c commit d593fc6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/cronjob_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_namespaced_cron_job(namespace='default', body=None):
if judge_crontab_exists(namespace, name):
print(f'{name} exists, please do not repeat!')
else:
v1 = client.BatchV1beta1Api()
v1 = client.BatchV1Api()
ret = v1.create_namespaced_cron_job(namespace=namespace, body=cronjob_json, pretty=True,
_preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
Expand All @@ -32,7 +32,7 @@ def delete_namespaced_cron_job(namespace='default', name=None):
if not judge_crontab_exists(namespace, name):
print(f"{name} doesn't exists, please enter a new one!")
else:
v1 = client.BatchV1beta1Api()
v1 = client.BatchV1Api()
ret = v1.delete_namespaced_cron_job(name=name, namespace=namespace, _preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
print(f'delete succeed\n{json.dumps(ret_dict)}')
Expand All @@ -45,7 +45,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):
exit(0)
name = body['metadata']['name']
if judge_crontab_exists(namespace, name):
v1 = client.BatchV1beta1Api()
v1 = client.BatchV1Api()
ret = v1.patch_namespaced_cron_job(name=name, namespace=namespace, body=cronjob_json,
_preload_content=False, async_req=False)
ret_dict = json.loads(ret.data)
Expand All @@ -55,7 +55,7 @@ def patch_namespaced_cron_job(namespace='default', body=None):


def get_cronjob_list(namespace='default'):
v1 = client.BatchV1beta1Api()
v1 = client.BatchV1Api()
ret = v1.list_namespaced_cron_job(namespace=namespace, pretty=True, _preload_content=False)
cron_job_list = json.loads(ret.data)
print(f'cronjob number={len(cron_job_list["items"])}')
Expand All @@ -72,7 +72,7 @@ def judge_crontab_exists(namespace, name):

def get_cronjob_body(namespace, name, command):
body = {
"apiVersion": "batch/v1beta1",
"apiVersion": "batch/v1",
"kind": "CronJob",
"metadata": {
"name": name,
Expand Down

0 comments on commit d593fc6

Please sign in to comment.