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

All entra m365group commands should accept displayName option #6234

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,29 @@ m365 entra m365group conversation list [options]
## Options

```md definition-list
`-i, --groupId <groupId>`
: The ID of the Microsoft 365 group
`-i, --groupId [groupId]`
: The ID of the Microsoft 365 Group. Specify either `groupId` or `groupName`, but not both.

`-n, --groupName [groupName]`
MartinM85 marked this conversation as resolved.
Show resolved Hide resolved
: Display name of the Microsoft 365 Group. Specify either `groupId` or `groupName`, but not both.
```

<Global />

## Examples

Lists conversations for the specified Microsoft 365 group
Lists conversations for the Microsoft 365 group specified by id.

```sh
m365 entra m365group conversation list --groupId '00000000-0000-0000-0000-000000000000'
```

Lists conversations for the Microsoft 365 group specified by displayName.

```sh
m365 entra m365group conversation list --groupName Finance
```

## Response

<Tabs>
Expand Down
13 changes: 11 additions & 2 deletions docs/docs/cmd/entra/m365group/m365group-get.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ m365 entra m365group get [options]
## Options

```md definition-list
`-i, --id <id>`
: The ID of the Microsoft 365 Group or Microsoft Teams team to retrieve information for
`-i, --id [id]`
: The ID of the Microsoft 365 Group or Microsoft Teams team to retrieve information for. Specify either `id` or `displayName`, but not both.

`-n, --displayName [displayName]`
: Display name of the Microsoft 365 Group or Microsoft Teams team to retrieve information for. Specify either `id` or `displayName`, but not both.

`--includeSiteUrl`
: Set to retrieve the site URL for the group
Expand All @@ -32,6 +35,12 @@ Get information about the Microsoft 365 Group with id _1caf7dcd-7e83-4c3a-94f7-9
m365 entra m365group get --id 1caf7dcd-7e83-4c3a-94f7-932a1299c844
```

Get information about the Microsoft 365 Group with displayName _Finance_

```sh
m365 entra m365group get --displayName Finance
```

Get information about the Microsoft 365 Group with id _1caf7dcd-7e83-4c3a-94f7-932a1299c844_ and also retrieve the URL of the corresponding SharePoint site

```sh
Expand Down
11 changes: 7 additions & 4 deletions docs/docs/cmd/entra/m365group/m365group-remove.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ m365 entra m365group remove [options]
## Options

```md definition-list
`-i, --id <id>`
: The ID of the Microsoft 365 Group to remove
`-i, --id [id]`
: The ID of the Microsoft 365 Group to remove. Specify either `id` or `displayName`, but not both.

`-n, --displayName [displayName]`
: Display name of the Microsoft 365 Group to remove. Specify either `id` or `displayName`, but not both.

`-f, --force`
: Don't prompt for confirming removing the group
Expand Down Expand Up @@ -47,10 +50,10 @@ Remove group with id _28beab62-7540-4db1-a23f-29a6018a3848_. Will prompt for con
m365 entra m365group remove --id 28beab62-7540-4db1-a23f-29a6018a3848
```

Remove group with id _28beab62-7540-4db1-a23f-29a6018a3848_ without prompting for confirmation
Remove group with displayName _Finance_ without prompting for confirmation

```sh
m365 entra m365group remove --id 28beab62-7540-4db1-a23f-29a6018a3848 --force
m365 entra m365group remove --displayName Finance --force
```

Remove group with id _28beab62-7540-4db1-a23f-29a6018a3848_ without prompting for confirmation and without moving it to the Recycle Bin
Expand Down
13 changes: 11 additions & 2 deletions docs/docs/cmd/entra/m365group/m365group-renew.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ m365 entra m365group renew [options]
## Options

```md definition-list
`-i, --id <id>`
: The ID of the Microsoft 365 group to renew
`-i, --id [id]`
: The ID of the Microsoft 365 group to renew. Specify either `id` or `displayName`, but not both.

`-n, --displayName [displayName]`
: Display name of the Microsoft 365 Group to renew. Specify either `id` or `displayName`, but not both.
```

<Global />
Expand All @@ -31,6 +34,12 @@ Renew the Microsoft 365 group with id _28beab62-7540-4db1-a23f-29a6018a3848_
m365 entra m365group renew --id 28beab62-7540-4db1-a23f-29a6018a3848
```

