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 entra pim role request list' - Retrieves a list of PIM requests for roles #5781

Open
Tracked by #5669
martinlingstuyl opened this issue Jan 16, 2024 · 8 comments · May be fixed by #5986
Open
Tracked by #5669

Comments

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Jan 16, 2024

An important part of the PIM space is checking if you've already requested a roleassignment request and if that request has been approved. We need to have a command to list pim requests.

I've not added the roleassignment noun here on purpose, as the request list can encompass requests for multiple types of requests.

Usage

m365 entra pim role request list [options]

Description

Retrieves a list of PIM requests for roles.

Options

Option Description
--userId [userId] Id of the user for which to list requests. Specify either userId, userName, groupId or groupName. If not specified, all requests will be listed.
--userName [userName] UPN of the user for which to list requests. Specify either userId, userName, groupId or groupName. If not specified, all requests will be listed.
--groupId [groupId] Id of the group for which to list requests. Specify either userId, userName, groupId or groupName. If not specified, all requests will be listed.
--groupName [groupName] Display name of the group for which to list requests. Specify either userId, userName, groupId or groupName. If not specified, all requests will be listed.
-c, --createdDateTime [createdDateTime] An optional ISO 8601 formatted date filter to search from.
-s, --status [status] An optional value to filter the list of requests. Allowed values are: CanceledDeniedFailedGrantedPendingAdminDecisionPendingApprovalPendingProvisioningPendingScheduleCreationProvisionedRevoked, and ScheduleCreated.
--includePrincipalDetails An optional flag to include details of the principals.

Examples

Get a list of all PIM requests for roles.

m365 entra pim role request list

Get a list of PIM requests for the current user.

m365 entra pim role request list --userId '@meID'

Get a list of PIM requests for a specified user since the first of January 2024

m365 entra pim role request list --userName 'admin-john@contoso.com' --startDateTime 2024-01-01T00:00:00Z

Get a list of PIM requests with principal details

m365 entra pim role request list --includePrincipalDetails

Response

 [
        {
            "id": "95c690fb-3eb3-4942-a03f-4524aed6f31e",
            "status": "Provisioned",
            "createdDateTime": "2022-04-11T11:50:05.95Z",
            "completedDateTime": "2022-04-11T11:50:06Z",
            "approvalId": null,
            "customData": null,
            "action": "adminAssign",
            "principalId": "071cc716-8147-4397-a5ba-b2105951cc0b",
            "roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
            "directoryScopeId": "/",
            "appScopeId": null,
            "isValidationOnly": false,
            "targetScheduleId": "95c690fb-3eb3-4942-a03f-4524aed6f31e",
            "justification": "Assign Groups Admin to IT Helpdesk group",
            "createdBy": {
                "application": null,
                "device": null,
                "user": {
                    "displayName": null,
                    "id": "3fbd929d-8c56-4462-851e-0eb9a7b3a2a5"
                }
            },
            "scheduleInfo": {
                "startDateTime": "2022-04-11T11:50:05.9999343Z",
                "recurrence": null,
                "expiration": {
                    "type": "noExpiration",
                    "endDateTime": null,
                    "duration": null
                }
            },
            "ticketInfo": {
                "ticketNumber": null,
                "ticketSystem": null
            }
        },
        "roleDefinition": {
            "displayName": "Global Administrator"
        }
]

Response with details of the principal

 [
        {
            "id": "95c690fb-3eb3-4942-a03f-4524aed6f31e",
            "status": "Provisioned",
            "createdDateTime": "2022-04-11T11:50:05.95Z",
            "completedDateTime": "2022-04-11T11:50:06Z",
            "approvalId": null,
            "customData": null,
            "action": "adminAssign",
            "principalId": "071cc716-8147-4397-a5ba-b2105951cc0b",
            "roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
            "directoryScopeId": "/",
            "appScopeId": null,
            "isValidationOnly": false,
            "targetScheduleId": "95c690fb-3eb3-4942-a03f-4524aed6f31e",
            "justification": "Assign Groups Admin to IT Helpdesk group",
            "createdBy": {
                "application": null,
                "device": null,
                "user": {
                    "displayName": null,
                    "id": "3fbd929d-8c56-4462-851e-0eb9a7b3a2a5"
                }
            },
            "scheduleInfo": {
                "startDateTime": "2022-04-11T11:50:05.9999343Z",
                "recurrence": null,
                "expiration": {
                    "type": "noExpiration",
                    "endDateTime": null,
                    "duration": null
                }
            },
            "ticketInfo": {
                "ticketNumber": null,
                "ticketSystem": null
            }
        },
        "roleDefinition": "Global Administrator",
        "principal":  {
		"@odata.type": "#microsoft.graph.user",
		"id": "6be4b305-b75e-4efc-bfcc-31bd3b53a5f8",
		"displayName": "Alex Wilber",
		"userPrincipalName": "alexw@contoso.com",
		"mail": "alexw@contoso.com",
		"businessPhones": [],
		"givenName": null,
		"jobTitle": null,
		"mobilePhone": null,
		"officeLocation": null,
		"preferredLanguage": null,
		"surname": null
	}
]

