Skip to content

Commit

Permalink
Merge pull request #230 from sinamics/extend_api
Browse files Browse the repository at this point in the history
Extend API endpoints
  • Loading branch information
sinamics authored Dec 9, 2023
2 parents 7071837 + 8469b4d commit 6e2188d
Show file tree
Hide file tree
Showing 17 changed files with 813 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ yarn-error.log*

# typescript
*.tsbuildinfo
zeronsd.sh*
3 changes: 2 additions & 1 deletion docs/ztnet/docs/Rest Api/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.mdx
*.mdx
*.js
80 changes: 77 additions & 3 deletions docs/ztnet/docs/Rest Api/_example/NetworkExample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ NetworkExample:
creationTime: 1698676570111
dns: []
enableBroadcast: true
id: "network_id"
id: "8056c2e21c000001"
ipAssignmentPools:
- ipRangeEnd: "172.25.25.254"
ipRangeStart: "172.25.25.1"
mtu: 2800
multicastLimit: 32
name: "slimy-earwig"
nwid: "network_id"
nwid: "8056c2e21c000001"
objtype: "network"
private: true
remoteTraceLevel: 0
Expand All @@ -34,4 +34,78 @@ NetworkExample:
v6AssignMode:
6plane: false
rfc4193: false
zt: false
zt: false

