From 0a77ebf5c5b964cbe8da1cc7aa9c920ea196a43d Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 8 Sep 2020 17:01:24 +0300 Subject: [PATCH] feat: added sourceFolder URI capability to moveFolder function --- ...eflection-640.reflection-158.sasviyaapiclient.html | 10 +++++----- src/SASViyaApiClient.ts | 11 +++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/classes/reflection-640.reflection-158.sasviyaapiclient.html b/docs/classes/reflection-640.reflection-158.sasviyaapiclient.html index 00a3bef..4199fe8 100644 --- a/docs/classes/reflection-640.reflection-158.sasviyaapiclient.html +++ b/docs/classes/reflection-640.reflection-158.sasviyaapiclient.html @@ -374,12 +374,12 @@
  • -

    For performance (and in case of accidental error) the deleteFolder function does not actually delete the folder (and all it's content and subfolder content). Instead the folder is simply moved to the recycle bin. Deletion time will be added to the folder name.

    +

    For performance (and in case of accidental error) the deleteFolder function does not actually delete the folder (and all it's content and subfolder content). Instead the folder is simply moved to the recycle bin. Deletion time will be added to the folder name.

    Parameters

    @@ -780,13 +780,13 @@
  • sourceFolder: string
    -

    The full path to the source folder to be moved (eg /Public/example/myFolder)

    +

    The full path (eg /Public/example/myFolder) or URI of the source folder to be moved. Providing URI instead of path will save one extra request.

  • targetParentFolder: string
    -

    The parent folder to which the sourceFolder will be moved (eg /Public/newDestination). To move a folder, a user has to have write permissions in targetParentFolder. If moving to recycle bin, 'targetParentFolder' will be a uri.

    +

    The full path or URI of the parent folder to which the sourceFolder will be moved (eg /Public/newDestination). To move a folder, a user has to have write permissions in targetParentFolder. Providing URI instead of path will save one extra request.

  • @@ -893,7 +893,7 @@
  • Parameters

    diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 24e937f..727fd8a 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -1142,8 +1142,8 @@ export class SASViyaApiClient { /** * Moves a Viya folder to a new location. The folder may be renamed at the same time. - * @param sourceFolder - The full path to the source folder to be moved (eg `/Public/example/myFolder`) - * @param targetParentFolder - The _parent_ folder to which the `sourceFolder` will be moved (eg `/Public/newDestination`). To move a folder, a user has to have write permissions in targetParentFolder. If moving to recycle bin, 'targetParentFolder' will be a uri. + * @param sourceFolder - The full path (eg `/Public/example/myFolder`) or URI of the source folder to be moved. Providing URI instead of path will save one extra request. + * @param targetParentFolder - The full path or URI of the _parent_ folder to which the `sourceFolder` will be moved (eg `/Public/newDestination`). To move a folder, a user has to have write permissions in targetParentFolder. Providing URI instead of path will save one extra request. * @param targetFolderName - The name of the "moved" folder. If left blank, the original folder name will be used (eg `myFolder` in `/Public/newDestination/myFolder` for the example above). Optional field. * @param accessToken - an access token for authorizing the request */ @@ -1153,9 +1153,12 @@ export class SASViyaApiClient { targetFolderName: string, accessToken: string ) { - const sourceFolderUri = await this.getFolderUri(sourceFolder, accessToken) + // checks if 'sourceFolder' is already a URI + const sourceFolderUri = /^\/folders\/folders\//.test(sourceFolder) + ? sourceFolder + : await this.getFolderUri(sourceFolder, accessToken) - // checks if 'targetParentFolder' is already a uri + // checks if 'targetParentFolder' is already a URI const targetParentFolderUri = /^\/folders\/folders\//.test( targetParentFolder )