Update API.md

This commit is contained in:
Alex 2021-04-13 16:28:06 -04:00 committed by GitHub
parent 56da9e0d76
commit cc068d1eb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,7 @@ In general, requests will take the format of `curl -H "Authorization: Bearer <YO
### Network API Call Examples ### Network API Call Examples
**Get All Networks:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks | jq` **Get All Networks:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks | jq`
**Create Network:** `curl -d '{"addressrange":"10.70.0.0/16","netid":"skynet"}' -H "Authorization: Bearer YOUR_SECRET_KEY" -H 'Content-Type: application/json' localhost:8081/api/networks` **Create Network:** `curl -d '{"addressrange":"10.70.0.0/16","netid":"skynet"}' -H "Authorization: Bearer YOUR_SECRET_KEY" -H 'Content-Type: application/json' localhost:8081/api/networks`
@ -49,16 +50,20 @@ In general, requests will take the format of `curl -H "Authorization: Bearer <YO
**Delete Key:** `/api/networks/{network id}/keys/{keyname}`, `DELETE` **Delete Key:** `/api/networks/{network id}/keys/{keyname}`, `DELETE`
### Access Key API Call Examples ### Access Key API Call Examples
**Get All Keys:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks/skynet/keys | jq` **Get All Keys:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks/skynet/keys | jq`
**Create Key:** `curl -d '{"uses":10,"name":"mykey"}' -H "Authorization: Bearer YOUR_SECRET_KEY" -H 'Content-Type: application/json' localhost:8081/api/networks/skynet/keys` **Create Key:** `curl -d '{"uses":10,"name":"mykey"}' -H "Authorization: Bearer YOUR_SECRET_KEY" -H 'Content-Type: application/json' localhost:8081/api/networks/skynet/keys`
**Delete Key:** `curl -X DELETE -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks/skynet/keys/mykey` **Delete Key:** `curl -X DELETE -H "Authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/networks/skynet/keys/mykey`
## NODES (COMPUTERS) ## NODES (COMPUTERS)
**Get All Nodes:** `/api/nodes`, `GET` **Get All Nodes:** `/api/nodes`, `GET`
**Get Network Nodes:** `/api/nodes/{network id}`, `GET` **Get Network Nodes:** `/api/nodes/{network id}`, `GET`
@ -83,8 +88,10 @@ In general, requests will take the format of `curl -H "Authorization: Bearer <YO
**Authenticate:** `/api/nodes/adm/{network id}/authenticate`, `POST` **Authenticate:** `/api/nodes/adm/{network id}/authenticate`, `POST`
### Example Node API Calls ### Example Node API Calls
**Get All Nodes:**`curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/nodes | jq` **Get All Nodes:**`curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/nodes | jq`
**Get Network Nodes:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/nodes/skynet | jq` **Get Network Nodes:** `curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/nodes/skynet | jq`
@ -107,8 +114,10 @@ In general, requests will take the format of `curl -H "Authorization: Bearer <YO
**Authenticate:** `curl -d '{"macaddress": "8c:90:b5:06:f1:d9", "password": "YOUR_PASSWORD"}' -H 'Content-Type: application/json' localhost:8081/api/nodes/adm/skynet/authenticate` **Authenticate:** `curl -d '{"macaddress": "8c:90:b5:06:f1:d9", "password": "YOUR_PASSWORD"}' -H 'Content-Type: application/json' localhost:8081/api/nodes/adm/skynet/authenticate`
## USERS ## USERS
**Note:** Only able to create Admin user at this time. The "user" is only used by the [user interface](https://github.com/gravitl/netmaker-ui) to authenticate the single admin user. **Note:** Only able to create Admin user at this time. The "user" is only used by the [user interface](https://github.com/gravitl/netmaker-ui) to authenticate the single admin user.
**Get User:** `/api/users/{username}`, `GET` **Get User:** `/api/users/{username}`, `GET`
@ -123,6 +132,10 @@ In general, requests will take the format of `curl -H "Authorization: Bearer <YO
**Authenticate:** `/api/users/adm/authenticate`, `POST` **Authenticate:** `/api/users/adm/authenticate`, `POST`
### Example User API Calls
**Get User:**`curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/users/{username} | jq` **Get User:**`curl -H "Authorization: Bearer YOUR_SECRET_KEY" http://localhost:8081/api/users/{username} | jq`
**Update User:** `curl -X PUT -d '{"password":"noonewillguessthis"}' -H 'Content-Type: application/json' -H "authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/users/{username}` **Update User:** `curl -X PUT -d '{"password":"noonewillguessthis"}' -H 'Content-Type: application/json' -H "authorization: Bearer YOUR_SECRET_KEY" localhost:8081/api/users/{username}`
@ -148,4 +161,5 @@ The Server Mgmt. API allows you to add and remove the server from networks.
## FILE SERVER ## FILE SERVER
**Get File:** `/meshclient/files/{filename}`, `GET` **Get File:** `/meshclient/files/{filename}`, `GET`
**Example:** `curl localhost:8081/meshclient/files/meshclient` **Example:** `curl localhost:8081/meshclient/files/meshclient`