-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
34 changed files
with
2,094 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# User Risk Profiles | ||
|
||
```{eval-rst} | ||
.. autoclass:: py42.clients.userriskprofile.UserRiskProfileClient | ||
:members: | ||
:show-inheritance: | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Watchlists | ||
|
||
```{eval-rst} | ||
.. autoclass:: py42.clients.watchlists.WatchlistType | ||
:members: | ||
:show-inheritance: | ||
``` | ||
|
||
```{eval-rst} | ||
.. autoclass:: py42.clients.watchlists.WatchlistsClient | ||
:members: | ||
:show-inheritance: | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# User Risk Profile | ||
|
||
A user risk profile is created for each user. Use py42 to manage these user risk profiles. | ||
|
||
## Update a User Risk Profile | ||
|
||
Determine the user ID to manage a user's risk profile. For example, the following code uses the `get_username()` method to find the ID of a user with the username `test.user@code42.com`. | ||
|
||
```python | ||
response = sdk.userriskprofile.get_username() | ||
|
||
user_id = response.data["userId"] | ||
``` | ||
|
||
Use the user ID with the `update()` method to manage a user risk profiles' `startDate`, `endDate`, and `notes` fields. | ||
|
||
The `startDate` and `endDate` arguments expect a format of `YYYY-MM-DD` or a `datetime` object. | ||
|
||
The following code updates the departure date of the user risk profile to March 1st, 2025: | ||
|
||
```python | ||
# update the user risk profile | ||
sdk.userriskprofile.update(user_id, end_date="2025-03-01", notes="Updated the departure date.") | ||
|
||
# view updated user details | ||
py42.util.print_response(sdk.userriskprofile.get(user_id)) | ||
``` | ||
|
||
If you want to clear a field, provide an empty string to the corresponding argument. | ||
|
||
For example, the following code will clear the `endDate` and `notes` fields: | ||
|
||
```python | ||
# clear fields on the user risk profile | ||
sdk.userriskprofile.update(user_id, end_date="", notes="") | ||
``` | ||
|
||
## Manage Cloud Aliases | ||
|
||
Each user risk profile starts with a default alias of their code42 username and can have one additional cloud alias. | ||
Use the `UserRiskProfileClient` to manage these aliases. | ||
|
||
Use `add_cloud_aliases()` to assign additional cloud aliases to a user: | ||
|
||
```python | ||
user_id = "test-user-123" | ||
cloud_aliases = "test-user@email.com" | ||
sdk.userriskprofile.add_cloud_aliases(user_id, cloud_aliases) | ||
|
||
# view updated user cloud aliases | ||
py42.util.print_response(sdk.userriskprofile.get(user_id)) | ||
``` | ||
|
||
Remove cloud aliases in a similar manner using the `delete_cloud_aliases()` method. Provide a list of values to add or remove multiple aliases at once. | ||
|
||
```python | ||
sdk.userriskprofile.delete_cloud_aliases(user_id, ["test-user@email.com", "username@email.com"]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Watchlists | ||
|
||
Use py42 to create and manage watchlists. | ||
|
||
Watchlists have replaced the Departing Employees and High Risk Employees detections lists. See the [Code42 support documentation](https://support.code42.com/Incydr/Admin/Monitoring_and_managing/Manage_watchlists) on managing watchlists for more information. | ||
|
||
## Create a Watchlist | ||
|
||
```python | ||
from py42.constants import WatchlistType | ||
|
||
watchlist = sdk.watchlists.create(WatchlistType.DEPARTING) | ||
|
||
# store the id of the new watchlist | ||
watchlist_id = watchlist.data["watchlistId"] | ||
``` | ||
|
||
Watchlist types are available as constants in the [WatchlistType](https://py42docs.code42.com/en/stable/methoddocs/constants.html#py42.constants.WatchlistType) class. | ||
|
||
## View Watchlist Details | ||
|
||
There are several methods to view different details about watchlists. | ||
|
||
```python | ||
import py42.util | ||
|
||
# Get information on all current watchlists | ||
response = sdk.watchlists.get_all() | ||
|
||
# print all information to the console | ||
for page in response: | ||
py42.util.print_response(page) | ||
``` | ||
|
||
Once you have the watchlist's ID, use the following methods to see more details: | ||
|
||
```python | ||
# To get watchlist details | ||
sdk.watchlists.get(watchlist_id) | ||
|
||
# To see all included users | ||
sdk.watchlists.get_all_included_users(watchlist_id) | ||
``` | ||
|
||
## Manage Users on Watchlists | ||
|
||
Use the `included_users` methods to manage individual users who are explicitly included on watchlists. | ||
|
||
Py42 allows you to reference a watchlist either by its ID or by its type. If adding individual users to a watchlist with the `add_included_users_by_watchlist_type()` method, py42 will create the watchlist for you if it doesn't already exist. | ||
|
||
For example, the following code demonstrates two methods to add users to the Departing watchlist: | ||
|
||
```python | ||
user_ids = ["test-user-123", "test-user-456"] | ||
|
||
# METHOD 1: add by watchlist id | ||
sdk.watchlists.add_included_users_by_watchlist_id(user_ids, watchlist_id) | ||
|
||
# METHOD 2: add by watchlist type | ||
from py42.constants import WatchlistType | ||
|
||
# this method will create the DEPARTING watchlist for you if it doesn't already exist | ||
sdk.watchlists.add_included_users_by_watchlist_type(user_ids, WatchlistType.DEPARTING) | ||
|
||
# View your updated watchlist users | ||
sdk.watchlists.get_all_included_users(watchlist_id) | ||
``` | ||
|
||
The `delete_included_users_by_watchlist_id()` and `delete_included_users_by_watchlist_type()` methods can be used similarly to remove users from a watchlist. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,7 @@ | |
"cases", | ||
"loginconfig", | ||
"trustedactivities", | ||
"userriskprofile", | ||
"watchlists", | ||
], | ||
) |
Oops, something went wrong.