Add outlook calendargroup get command. Closes #7111#7166
Add outlook calendargroup get command. Closes #7111#7166AlejandroGispert wants to merge 2 commits intopnp:mainfrom
Conversation
46032d6 to
3da5852
Compare
Made-with: Cursor
e63aaba to
d002fb8
Compare
|
Hi @milanholemans @MartinM85 , Can you check my PR? |
There was a problem hiding this comment.
Pull request overview
Adds the missing m365 outlook calendargroup get command to the CLI for Microsoft 365 to retrieve a specific Outlook calendar group for a user, supporting lookup by either --id or --name, and documenting/validating delegated vs app-only behavior.
Changes:
- Introduces
outlook calendargroup getcommand implementation with Zod validation and Graph calls - Adds unit tests covering key permission/lookup scenarios
- Adds documentation page and wires it into the Docusaurus sidebar
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/m365/outlook/commands/calendargroup/calendargroup-get.ts | Implements the new calendargroup get command, including permission handling and name-to-id resolution |
| src/m365/outlook/commands/calendargroup/calendargroup-get.spec.ts | Adds unit tests for the new command (id/name, delegated/app-only, shared-scope handling) |
| src/m365/outlook/commands.ts | Registers the new command name constant |
| docs/src/config/sidebars.ts | Adds the new command docs page to the Outlook sidebar group |
| docs/docs/cmd/outlook/calendargroup/calendargroup-get.mdx | Adds reference documentation for outlook calendargroup get |
…rs for API requests - Updated the command to encode user identifiers before constructing API URLs. - Adjusted test cases to reflect changes in user identifier handling.
|
Hi @milanholemans @MartinM85 , Can you check my PR? |
MartinM85
left a comment
There was a problem hiding this comment.
Hi @AlejandroGispert, great start 👍.
I have a couple of comments, nothing major.
| "id": "id-value", | ||
| "name": "name-value", | ||
| "changeKey": "changeKey-value", | ||
| "classId": "classId-value" |
There was a problem hiding this comment.
Could you please improve the response? It would be better use some "real" values instead of the id-value, etc.
Check the response for the similar command outlook calendargroup list
| ```text | ||
| id | name | ||
| ------------------------------------------------------------------ ---------------- | ||
| id-value name-value |
There was a problem hiding this comment.
Could you please improve the response? It would be better use some "real" values instead of the id-value, etc.
Check the response for the similar command outlook calendargroup list
|
|
||
| ```csv | ||
| id,name | ||
| id-value,name-value |
There was a problem hiding this comment.
Could you please improve the response? It would be better use some "real" values instead of the id-value, etc.
Check the response for the similar command outlook calendargroup list
| id | id-value | ||
| name | name-value |
There was a problem hiding this comment.
Could you please improve the response? It would be better use some "real" values instead of the id-value, etc.
Check the response for the similar command outlook calendargroup list
| public defaultProperties(): string[] | undefined { | ||
| return ['id', 'name']; | ||
| } |
There was a problem hiding this comment.
Please remove it. We define the default properties only for the list commands.
| const getCalendarGroupId = async (calendarGroupName: string): Promise<string> => { | ||
| const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me'; | ||
| const calendarGroups = await odata.getAllItems<CalendarGroup>( | ||
| `${this.resource}/v1.0/${userPath}/calendarGroups?$select=id,name&$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'` | ||
| ); | ||
|
|
||
| if (calendarGroups.length === 0) { | ||
| throw `The specified calendar group '${calendarGroupName}' does not exist.`; | ||
| } | ||
|
|
||
| return calendarGroups[0].id!; | ||
| }; |
There was a problem hiding this comment.
This method already returns the calendar group. No need to call the endpoint again to get the calendar group by id.
| const getCalendarGroupId = async (calendarGroupName: string): Promise<string> => { | |
| const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me'; | |
| const calendarGroups = await odata.getAllItems<CalendarGroup>( | |
| `${this.resource}/v1.0/${userPath}/calendarGroups?$select=id,name&$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'` | |
| ); | |
| if (calendarGroups.length === 0) { | |
| throw `The specified calendar group '${calendarGroupName}' does not exist.`; | |
| } | |
| return calendarGroups[0].id!; | |
| }; | |
| const getCalendarGroupByName = async (calendarGroupName: string): Promise<CalendarGroup> => { | |
| const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me'; | |
| const calendarGroups = await odata.getAllItems<CalendarGroup>( | |
| `${this.resource}/v1.0/${userPath}/calendarGroups?$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'` | |
| ); | |
| if (calendarGroups.length === 0) { | |
| throw `The specified calendar group '${calendarGroupName}' does not exist.`; | |
| } | |
| return calendarGroups[0]; | |
| }; |
Closes #7111
Summary
Adds the missing m365 outlook calendargroup get command to retrieve a specific calendar group for a user, supporting lookup by either --id or --name (with --name resolving to an id via OData filtering).
Details
Implements m365 outlook calendargroup get with delegated vs app-only permission handling.
Enforces mutually exclusive --id/--name and --userId/--userName.
Adds unit tests and a docs page, and wires the command into the docs sidebar.