diff --git a/docs/docs/Rest Api/_example/NetworkMemberExample.yml b/docs/docs/Rest Api/_example/NetworkMemberExample.yml index 21cd3392..96501720 100644 --- a/docs/docs/Rest Api/_example/NetworkMemberExample.yml +++ b/docs/docs/Rest Api/_example/NetworkMemberExample.yml @@ -30,6 +30,19 @@ NetworkMemberExample: vMinor: 12 vProto: 12 vRev: 2 + physicalAddress: null + peers: + address: "abcdef01234" + isBonded: false + latency: -1 + paths: [] + role: "LEAF" + tunneled: false + version: "1.12.2" + versionMajor: 1 + versionMinor: 12 + versionRev: 2 + conStatus: 1 NetworkArrayMemberExample: - nodeid: 1 @@ -63,6 +76,19 @@ NetworkArrayMemberExample: vMinor: 12 vProto: 12 vRev: 2 + physicalAddress: null + peers: + address: "abcdef01234" + isBonded: false + latency: -1 + paths: [] + role: "LEAF" + tunneled: false + version: "1.12.2" + versionMajor: 1 + versionMinor: 12 + versionRev: 2 + conStatus: 1 - nodeid: 2 id: "abcdef01235" nwid: "8056c2e21c000001" @@ -93,4 +119,17 @@ NetworkArrayMemberExample: vMajor: 1 vMinor: 12 vProto: 12 - vRev: 2 \ No newline at end of file + vRev: 2 + physicalAddress: null + peers: + address: "abcdef01234" + isBonded: false + latency: -1 + paths: [] + role: "LEAF" + tunneled: false + version: "1.12.2" + versionMajor: 1 + versionMinor: 12 + versionRev: 2 + conStatus: 1 \ No newline at end of file diff --git a/docs/docs/Rest Api/_schema/NetworkMemberSchema.yml b/docs/docs/Rest Api/_schema/NetworkMemberSchema.yml index b9819885..8721bc81 100644 --- a/docs/docs/Rest Api/_schema/NetworkMemberSchema.yml +++ b/docs/docs/Rest Api/_schema/NetworkMemberSchema.yml @@ -100,3 +100,57 @@ NetworkMemberResponse: vRev: type: integer description: Revision version number + physicalAddress: + type: string + description: External ip address of the user + peers: + type: array + items: + type: object + properties: + address: + type: string + description: Address of the peer + isBonded: + type: boolean + description: Bonded status + latency: + type: integer + description: Latency + paths: + type: array + items: + type: string + description: List of paths + role: + type: string + description: Role of the peer + tunneled: + type: boolean + description: Tunneled status + version: + type: string + description: Version of the peer + versionMajor: + type: integer + description: Major version of the peer + versionMinor: + type: integer + description: Minor version of the peer + versionRev: + type: integer + description: Revision version of the peer + description: List of peers + conStatus: + type: integer + description: | + Connection status + Possible values: + * 0 - Offline: The connection is not established + * 1 - Relayed or DirectLAN: The connection is either relayed or direct within a LAN + * 2 - DirectWAN: The connection is direct over WAN + enum: + - 0 + - 1 + - 2 + \ No newline at end of file diff --git a/src/pages/api/v1/org/[orgid]/network/[nwid]/member/index.ts b/src/pages/api/v1/org/[orgid]/network/[nwid]/member/index.ts index ea012ad2..f3f8c830 100644 --- a/src/pages/api/v1/org/[orgid]/network/[nwid]/member/index.ts +++ b/src/pages/api/v1/org/[orgid]/network/[nwid]/member/index.ts @@ -7,7 +7,6 @@ import { decryptAndVerifyToken } from "~/utils/encryption"; import { handleApiErrors } from "~/utils/errors"; import rateLimit from "~/utils/rateLimit"; import { checkUserOrganizationRole } from "~/utils/role"; -import * as ztController from "~/utils/ztApi"; // Number of allowed requests per minute const limiter = rateLimit({ @@ -91,23 +90,13 @@ export const GET_orgNetworkMembers = async ( // @ts-expect-error const caller = appRouter.createCaller(ctx); - const network = await caller.network - .getNetworkById({ nwid: networkId }) - .then(async (res) => { - return res.network || null; - }); + const response = await caller.network.getNetworkById({ nwid: networkId }); - if (!network) { + if (!response?.network) { return res.status(401).json({ error: "Network not found or access denied." }); } - const ztControllerResponse = await ztController.local_network_detail( - //@ts-expect-error - ctx, - networkId, - false, - ); - return res.status(200).json(ztControllerResponse?.members); + return res.status(200).json(response?.members); } catch (cause) { return handleApiErrors(cause, res); } diff --git a/src/server/api/routers/memberRouter.ts b/src/server/api/routers/memberRouter.ts index 71340f7d..4f6a458a 100644 --- a/src/server/api/routers/memberRouter.ts +++ b/src/server/api/routers/memberRouter.ts @@ -105,7 +105,7 @@ export const networkMemberRouter = createTRPCRouter({ where: { id_nwid: { id: input.id, - nwid: input.nwid, // this should be the value of `nwid` you are looking for + nwid: input.nwid, }, }, }); @@ -114,7 +114,7 @@ export const networkMemberRouter = createTRPCRouter({ where: { id_nwid: { id: input.id, - nwid: input.nwid, // this should be the value of `nwid` you are looking for + nwid: input.nwid, }, }, data: {