Skip to content

Commit 0d93e0c

Browse files
committed
txn delete
1 parent 2ffe20c commit 0d93e0c

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
}

rai-sdk/src/main/java/com/relationalai/Client.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,11 @@ public List<Object> getTransactionProblems(String id) throws HttpError, IOExcept
809809
return parseProblemsResult(rsp);
810810
}
811811

812+
public TransactionAsyncDeleteResponse deleteTransaction(String id) throws HttpError, IOException, InterruptedException {
813+
var rsp = (String) delete(String.format("%s/%s", PATH_TRANSACTIONS, id));
814+
return Json.deserialize(rsp, TransactionAsyncDeleteResponse.class);
815+
}
816+
812817
// EDBs
813818

814819
public Edb[] listEdbs(String database, String engine)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.relationalai;
2+
3+
import com.jsoniter.annotation.JsonProperty;
4+
5+
public class TransactionAsyncDeleteResponse {
6+
@JsonProperty(value = "txn_id", required = true)
7+
public String id;
8+
9+
@JsonProperty(value = "message", required = true)
10+
public String message;
11+
12+
public TransactionAsyncDeleteResponse() {}
13+
public TransactionAsyncDeleteResponse(String id, String state) {
14+
this.id = id;
15+
this.message = state;
16+
}
17+
}

0 commit comments

Comments
 (0)