Renew the Microsoft 365 group with displayName _Finance_

```sh
m365 entra m365group renew --displayName Finance
```

## Response

The command won't return a response on success.
15 changes: 12 additions & 3 deletions docs/docs/cmd/entra/m365group/m365group-teamify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ m365 entra m365group teamify [options]

```md definition-list
`-i, --id [id]`
: The ID of the Microsoft 365 Group to connect to Microsoft Teams. Specify either `id` or `mailNickname` but not both.
: The ID of the Microsoft 365 Group to connect to Microsoft Teams. Specify either `id`, `displayName` or `mailNickname`, but not multiple.

`-n, --displayName [displayName]`
: Display name of the Microsoft 365 Group to connect to Microsoft Teams. Specify either `id`, `displayName` or `mailNickname`, but not multiple.

`--mailNickname [mailNickname]`
: The mail alias of the Microsoft 365 Group to connect to Microsoft Teams. Specify either `id` or `mailNickname` but not both.
: The mail alias of the Microsoft 365 Group to connect to Microsoft Teams. Specify either `id`, `displayName` or `mailNickname`, but not multiple.
```

<Global />
Expand All @@ -30,7 +33,13 @@ Creates a new Microsoft Teams team under existing Microsoft 365 group with the s
m365 entra m365group teamify --id e3f60f99-0bad-481f-9e9f-ff0f572fbd03
```

Creates a new Microsoft Teams team under existing Microsoft 365 group with the specified mailNickname.
Creates a new Microsoft Teams team under existing Microsoft 365 group with the specified displayName.

```sh
m365 entra m365group teamify --displayName Finance
```

Creates a new Microsoft Teams team under existing Microsoft 365 group with the specified mailNickname._

```sh
m365 entra m365group teamify --mailNickname GroupName
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/cmd/entra/m365group/m365group-user-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ m365 entra m365group user add [options]
## Alias

```sh
m365 teams user add
m365 teams user add [options]
```

## Options
Expand All @@ -38,7 +38,7 @@ m365 teams user add
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both.

`-r, --role [role]`
: The role to be assigned to the new user: `Owner,Member`. Default `Member`.
: The role to be assigned to the new user. Allowed values: `Owner`, `Member`. Default `Member`.
```

<Global />
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/cmd/entra/m365group/m365group-user-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ List specific properties for all group users from a group specified by ID.
m365 entra m365group user list --groupId 03cba9da-3974-46c1-afaf-79caa2e45bbe --properties "id,jobTitle,companyName,accountEnabled"
```

List all group members that are guest users.

```sh
m365 entra m365group user list --groupDisplayName Developers --filter "userType eq 'Guest'"
```

## Response

<Tabs>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/cmd/entra/m365group/m365group-user-remove.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ m365 entra m365group user remove [options]
: The ID of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`--groupName [groupName]`
: The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`..
: The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`--teamId [teamId]`
: The ID of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/cmd/entra/m365group/m365group-user-set.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ m365 entra m365group user set [options]
: The user principal names of users. You can also pass a comma-separated list of UPNs. Specify only one of the following `ids` or `userNames`.

`-r, --role <role>`
: Role to set for the given user in the specified Microsoft 365 Group or Microsoft Teams team. Allowed values: `Owner`, `Member`
: Role to set for the given user in the specified Microsoft 365 Group or Microsoft Teams team. Allowed values: `Owner`, `Member`.
```

<Global />
Expand Down Expand Up @@ -70,13 +70,13 @@ m365 entra m365group user set --groupId '00000000-0000-0000-0000-000000000000' -
Demote multiple users specified by the userNames parameter from Owner to Member of the given Microsoft Teams team

```sh
m365 entra teams user set --teamId '00000000-0000-0000-0000-000000000000' --userNames '[email protected],[email protected]' --role Member
m365 teams user set --teamId '00000000-0000-0000-0000-000000000000' --userNames '[email protected],[email protected]' --role Member
```

Demote multiple users specified by the ids parameter from Owner to Member in the given Microsoft Teams team

