Skip to content

Commit

Permalink
Merge branch 'vitaly/Enpoints-Documentation-Edits' into 'develop'
Browse files Browse the repository at this point in the history
Vitaly/enpoints documentation edits

See merge request vvol/oasis-api-server!18
  • Loading branch information
Vitaly committed May 20, 2020
2 parents 232cd9b + 236b552 commit cb68157
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 152 deletions.
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
## 1.0.2

Released on May 2020

### Changed

* Changed endpoints by removing trailing `/` E.G `/api/ping/` is now `/api/ping`


## 1.0.1

Released on May 2020

### Changed

* Updated Tendermint Version together with Oasis-Core version.
* This update changes blocklast commits from Precommits to Signatures

Expand Down
72 changes: 36 additions & 36 deletions docs/DESIGN_AND_FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,43 @@ The API Server works as follows:
6. [Sentry](https://godoc.org/github.com/oasislabs/oasis-core/go/sentry/api#Backend)

## Complete List of Endpoints
| API Endpoint | Required Inputs | Optional Inputs | Output | Description |
| API Endpoint | Required Inputs | Optional Inputs | Output |
|----------------------------------|---------------------------------|-----------------|---------------------------|-------------------------------------------------------------------------------------|
| /api/ping/ | none | none | Pong |
| /api/getconnectionslist/ | none | none | List of Connections |
| /api/consensus/genesis/ | Node Name | Height | Consensus Genesis State |
| /api/consensus/epoch/ | Node Name | Height | Epoch |
| /api/consensus/block/ | Node Name | Height | Block Object |
| /api/consensus/blockheader/ | Node Name | Height | Block Header Object |
| /api/consensus/blocklastcommit/ | Node Name | Height | Block Last Commit Object |
| /api/consensus/pubkeyaddress/ | Consensus Public Key | none | Tendermint Key Address |
| /api/consensus/transactions/ | Node Name | Height | List of Transactions |
| /api/pingnode/ | Node Name | None | Pong |
| /api/registry/entities/ | Node Name | Height | List of entities |
| /api/registry/nodes/ | Node Name | Height | List of Nodes |
| /api/registry/runtimes/ | Node Name | Height | List of RunTimes |
| /api/registry/genesis/ | Node Name | Height | Genesis State of Registry |
| /api/registry/entity/ | Node Name, Entity Public Key | Height | Entity |
| /api/registry/node/ | Node Name, Node Public Key | Height | Node |
| /api/registry/runtime/ | Node Name, Runtime Namespace | Height | Runtime |
| /api/staking/totalsupply/ | Node Name | Height | Total Supply |
| /api/staking/commonpool/ | Node Name | Height | Common Pool |
| /api/staking/genesis/ | Node Name | Height | Staking Genesis State |
| /api/staking/threshold/ | Node Name, kind | Height | Threshold |
| /api/staking/accounts/ | Node Name | Height | List of accounts |
| /api/staking/accountinfo/ | Node Name, Account Public Key | Height | Account information |
| /api/staking/delegations/ | Node Name, Account Public Key | Height | Delegations |
| /api/staking/debondingdelegations/ | Node Name, Account Public Key | Height | DebondingDelegations |
| /api/staking/events/ | Node Name | Height | List of Events |
| /api/nodecontroller/synced/ | Node Name | None | Synchronized State |
| /api/scheduler/validators/ | Node Name | Height | List of Validators |
| /api/scheduler/committees/ | Node Name, Namespace | Height | Committees |
| /api/scheduler/genesis/ | Node Name | Height | Scheduler Genesis State |
| /api/prometheus/gauge/ | Node Name, Gauge Name | none | Gauge Value |
| /api/prometheus/counter/ | Node Name, Counter Name | none | Counter Value |
| /api/exporter/gauge/ | Gauge Name | none | Gauge Value |
| /api/exporter/counter/ | Counter Name | none | Counter Value |
| /api/sentry/addresses/ | Node Name | none | Nodes Connected to Sentry |
| /api/ping | none | none | Pong |
| /api/getconnectionslist | none | none | List of Connections |
| /api/consensus/genesis | Node Name | Height | Consensus Genesis State |
| /api/consensus/epoch | Node Name | Height | Epoch |
| /api/consensus/block | Node Name | Height | Block Object |
| /api/consensus/blockheader | Node Name | Height | Block Header Object |
| /api/consensus/blocklastcommit | Node Name | Height | Block Last Commit Object |
| /api/consensus/pubkeyaddress | Consensus Public Key | none | Tendermint Key Address |
| /api/consensus/transactions | Node Name | Height | List of Transactions |
| /api/pingnode | Node Name | None | Pong |
| /api/registry/entities | Node Name | Height | List of entities |
| /api/registry/nodes | Node Name | Height | List of Nodes |
| /api/registry/runtimes | Node Name | Height | List of RunTimes |
| /api/registry/genesis | Node Name | Height | Genesis State of Registry |
| /api/registry/entity | Node Name, Entity Public Key | Height | Entity |
| /api/registry/node | Node Name, Node Public Key | Height | Node |
| /api/registry/runtime | Node Name, Runtime Namespace | Height | Runtime |
| /api/staking/totalsupply | Node Name | Height | Total Supply |
| /api/staking/commonpool | Node Name | Height | Common Pool |
| /api/staking/genesis | Node Name | Height | Staking Genesis State |
| /api/staking/threshold | Node Name, kind | Height | Threshold |
| /api/staking/accounts | Node Name | Height | List of accounts |
| /api/staking/accountinfo | Node Name, Account Public Key | Height | Account information |
| /api/staking/delegations | Node Name, Account Public Key | Height | Delegations |
| /api/staking/debondingdelegations | Node Name, Account Public Key | Height | DebondingDelegations |
| /api/staking/events | Node Name | Height | List of Events |
| /api/nodecontroller/synced | Node Name | None | Synchronized State |
| /api/scheduler/validators | Node Name | Height | List of Validators |
| /api/scheduler/committees | Node Name, Namespace | Height | Committees |
| /api/scheduler/genesis | Node Name | Height | Scheduler Genesis State |
| /api/prometheus/gauge | Node Name, Gauge Name | none | Gauge Value |
| /api/prometheus/counter | Node Name, Counter Name | none | Counter Value |
| /api/exporter/gauge | Gauge Name | none | Gauge Value |
| /api/exporter/counter | Counter Name | none | Counter Value |
| /api/sentry/addresses | Node Name | none | Nodes Connected to Sentry |

## Using the API

Expand Down
6 changes: 3 additions & 3 deletions docs/INSTALL_AND_RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ git clone https://github.com/SimplyVC/oasis_api_server
Then run the following commands to build the image:
```bash
cd oasis_api_server
docker build -t simplyvc/oasis_api_server:1.0.0 .
docker build -t simplyvc/oasis_api_server:1.0.2 .
```


##### Downloading the Pre-Built Docker Image from DockerHub

The pre-built Docker image can simply be downloaded by running the following command:
```bash
docker pull simplyvc/oasis_api_server:1.0.0
docker pull simplyvc/oasis_api_server:1.0.2
```

#### Config Files Directory and Permissions
Expand All @@ -175,7 +175,7 @@ docker run --network="host" -p 127.0.0.1:8686:8686 \
--mount type=bind,source=<CONFIG_DIR>,target=/app/config/ \
--mount type=bind,source=<INTERNAL_SOCK_DIR>,target=<PATH_IN_NODE_CONFIG> \
--mount type=bind,source=<INTERNAL_TLS_DIR>,target=<PATH_IN_SENTRY_CONFIG> \
-d simplyvc/oasis_api_server:1.0.0
-d simplyvc/oasis_api_server:1.0.2
```

Note: The port after `-p` and before the `:` can be used to route a port from the machine to the internal port of the Docker. If changing this, any program which refers to the API Docker container must refer to this port.\
Expand Down
Binary file modified docs/OASIS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/resources/Oasis_API_Cover.xcf
Binary file not shown.
42 changes: 21 additions & 21 deletions src/handlers/consensus_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ func GetConsensusStateToGenesis(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to get Genesis file of Block!"})

lgr.Error.Println("Request at /api/GetStateToGenesis/ failed "+
lgr.Error.Println("Request at /api/consensus/genesis failed "+
"to retrieve genesis file : ", err)
return
}

// Responding with consensus genesis state object, retrieved above.
lgr.Info.Println("Request at /api/GetStateToGenesis/ responding with" +
lgr.Info.Println("Request at /api/consensus/genesis responding with" +
" genesis file!")
json.NewEncoder(w).Encode(responses.ConsensusGenesisResponse{
GenJSON: consensusGenesis})
Expand Down Expand Up @@ -145,13 +145,13 @@ func GetEpoch(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to retrieve Epoch of Block!"})

lgr.Error.Println("Request at /api/consensus/epoch/ failed to"+
lgr.Error.Println("Request at /api/consensus/epoch failed to"+
" retrieve Epoch : ", err)
return
}

// Respond with retrieved epoch above
lgr.Info.Println("Request at /api/consensus/epoch/ responding" +
lgr.Info.Println("Request at /api/consensus/epoch responding" +
" with an Epoch!")
json.NewEncoder(w).Encode(responses.EpochResponse{Ep: epoch})
}
Expand All @@ -162,7 +162,7 @@ func PingNode(w http.ResponseWriter, r *http.Request) {

// Add header so that received knows they're receiving JSON
w.Header().Add("Content-Type", "application/json")
lgr.Info.Println("Received request for /api/pingnode/")
lgr.Info.Println("Received request for /api/pingnode")

// Retrieving name of node from query request
nodeName := r.URL.Query().Get("name")
Expand Down Expand Up @@ -202,13 +202,13 @@ func PingNode(w http.ResponseWriter, r *http.Request) {
Error: "Failed to ping node by retrieving highest " +
"block height!"})

lgr.Error.Println("Request at /api/pingnode/ failed to ping"+
lgr.Error.Println("Request at /api/pingnode failed to ping"+
" node : ", err)
return
}

// Responding with Pong response
lgr.Info.Println("Request at /api/pingnode/ responding with Pong!")
lgr.Info.Println("Request at /api/pingnode responding with Pong!")
json.NewEncoder(w).Encode(responses.SuccessResponsed)
}

Expand Down Expand Up @@ -263,14 +263,14 @@ func GetBlock(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to retrieve Block!"})

lgr.Error.Println("Request at /api/consensus/block/ failed "+
lgr.Error.Println("Request at /api/consensus/block failed "+
"to retrieve Block : ", err)
return
}

// Responding with retrieved block
lgr.Info.Println(
"Request at /api/consensus/block/ responding with Block!")
"Request at /api/consensus/block responding with Block!")
json.NewEncoder(w).Encode(responses.BlockResponse{Blk: blk})
}

Expand Down Expand Up @@ -325,15 +325,15 @@ func GetBlockHeader(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to retrieve Block!"})

lgr.Error.Println("Request at /api/consensus/blockheader/ "+
lgr.Error.Println("Request at /api/consensus/blockheader "+
"failed to retrieve Block : ", err)
return
}

// Creating BlockMeta object
var meta mint_api.BlockMeta
if err := cbor.Unmarshal(blk.Meta, &meta); err != nil {
lgr.Error.Println("Request at /api/consensus/blockheader/ "+
lgr.Error.Println("Request at /api/consensus/blockheader "+
"failed to Unmarshal Block Metadata : ", err)

json.NewEncoder(w).Encode(responses.ErrorResponse{
Expand All @@ -342,7 +342,7 @@ func GetBlockHeader(w http.ResponseWriter, r *http.Request) {
}

// Responds with block header retrieved above
lgr.Info.Println("Request at /api/consensus/blockheader/ responding " +
lgr.Info.Println("Request at /api/consensus/blockheader responding " +
"with Block Header!")
json.NewEncoder(w).Encode(responses.BlockHeaderResponse{
BlkHeader: meta.Header})
Expand Down Expand Up @@ -399,22 +399,22 @@ func GetBlockLastCommit(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to retrieve Block!"})

lgr.Error.Println("Request at /api/consensus/blocklastcommit/"+
lgr.Error.Println("Request at /api/consensus/blocklastcommit "+
"failed to retrieve Block : ", err)
return
}

// Creating BlockMeta object
var meta mint_api.BlockMeta
if err := cbor.Unmarshal(blk.Meta, &meta); err != nil {
lgr.Error.Println("Request at /api/consensus/blocklastcommit/"+
" failed Unmarshal Block Metadata : ", err)
lgr.Error.Println("Request at /api/consensus/blocklastcommit "+
"failed Unmarshal Block Metadata : ", err)
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to Unmarshal Block Metadata!"})
return
}
// Responds with Block Last commit retrieved above
lgr.Info.Println("Request at /api/consensus/blocklastcommit/ " +
lgr.Info.Println("Request at /api/consensus/blocklastcommit " +
"responding with Block Last Commit!")
json.NewEncoder(w).Encode(responses.BlockLastCommitResponse{
BlkLastCommit: meta.LastCommit})
Expand All @@ -440,7 +440,7 @@ func PublicKeyToAddress(w http.ResponseWriter, r *http.Request) {

err := consensusPublicKey.UnmarshalText([]byte(consensusKey))
if err != nil {
lgr.Error.Println("Request at /api/consensus/pubkeyaddress/ "+
lgr.Error.Println("Request at /api/consensus/pubkeyaddress "+
"failed to Unmarshal Consensus PublicKey : ", err)
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to Unmarshal Public Key!"})
Expand All @@ -450,8 +450,8 @@ func PublicKeyToAddress(w http.ResponseWriter, r *http.Request) {
tendermintKey := crypto.PublicKeyToTendermint(consensusPublicKey)
cryptoAddress := tendermintKey.Address()
// Responds with transactions retrieved above
lgr.Info.Println("Request at /api/consensus/pubkeyaddress/ responding" +
" with Tendermint Public Key Address!")
lgr.Info.Println("Request at /api/consensus/pubkeyaddress responding " +
"with Tendermint Public Key Address!")
json.NewEncoder(w).Encode(responses.TendermintAddress{
TendermintAddress: &cryptoAddress})
}
Expand Down Expand Up @@ -508,13 +508,13 @@ func GetTransactions(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to retrieve Transactions!"})

lgr.Error.Println("Request at /api/consensus/transactions/ "+
lgr.Error.Println("Request at /api/consensus/transactions "+
"failed to retrieve Transactions : ", err)
return
}

// Responds with transactions retrieved above
lgr.Info.Println("Request at /api/consensus/transactions/ responding" +
lgr.Info.Println("Request at /api/consensus/transactions responding" +
"with all transactions in specified Block!")
json.NewEncoder(w).Encode(responses.TransactionsResponse{
Transactions: transactions})
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/general_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Pong(w http.ResponseWriter, r *http.Request) {

// Add header so that received knows they're receiving JSON
w.Header().Add("Content-Type", "application/json")
lgr.Info.Println("Received request for /api/pingapi")
lgr.Info.Println("Received request for /api/ping")
json.NewEncoder(w).Encode(responses.SuccessResponsed)
}

Expand Down
4 changes: 2 additions & 2 deletions src/handlers/node_controller_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func GetIsSynced(w http.ResponseWriter, r *http.Request) {
if err != nil {
json.NewEncoder(w).Encode(responses.ErrorResponse{
Error: "Failed to get IsSynced!"})
lgr.Error.Println("Request at /api/nodecontroller/synced/ "+
lgr.Error.Println("Request at /api/nodecontroller/synced "+
"failed to get IsSynced : ", err)
return
}

// Responding with retrieved synchronizatio state above
lgr.Info.Println("Request at /api/nodecontroller/synced/ sending with" +
lgr.Info.Println("Request at /api/nodecontroller/synced sending with" +
" IsSynced State!")
json.NewEncoder(w).Encode(responses.IsSyncedResponse{Synced: synced})
}
Loading

0 comments on commit cb68157

Please sign in to comment.