import {z} from 'zod' export type LabelRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, projectId?: boolean | undefined, color?: boolean | undefined, isArchived?: boolean | undefined}; export type NetworkDeviceSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, slug?: boolean | undefined, description?: boolean | undefined, hostname?: boolean | undefined, dnsName?: boolean | undefined, otherAddresses?: boolean | undefined, discoveredName?: boolean | undefined, discoveredNameSource?: boolean | undefined, discoveredDetails?: boolean | undefined, macAddress?: boolean | undefined, isMacAddressLearned?: boolean | undefined, probeId?: boolean | undefined, siteId?: boolean | undefined, oidTemplateId?: boolean | undefined, snmpCredentialProfileId?: boolean | undefined, currentMonitorStatusId?: boolean | undefined, monitoringMethod?: boolean | undefined, deviceRole?: boolean | undefined, networkDeviceRoleId?: boolean | undefined, monitorId?: boolean | undefined, snmpVersion?: boolean | undefined, snmpCommunityString?: boolean | undefined, snmpPort?: boolean | undefined, snmpV3Auth?: boolean | undefined, snmpV3SecurityLevel?: boolean | undefined, snmpV3Username?: boolean | undefined, snmpV3AuthProtocol?: boolean | undefined, snmpV3AuthKey?: boolean | undefined, snmpV3PrivProtocol?: boolean | undefined, snmpV3PrivKey?: boolean | undefined, isPollingEnabled?: boolean | undefined, pollingIntervalInMinutes?: boolean | undefined, walkInterfaces?: boolean | undefined, collectEndpoints?: boolean | undefined, snmpOids?: boolean | undefined, snmpTables?: boolean | undefined, autoApplyVendorHealthTemplate?: boolean | undefined, nextPollAt?: boolean | undefined, lastWalkLog?: boolean | undefined, sysDescr?: boolean | undefined, sysName?: boolean | undefined, sysObjectId?: boolean | undefined, sysLocation?: boolean | undefined, sysContact?: boolean | undefined, vendor?: boolean | undefined, deviceModel?: boolean | undefined, serialNumber?: boolean | undefined, firmwareVersion?: boolean | undefined, softwareVersion?: boolean | undefined, lastRebootedAt?: boolean | undefined, cdpNeighbors?: boolean | undefined, lldpNeighbors?: boolean | undefined, snmpTableSnapshot?: boolean | undefined, transceiverSnapshot?: boolean | undefined, lastSeenAt?: boolean | undefined, lastPolledAt?: boolean | undefined, isReachable?: boolean | undefined, isSnmpReachable?: boolean | undefined, lastSnmpSeenAt?: boolean | undefined, refreshRequestedAt?: boolean | undefined, interfacesTotal?: boolean | undefined, interfacesUp?: boolean | undefined, interfacesDown?: boolean | undefined, createdByUserId?: boolean | undefined, isArchived?: boolean | undefined, archivedAt?: boolean | undefined, archivedByUserId?: boolean | undefined, deletedByUserId?: boolean | undefined, labels?: LabelRelationSelectSchema | undefined}; export type CreateApiNetworkDeviceIdGetItemArgs = {id: string, body: {select?: NetworkDeviceSelectSchema | undefined}}; export type CreateApiNetworkDeviceIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const networkDevice = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), projectId: z.string(), name: z.string(), slug: z.string(), description: z.string().optional(), hostname: z.string(), dnsName: z.string().optional(), otherAddresses: z.string().optional(), discoveredName: z.string().optional(), discoveredNameSource: z.string().optional(), discoveredDetails: z.object({}).optional(), macAddress: z.string().optional(), isMacAddressLearned: z.boolean().optional(), probeId: z.string().optional(), siteId: z.string().optional(), oidTemplateId: z.string().optional(), snmpCredentialProfileId: z.string().optional(), currentMonitorStatusId: z.string().optional(), monitoringMethod: z.string().optional(), deviceRole: z.string().optional(), networkDeviceRoleId: z.string().optional(), monitorId: z.string().optional(), snmpVersion: z.string().optional(), snmpCommunityString: z.string().optional(), snmpPort: z.number().optional(), snmpV3Auth: z.object({}).optional(), snmpV3SecurityLevel: z.string().optional(), snmpV3Username: z.string().optional(), snmpV3AuthProtocol: z.string().optional(), snmpV3AuthKey: z.string().optional(), snmpV3PrivProtocol: z.string().optional(), snmpV3PrivKey: z.string().optional(), isPollingEnabled: z.boolean(), pollingIntervalInMinutes: z.number().optional(), walkInterfaces: z.boolean(), collectEndpoints: z.boolean(), snmpOids: z.object({}).optional(), snmpTables: z.object({}).optional(), autoApplyVendorHealthTemplate: z.boolean(), nextPollAt: z.object({}), lastWalkLog: z.object({}).optional(), sysDescr: z.string().optional(), sysName: z.string().optional(), sysObjectId: z.string().optional(), sysLocation: z.string().optional(), sysContact: z.string().optional(), vendor: z.string().optional(), deviceModel: z.string().optional(), serialNumber: z.string().optional(), firmwareVersion: z.string().optional(), softwareVersion: z.string().optional(), lastRebootedAt: z.object({}).optional(), cdpNeighbors: z.object({}).optional(), lldpNeighbors: z.object({}).optional(), snmpTableSnapshot: z.object({}).optional(), transceiverSnapshot: z.object({}).optional(), lastSeenAt: z.object({}).optional(), lastPolledAt: z.object({}).optional(), isReachable: z.boolean().optional(), isSnmpReachable: z.boolean().optional(), lastSnmpSeenAt: z.object({}).optional(), refreshRequestedAt: z.object({}).optional(), interfacesTotal: z.number().optional(), interfacesUp: z.number().optional(), interfacesDown: z.number().optional(), createdByUserId: z.string().optional(), isArchived: z.boolean(), archivedAt: z.object({}).optional(), archivedByUserId: z.string().optional(), deletedByUserId: z.string().optional(), labels: z.array(z.object({_id: z.string().optional()})).optional()}); export const createApiNetworkDeviceIdGetItemResponse = z.object({data: networkDevice.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Get Network Device * * POST /network-device/{id}/get-item */ export const createApiNetworkDeviceIdGetItem = async (args: CreateApiNetworkDeviceIdGetItemArgs, options?: CreateApiNetworkDeviceIdGetItemOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/network-device/${encodeURIComponent(String(args.id))}/get-item${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiNetworkDeviceIdGetItemResponse, await res.json()) };