pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
882 stars 312 forks source link

New command: m365 spe containertype get #5991

Open Adam-it opened 2 months ago

Adam-it commented 2 months ago

Usage

m365 spe containertype get [options]

Description

Get a specific Container Type

Options

Option Description
-i, --id [id] The Id of the Container Type. Specify either id or name but not both.
-n, --name [name] The Container Type name. Specify either id or name but not both.

Examples

Gets Container Type by id

m365 spe containertype get --id '4ec4aefd-4fa3-0e4a-20c3-6e68389e7138'

Gets Container Type by name

m365 spe containertype get --name 'test container'

Additional Info

We may use CSOM for this command passing the following

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SharePoint Online PowerShell (16.0.24322.0)"
    xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <ObjectPath Id="49" ObjectPathId="48" />
        <Method Name="GetSPOContainerTypeById" Id="50" ObjectPathId="48">
            <Parameters>
                <Parameter Type="Guid">{4ec4aefd-4fa3-0e4a-20c3-6e68389e7138}</Parameter>
                <Parameter Type="Enum">1</Parameter>
            </Parameters>
        </Method>
    </Actions>
    <ObjectPaths>
        <Constructor Id="48" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
    </ObjectPaths>
</Request>

⚠️ Tricky part

The CSOM call does not support filtering by name only by Guid so if we want to add handling also querying the Container Type by name what we will need to do under the hood is query all Container Types and filter them by name. Also if more than one Container Type will be found (as the name does not have to be unique) CLI (when interactive mode on) should prompt to pick the correct one based on id

Adam-it commented 2 months ago

@andrewconnell any feed on 👆

andrewconnell commented 2 months ago

Sorry, no insights to share on this one.

milanholemans commented 2 months ago

The only remark from my side is that get commands don't implement default properties.

Adam-it commented 2 months ago

The only remark from my side is that get commands don't implement default properties.

Thanks for the comment. Removed. @pnp/cli-for-microsoft-365-maintainers any other comment before I open this up?

waldekmastykarz commented 2 months ago

No comments. Good remark about getting containers by name. Let's do this.

reshmee011 commented 2 months ago

Happy to work on it:)

milanholemans commented 2 months ago

Thank you!