@js4cytoscape/ndex-client 0.5.0-alpha.9 → 0.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,653 @@
1
+ import { HTTPService } from './HTTPService';
2
+ import { NetworkServiceV2 } from './NetworkServiceV2';
3
+ import { NetworkServiceV3 } from './NetworkServiceV3';
4
+ import {
5
+ NetworkSummaryV3,
6
+ PaginationParams,
7
+ AccessParams,
8
+ CX2Network as CX2NetworkType,
9
+ CX2Edge,
10
+ CX1Edge,
11
+ CX2MetaData,
12
+ NetworkPermission
13
+ } from '../types';
14
+ import { CX2Network } from '../models/CX2Network';
15
+
16
+ /**
17
+ * UnifiedNetworkService - Provides access to both V2/V3 network services
18
+ * Allows individual function calls to choose between v2 and v3 APIs
19
+ */
20
+ export class UnifiedNetworkService {
21
+ private v2Service: NetworkServiceV2;
22
+ private v3Service: NetworkServiceV3;
23
+
24
+ constructor(private http: HTTPService) {
25
+ this.v2Service = new NetworkServiceV2(http);
26
+ this.v3Service = new NetworkServiceV3(http);
27
+ }
28
+
29
+ /**
30
+ * Get network summary using specified API version
31
+ */
32
+ async getNetworkSummary(
33
+ networkUUID: string,
34
+ options: AccessParams = {}
35
+ ): Promise<NetworkSummaryV3> {
36
+ return this.v3Service.getNetworkSummary(networkUUID, options);
37
+ }
38
+
39
+ /**
40
+ * Search networks using specified API version
41
+ * NOTE: This method is temporarily commented out as the V2 searchNetworks
42
+ * signature has been migrated from NDEx.js and needs separate integration
43
+ */
44
+ // async searchNetworks(
45
+ // searchParams: SearchParameters & { useV3?: boolean } = {}
46
+ // ): Promise<SearchResult> {
47
+ // const { useV3, ...params } = searchParams;
48
+ //
49
+ // if (useV3) {
50
+ // return this.v3Service.searchNetworks(params);
51
+ // }
52
+ //
53
+ // return this.v2Service.searchNetworks(params);
54
+ // }
55
+
56
+
57
+ /**
58
+ * Get network in CX1 format (V2 API)
59
+ */
60
+ async getRawCX1Network(
61
+ networkUUID: string,
62
+ options: AccessParams = {}
63
+ ): Promise<any[]> {
64
+ return this.v2Service.getRawCX1Network(networkUUID, options);
65
+ }
66
+
67
+ /**
68
+ * Get network in CX2 format (V3 API)
69
+ */
70
+ async getRawCX2Network(
71
+ networkUUID: string,
72
+ options: AccessParams = {}
73
+ ): Promise<CX2NetworkType> {
74
+ return this.v3Service.getRawCX2Network(networkUUID, options);
75
+ }
76
+
77
+
78
+
79
+ /**
80
+ * Delete network
81
+ */
82
+ async deleteNetwork(networkUUID: string): Promise<void> {
83
+ return this.v2Service.deleteNetwork(networkUUID);
84
+ }
85
+
86
+
87
+ /**
88
+ * Create network DOI
89
+ *
90
+ * @param networkUUID - The UUID of the network to create a DOI for
91
+ * @param key - DOI creation key
92
+ * @param email - Email address for DOI registration
93
+ * @returns Promise resolving to a confirmation message string from the server
94
+ */
95
+ async createNetworkDOI(
96
+ networkUUID: string,
97
+ key: string,
98
+ email: string
99
+ ): Promise<string> {
100
+ return this.v3Service.createNetworkDOI(networkUUID, key, email);
101
+ }
102
+
103
+ /**
104
+ * Get attributes of selected nodes
105
+ *
106
+ * Retrieves specific attributes for a set of nodes in a network. The server will return
107
+ * a 404 error if the network has no attributes on nodes.
108
+ *
109
+ * @param networkUUID - The UUID of the network
110
+ * @param nodeSelection - Object containing node IDs and attribute names to retrieve
111
+ * @param nodeSelection.ids - Array of node IDs (long numbers) to get attributes for
112
+ * @param nodeSelection.attributeNames - Array of attribute names to retrieve
113
+ * @param options - Access options including optional access key
114
+ * @returns Promise resolving to a JSON object where keys are stringified node IDs
115
+ * and values are the selected attributes for that node
116
+ * @throws {404} When the network has no attributes on nodes
117
+ */
118
+ async getAttributesOfSelectedNodes(
119
+ networkUUID: string,
120
+ nodeSelection: { ids: number[]; attributeNames: string[] },
121
+ options: AccessParams = {}
122
+ ): Promise<Record<string, any>> {
123
+ return this.v3Service.getAttributesOfSelectedNodes(networkUUID, nodeSelection, options);
124
+ }
125
+
126
+ /**
127
+ * Neighborhood query (migrated from original NDEx.js)
128
+ *
129
+ * Performs a neighborhood search within a network, returning nodes and edges
130
+ * within the specified search depth from nodes matching the search terms.
131
+ * Can return either raw CX1 or CX2 format based on outputCX2 parameter.
132
+ *
133
+ * @param networkUUID - The UUID of the network to search
134
+ * @param searchTerms - Search string to find starting nodes
135
+ * @param saveResult - Whether to save the query result as a new network
136
+ * @param parameters - Additional query parameters
137
+ * @param parameters.searchDepth - How many hops to search (default: 1)
138
+ * @param parameters.edgeLimit - Maximum number of edges to return
139
+ * @param parameters.errorWhenLimitIsOver - Throw error if edge limit exceeded
140
+ * @param parameters.directOnly - Only include direct connections
141
+ * @param parameters.nodeIds - Specific node IDs to start search from
142
+ * @param outputCX2 - If true, return CX2 format via V3 API; if false, return CX1 format via V2 API
143
+ * @returns Promise resolving to raw CX1 or CX2 network data
144
+ */
145
+ async neighborhoodQuery(
146
+ networkUUID: string,
147
+ searchTerms: string,
148
+ saveResult?: boolean,
149
+ parameters?: {
150
+ searchDepth?: number;
151
+ edgeLimit?: number;
152
+ errorWhenLimitIsOver?: boolean;
153
+ directOnly?: boolean;
154
+ nodeIds?: number[];
155
+ },
156
+ outputCX2: boolean = false
157
+ ): Promise<any[] | CX2NetworkType> {
158
+ const params: Record<string, string> = {};
159
+
160
+ if (saveResult !== undefined && saveResult === true) {
161
+ params.save = 'true';
162
+ }
163
+
164
+ const data: Record<string, any> = {
165
+ searchString: searchTerms,
166
+ searchDepth: 1
167
+ };
168
+
169
+ if (parameters !== undefined) {
170
+ if (parameters.searchDepth !== undefined) {
171
+ data.searchDepth = parameters.searchDepth;
172
+ }
173
+ if (parameters.edgeLimit !== undefined) {
174
+ data.edgeLimit = parameters.edgeLimit;
175
+ }
176
+ if (parameters.errorWhenLimitIsOver !== undefined) {
177
+ data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;
178
+ }
179
+ if (parameters.directOnly !== undefined) {
180
+ data.directOnly = parameters.directOnly;
181
+ }
182
+ if (parameters.nodeIds != null) {
183
+ data.nodeIds = parameters.nodeIds;
184
+ }
185
+ }
186
+
187
+ if (outputCX2) {
188
+ const endpoint = `search/network/${networkUUID}/query`;
189
+ return this.http.post<CX2NetworkType>(endpoint, data, {
190
+ version: 'v3',
191
+ params
192
+ });
193
+ }
194
+
195
+ const endpoint = `search/network/${networkUUID}/query`;
196
+ return this.http.post<any[]>(endpoint, data, {
197
+ version: 'v2',
198
+ params
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Interconnect query (migrated from original NDEx.js)
204
+ *
205
+ * Finds connections between nodes matching the search terms within a network.
206
+ * Returns the interconnected subnetwork as either raw CX1 or CX2 format.
207
+ * Can return either raw CX1 or CX2 format based on outputCX2 parameter.
208
+ *
209
+ * @param networkUUID - The UUID of the network to search
210
+ * @param searchTerms - Search string to find nodes to interconnect
211
+ * @param saveResult - Whether to save the query result as a new network
212
+ * @param parameters - Additional query parameters
213
+ * @param parameters.edgeLimit - Maximum number of edges to return
214
+ * @param parameters.errorWhenLimitIsOver - Throw error if edge limit exceeded
215
+ * @param parameters.nodeIds - Specific node IDs to find connections between
216
+ * @param outputCX2 - If true, return CX2 format via V3 API; if false, return CX1 format via V2 API
217
+ * @returns Promise resolving to raw CX1 or CX2 network data
218
+ */
219
+ async interConnectQuery(
220
+ networkUUID: string,
221
+ searchTerms: string,
222
+ saveResult?: boolean,
223
+ parameters?: {
224
+ edgeLimit?: number;
225
+ errorWhenLimitIsOver?: boolean;
226
+ nodeIds?: number[];
227
+ },
228
+ outputCX2: boolean = false
229
+ ): Promise<any[] | CX2NetworkType> {
230
+ const params: Record<string, string> = {};
231
+
232
+ if (saveResult !== undefined && saveResult === true) {
233
+ params.save = 'true';
234
+ }
235
+
236
+ const data: Record<string, any> = { searchString: searchTerms };
237
+
238
+ if (parameters !== undefined) {
239
+ if (parameters.edgeLimit !== undefined) {
240
+ data.edgeLimit = parameters.edgeLimit;
241
+ }
242
+ if (parameters.errorWhenLimitIsOver !== undefined) {
243
+ data.errorWhenLimitIsOver = parameters.errorWhenLimitIsOver;
244
+ }
245
+ if (parameters.nodeIds != null) {
246
+ data.nodeIds = parameters.nodeIds;
247
+ }
248
+ }
249
+
250
+ if (outputCX2) {
251
+ const endpoint = `search/networks/${networkUUID}/interconnectquery`;
252
+ return this.http.post<CX2NetworkType>(endpoint, data, {
253
+ version: 'v3',
254
+ params
255
+ });
256
+ }
257
+
258
+ const endpoint = `search/network/${networkUUID}/interconnectquery`;
259
+ return this.http.post<any[]>(endpoint, data, {
260
+ version: 'v2',
261
+ params
262
+ });
263
+ }
264
+
265
+ /**
266
+ * Get network permissions by UUIDs (migrated from original NDEx.js)
267
+ *
268
+ * Retrieves network permissions for multiple networks in a single batch request.
269
+ * Uses the V2 API batch endpoint to efficiently get permission information.
270
+ *
271
+ * @param uuidList - Array of network UUIDs to retrieve permissions for
272
+ * @returns Promise resolving to permission information for the specified networks
273
+ */
274
+ async getNetworkPermissionsByUUIDs(uuidList: string[]): Promise<any[]> {
275
+ const endpoint = 'batch/network/permission';
276
+ return this.http.post<any[]>(endpoint, uuidList, { version: 'v2' });
277
+ }
278
+
279
+ /**
280
+ * Export networks (migrated from original NDEx.js)
281
+ *
282
+ * Creates an export job for networks using the V2 batch export endpoint.
283
+ * This allows exporting multiple networks in various formats.
284
+ *
285
+ * @param exportJob - Export job configuration specifying networks and format
286
+ * @returns Promise resolving to export job result
287
+ */
288
+ async exportNetworks(exportJob: any): Promise<any> {
289
+ const endpoint = 'batch/network/export';
290
+ return this.http.post<any>(endpoint, exportJob, { version: 'v2' });
291
+ }
292
+
293
+ /**
294
+ * Move networks to folder (migrated from original NDEx.js)
295
+ *
296
+ * Moves multiple networks to a specified folder using the V3 API.
297
+ * This is a V3-specific feature for organizing networks in folders.
298
+ *
299
+ * @param networkIds - Array of network IDs to move
300
+ * @param folderId - Target folder ID to move networks to
301
+ * @returns Promise resolving when networks are moved
302
+ */
303
+ async moveNetworks(networkIds: string[], folderId: string): Promise<any> {
304
+ if (!Array.isArray(networkIds)) {
305
+ throw new Error('Invalid networkIds - must be an array');
306
+ }
307
+
308
+ const endpoint = 'batch/networks/move';
309
+ const data = {
310
+ targetFolder: folderId,
311
+ networks: networkIds
312
+ };
313
+
314
+ return this.http.post<any>(endpoint, data, { version: 'v3' });
315
+ }
316
+
317
+ /**
318
+ * Set networks visibility (migrated from original NDEx.js)
319
+ *
320
+ * Changes visibility settings for multiple networks using the V3 API.
321
+ * Requires proper file validation to ensure data integrity.
322
+ *
323
+ * @param files - Object containing files with their types (must have 'files' property)
324
+ * @param visibility - Visibility setting (e.g., 'PUBLIC', 'PRIVATE')
325
+ * @returns Promise resolving when visibility is updated
326
+ */
327
+ async setNetworksVisibility(
328
+ files: { files: Record<string, 'NETWORK' | 'FOLDER' | 'SHORTCUT'> },
329
+ visibility: string
330
+ ): Promise<any> {
331
+ this.validateShareData(files);
332
+
333
+ const endpoint = 'batch/networks/visibility';
334
+ const data = {
335
+ items: files,
336
+ visibility: visibility
337
+ };
338
+
339
+ return this.http.post<any>(endpoint, data, { version: 'v3' });
340
+ }
341
+
342
+ /**
343
+ * Get random edges from network (migrated from original NDEx.js)
344
+ *
345
+ * Retrieves a random sample of edges from a network using the V3 API.
346
+ * This is useful for previewing large networks or sampling edge data.
347
+ *
348
+ * @param networkUUID - The UUID of the network to get edges from
349
+ * @param limit - Number of random edges to retrieve (must be greater than 0)
350
+ * @param accessKey - Optional access key for private networks
351
+ * @returns Promise resolving to array of CX2Edge objects
352
+ * @throws Error if limit is less than or equal to 0
353
+ */
354
+ async getRandomEdges(
355
+ networkUUID: string,
356
+ limit: number,
357
+ accessKey?: string
358
+ ): Promise<CX2Edge[]> {
359
+ if (limit <= 0) {
360
+ throw new Error("Value of parameter limit has to be greater than 0.");
361
+ }
362
+
363
+ const params: Record<string, string> = {
364
+ size: limit.toString(),
365
+ method: "random"
366
+ };
367
+
368
+ if (accessKey !== undefined) {
369
+ params.accesskey = accessKey;
370
+ }
371
+
372
+ const endpoint = `networks/${networkUUID}/aspects/edges`;
373
+ return this.http.get<CX2Edge[]>(endpoint, {
374
+ version: 'v3',
375
+ params
376
+ });
377
+ }
378
+
379
+ /**
380
+ * Validate share data format (helper method for file operations)
381
+ *
382
+ * Validates the structure and content of file data used in sharing operations.
383
+ * Ensures proper UUID format and valid file types.
384
+ *
385
+ * @param data - Data object to validate (must contain 'files' property)
386
+ * @throws Error if validation fails
387
+ */
388
+ private validateShareData(data: any): void {
389
+ // Check if data is an object and has files property
390
+ if (typeof data !== 'object' || data === null || data.files === undefined) {
391
+ throw new Error('Data must be an object with a "files" property');
392
+ }
393
+
394
+ // Check if files is an object
395
+ if (typeof data.files !== 'object' || data.files === null) {
396
+ throw new Error('The "files" property must be an object');
397
+ }
398
+
399
+ // Check each key-value pair in files
400
+ const validValues = ['NETWORK', 'FOLDER', 'SHORTCUT'];
401
+
402
+ for (const [uuid, fileType] of Object.entries(data.files)) {
403
+ // Validate UUID format (basic validation)
404
+ if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(uuid)) {
405
+ throw new Error(`Invalid UUID format: ${uuid}`);
406
+ }
407
+
408
+ // Validate file type
409
+ if (!validValues.includes(fileType as string)) {
410
+ throw new Error(`Invalid file type for ${uuid}: ${fileType}. Must be one of: ${validValues.join(', ')}`);
411
+ }
412
+ }
413
+ }
414
+
415
+ /**
416
+ * Get aspect elements (migrated from original NDEx.js)
417
+ *
418
+ * Retrieves elements from a specific aspect of a network using the V3 API.
419
+ * This function can be used to get nodes, edges, or other aspect data
420
+ * with optional size limiting and access key support for private networks.
421
+ *
422
+ * @param networkUUID - The UUID of the network to get aspect elements from
423
+ * @param aspectName - Name of the aspect to retrieve (e.g., 'nodes', 'edges', 'networkAttributes')
424
+ * @param limit - Optional maximum number of elements to return
425
+ * @param accessKey - Optional access key for private networks
426
+ * @returns Promise resolving to array of aspect elements
427
+ * @example
428
+ * ```typescript
429
+ * // Get first 100 nodes from a network
430
+ * const nodes = await client.networks.getAspectElements('network-uuid', 'nodes', 100);
431
+ *
432
+ * // Get all edges from a network
433
+ * const edges = await client.networks.getAspectElements('network-uuid', 'edges');
434
+ * ```
435
+ */
436
+ async getAspectElements(
437
+ networkUUID: string,
438
+ aspectName: string,
439
+ limit?: number,
440
+ accessKey?: string
441
+ ): Promise<any[]> {
442
+ const params: Record<string, string> = {};
443
+
444
+ if (limit !== undefined) {
445
+ params.size = limit.toString();
446
+ }
447
+
448
+ if (accessKey !== undefined) {
449
+ params.accesskey = accessKey;
450
+ }
451
+
452
+ const endpoint = `networks/${networkUUID}/aspects/${aspectName}`;
453
+ return this.http.get<any[]>(endpoint, {
454
+ version: 'v3',
455
+ params
456
+ });
457
+ }
458
+
459
+ /**
460
+ * Get filtered edges (migrated from original NDEx.js)
461
+ *
462
+ * Retrieves edges from a network that match specific filtering criteria on a column value.
463
+ * The function supports both CX1 and CX2 formats based on the format parameter, with CX2
464
+ * being the default format used by the server.
465
+ *
466
+ * @param networkUUID - The UUID of the network to get filtered edges from
467
+ * @param columnName - Name of the edge attribute column to filter on
468
+ * @param valueString - Value to filter by (converted to string for comparison)
469
+ * @param operator - Filtering operation: '>' | '<' | '=' | '!='
470
+ * @param limit - Optional maximum number of edges to return (default: -1 = all matching edges)
471
+ * @param order - Optional sort order for edges before applying limit: 'asc' | 'desc' (default: 'desc')
472
+ * @param format - Optional output format: 'cx' | 'cx2' (default: 'cx2')
473
+ * @param accessKey - Optional access key for private networks
474
+ * @returns Promise resolving to array of edges in the specified format
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * // Get edges with weight > 0.5 in CX2 format (default)
479
+ * const cx2Edges = await client.networks.getFilteredEdges(
480
+ * 'network-uuid', 'weight', '0.5', '>'
481
+ * );
482
+ *
483
+ * // Get top 10 edges with highest score in CX1 format
484
+ * const cx1Edges = await client.networks.getFilteredEdges(
485
+ * 'network-uuid', 'score', '0', '>', 10, 'desc', 'cx'
486
+ * );
487
+ *
488
+ * // Get edges where interaction equals 'pp'
489
+ * const ppEdges = await client.networks.getFilteredEdges(
490
+ * 'network-uuid', 'interaction', 'pp', '=', undefined, undefined, 'cx2'
491
+ * );
492
+ * ```
493
+ */
494
+ async getFilteredEdges(
495
+ networkUUID: string,
496
+ columnName: string,
497
+ valueString: string,
498
+ operator: '>' | '<' | '=' | '!=',
499
+ limit?: number,
500
+ order?: 'asc' | 'desc',
501
+ format?: 'cx' | 'cx2',
502
+ accessKey?: string
503
+ ): Promise<CX2Edge[] | CX1Edge[]> {
504
+ const params: Record<string, string> = {};
505
+
506
+ if (limit !== undefined) {
507
+ params.size = limit.toString();
508
+ }
509
+
510
+ if (order !== undefined) {
511
+ params.order = order;
512
+ }
513
+
514
+ if (accessKey !== undefined) {
515
+ params.accesskey = accessKey;
516
+ }
517
+
518
+ if (format !== undefined) {
519
+ params.format = format;
520
+ }
521
+
522
+ const data = {
523
+ name: columnName,
524
+ value: valueString,
525
+ operator: operator
526
+ };
527
+
528
+ const endpoint = `search/networks/${networkUUID}/edges`;
529
+ return this.http.post<CX2Edge[] | CX1Edge[]>(endpoint, data, {
530
+ version: 'v3',
531
+ params
532
+ });
533
+ }
534
+
535
+ /**
536
+ * Get CX2 metadata (migrated from original NDEx.js)
537
+ *
538
+ * Retrieves metadata information for all aspects in a CX2 network format.
539
+ * This function provides aspect metadata including element counts for each
540
+ * aspect in the network using the V3 API.
541
+ *
542
+ * @param networkUUID - The UUID of the network to get CX2 metadata for
543
+ * @param accessKey - Optional access key for private networks
544
+ * @returns Promise resolving to array of CX2MetaData objects
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * // Get CX2 metadata for a network
549
+ * const metaData = await client.networks.getCX2MetaData('network-uuid');
550
+ * console.log(metaData); // [{ name: 'nodes', elementCount: 100 }, { name: 'edges', elementCount: 150 }]
551
+ *
552
+ * // Get CX2 metadata for a private network
553
+ * const privateMetaData = await client.networks.getCX2MetaData('private-network-uuid', 'access-key');
554
+ * ```
555
+ */
556
+ async getCX2MetaData(
557
+ networkUUID: string,
558
+ accessKey?: string
559
+ ): Promise<CX2MetaData[]> {
560
+ const params: Record<string, string> = {};
561
+
562
+ if (accessKey !== undefined) {
563
+ params.accesskey = accessKey;
564
+ }
565
+
566
+ const endpoint = `networks/${networkUUID}/aspects`;
567
+ return this.http.get<CX2MetaData[]>(endpoint, {
568
+ version: 'v3',
569
+ params
570
+ });
571
+ }
572
+
573
+ /**
574
+ * Create network from raw CX2 data (migrated from original NDEx.js)
575
+ *
576
+ * Creates a new network in NDEx from raw CX2 network data. This is an unstable function
577
+ * for uploading CX2 format networks directly to NDEx using the V3 API. The function
578
+ * extracts the network UUID from the response location header.
579
+ *
580
+ * @param rawCX2 - Raw CX2 network data as an object or CX2Network instance
581
+ * @param makePublic - Whether to make the network public (default: false = private)
582
+ * @returns Promise resolving to an object containing the UUID of the created network
583
+ *
584
+ * @example
585
+ * ```typescript
586
+ * // Create private network from raw CX2 data
587
+ * const result = await client.networks.createNetworkFromRawCX2(cx2Data);
588
+ * console.log(result.uuid); // "12345678-1234-1234-1234-123456789abc"
589
+ *
590
+ * // Create public network from raw CX2 data
591
+ * const publicResult = await client.networks.createNetworkFromRawCX2(cx2Data, true);
592
+ * console.log(publicResult.uuid);
593
+ * ```
594
+ */
595
+ async createNetworkFromRawCX2(
596
+ rawCX2: CX2NetworkType | any,
597
+ makePublic: boolean = false
598
+ ): Promise<{ uuid: string }> {
599
+ const params = {
600
+ visibility: makePublic ? 'PUBLIC' as const : 'PRIVATE' as const
601
+ };
602
+
603
+ const endpoint = 'networks';
604
+ const response = await this.http.post<string>(endpoint, rawCX2, {
605
+ version: 'v3',
606
+ params
607
+ });
608
+
609
+ // Extract UUID from response location header (e.g., "/v3/networks/12345" -> "12345")
610
+ const uuid = response.split('/').pop();
611
+
612
+ if (!uuid) {
613
+ throw new Error('Failed to extract network UUID from response');
614
+ }
615
+
616
+ return { uuid };
617
+ }
618
+
619
+ /**
620
+ * Update network from raw CX2 data (migrated from original NDEx.js)
621
+ *
622
+ * Updates an existing network with new raw CX2 data using the V3 API.
623
+ * This function replaces the entire network content with the provided CX2 data.
624
+ *
625
+ * @param networkUUID - The UUID of the network to update
626
+ * @param rawCX2 - Raw CX2 network data as an object or CX2Network instance
627
+ * @returns Promise resolving when the network update is complete
628
+ *
629
+ * @example
630
+ * ```typescript
631
+ * // Update existing network with new CX2 data
632
+ * await client.networks.updateNetworkFromRawCX2('network-uuid', updatedCx2Data);
633
+ * ```
634
+ */
635
+ async updateNetworkFromRawCX2(
636
+ networkUUID: string,
637
+ rawCX2: CX2NetworkType | any
638
+ ): Promise<void> {
639
+ const endpoint = `networks/${networkUUID}`;
640
+ return this.http.put<void>(endpoint, rawCX2, { version: 'v3' });
641
+ }
642
+
643
+ /**
644
+ * Access to underlying service instances for advanced usage
645
+ */
646
+ get v2(): NetworkServiceV2 {
647
+ return this.v2Service;
648
+ }
649
+
650
+ get v3(): NetworkServiceV3 {
651
+ return this.v3Service;
652
+ }
653
+ }