The roleDefinitionName property will need to be added to the objects, based on the expanded property roleDefinition.

Default properties

From the response output in text mode we'll show id, roleDefinitionName and principalId

Additional information

Needs Entra permission scopes "RoleAssignmentSchedule.ReadWrite.Directory" and/or "RoleManagement.Read.Directory" OR "Directory.ReadWrite.All" which we already may have. (I'm using ReadWrite, as we're also writing in other subcommands of pim.)

https://learn.microsoft.com/en-us/graph/api/rbacapplication-list-roleassignmentschedulerequests?view=graph-rest-1.0&tabs=http

By default, we need to expand/request the displayName of the role definition when calling the endpoint, using ?$expand=roleDefinition($select=displayName)

@martinlingstuyl martinlingstuyl added new feature needs peer review Needs second pair of eyes to review the spec or PR labels Jan 16, 2024
@martinlingstuyl martinlingstuyl changed the title New command: 'm365 entra pim roleassignment request list' - Retrieves a list of open role assignment requests for the current user. New command: 'm365 entra pim roleassignment request list' - Retrieves a list of role assignment requests for the current user. Jan 16, 2024
@martinlingstuyl martinlingstuyl changed the title New command: 'm365 entra pim roleassignment request list' - Retrieves a list of role assignment requests for the current user. New command: 'm365 entra pim roleassignment request list' - Retrieves a list of role assignment requests for a user or group Jan 16, 2024
@waldekmastykarz
Copy link
Member

Since this is a list command, which properties are we going to display by default? Also, do we need to do any additional work to handle the nested objects in non-JSON outputs?

@martinlingstuyl martinlingstuyl added enhancement good first issue and removed needs peer review Needs second pair of eyes to review the spec or PR labels Feb 4, 2024
@martinlingstuyl martinlingstuyl changed the title New command: 'm365 entra pim roleassignment request list' - Retrieves a list of role assignment requests for a user or group New command: 'm365 entra pim request list' - Retrieves a list of PIM requests Feb 10, 2024
@martinlingstuyl martinlingstuyl changed the title New command: 'm365 entra pim request list' - Retrieves a list of PIM requests New command: 'm365 entra pim roles request list' - Retrieves a list of PIM requests for roles Feb 13, 2024
@martinlingstuyl martinlingstuyl changed the title New command: 'm365 entra pim roles request list' - Retrieves a list of PIM requests for roles New command: 'm365 entra pim role request list' - Retrieves a list of PIM requests for roles Feb 18, 2024
@MartinM85
Copy link
Contributor

Compared to similar ones, looks good. I will take it once is reviewed by other maintainers

@martinlingstuyl
Copy link
Contributor Author

Any comments before we open this up @pnp/cli-for-microsoft-365-maintainers?

@Jwaegebaert
Copy link
Contributor

Looks good to me! I'll assign you @MartinM85.

@MartinM85
Copy link
Contributor

@martinlingstuyl Do you want to allow filtering by scheduleInfo/startDateTime or createdDateTime?

What about an option status to allow filter by the status of the role assignment request? Seems to me it can be useful.

https://learn.microsoft.com/en-us/graph/api/resources/request?view=graph-rest-1.0

But the option status can be added later.

@martinlingstuyl
Copy link
Contributor Author

Do you want to allow filtering by scheduleInfo/startDateTime or createdDateTime?

Good question.. I now see that its not at alle clear...

I think it's more logical to be able to filter from the creation of the request. What about you?

Let's rename the option to createdDateTime!

What about an option status to allow filter by the status of the role assignment request? Seems to me it can be useful.

I really like this one, yes... You need to be able to filter requests that have not been approved yet. I'll add it to the specs. Can you review?

@martinlingstuyl
Copy link
Contributor Author

I've updated the specs.

We'll need a clear example though, to show how to list requests that need approval. Or something like that.

@MartinM85
Copy link
Contributor

I would also prefer createdDateTime. Spec looks good now. I will add clear examples into the doc

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.

4 participants