2019-03-13 04:31:04 -04:00
|
|
|
"""
|
|
|
|
* *******************************************************
|
|
|
|
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
* *******************************************************
|
|
|
|
*
|
|
|
|
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
|
|
|
|
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
|
|
|
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
|
|
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'VMware, Inc.'
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
from com.vmware.vmc.model_client import Task
|
|
|
|
from vmware.vapi.vmc.client import create_vmc_client
|
|
|
|
|
|
|
|
"""
|
|
|
|
Demonstrates how to cancel a running task
|
|
|
|
|
|
|
|
Sample Prerequisites:
|
|
|
|
- VMware Cloud on AWS console API access
|
|
|
|
- A running task
|
|
|
|
"""
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
2019-08-20 02:54:24 -04:00
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
|
|
|
|
|
|
required_args = parser.add_argument_group(
|
|
|
|
'required arguments')
|
2019-03-13 04:31:04 -04:00
|
|
|
|
2019-08-20 02:54:24 -04:00
|
|
|
required_args.add_argument(
|
2019-09-06 05:17:32 -04:00
|
|
|
'--refresh_token',
|
2019-08-20 02:54:24 -04:00
|
|
|
required=True,
|
|
|
|
help='Refresh token obtained from CSP')
|
2019-03-13 04:31:04 -04:00
|
|
|
|
2019-08-20 02:54:24 -04:00
|
|
|
required_args.add_argument(
|
|
|
|
'--org-id',
|
|
|
|
required=True,
|
|
|
|
help='Organization identifier.')
|
2019-03-13 04:31:04 -04:00
|
|
|
|
2019-08-20 02:54:24 -04:00
|
|
|
required_args.add_argument(
|
|
|
|
'--task-id',
|
|
|
|
required=True,
|
|
|
|
help='Task ID to be cancelled')
|
2019-03-13 04:31:04 -04:00
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
vmc_client = create_vmc_client(args.refresh_token)
|
|
|
|
|
|
|
|
vmc_client.orgs.Tasks.update(org=args.org_id, task=args.task_id, action='cancel')
|
|
|
|
|
|
|
|
print('Task "{}" is cancelled'.format(args.task_id))
|