sempy_labs.graph package
Module contents
- sempy_labs.graph.add_group_members(group: str | UUID, user: str | UUID | List[str | UUID])
Adds a member to a group.
This is a wrapper function for the following API: Add members.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.add_group_owners(group: str | UUID, user: str | UUID | List[str | UUID])
Adds an owner to a group.
This is a wrapper function for the following API: Add owners.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.add_user_license(user: str | UUID, sku_id: UUID, disabled_plans: UUID | List[UUID] | None = None)
Assigns a license to a user.
This is a wrapper function for the following API: user: assignLicense.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.create_group(display_name: str, description: str | None = None, mail_enabled: bool = False, security_enabled: bool = True, mail_nickname: str = None, owners: str | UUID | List[str | UUID] | None = None, members: str | UUID | List[str | UUID] | None = None)
Creates a new group.
This is a wrapper function for the following API: Create group.
Service Principal Authentication is required (see here for examples).
- Parameters:
display_name (str) – The name of the group.
description (str, optional) – The description of the group.
mail_enabled (bool, default=False) – Whether the group is mail-enabled.
security_enabled (bool, default=True) – Whether the group is security-enabled.
mail_nickname (str, default=None) – The mail alias for the group.
owners (str | uuid.UUID | List[str | uuid.UUID], default=None) – The owners of the group.
members (str | uuid.UUID | List[str | uuid.UUID], default=None) – The members of the group.
- sempy_labs.graph.create_user(display_name: str, user_principal_name: str, mail_nickname: str, password: str, account_enabled: bool = True, force_change_password_next_sign_in: bool = True)
Creates a new user.
This is a wrapper function for the following API: Create User.
Service Principal Authentication is required (see here for examples).
- Parameters:
display_name (str) – The name to display in the address book for the user.
user_principal_name (str) – The user principal name (someuser@contoso.com).
mail_nickname (str) – The mail alias for the user.
password (str) – The initial password for the user.
account_enabled (bool, default=True) – Whether the account is enabled. Default is True.
force_change_password_next_sign_in (bool, default=True) – Whether the user must change their password on next sign-in. Default is True.
- sempy_labs.graph.delete_group(group: str | UUID)
Deletes a group.
This is a wrapper function for the following API: Delete group.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.delete_user(user: str | UUID)
Deletes a user.
This is a wrapper function for the following API: Delete User.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.get_user(user: str | UUID, show_manager: bool = False) DataFrame
Shows properties of a given user.
This is a wrapper function for the following API: Get a user.
Service Principal Authentication is required (see here for examples).
- Parameters:
- Returns:
A pandas dataframe showing properties of a given user.
- Return type:
- sempy_labs.graph.list_group_members(group: str | UUID) DataFrame
Shows a list of the members of a group.
This is a wrapper function for the following API: List group members.
Service Principal Authentication is required (see here for examples).
- Parameters:
- Returns:
A pandas dataframe showing a list of the members of a group.
- Return type:
- sempy_labs.graph.list_group_owners(group: str | UUID) DataFrame
Shows a list of the owners of a group.
This is a wrapper function for the following API: List group owners.
Service Principal Authentication is required (see here for examples).
- Parameters:
- Returns:
A pandas dataframe showing a list of the owners of a group.
- Return type:
- sempy_labs.graph.list_group_transitive_members(group: str | UUID) DataFrame
Shows a list of the members of a group. This operation is transitive and returns a flat list of all nested members.
This is a wrapper function for the following API: List group transitive members.
Service Principal Authentication is required (see here for examples).
- Parameters:
- Returns:
A pandas dataframe showing a list of the members of a group.
- Return type:
- sempy_labs.graph.list_groups() DataFrame
Shows a list of groups and their properties.
This is a wrapper function for the following API: List groups.
Service Principal Authentication is required (see here for examples).
- Returns:
A pandas dataframe showing a list of groups and their properties.
- Return type:
- sempy_labs.graph.list_sensitivity_labels(user: str | UUID | None = None) DataFrame
Get a list of sensitivity label objects associated with a user or organization.
This is a wrapper function for the following API: `List sensitivityLabels https://learn.microsoft.com/graph/api/security-informationprotection-list-sensitivitylabels>`_.
Service Principal Authentication is required (see here for examples).
- Parameters:
user (str | uuid.UUID) – The user ID or user principal name.
- Returns:
A pandas dataframe showing a list of sensitivity label objects associated with a user or organization.
- Return type:
- sempy_labs.graph.list_teams() DataFrame
Shows a list of teams and their properties.
This is a wrapper function for the following API: List teams.
Service Principal Authentication is required (see here for examples).
- Returns:
A pandas dataframe showing a list of teams and their properties.
- Return type:
- sempy_labs.graph.list_users(show_manager: bool = False) DataFrame
Shows a list of users and their properties.
This is a wrapper function for the following API: List users.
Service Principal Authentication is required (see here for examples).
- Parameters:
show_manager (bool, default=False) – Whether to include the user’s manager information.
- Returns:
A pandas dataframe showing a list of users and their properties.
- Return type:
- sempy_labs.graph.remove_user_license(user: str | UUID, sku_ids: UUID | List[UUID])
Removes a license from a user.
This is a wrapper function for the following API: user: assignLicense.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.renew_group(group: str | UUID)
Renews the group.
This is a wrapper function for the following API: Renew group.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.resolve_group_id(group: str | UUID) UUID
Resolves the group ID from the group name or ID.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.resolve_sensitivity_label_id(label: str | UUID, user: str | UUID | None = None) UUID | None
Resolve a sensitivity label name or ID to its corresponding sensitivity label ID.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.resolve_user_id(user: str | UUID) UUID
Resolves the user ID from the user principal name or ID.
Service Principal Authentication is required (see here for examples).
- sempy_labs.graph.send_mail(user: UUID | str, subject: str, to_recipients: str | List[str], content: str, content_type: Literal['Text', 'HTML'] = 'Text', cc_recipients: str | List[str] | None = None, bcc_recipients: str | List[str] | None = None, priority: Literal['Normal', 'High', 'Low'] = 'Normal', attachments: str | List[str] | None = None)
Sends an email to the specified recipients.
This is a wrapper function for the following API: user: sendMail.
Service Principal Authentication is required (see here for examples).
- Parameters:
user (uuid.UUID | str) – The user ID or user principal name.
subject (str) – The email subject.
to_recipients (str | List[str]) – The email address of the recipients.
content (str) – The email content.
content_type (Literal["Text", "HTML"], default="Text") – The email content type. Options: “Text” or “HTML”.
cc_recipients (str | List[str], default=None) – The email address of the CC recipients.
bcc_recipients (str | List[str], default=None) – The email address of the BCC recipients.
priority (Literal["Normal", "High", "Low"], default="Normal") – The email priority.
attachments (str | List[str], default=None) – The abfss path or a list of the abfss paths of the attachments to include in the email.
- sempy_labs.graph.update_group(group: str | UUID, display_name: str | None = None, mail_nickname: str | None = None, description: str | None = None, security_enabled: bool | None = None)
Updates a group’s properties.
This is a wrapper function for the following API: Update group.
Service Principal Authentication is required (see here for examples).
- Parameters:
- sempy_labs.graph.update_user(user: str | UUID, display_name: str | None = None, user_principal_name: str | None = None, given_name: str | None = None, surname: str | None = None, job_title: str | None = None, mail_nickname: str | None = None, my_site: str | None = None, office_location: str | None = None, account_enabled: bool | None = None)
Updates a user’s properties.
This is a wrapper function for the following API: Update user.
Service Principal Authentication is required (see here for examples).
- Parameters:
display_name (str, default=None) – The name displayed in the address book for the user.
user_principal_name (str, default=None) – The user principal name (UPN) of the user.
given_name (str, default=None) – The given name (first name) of the user.
surname (str, default=None) – The user’s surname (family name or last name).
job_title (str, default=None) – The user’s job title.
mail_nickname (str, default=None) – The mail alias for the user. This property must be specified when a user is created.
my_site (str, default=None) – The URL for the user’s personal site.
office_location (str, default=None) – The office location in the user’s place of business.
account_enabled (bool, default=None) – Whether the account is enabled. If None, the property will not be updated.