Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command: m365 spo folder sharinglink add #5963

Open
Tracked by #3996
MathijsVerbeeck opened this issue Apr 5, 2024 · 8 comments · May be fixed by #6002
Open
Tracked by #3996

New command: m365 spo folder sharinglink add #5963

MathijsVerbeeck opened this issue Apr 5, 2024 · 8 comments · May be fixed by #6002

Comments

@MathijsVerbeeck
Copy link
Contributor

MathijsVerbeeck commented Apr 5, 2024

Usage

m365 spo folder sharinglink add [options]

Description

Creates a new sharing link to a folder

Options

Option Description
-u, --webUrl <webUrl> The URL of the site where the file is located
--folderUrl [folderUrl] The server- or site-relative decoded URL of the folder. Specify either folderUrl or folderId but not both
--folderId [folderId] The unique ID (GUID) of the folder. Specify either folderUrl or folderId but not both
--type <type> The type of sharing link to create. Either view or edit
--expirationDateTime [expirationDateTime] The date and time to set the expiration. This should be defined as a valid ISO 8601 string
--scope [scope] Optional. The scope of link to create. Either anonymous, organization or users. If not specified, the default of the organization will be used
--retainInheritedPermissions [retainInheritiedPermissions] Optional. If true, any existing inherited permissions are retained on the shared item when sharing this item for the first time. If false, all existing permissions are removed when sharing for the first time.
--recipients [recipients] Comma separated list of users with whom we wish to share the item with. Required when using scope users

Examples

Creates a view-only anonymous sharing link of a folder by id

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --folderId daebb04b-a773-4baa-b1d1-3625418e3234 --type view --scope anonymous

Creates an edit organization sharing link of a folder by url with a specific expiration date.

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --shareId 123ABC --folderUrl /sites/demo/shared%20documents/Folder --type edit --scope organization --expirationDateTime '2022-11-30T00:00:00Z'

Creates a user sharing link of a folder by id

m365 spo folder sharinglink add --webUrl https://contoso.sharepoint.com/sites/demo --folderId daebb04b-a773-4baa-b1d1-3625418e3234 --type view --scope users --recipients john@contoso.com,doe@contoso.com

Default properties

No response

Additional Info

The API call to create a sharing link can be found on the following documentation: https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0

@milanholemans milanholemans added new feature needs peer review Needs second pair of eyes to review the spec or PR labels Apr 5, 2024
@Adam-it
Copy link
Contributor

Adam-it commented Apr 10, 2024

  • besides the usual naming and support for site-relative URL
  • why don't we want to use retainInheritedPermissions as well?
  • any reason why in the scope we don't allow the user option? seems to be supported as well
    image
  • the default response it return has complex object
{
  "id": "123ABC",
  "roles": ["write"],
  "link": {
    "type": "view",
    "scope": "anonymous",
    "webUrl": "https://1drv.ms/A6913278E564460AA616C71B28AD6EB6",
    "application": {
      "id": "1234",
      "displayName": "Sample Application"
    },
  },
  "hasPassword": true
}

which is a shame as we will lose a lot of useful info in the text and csv output mode. I wonder if it would be possible to customize the response for this mode to also print out this info 🤔 @pnp/cli-for-microsoft-365-maintainers any comments on that.

besides the above I don't currently see anything else

@MathijsVerbeeck
Copy link
Contributor Author

  • any reason why in the scope we don't allow the user option? seems to be supported as well

It is supported now indeed. I'll add this to the scope, however this requires another option for the recipients.

@MathijsVerbeeck
Copy link
Contributor Author

Thanks for the feedback @Adam-it. I have implemented all the suggestions.
Regarding the output, it's hard for me to judge.

@Jwaegebaert
Copy link
Contributor

@milanholemans, if I recall, we talked a while ago about formatting nested properties for the text output. We ended up creating a custom property (#5900). What was the decision on handling these situations moving forward?

@milanholemans
Copy link
Contributor

I think for the time being, it's ok to manipulate the result object for text etc.
But in the future there will probably another way of working which we can't do right now.

@Adam-it
Copy link
Contributor

Adam-it commented Apr 20, 2024

in this case, I would flatten the complex to return also type, scope, webUrl and other properties

@Adam-it Adam-it added help wanted and removed needs peer review Needs second pair of eyes to review the spec or PR labels Apr 20, 2024
@Saurabh7019
Copy link
Contributor

Can I work on this?

@milanholemans
Copy link
Contributor

Definitely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants