-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate code from specification file
- Loading branch information
1 parent
672b9c3
commit 6193384
Showing
11 changed files
with
476 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/com/algorand/algosdk/v2/client/algod/GetBlockHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
import com.algorand.algosdk.v2.client.model.BlockHeaderResponse; | ||
|
||
|
||
/** | ||
* Get the block header for the block on the given round. | ||
* /v2/blocks/{round}/header | ||
*/ | ||
public class GetBlockHeader extends Query { | ||
|
||
private Long round; | ||
|
||
/** | ||
* @param round The round from which to fetch block header information. | ||
*/ | ||
public GetBlockHeader(Client client, Long round) { | ||
super(client, new HttpMethod("get")); | ||
addQuery("format", "msgpack"); | ||
this.round = round; | ||
} | ||
|
||
/** | ||
* Execute the query. | ||
* @return the query response object. | ||
* @throws Exception | ||
*/ | ||
@Override | ||
public Response<BlockHeaderResponse> execute() throws Exception { | ||
Response<BlockHeaderResponse> resp = baseExecute(); | ||
resp.setValueType(BlockHeaderResponse.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<BlockHeaderResponse> execute(String[] headers, String[] values) throws Exception { | ||
Response<BlockHeaderResponse> resp = baseExecute(headers, values); | ||
resp.setValueType(BlockHeaderResponse.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("blocks")); | ||
addPathSegment(String.valueOf(round)); | ||
addPathSegment(String.valueOf("header")); | ||
|
||
return qd; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForBlockHeaders.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
package com.algorand.algosdk.v2.client.indexer; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import com.algorand.algosdk.crypto.Address; | ||
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.common.Utils; | ||
import com.algorand.algosdk.v2.client.model.BlockHeadersResponse; | ||
|
||
|
||
/** | ||
* Search for block headers. Block headers are returned in ascending round order. | ||
* Transactions are not included in the output. | ||
* /v2/block-headers | ||
*/ | ||
public class SearchForBlockHeaders extends Query { | ||
|
||
public SearchForBlockHeaders(Client client) { | ||
super(client, new HttpMethod("get")); | ||
} | ||
|
||
/** | ||
* Accounts marked as absent in the block header's participation updates. This | ||
* parameter accepts a comma separated list of addresses. | ||
*/ | ||
public SearchForBlockHeaders absent(List<Address> absent) { | ||
addQuery("absent", StringUtils.join(absent, ",")); | ||
return this; | ||
} | ||
|
||
/** | ||
* Include results after the given time. Must be an RFC 3339 formatted string. | ||
*/ | ||
public SearchForBlockHeaders afterTime(Date afterTime) { | ||
addQuery("after-time", Utils.getDateString(afterTime)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Include results before the given time. Must be an RFC 3339 formatted string. | ||
*/ | ||
public SearchForBlockHeaders beforeTime(Date beforeTime) { | ||
addQuery("before-time", Utils.getDateString(beforeTime)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Accounts marked as expired in the block header's participation updates. This | ||
* parameter accepts a comma separated list of addresses. | ||
*/ | ||
public SearchForBlockHeaders expired(List<Address> expired) { | ||
addQuery("expired", StringUtils.join(expired, ",")); | ||
return this; | ||
} | ||
|
||
/** | ||
* Maximum number of results to return. There could be additional pages even if the | ||
* limit is not reached. | ||
*/ | ||
public SearchForBlockHeaders limit(Long limit) { | ||
addQuery("limit", String.valueOf(limit)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Include results at or before the specified max-round. | ||
*/ | ||
public SearchForBlockHeaders maxRound(Long maxRound) { | ||
addQuery("max-round", String.valueOf(maxRound)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Include results at or after the specified min-round. | ||
*/ | ||
public SearchForBlockHeaders minRound(Long minRound) { | ||
addQuery("min-round", String.valueOf(minRound)); | ||
return this; | ||
} | ||
|
||
/** | ||
* The next page of results. Use the next token provided by the previous results. | ||
*/ | ||
public SearchForBlockHeaders next(String next) { | ||
addQuery("next", String.valueOf(next)); | ||
return this; | ||
} | ||
|
||
/** | ||
* Accounts marked as proposer in the block header's participation updates. This | ||
* parameter accepts a comma separated list of addresses. | ||
*/ | ||
public SearchForBlockHeaders proposers(List<Address> proposers) { | ||
addQuery("proposers", StringUtils.join(proposers, ",")); | ||
return this; | ||
} | ||
|
||
/** | ||
* Execute the query. | ||
* @return the query response object. | ||
* @throws Exception | ||
*/ | ||
@Override | ||
public Response<BlockHeadersResponse> execute() throws Exception { | ||
Response<BlockHeadersResponse> resp = baseExecute(); | ||
resp.setValueType(BlockHeadersResponse.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<BlockHeadersResponse> execute(String[] headers, String[] values) throws Exception { | ||
Response<BlockHeadersResponse> resp = baseExecute(headers, values); | ||
resp.setValueType(BlockHeadersResponse.class); | ||
return resp; | ||
} | ||
|
||
protected QueryData getRequestString() { | ||
addPathSegment(String.valueOf("v2")); | ||
addPathSegment(String.valueOf("block-headers")); | ||
|
||
return qd; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/algorand/algosdk/v2/client/model/BlockHeaderResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.algorand.algosdk.v2.client.model; | ||
|
||
import java.util.HashMap; | ||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.v2.client.common.PathResponse; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Block header. | ||
*/ | ||
public class BlockHeaderResponse extends PathResponse { | ||
|
||
/** | ||
* Block header data. | ||
*/ | ||
@JsonProperty("blockHeader") | ||
public HashMap<String,Object> blockHeader; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (this == o) return true; | ||
if (o == null) return false; | ||
|
||
BlockHeaderResponse other = (BlockHeaderResponse) o; | ||
if (!Objects.deepEquals(this.blockHeader, other.blockHeader)) return false; | ||
|
||
return true; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/algorand/algosdk/v2/client/model/BlockHeadersResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.algorand.algosdk.v2.client.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import com.algorand.algosdk.v2.client.common.PathResponse; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class BlockHeadersResponse extends PathResponse { | ||
|
||
@JsonProperty("blocks") | ||
public List<Block> blocks = new ArrayList<Block>(); | ||
|
||
/** | ||
* Round at which the results were computed. | ||
*/ | ||
@JsonProperty("current-round") | ||
public Long currentRound; | ||
|
||
/** | ||
* Used for pagination, when making another request provide this token with the | ||
* next parameter. | ||
*/ | ||
@JsonProperty("next-token") | ||
public String nextToken; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
|
||
if (this == o) return true; | ||
if (o == null) return false; | ||
|
||
BlockHeadersResponse other = (BlockHeadersResponse) o; | ||
if (!Objects.deepEquals(this.blocks, other.blocks)) return false; | ||
if (!Objects.deepEquals(this.currentRound, other.currentRound)) return false; | ||
if (!Objects.deepEquals(this.nextToken, other.nextToken)) return false; | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.