Skip to content

Commit c5e43a8

Browse files
committed
update registrar readme
1 parent a99c418 commit c5e43a8

File tree

5 files changed

+59
-24
lines changed

5 files changed

+59
-24
lines changed

node-registrar/README.md

Lines changed: 54 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11

22
# Node Registrar Service
33

4+
[![Go Report Card](https://goreportcard.com/badge/github.com/threefoldtech/tfgrid-sdk-go/node-registrar)](https://goreportcard.com/report/github.com/threefoldtech/tfgrid-sdk-go/node-registrar)
5+
[![GoDoc](https://godoc.org/github.com/threefoldtech/tfgrid-sdk-go/node-registrar?status.svg)](https://godoc.org/github.com/threefoldtech/tfgrid-sdk-go/node-registrar)
6+
47
## Overview
58

6-
This project provides an API for registring zos nodes using the Go Gin framework and PostgreSQL database.
7-
The API supports operations like registring, listing, and updating farms and nodes, as well as reporting uptime and consumption data for nodes.
9+
This project provides an API for registring and managing zos nodes on ThreeFold GridV4. Built with the Go Gin framework and PostgreSQL database,
10+
It offers operations like registring, listing, and updating farms and nodes, as well as reporting uptime and consumption data for nodes.
811

912
## Features
1013

@@ -31,25 +34,29 @@ The API supports operations like registring, listing, and updating farms and nod
3134

3235
### Farms Endpoints
3336

34-
1. **GET /farms/** - List all farms, or use FarmFilter to list specific set of farms.
35-
2. **GET /farms/:farm_id** - Get a specific farm by ID.
36-
3. **POST /farms/** - Create a new farm.
37-
4. **PATCH /farms/** - Update an existing farm.
37+
| Method | Endpoint | Description |
38+
|--------|----------|-------------|
39+
| GET | `/farms/` | List all farms with optional filtering |
40+
| GET | `/farms/:farm_id` | Get a specific farm by ID |
41+
| POST | `/farms/` | Create a new farm |
42+
| PATCH | `/farms/` | Update an existing farm |
3843

3944
### Nodes Endpoints
4045

41-
1. **GET /nodes/** - List all nodes, or use NodeFilter to list specific set of nodes.
42-
2. **GET /nodes/:node_id** - Get a specific node by ID.
43-
3. **POST /nodes/** - Register a new node.
44-
4. **POST /nodes/:node_id/uptime** - Report uptime for a specific node.
45-
5. **POST /nodes/:node_id/consumption** - Report consumption for a specific node.
46+
| Method | Endpoint | Description |
47+
|--------|----------|-------------|
48+
| GET | `/nodes/` | List all nodes with optional filtering |
49+
| GET | `/nodes/:node_id` | Get a specific node by ID |
50+
| POST | `/nodes/` | Register a new node |
51+
| POST | `/nodes/:node_id/uptime` | Report uptime for a specific node |
52+
| POST | `/nodes/:node_id/consumption` | Report consumption for a specific node |
4653

4754
## Setup Instructions
4855

4956
1. **Start PostgreSQL:**
5057

5158
```bash
52-
make postgres
59+
make start-postgres
5360
```
5461

5562
2. **Run the Server:**
@@ -125,14 +132,14 @@ X-Auth: Base64(Challenge):Base64(Signature)
125132
**Signature:**
126133
ED25519/SR25519 signature of challenge bytes
127134

128-
## Database Schema
129-
130-
Key Tables:
135+
The service uses a PostgreSQL database with the following key tables:
131136

132-
- `accounts` - Authentication credentials and relay configs
133-
- `farms` - Farm metadata with owner relationship
134-
- `nodes` - Node hardware/resources specification
135-
- `uptime_reports` - Historical node availability data
137+
| Table | Description |
138+
|-------|-------------|
139+
| `accounts` | Authentication credentials and relay configurations |
140+
| `farms` | Farm metadata with owner relationship |
141+
| `nodes` | Node hardware specifications and resources |
142+
| `uptime_reports` | Historical node availability data |
136143

137144
## Development
138145

@@ -141,3 +148,31 @@ Key Tables:
141148
```bash
142149
swag init -g pkg/server/handlers.go --output docs --parseDependency --parseDepth 2
143150
```
151+
152+
## Client Library
153+
154+
A Go client library is available to interact with the Node Registrar Service. See the [client documentation](./client/README.md) for details on installation and usage.
155+
156+
Example usage:
157+
158+
```go
159+
import "github.com/threefoldtech/tfgrid-sdk-go/node-registrar/client"
160+
161+
// Initialize client
162+
cli, err := client.NewRegistrarClient("https://registrar.dev.grid.tf", mnemonic)
163+
164+
// Register a node
165+
nodeID, err := cli.RegisterNode(farmID, twinID, interfaces, location, resources, serialNumber, secureBoot, virtualized)
166+
```
167+
168+
### Generating Swagger Documentation
169+
170+
```bash
171+
swag init -g pkg/server/handlers.go --output docs --parseDependency --parseDepth 2
172+
```
173+
174+
### Running Tests
175+
176+
```bash
177+
make test
178+
```

node-registrar/client/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/pkg/errors"
13-
"github.com/vedhavyas/go-subkey/v2"
13+
subkey "github.com/vedhavyas/go-subkey/v2"
1414
)
1515

1616
var ErrorAccountNotFound = fmt.Errorf("failed to get requested account from node registrar")

node-registrar/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55

66
"github.com/pkg/errors"
7-
"github.com/vedhavyas/go-subkey/v2"
7+
subkey "github.com/vedhavyas/go-subkey/v2"
88
)
99

1010
type RegistrarClient struct {

node-registrar/client/mnemonic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package client
22

33
import (
4-
"github.com/cosmos/go-bip39"
4+
bip39 "github.com/cosmos/go-bip39"
55
"github.com/pkg/errors"
66
subkeyEd25519 "github.com/vedhavyas/go-subkey/v2/ed25519"
77

8-
"github.com/vedhavyas/go-subkey/v2"
8+
subkey "github.com/vedhavyas/go-subkey/v2"
99
)
1010

1111
func (c *RegistrarClient) Mnemonic() string {

node-registrar/pkg/server/sigverifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package server
22

33
import (
44
"github.com/pkg/errors"
5-
"github.com/vedhavyas/go-subkey/v2"
5+
subkey "github.com/vedhavyas/go-subkey/v2"
66
"github.com/vedhavyas/go-subkey/v2/ed25519"
77
"github.com/vedhavyas/go-subkey/v2/sr25519"
88
)

0 commit comments

Comments
 (0)