|
| 1 | +# Copyright 2021-2022 RelationalAI, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License |
| 14 | + |
| 15 | + |
| 16 | +import json |
| 17 | +from argparse import ArgumentParser |
| 18 | +from urllib.request import HTTPError |
| 19 | + |
| 20 | +from railib import api, config, show |
| 21 | + |
| 22 | + |
| 23 | +def run(id: str, profile: str): |
| 24 | + cfg = config.read(profile=profile) |
| 25 | + ctx = api.Context(**cfg) |
| 26 | + rsp = api.cancel_transaction(ctx, id) |
| 27 | + print(json.dumps(rsp, indent=2)) |
| 28 | + |
| 29 | + |
| 30 | +if __name__ == "__main__": |
| 31 | + p = ArgumentParser() |
| 32 | + p.add_argument("id", type=str, help="transaction id") |
| 33 | + p.add_argument("-p", "--profile", type=str, |
| 34 | + help="profile name", default="default") |
| 35 | + args = p.parse_args() |
| 36 | + try: |
| 37 | + run(args.id, args.profile) |
| 38 | + except HTTPError as e: |
| 39 | + show.http_error(e) |
0 commit comments