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 spe containertype remove #5992

Open
Adam-it opened this issue Apr 24, 2024 · 4 comments
Open

New command: m365 spe containertype remove #5992

Adam-it opened this issue Apr 24, 2024 · 4 comments

Comments

@Adam-it
Copy link
Contributor

Adam-it commented Apr 24, 2024

Usage

m365 spe containertype remove [options]

Description

Remove 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.
-f, --force Don't prompt for confirming removal

Examples

Removes Container Type by id

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

Removes Container Type by name

m365 spe containertype remove --name 'test container'

Removes Container Type by id and doesn't prompt for confirmation

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

Default properties

No response

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="58" ObjectPathId="57" />
        <Method Name="RemoveSPOContainerType" Id="59" ObjectPathId="57">
            <Parameters>
                <Parameter TypeId="{b66ab1ca-fd51-44f9-8cfc-01f5c2a21f99}">
                    <Property Name="ContainerTypeId" Type="Guid">{4ec4aefd-4fa3-0e4a-20c3-6e68389e7138}</Property>
                </Parameter>
            </Parameters>
        </Method>
    </Actions>
    <ObjectPaths>
        <Constructor Id="57" 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 remove 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

❗Important

We need to handle that only Trail Container Type may be removed. This should be added to the command spec

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

Adam-it commented Apr 24, 2024

@andrewconnell any opinion on that 👆

@milanholemans
Copy link
Contributor

2 remarks:

  1. Only trial Container Types can be removed, does this mean that we don't have to check for the type ourselves and the API will just throw a decent error when you try to remove a standard container type?

Documentation quote:

To delete a trial Container Type, you must remove all Containers of the Trial Container Type first, including from the recycle bin. To remove Containers from the Trial Container Type, refer to Consuming Tenant Admin. Once all the Containers are deleted, Developer Admins can delete the Container Types using the below PowerShell cmdlet.

What will happen if we run this command when there are still containers attached? Will we remove them, or just throw an error?

@Adam-it
Copy link
Contributor Author

Adam-it commented Apr 25, 2024

2 remarks:

  1. Only trial Container Types can be removed, does this mean that we don't have to check for the type ourselves and the API will just throw a decent error when you try to remove a standard container type?

yes it will return something like Tenant 2942bb31-1d49-4da6-8d3d-d0f9e1141486 cannot delete Container Type 32793d51-870d-07da-113f-b586dee1c12a as it is Standard ContainerType.

Documentation quote:

To delete a trial Container Type, you must remove all Containers of the Trial Container Type first, including from the recycle bin. To remove Containers from the Trial Container Type, refer to Consuming Tenant Admin. Once all the Containers are deleted, Developer Admins can delete the Container Types using the below PowerShell cmdlet.

What will happen if we run this command when there are still containers attached? Will we remove them, or just throw an error?

I think we should throw an error.

@milanholemans
Copy link
Contributor

Ok, thanks for clarifying. Let's open it up then.

@milanholemans milanholemans added help wanted and removed needs peer review Needs second pair of eyes to review the spec or PR labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants