DatasetService.ts 21.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
import * as UrlTemplate from 'url-template';
import * as QueryString from 'query-string';
import { axiosBackend } from 'utilities/requestUtils';

import { AccessionRef } from 'model/accession/AccessionRef';
import Dataset from 'model/catalog/Dataset';
import DatasetCreator from 'model/catalog/DatasetCreator';
import DatasetFilter from 'model/catalog/DatasetFilter';
import DatasetLocation from 'model/catalog/DatasetLocation';
import FilteredPage from 'model/FilteredPage';
import Page, { IPageRequest } from 'model/Page';
import RepositoryFile from 'model/repository/RepositoryFile';

14
15
const URL_LIST_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/accessions/{uuid}`);
const URL_ADD_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/add-descriptors/{uuid},{version}`);
16
17
18
19
20
const URL_APPROVE_DATASET = `/api/v1/dataset/approve`;
const URL_CREATE_DATASET = `/api/v1/dataset/create`;
const URL_REVIEW_DATASET = `/api/v1/dataset/for-review`;
const URL_DATASET_LIST = `/api/v1/dataset/list`;
const URL_MY_DATASETS = `/api/v1/dataset/list-mine`;
Matija Obreza's avatar
Matija Obreza committed
21
const URL_REMATCH_DATASET_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/rematch-accessions/{uuid},{version}`);
22
const URL_REJECT_DATASET = `/api/v1/dataset/reject`;
23
24
const URL_REMOVE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/remove-descriptors/{uuid},{version}`);
const URL_UPDATE_DESCRIPTORS = UrlTemplate.parse(`/api/v1/dataset/set-descriptors/{uuid},{version}`);
25
const URL_UPDATE_DATASET = `/api/v1/dataset/update`;
26
27
const URL_ADD_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/add-accessions/{uuid},{version}`);
const URL_SET_ACCESSIONS = UrlTemplate.parse(`/api/v1/dataset/set-accessions/{uuid},{version}`);
28
29
const URL_GET_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid}`);
const URL_DELETE_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid},{version}`);
30
const URL_AUTOCOMPLETE = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/autocomplete`);
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const URL_CREATE_DATASET_CREATOR = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/create`);
const URL_DELETE_DATASET_CREATOR = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/delete`);
const URL_LIST_DATASET_CREATORS = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/list`);
const URL_UPDATE_DATASET_CREATOR = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/update`);
const URL_LOAD_BY_UUID = UrlTemplate.parse(`/api/v1/dataset/{uuid}/datasetcreator/{creatorUuid}`);
const URL_ADD_FILE_TO_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid}/files/add`);
const URL_REMOVE_FILE_OF_DATASET = UrlTemplate.parse(`/api/v1/dataset/{uuid}/files/delete/{fileUuid}`);
const URL_GET_LIST = UrlTemplate.parse(`/api/v1/dataset/{uuid}/files/list`);
const URL_UPDATE_DATASET_FILE = UrlTemplate.parse(`/api/v1/dataset/{uuid}/files/update`);
const URL_CREATE_LOCATION = UrlTemplate.parse(`/api/v1/dataset/{uuid}/location/create`);
const URL_DELETE_LOCATION = UrlTemplate.parse(`/api/v1/dataset/{uuid}/location/delete`);
const URL_LIST_LOCATION = UrlTemplate.parse(`/api/v1/dataset/{uuid}/location/list`);
const URL_UPDATE_LOCATION = UrlTemplate.parse(`/api/v1/dataset/{uuid}/location/update`);
const URL_LOAD_LOCATION_BY_UUID = UrlTemplate.parse(`/api/v1/dataset/{uuid}/location/{locationUuid}`);
45
46
47
48
49

/*
* Defined in Swagger as 'dataset'
*/
class DatasetService {
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  /**
   * listAccessions at /api/v1/dataset/accessions/{uuid}
   *
   * @param uuid UUID of Dataset
   * @param page undefined
   */
  public static listAccessions(uuid: string, page?: IPageRequest): Promise<Page<AccessionRef>> {

    const qs = QueryString.stringify({
      p: page.page || undefined,
      l: page.size || undefined,
      d: page.direction && page.direction.length && page.direction || undefined,
      s: page.properties || undefined,
    }, {});
    const apiUrl = URL_LIST_ACCESSIONS.expand({ uuid }) + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as Page<AccessionRef>);
  }
74
75

  /**
76
   * addDescriptors at /api/v1/dataset/add-descriptors/{uuid},{version}
77
   *
78
   * @param uuid uuid
79
80
81
   * @param version version
   * @param descriptorUuids descriptorUuids
   */
82
  public static addDescriptors(uuid: string, version: number, descriptorUuids: string[]): Promise<Dataset> {
83

84
    const apiUrl = URL_ADD_DESCRIPTORS.expand({ uuid, version });
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: descriptorUuids };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * approveDataset at /api/v1/dataset/approve
   *
   * @param uuid uuid
   * @param version version
   */
  public static approveDataset(uuid: string, version: number): Promise<Dataset> {

    const qs = QueryString.stringify({
      uuid: uuid || undefined,
      version: version || undefined,
    }, {});
    const apiUrl = URL_APPROVE_DATASET + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * createDataset at /api/v1/dataset/create
   *
   * @param dataset dataset
   */
  public static createDataset(dataset: Dataset): Promise<Dataset> {

    const apiUrl = URL_CREATE_DATASET;
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: dataset };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * reviewDataset at /api/v1/dataset/for-review
   *
   * @param uuid uuid
   * @param version version
   */
  public static reviewDataset(uuid: string, version: number): Promise<Dataset> {

    const qs = QueryString.stringify({
      uuid: uuid || undefined,
      version: version || undefined,
    }, {});
    const apiUrl = URL_REVIEW_DATASET + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * datasetList at /api/v1/dataset/list
   *
   * @param filter filter
   * @param page undefined
   */
  public static datasetList(filter: string | DatasetFilter, page?: IPageRequest): Promise<FilteredPage<Dataset>> {

    const qs = QueryString.stringify({
      f: typeof filter === 'string' ? filter : undefined,
      p: page.page || undefined,
      l: page.size || undefined,
      d: page.direction && page.direction.length && page.direction || undefined,
      s: page.properties || undefined,
    }, {});
    const apiUrl = URL_DATASET_LIST + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: typeof filter === 'string' ? null : { ...filter } };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as FilteredPage<Dataset>);
  }

  /**
   * myDatasets at /api/v1/dataset/list-mine
   *
   * @param filter filter
   * @param page undefined
   */
  public static myDatasets(filter: string | DatasetFilter, page?: IPageRequest): Promise<FilteredPage<Dataset>> {

    const qs = QueryString.stringify({
      f: typeof filter === 'string' ? filter : undefined,
      p: page.page || undefined,
      l: page.size || undefined,
      d: page.direction && page.direction.length && page.direction || undefined,
      s: page.properties || undefined,
    }, {});
    const apiUrl = URL_MY_DATASETS + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: typeof filter === 'string' ? null : { ...filter } };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as FilteredPage<Dataset>);
  }

  /**
   * rejectDataset at /api/v1/dataset/reject
   *
   * @param uuid uuid
   * @param version version
   */
  public static rejectDataset(uuid: string, version: number): Promise<Dataset> {

    const qs = QueryString.stringify({
      uuid: uuid || undefined,
      version: version || undefined,
    }, {});
    const apiUrl = URL_REJECT_DATASET + (qs ? `?${qs}` : '');
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
235
   * removeDescriptors at /api/v1/dataset/remove-descriptors/{uuid},{version}
236
   *
237
   * @param uuid uuid
238
239
240
   * @param version version
   * @param descriptorUuids descriptorUuids
   */
241
  public static removeDescriptors(uuid: string, version: number, descriptorUuids: string[]): Promise<Dataset> {
242

243
    const apiUrl = URL_REMOVE_DESCRIPTORS.expand({ uuid, version });
244
245
246
247
248
249
250
251
252
253
254
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: descriptorUuids };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
255
   * updateDescriptors at /api/v1/dataset/set-descriptors/{uuid},{version}
256
   *
257
   * @param uuid uuid
258
259
260
   * @param version version
   * @param descriptorUuids descriptorUuids
   */
261
  public static updateDescriptors(uuid: string, version: number, descriptorUuids: string[]): Promise<Dataset> {
262

263
    const apiUrl = URL_UPDATE_DESCRIPTORS.expand({ uuid, version });
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: descriptorUuids };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * updateDataset at /api/v1/dataset/update
   *
   * @param dataset dataset
   */
  public static updateDataset(dataset: Dataset): Promise<Dataset> {

    const apiUrl = URL_UPDATE_DATASET;
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: dataset };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
293
   * addAccessions at /api/v1/dataset/add-accessions/{uuid},{version}
294
   *
295
   * @param uuid uuid
296
297
298
   * @param version version
   * @param accessionRefs accessionRefs
   */
299
  public static addAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Dataset> {
300

301
    const apiUrl = URL_ADD_ACCESSIONS.expand({ uuid, version });
302
303
304
305
306
307
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: accessionRefs };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
      timeout: 0, // don't timeout
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
   * setAccessions at /api/v1/dataset/add-accessions/{uuid},{version}
   *
   * @param uuid uuid
   * @param version version
   * @param accessionRefs accessionRefs
   */
  public static setAccessions(uuid: string, version: number, accessionRefs: AccessionRef[]): Promise<Dataset> {

    const apiUrl = URL_SET_ACCESSIONS.expand({ uuid, version });
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: accessionRefs };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      timeout: 0, // don't timeout
330
331
332
333
334
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
335
   * getDataset at /api/v1/dataset/{uuid}
336
   *
337
   * @param uuid uuid
338
   */
339
  public static getDataset(uuid: string): Promise<Dataset> {
340

341
    const apiUrl = URL_GET_DATASET.expand({ uuid });
342
343
344
345
346
347
348
349
350
351
352
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
353
   * deleteDataset at /api/v1/dataset/{uuid},{version}
354
   *
355
   * @param uuid uuid
356
357
   * @param version version
   */
358
  public static deleteDataset(uuid: string, version: number): Promise<Dataset> {
359

360
    const apiUrl = URL_DELETE_DATASET.expand({ uuid, version });
361
362
363
364
365
366
367
368
369
370
371
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'DELETE',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
372
   * autocomplete at /api/v1/dataset/{uuid}/datasetcreator/autocomplete
373
374
375
   *
   * @param c c
   */
376
  public static autocomplete(uuid: string, c: string): Promise<DatasetCreator[]> {
377
378
379
380

    const qs = QueryString.stringify({
      c: c || undefined,
    }, {});
381
    const apiUrl = URL_AUTOCOMPLETE.expand({uuid}) + (qs ? `?${qs}` : '');
382
383
384
385
386
387
388
389
390
391
392
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as DatasetCreator[]);
  }

  /**
393
   * createDatasetCreator at /api/v1/dataset/{uuid}/datasetcreator/create
394
   *
395
   * @param uuid uuid
396
397
   * @param datasetCreator datasetCreator
   */
398
  public static createDatasetCreator(uuid: string, datasetCreator: DatasetCreator): Promise<DatasetCreator> {
399

400
    const apiUrl = URL_CREATE_DATASET_CREATOR.expand({ uuid });
401
402
403
404
405
406
407
408
409
410
411
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetCreator };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetCreator);
  }

  /**
412
   * deleteDatasetCreator at /api/v1/dataset/{uuid}/datasetcreator/delete
413
   *
414
   * @param uuid uuid
415
416
   * @param datasetCreator datasetCreator
   */
417
  public static deleteDatasetCreator(uuid: string, datasetCreator: DatasetCreator): Promise<DatasetCreator> {
418

419
    const apiUrl = URL_DELETE_DATASET_CREATOR.expand({ uuid });
420
421
422
423
424
425
426
427
428
429
430
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetCreator };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetCreator);
  }

  /**
431
   * listDatasetCreators at /api/v1/dataset/{uuid}/datasetcreator/list
432
   *
433
   * @param uuid uuid
434
435
   * @param page undefined
   */
436
  public static listDatasetCreators(uuid: string, page?: IPageRequest): Promise<Page<DatasetCreator>> {
437
438
439
440
441
442
443

    const qs = QueryString.stringify({
      p: page.page || undefined,
      l: page.size || undefined,
      d: page.direction && page.direction.length && page.direction || undefined,
      s: page.properties || undefined,
    }, {});
444
    const apiUrl = URL_LIST_DATASET_CREATORS.expand({ uuid }) + (qs ? `?${qs}` : '');
445
446
447
448
449
450
451
452
453
454
455
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as Page<DatasetCreator>);
  }

  /**
456
   * updateDatasetCreator at /api/v1/dataset/{uuid}/datasetcreator/update
457
   *
458
   * @param uuid uuid
459
460
   * @param datasetCreator datasetCreator
   */
461
  public static updateDatasetCreator(uuid: string, datasetCreator: DatasetCreator): Promise<DatasetCreator> {
462

463
    const apiUrl = URL_UPDATE_DATASET_CREATOR.expand({ uuid });
464
465
466
467
468
469
470
471
472
473
474
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetCreator };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetCreator);
  }

  /**
475
   * loadByUuid at /api/v1/dataset/{uuid}/datasetcreator/{creatorUuid}
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
   *
   * @param creatorUuid creatorUuid
   */
  public static loadByUuid(creatorUuid: string): Promise<DatasetCreator> {

    const apiUrl = URL_LOAD_BY_UUID.expand({ creatorUuid });
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as DatasetCreator);
  }

  /**
493
   * addFileToDataset at /api/v1/dataset/{uuid}/files/add
494
   *
495
   * @param uuid uuid
496
497
   * @param file file
   */
498
  public static addFileToDataset(uuid: string, file: File): Promise<Dataset> {
499

500
    const apiUrl = URL_ADD_FILE_TO_DATASET.expand({ uuid });
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
    // console.log(`Fetching from ${apiUrl}`);
    const data = new FormData();
    data.append('file', file);
    // data.append('metadata', new Blob([ JSON.stringify(metadata) ], { type : 'application/json' }));
    const content = { data };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      headers: { 'Content-Type': 'multipart/form-data' },
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
516
   * removeFileOfDataset at /api/v1/dataset/{uuid}/files/delete/{fileUuid}
517
518
   *
   * @param fileUuid fileUuid
519
   * @param uuid uuid
520
   */
521
  public static removeFileOfDataset(uuid: string, fileUuid: string): Promise<Dataset> {
522

523
    const apiUrl = URL_REMOVE_FILE_OF_DATASET.expand({ uuid, fileUuid });
524
525
526
527
528
529
530
531
532
533
534
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'DELETE',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
535
   * getList at /api/v1/dataset/{uuid}/files/list
536
   *
537
   * @param uuid uuid
538
   */
539
  public static getList(uuid: string): Promise<RepositoryFile[]> {
540

541
    const apiUrl = URL_GET_LIST.expand({ uuid });
542
543
544
545
546
547
548
549
550
551
552
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as RepositoryFile[]);
  }

  /**
553
   * updateDatasetFile at /api/v1/dataset/{uuid}/files/update
554
   *
555
   * @param uuid uuid
556
557
   * @param metadata metadata
   */
558
  public static updateDatasetFile(uuid: string, metadata: RepositoryFile): Promise<Dataset> {
559

560
    const apiUrl = URL_UPDATE_DATASET_FILE.expand({ uuid });
561
562
563
564
565
566
567
568
569
570
571
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: metadata };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

  /**
572
   * createLocation at /api/v1/dataset/{uuid}/location/create
573
   *
574
   * @param uuid uuid
575
576
   * @param datasetLocation datasetLocation
   */
577
  public static createLocation(uuid: string, datasetLocation: DatasetLocation): Promise<DatasetLocation> {
578

579
    const apiUrl = URL_CREATE_LOCATION.expand({ uuid });
580
581
582
583
584
585
586
587
588
589
590
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetLocation };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetLocation);
  }

  /**
591
   * deleteLocation at /api/v1/dataset/{uuid}/location/delete
592
   *
593
   * @param uuid uuid
594
595
   * @param datasetLocation datasetLocation
   */
596
  public static deleteLocation(uuid: string, datasetLocation: DatasetLocation): Promise<DatasetLocation> {
597

598
    const apiUrl = URL_DELETE_LOCATION.expand({ uuid });
599
600
601
602
603
604
605
606
607
608
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetLocation };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetLocation);
  }

609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
  /**
   * rematchDatasetAccessions at /api/v1/dataset/rematchAccessions/{uuid},{version}
   *
   * @param uuid uuid
   * @param version version
   */
  public static rematchDatasetAccessions(uuid: string, version: number): Promise<Dataset> {

    const apiUrl = URL_REMATCH_DATASET_ACCESSIONS.expand({ uuid, version });
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as Dataset);
  }

628
  /**
629
   * listLocation at /api/v1/dataset/{uuid}/location/list
630
   *
631
   * @param uuid uuid
632
633
   * @param page undefined
   */
634
  public static listLocation(uuid: string, page?: IPageRequest): Promise<Page<DatasetLocation>> {
635
636
637
638
639
640
641

    const qs = QueryString.stringify({
      p: page.page || undefined,
      l: page.size || undefined,
      d: page.direction && page.direction.length && page.direction || undefined,
      s: page.properties || undefined,
    }, {});
642
    const apiUrl = URL_LIST_LOCATION.expand({ uuid }) + (qs ? `?${qs}` : '');
643
644
645
646
647
648
649
650
651
652
653
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as Page<DatasetLocation>);
  }

  /**
654
   * updateLocation at /api/v1/dataset/{uuid}/location/update
655
   *
656
   * @param uuid uuid
657
658
   * @param datasetLocation datasetLocation
   */
659
  public static updateLocation(uuid: string, datasetLocation: DatasetLocation): Promise<DatasetLocation> {
660

661
    const apiUrl = URL_UPDATE_LOCATION.expand({ uuid });
662
663
664
665
666
667
668
669
670
671
672
    // console.log(`Fetching from ${apiUrl}`);
    const content = { data: datasetLocation };

    return axiosBackend.request({
      url: apiUrl,
      method: 'POST',
      ...content,
    }).then(({ data }) => data as DatasetLocation);
  }

  /**
673
   * loadLocationByUuid at /api/v1/dataset/{uuid}/location/{locationUuid}
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
   *
   * @param locationUuid locationUuid
   */
  public static loadLocationByUuid(locationUuid: string): Promise<DatasetLocation> {

    const apiUrl = URL_LOAD_LOCATION_BY_UUID.expand({ locationUuid });
    // console.log(`Fetching from ${apiUrl}`);
    const content = { /* No content in request body */ };

    return axiosBackend.request({
      url: apiUrl,
      method: 'GET',
      ...content,
    }).then(({ data }) => data as DatasetLocation);
  }


}

export default DatasetService;