NetworkArrayExample:
- authTokens: [null]
authorizationEndpoint: ""
capabilities: []
clientId: ""
creationTime: 1698676570111
dns: []
enableBroadcast: true
id: "8056c2e21c000001"
ipAssignmentPools:
- ipRangeEnd: "172.25.25.254"
ipRangeStart: "172.25.25.1"
mtu: 2800
multicastLimit: 32
name: "slimy-earwig"
nwid: "8056c2e21c000001"
objtype: "network"
private: true
remoteTraceLevel: 0
remoteTraceTarget: null
revision: 1
routes:
- target: "172.25.25.0/24"
via: null
rules:
- not: false
or: false
type: "ACTION_ACCEPT"
rulesSource: ""
ssoEnabled: false
tags: []
v4AssignMode:
zt: true
v6AssignMode:
6plane: false
rfc4193: false
zt: false
- authTokens: [null]
authorizationEndpoint: ""
capabilities: []
clientId: ""
creationTime: 1698676570111
dns: []
enableBroadcast: true
id: "8056c2e21c000001"
ipAssignmentPools:
- ipRangeEnd: "172.25.25.254"
ipRangeStart: "172.25.25.1"
mtu: 2800
multicastLimit: 32
name: "slimy-earwig"
nwid: "network_id"
objtype: "network"
private: true
remoteTraceLevel: 0
remoteTraceTarget: null
revision: 1
routes:
- target: "172.25.25.0/24"
via: null
rules:
- not: false
or: false
type: "ACTION_ACCEPT"
rulesSource: ""
ssoEnabled: false
tags: []
v4AssignMode:
zt: true
v6AssignMode:
6plane: false
rfc4193: false
zt: false
32 changes: 32 additions & 0 deletions docs/ztnet/docs/Rest Api/_example/NetworkMemberExample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
NetworkMemberExample:
nodeid: 1
id: "abcdef01234"
nwid: "8056c2e21c000001"
lastSeen: "2023-12-09T12:06:24.529Z"
online: false
deleted: false
name: "my-awesome-computer"
address: "abcdef01234"
creationTime: 1702110030561
activeBridge: false
authenticationExpiryTime: 0
authorized: true
capabilities: []
identity: "abcdef0123:0:abcdef0123abcdef0123abcdef0123abcdef0123abcdef0123abcdef0123abcdef0123"
ipAssignments:
- "10.0.0.3"
lastAuthorizedCredential: null
lastAuthorizedCredentialType: "api"
lastAuthorizedTime: 1599853637989
lastDeauthorizedTime: 0
noAutoAssignIps: false
objtype: "member"
remoteTraceLevel: 0
remoteTraceTarget: null
revision: 3
ssoExempt: false
tags: []
vMajor: 1
vMinor: 12
vProto: 12
vRev: 2
102 changes: 102 additions & 0 deletions docs/ztnet/docs/Rest Api/_schema/NetworkMemberResponse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
NetworkMemberResponse:
type: object
properties:
nodeid:
type: integer
description: Node identifier
id:
type: string
description: Unique user identifier
nwid:
type: string
description: Network identifier
lastSeen:
type: string
format: date-time
description: Timestamp of last seen
online:
type: boolean
description: Online status
deleted:
type: boolean
description: Deleted status
name:
type: string
description: Name of the user
address:
type: string
description: Address of the user
creationTime:
type: integer
description: User creation time in milliseconds since epoch
activeBridge:
type: boolean
description: Active bridge status
authenticationExpiryTime:
type: integer
description: Authentication expiry time
authorized:
type: boolean
description: Authorization status
capabilities:
type: array
items:
type: string
description: List of capabilities
identity:
type: string
description: User identity information
ipAssignments:
type: array
items:
type: string
description: IP assignments
lastAuthorizedCredential:
type: string
nullable: true
description: Last authorized credential
lastAuthorizedCredentialType:
type: string
description: Type of the last authorized credential
lastAuthorizedTime:
type: integer
description: Timestamp of the last authorized time
lastDeauthorizedTime:
type: integer
description: Timestamp of the last deauthorized time
noAutoAssignIps:
type: boolean
description: No auto-assign IPs status
objtype:
type: string
description: Object type
remoteTraceLevel:
type: integer
description: Remote trace level
remoteTraceTarget:
type: string
nullable: true
description: Remote trace target
revision:
type: integer
description: Revision number
ssoExempt:
type: boolean
description: SSO exempt status
tags:
type: array
items:
type: string
description: Tags associated with the user
vMajor:
type: integer
description: Major version number
vMinor:
type: integer
description: Minor version number
vProto:
type: integer
description: Protocol version number
vRev:
type: integer
description: Revision version number
2 changes: 1 addition & 1 deletion docs/ztnet/docs/Rest Api/_schema/NetworkResponse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ NetworkResponse:
rfc4193:
type: boolean
zt:
type: boolean
type: boolean
67 changes: 60 additions & 7 deletions docs/ztnet/docs/Rest Api/_source/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ paths:
/network:
get:
summary: Returns a list of Networks you have access to
description: |
Returns an array of Networks you have access to.
operationId: getUserNetworks
parameters:
- name: x-ztnet-auth
Expand All @@ -33,12 +35,63 @@ paths:
content:
application/json:
schema:
type: array
items:
type: string
examples:
example1:
value: ["networkid#1", "networkid#2"]
$ref: '../_schema/NetworkResponse.yml#/NetworkResponse'
example:
$ref: '../_example/NetworkExample.yml#/NetworkArrayExample'
401:
description: Unauthorized
content:
application/json:
schema:
type: object
properties:
error:
type: string
429:
description: Rate limit exceeded
content:
application/json:
schema:
type: object
properties:
error:
type: string
500:
description: Internal server error
content:
application/json:
schema:
type: object
properties:
message:
type: string

/network/{networkId}:
get:
summary: Returns information about a specific network
operationId: getNetworkInfo
parameters:
- name: x-ztnet-auth
in: header
required: true
schema:
type: string
description: API Key for the user
- name: networkId
in: path
required: true
schema:
type: string
description: Unique identifier of the network
responses:
200:
description: Detailed information of the specified Network
content:
application/json:
schema:
$ref: '../_schema/NetworkResponse.yml#/NetworkResponse'
example:
$ref: '../_example/NetworkExample.yml#/NetworkExample'
401:
description: Unauthorized
content:
Expand Down Expand Up @@ -99,7 +152,7 @@ paths:
schema:
$ref: '../_schema/NetworkResponse.yml#/NetworkResponse'
example:
$ref: '../_example/NetworkExample.yml'
$ref: '../_example/NetworkExample.yml#/NetworkExample'

401:
description: Unauthorized
Expand Down
Loading

0 comments on commit 6e2188d

Please sign in to comment.