```sh
m365 entra teams user set --teamName 'Engineering' --ids '74a3b772-3122-447b-b9da-10895e238219,dd3d21e4-a142-46b9-8482-bca8fe9596b3' --role Member
m365 teams user set --teamName 'Engineering' --ids '74a3b772-3122-447b-b9da-10895e238219,dd3d21e4-a142-46b9-8482-bca8fe9596b3' --role Member
```

## Response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe(commands.M365GROUP_CONVERSATION_LIST, () => {
sinon.stub(pid, 'getProcessName').returns('');
sinon.stub(session, 'getId').returns('');
sinon.stub(entraGroup, 'isUnifiedGroup').resolves(true);
sinon.stub(entraGroup, 'getGroupIdByDisplayName').resolves('00000000-0000-0000-0000-000000000000');
auth.connection.active = true;
commandInfo = cli.getCommandInfo(command);
});
Expand Down Expand Up @@ -102,7 +103,7 @@ describe(commands.M365GROUP_CONVERSATION_LIST, () => {
assert.strictEqual(actual, true);
});

it('Retrieve conversations for the specified group by groupId in the tenant (verbose)', async () => {
it('Retrieve conversations for the group specified by groupId in the tenant (verbose)', async () => {
sinon.stub(request, 'get').callsFake(async (opts) => {
if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/conversations`) {
return jsonOutput;
Expand All @@ -119,6 +120,25 @@ describe(commands.M365GROUP_CONVERSATION_LIST, () => {
jsonOutput.value
));
});

it('Retrieve conversations for the group specified by groupName in the tenant (verbose)', async () => {
sinon.stub(request, 'get').callsFake(async (opts) => {
if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/conversations`) {
return jsonOutput;
}
throw 'Invalid request';
});

await command.action(logger, {
options: {
verbose: true, groupName: "Finance"
}
});
assert(loggerLogSpy.calledWith(
jsonOutput.value
));
});

it('correctly handles error when listing conversations', async () => {
sinon.stub(request, 'get').rejects(new Error('An error has occurred'));

Expand Down
36 changes: 30 additions & 6 deletions src/m365/entra/commands/m365group/m365group-conversation-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ interface CommandArgs {
}

interface Options extends GlobalOptions {
groupId: string;
groupId?: string;
groupName?: string;
}

class EntraM365GroupConversationListCommand extends GraphCommand {
Expand All @@ -33,20 +34,25 @@ class EntraM365GroupConversationListCommand extends GraphCommand {

this.#initOptions();
this.#initValidators();
this.#initOptionSets();
this.#initTypes();
}

#initOptions(): void {
this.options.unshift(
{
option: '-i, --groupId <groupId>'
option: '-i, --groupId [groupId]'
},
{
option: '-n, --groupName [groupName]'
}
);
}

#initValidators(): void {
this.validators.push(
async (args: CommandArgs) => {
if (!validation.isValidGuid(args.options.groupId as string)) {
if (args.options.groupId && !validation.isValidGuid(args.options.groupId as string)) {
return `${args.options.groupId} is not a valid GUID`;
}

Expand All @@ -55,15 +61,33 @@ class EntraM365GroupConversationListCommand extends GraphCommand {
);
}

#initOptionSets(): void {
this.optionSets.push({ options: ['groupId', 'groupName'] });
}

#initTypes(): void {
this.types.string.push('groupId', 'groupName');
}

public async commandAction(logger: Logger, args: CommandArgs): Promise<void> {
if (this.verbose) {
await logger.logToStderr(`Retrieving conversations for Microsoft 365 Group: ${args.options.groupId || args.options.groupName}...`);
}

try {
const isUnifiedGroup = await entraGroup.isUnifiedGroup(args.options.groupId);
let groupId = args.options.groupId;

if (args.options.groupName) {
groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupName);
}

const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId!);

if (!isUnifiedGroup) {
throw Error(`Specified group with id '${args.options.groupId}' is not a Microsoft 365 group.`);
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
}

const conversations = await odata.getAllItems<Conversation>(`${this.resource}/v1.0/groups/${args.options.groupId}/conversations`);
const conversations = await odata.getAllItems<Conversation>(`${this.resource}/v1.0/groups/${groupId}/conversations`);
await logger.log(conversations);
}
catch (err: any) {
Expand Down
Loading