|
| 1 | +/* |
| 2 | + * Copyright 2022 RelationalAI, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"): you may |
| 5 | + * not use this file except in compliance with the License. You may obtain |
| 6 | + * a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations |
| 14 | + * under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.relationalai.examples; |
| 18 | + |
| 19 | +import com.relationalai.Client; |
| 20 | +import com.relationalai.Config; |
| 21 | +import com.relationalai.HttpError; |
| 22 | +import com.relationalai.Json; |
| 23 | + |
| 24 | +import java.io.IOException; |
| 25 | + |
| 26 | +public class DeleteTransaction implements Runnable { |
| 27 | + String id, profile; |
| 28 | + |
| 29 | + public void parseArgs(String[] args) { |
| 30 | + var c = Command.create("DeleteTransaction") |
| 31 | + .addArgument("id") |
| 32 | + .addOption("profile", "config profile (default: default)") |
| 33 | + .parseArgs(args); |
| 34 | + this.id = c.getValue("id"); |
| 35 | + this.profile = c.getValue("profile"); |
| 36 | + } |
| 37 | + |
| 38 | + public void run(String[] args) throws HttpError, InterruptedException, IOException { |
| 39 | + parseArgs(args); |
| 40 | + var cfg = Config.loadConfig("~/.rai/config", profile); |
| 41 | + var client = new Client(cfg); |
| 42 | + |
| 43 | + var rsp = client.deleteTransaction(id); |
| 44 | + Json.print(rsp); |
| 45 | + } |
| 46 | +} |
0 commit comments