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
49561 . ** Start PostgreSQL:**
5057
5158 ``` bash
52- make postgres
59+ make start- postgres
5360 ```
5461
55622 . ** Run the Server:**
@@ -125,14 +132,14 @@ X-Auth: Base64(Challenge):Base64(Signature)
125132** Signature:**
126133ED25519/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
142149swag 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+ ```
0 commit comments