@pnp/cli-microsoft365 11.9.0-beta.93bd508 → 11.9.0-beta.f8dc984

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,83 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import request from '../../../../request.js';
4
+ import { formatting } from '../../../../utils/formatting.js';
5
+ import { urlUtil } from '../../../../utils/urlUtil.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import SpoCommand from '../../../base/SpoCommand.js';
8
+ import commands from '../../commands.js';
9
+ import { cli } from '../../../../cli/cli.js';
10
+ export const options = z.strictObject({
11
+ ...globalOptionsZod.shape,
12
+ webUrl: z.string()
13
+ .refine(url => validation.isValidSharePointUrl(url) === true, {
14
+ error: 'Specify a valid SharePoint site URL.'
15
+ })
16
+ .alias('u'),
17
+ listTitle: z.string().optional().alias('t'),
18
+ listId: z.uuid().optional().alias('l'),
19
+ listUrl: z.string().optional(),
20
+ force: z.boolean().optional().alias('f')
21
+ });
22
+ class SpoListSensitivityLabelRemoveCommand extends SpoCommand {
23
+ get name() {
24
+ return commands.LIST_SENSITIVITYLABEL_REMOVE;
25
+ }
26
+ get description() {
27
+ return 'Clears a default sensitivity label from a document library';
28
+ }
29
+ get schema() {
30
+ return options;
31
+ }
32
+ getRefinedSchema(schema) {
33
+ return schema
34
+ .refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
35
+ error: 'Use one of the following options: listId, listTitle, or listUrl.'
36
+ });
37
+ }
38
+ async commandAction(logger, args) {
39
+ const removeSensitivityLabel = async () => {
40
+ try {
41
+ if (this.verbose) {
42
+ await logger.logToStderr(`Removing the sensitivity label from list '${args.options.listId || args.options.listTitle || args.options.listUrl}' in site at ${args.options.webUrl}...`);
43
+ }
44
+ let requestUrl = `${args.options.webUrl}/_api/web`;
45
+ if (args.options.listId) {
46
+ requestUrl += `/lists(guid'${formatting.encodeQueryParameter(args.options.listId)}')`;
47
+ }
48
+ else if (args.options.listTitle) {
49
+ requestUrl += `/lists/getByTitle('${formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ else if (args.options.listUrl) {
52
+ const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
53
+ requestUrl += `/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
54
+ }
55
+ const requestOptions = {
56
+ url: requestUrl,
57
+ headers: {
58
+ accept: 'application/json;odata=nometadata',
59
+ 'content-type': 'application/json;odata=nometadata',
60
+ 'if-match': '*'
61
+ },
62
+ data: { 'DefaultSensitivityLabelForLibrary': '' },
63
+ responseType: 'json'
64
+ };
65
+ await request.patch(requestOptions);
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ };
71
+ if (args.options.force) {
72
+ await removeSensitivityLabel();
73
+ }
74
+ else {
75
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove the sensitivity label from list '${args.options.listId || args.options.listTitle || args.options.listUrl}'?` });
76
+ if (result) {
77
+ await removeSensitivityLabel();
78
+ }
79
+ }
80
+ }
81
+ }
82
+ export default new SpoListSensitivityLabelRemoveCommand();
83
+ //# sourceMappingURL=list-sensitivitylabel-remove.js.map
@@ -162,6 +162,7 @@ export default {
162
162
  LIST_ROLEINHERITANCE_BREAK: `${prefix} list roleinheritance break`,
163
163
  LIST_ROLEINHERITANCE_RESET: `${prefix} list roleinheritance reset`,
164
164
  LIST_SENSITIVITYLABEL_ENSURE: `${prefix} list sensitivitylabel ensure`,
165
+ LIST_SENSITIVITYLABEL_REMOVE: `${prefix} list sensitivitylabel remove`,
165
166
  LIST_SET: `${prefix} list set`,
166
167
  LIST_SITESCRIPT_GET: `${prefix} list sitescript get`,
167
168
  LIST_VIEW_ADD: `${prefix} list view add`,
@@ -0,0 +1,77 @@
1
+ import Global from '../../_global.mdx';
2
+ import TabItem from '@theme/TabItem';
3
+ import Tabs from '@theme/Tabs';
4
+
5
+ # spo list sensitivitylabel remove
6
+
7
+ Clears a default sensitivity label from a document library
8
+
9
+ ## Usage
10
+
11
+ ```sh
12
+ m365 spo list sensitivitylabel remove [options]
13
+ ```
14
+
15
+ ## Options
16
+
17
+ ```md definition-list
18
+ `-u, --webUrl <webUrl>`
19
+ : The URL of the site where the list is located.
20
+
21
+ `-t, --listTitle [listTitle]`
22
+ : The title of the library on which to remove the label. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
23
+
24
+ `-l, --listId [listId]`
25
+ : The ID of the library on which to remove the label. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
26
+
27
+ `--listUrl [listUrl]`
28
+ : Server- or web-relative URL of the library on which to remove the label. Specify either `listTitle`, `listId`, or `listUrl` but not multiple.
29
+
30
+ `-f, --force`
31
+ : Don't prompt for confirmation.
32
+ ```
33
+
34
+ <Global />
35
+
36
+ ## Permissions
37
+
38
+ <Tabs>
39
+ <TabItem value="Delegated">
40
+
41
+ | Resource | Permissions |
42
+ |------------|----------------|
43
+ | SharePoint | AllSites.Write |
44
+
45
+ </TabItem>
46
+ <TabItem value="Application">
47
+
48
+ | Resource | Permissions |
49
+ |------------|---------------------|
50
+ | SharePoint | Sites.ReadWrite.All |
51
+
52
+ </TabItem>
53
+ </Tabs>
54
+
55
+ ## Examples
56
+
57
+ Removes a sensitivity label from a document library based on the list title.
58
+
59
+ ```sh
60
+ m365 spo list sensitivitylabel remove --webUrl 'https://contoso.sharepoint.com' --listTitle 'Shared Documents'
61
+ ```
62
+
63
+ Removes a sensitivity label from a document library based on the list url.
64
+
65
+ ```sh
66
+ m365 spo list sensitivitylabel remove --webUrl 'https://contoso.sharepoint.com' --listUrl '/Shared Documents'
67
+ ```
68
+
69
+ Removes a sensitivity label from a document library based on the list id without prompting for confirmation.
70
+
71
+ ```sh
72
+ m365 spo list sensitivitylabel remove --webUrl 'https://contoso.sharepoint.com' --listId 'b4cfa0d9-b3d7-49ae-a0f0-f14ffdd005f7' --force
73
+ ```
74
+
75
+ ## Response
76
+
77
+ The command won't return a response on success.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "11.9.0-beta.93bd508",
3
+ "version": "11.9.0-beta.f8dc984",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",