Skip to content

Commit

Permalink
Added: GetDatasetUserPermissions docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GPortas committed Jan 31, 2024
1 parent 5a76991 commit 2a175bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/useCases.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The different use cases currently available in the package are classified below,
- [Get Dataset Citation Text](#get-dataset-citation-text)
- [Get Dataset Locks](#get-dataset-locks)
- [Get Dataset Summary Field Names](#get-dataset-summary-field-names)
- [Get User Permissions on a Dataset](#get-user-permissions-on-a-dataset)
- [List All Datasets](#list-all-datasets)
- [Files](#Files)
- [Metadata Blocks](#metadata-blocks)
Expand Down Expand Up @@ -130,6 +131,32 @@ getDatasetSummaryFieldNames

*See [use case](../src/datasets/domain/useCases/GetDatasetSummaryFieldNames.ts) definition*.

#### Get User Permissions on a Dataset

Returns an instance of [DatasetUserPermissions](../src/datasets/domain/models/DatasetUserPermissions.ts) that includes the permissions that the calling user has on a particular Dataset.

##### Example call:

````typescript
import { getDatasetUserPermissions } from '@iqss/dataverse-client-javascript'

/* ... */

const datasetId = 'doi:10.77777/FK2/AAAAAA';

getDatasetUserPermissions
.execute(datasetId)
.then((permissions: DatasetUserPermissions) => {
/* ... */
});

/* ... */
````

*See [use case](../src/datasets/domain/useCases/GetDatasetUserPermissions.ts) definition*.

The `datasetId` parameter can be a string, for persistent identifiers, or a number, for numeric identifiers.

#### List All Datasets

Returns an instance of [DatasetPreviewSubset](../src/datasets/domain/models/DatasetPreviewSubset.ts) that contains reduced information for each dataset that the calling user can access in the installation.
Expand Down
6 changes: 6 additions & 0 deletions src/datasets/domain/useCases/GetDatasetUserPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export class GetDatasetUserPermissions implements UseCase<DatasetUserPermissions
this.datasetsRepository = datasetsRepository;
}

/**
* Returns an instance of DatasetUserPermissions that includes the permissions that the calling user has on a particular Dataset.
*
* @param {number | string} [datasetId] - The dataset identifier, which can be a string (for persistent identifiers), or a number (for numeric identifiers).
* @returns {Promise<DatasetUserPermissions>}
*/
async execute(datasetId: number | string): Promise<DatasetUserPermissions> {
return await this.datasetsRepository.getDatasetUserPermissions(datasetId);
}
Expand Down

0 comments on commit 2a175bc

Please sign in to comment.