Skip to content

Commit

Permalink
api: Regenerate Client Interfaces and implement cucumber tests. (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
winder authored Apr 27, 2023
1 parent 6cdd439 commit e37bbe2
Show file tree
Hide file tree
Showing 25 changed files with 1,002 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.GetBlockTimeStampOffsetResponse;


/**
* Gets the current timestamp offset.
* /v2/devmode/blocks/offset
*/
public class GetBlockTimeStampOffset extends Query {

public GetBlockTimeStampOffset(Client client) {
super(client, new HttpMethod("get"));
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<GetBlockTimeStampOffsetResponse> execute() throws Exception {
Response<GetBlockTimeStampOffsetResponse> resp = baseExecute();
resp.setValueType(GetBlockTimeStampOffsetResponse.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<GetBlockTimeStampOffsetResponse> execute(String[] headers, String[] values) throws Exception {
Response<GetBlockTimeStampOffsetResponse> resp = baseExecute(headers, values);
resp.setValueType(GetBlockTimeStampOffsetResponse.class);
return resp;
}

protected QueryData getRequestString() {
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("devmode"));
addPathSegment(String.valueOf("blocks"));
addPathSegment(String.valueOf("offset"));

return qd;
}
}
52 changes: 52 additions & 0 deletions src/main/java/com/algorand/algosdk/v2/client/algod/GetReady.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;


/**
* Returns OK if healthy and fully caught up.
* /ready
*/
public class GetReady extends Query {

public GetReady(Client client) {
super(client, new HttpMethod("get"));
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute() throws Exception {
Response<String> resp = baseExecute();
resp.setValueType(String.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute(String[] headers, String[] values) throws Exception {
Response<String> resp = baseExecute(headers, values);
resp.setValueType(String.class);
return resp;
}

protected QueryData getRequestString() {
addPathSegment(String.valueOf("ready"));

return qd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.GetSyncRoundResponse;


/**
* Gets the minimum sync round for the ledger.
* /v2/ledger/sync
*/
public class GetSyncRound extends Query {

public GetSyncRound(Client client) {
super(client, new HttpMethod("get"));
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<GetSyncRoundResponse> execute() throws Exception {
Response<GetSyncRoundResponse> resp = baseExecute();
resp.setValueType(GetSyncRoundResponse.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<GetSyncRoundResponse> execute(String[] headers, String[] values) throws Exception {
Response<GetSyncRoundResponse> resp = baseExecute(headers, values);
resp.setValueType(GetSyncRoundResponse.class);
return resp;
}

protected QueryData getRequestString() {
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("ledger"));
addPathSegment(String.valueOf("sync"));

return qd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


/**
* Broadcasts a raw transaction to the network.
* Broadcasts a raw transaction or transaction group to the network.
* /v2/transactions
*/
public class RawTransaction extends Query {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;


/**
* Sets the timestamp offset (seconds) for blocks in dev mode. Providing an offset
* of 0 will unset this value and try to use the real clock for the timestamp.
* /v2/devmode/blocks/offset/{offset}
*/
public class SetBlockTimeStampOffset extends Query {

private Long offset;

/**
* @param offset The timestamp offset for blocks in dev mode.
*/
public SetBlockTimeStampOffset(Client client, Long offset) {
super(client, new HttpMethod("post"));
this.offset = offset;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute() throws Exception {
Response<String> resp = baseExecute();
resp.setValueType(String.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute(String[] headers, String[] values) throws Exception {
Response<String> resp = baseExecute(headers, values);
resp.setValueType(String.class);
return resp;
}

protected QueryData getRequestString() {
if (this.offset == null) {
throw new RuntimeException("offset is not set. It is a required parameter.");
}
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("devmode"));
addPathSegment(String.valueOf("blocks"));
addPathSegment(String.valueOf("offset"));
addPathSegment(String.valueOf(offset));

return qd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;


/**
* Sets the minimum sync round on the ledger.
* /v2/ledger/sync/{round}
*/
public class SetSyncRound extends Query {

private Long round;

/**
* @param round The round for which the deltas are desired.
*/
public SetSyncRound(Client client, Long round) {
super(client, new HttpMethod("post"));
this.round = round;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute() throws Exception {
Response<String> resp = baseExecute();
resp.setValueType(String.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<String> execute(String[] headers, String[] values) throws Exception {
Response<String> resp = baseExecute(headers, values);
resp.setValueType(String.class);
return resp;
}

protected QueryData getRequestString() {
if (this.round == null) {
throw new RuntimeException("round is not set. It is a required parameter.");
}
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("ledger"));
addPathSegment(String.valueOf("sync"));
addPathSegment(String.valueOf(round));

return qd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.SimulateRequest;
import com.algorand.algosdk.v2.client.model.SimulateResponse;


/**
* Simulates a raw transaction or transaction group as it would be evaluated on the
* network. The simulation will use blockchain state from the latest committed
* round.
* /v2/transactions/simulate
*/
public class SimulateTransaction extends Query {

public SimulateTransaction(Client client) {
super(client, new HttpMethod("post"));
addQuery("format", "msgpack");
}

/**
* The transactions to simulate, along with any other inputs.
*/
public SimulateTransaction request(SimulateRequest request) {
addToBody(request);
return this;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<SimulateResponse> execute() throws Exception {
Response<SimulateResponse> resp = baseExecute();
resp.setValueType(SimulateResponse.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<SimulateResponse> execute(String[] headers, String[] values) throws Exception {
Response<SimulateResponse> resp = baseExecute(headers, values);
resp.setValueType(SimulateResponse.class);
return resp;
}

protected QueryData getRequestString() {
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("transactions"));
addPathSegment(String.valueOf("simulate"));

return qd;
}
}
Loading

0 comments on commit e37bbe2

Please sign in to comment.