|
1 | | -function remoteDatasetDoc = createRemoteDatasetDoc(cloudDatasetId, ndiDataset) |
| 1 | +function remoteDatasetDoc = createRemoteDatasetDoc(cloudDatasetId, ndiDataset, options) |
2 | 2 | % createRemoteDatasetDoc - Create NDI document with remote dataset details. |
3 | 3 | % |
4 | 4 | % Syntax: |
5 | | -% remoteDatasetDoc = createRemoteDatasetDoc(cloudDatasetId) |
| 5 | +% remoteDatasetDoc = createRemoteDatasetDoc(cloudDatasetId, ndiDataset) |
| 6 | +% remoteDatasetDoc = createRemoteDatasetDoc(cloudDatasetId, ndiDataset, 'replaceExisting', true) |
| 7 | +% |
6 | 8 | % This function retrieves a remote dataset from the cloud and creates |
7 | 9 | % a "dataset remote" NDI document for that dataset. |
8 | 10 | % |
9 | 11 | % Input Arguments: |
10 | 12 | % cloudDatasetId - The unique identifier for the cloud dataset to be |
11 | 13 | % retrieved. |
| 14 | +% ndiDataset - The NDI dataset object. |
| 15 | +% options.replaceExisting - A boolean that if true, will replace an |
| 16 | +% existing remote dataset document. |
12 | 17 | % |
13 | 18 | % Output Arguments: |
14 | 19 | % remoteDatasetDoc - A document object containing the remote dataset |
|
17 | 22 | arguments |
18 | 23 | cloudDatasetId |
19 | 24 | ndiDataset (1,1) ndi.dataset |
| 25 | + options.replaceExisting (1,1) logical = false |
| 26 | + end |
| 27 | + |
| 28 | + [~, existingDoc] = ndi.cloud.internal.getCloudDatasetIdForLocalDataset(ndiDataset); |
| 29 | + |
| 30 | + if ~isempty(existingDoc) |
| 31 | + if options.replaceExisting |
| 32 | + ndiDataset.database_rm(existingDoc{1}.id()); |
| 33 | + else |
| 34 | + error('An existing remote dataset document was found. Use ''replaceExisting'', true to replace it.'); |
| 35 | + end |
20 | 36 | end |
21 | 37 |
|
22 | 38 | [success, remoteDataset] = ndi.cloud.api.datasets.getDataset(cloudDatasetId); |
|
0 commit comments