-
Notifications
You must be signed in to change notification settings - Fork 5
Integ 3173/risk indicators #171
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
Merged
ceciliastevens
merged 2 commits into
feature/INTEG-3159/trust-updates
from
INTEG-3173/risk-indicators
May 4, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 @@ | ||
| # Risk Indicator Categories Commands | ||
|
|
||
| ::: mkdocs-click | ||
| :module: _incydr_cli.cmds.risk_indicator_categories | ||
| :command: risk_indicator_categories | ||
| :list_subcommands: |
This file contains hidden or 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 hidden or 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,5 @@ | ||
| # Risk Indicator Categories | ||
|
|
||
| ::: _incydr_sdk.risk_indicator_categories.client.RiskIndicatorCategoriesV1 | ||
| :docstring: | ||
| :members: |
This file contains hidden or 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 hidden or 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 hidden or 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,103 @@ | ||
| import itertools | ||
| from typing import Iterator | ||
| from typing import Optional | ||
|
|
||
| import click | ||
|
|
||
| from _incydr_cli import console | ||
| from _incydr_cli import logging_options | ||
| from _incydr_cli import render | ||
| from _incydr_cli.cmds.options.output_options import columns_option | ||
| from _incydr_cli.cmds.options.output_options import table_format_option | ||
| from _incydr_cli.cmds.options.output_options import TableFormat | ||
| from _incydr_cli.core import IncydrCommand | ||
| from _incydr_cli.core import IncydrGroup | ||
| from _incydr_sdk.core.client import Client | ||
| from _incydr_sdk.risk_indicator_categories.models import RiskIndicator | ||
|
|
||
|
|
||
| @click.group(cls=IncydrGroup) | ||
| @logging_options | ||
| def risk_indicator_categories(): | ||
| """View and manage risk indicators.""" | ||
|
|
||
|
|
||
| @risk_indicator_categories.command("list", cls=IncydrCommand) | ||
| @table_format_option | ||
| @columns_option | ||
| @logging_options | ||
| def list_categories( | ||
| format_: Optional[TableFormat] = None, | ||
| columns: Optional[str] = None, | ||
| ): | ||
| """ | ||
| List Risk Indicators by category and subcategory. | ||
| """ | ||
| client = Client() | ||
| categories = client.risk_indicator_categories.v1.list_categories().categories | ||
|
|
||
| if format_ == TableFormat.table: | ||
| columns = columns or [ | ||
| "id", | ||
| "name", | ||
| "description", | ||
| "category_name", | ||
| "category_id", | ||
| "subcategory_name", | ||
| "subcategory_id", | ||
| "type", | ||
| ] | ||
| render.table( | ||
| RiskIndicatorTableEntry, | ||
| iter_risk_indicator_table_entries(categories), | ||
| columns=columns, | ||
| flat=False, | ||
| ) | ||
| elif format_ == TableFormat.csv: | ||
| render.csv( | ||
| RiskIndicatorTableEntry, | ||
| iter_risk_indicator_table_entries(categories), | ||
| columns=columns, | ||
| flat=True, | ||
| ) | ||
| else: | ||
| printed = False | ||
| for indicator in iter_risk_indicator_table_entries(categories): | ||
| printed = True | ||
| if format_ == TableFormat.json_pretty: | ||
| console.print_json(indicator.json()) | ||
| else: | ||
| click.echo(indicator.json()) | ||
| if not printed: | ||
| console.print("No results found.") | ||
|
|
||
|
|
||
| class RiskIndicatorTableEntry(RiskIndicator): | ||
| category_name: str | ||
| category_id: str | ||
| category_description: Optional[str] | ||
| subcategory_name: str | ||
| subcategory_id: str | ||
| subcategory_description: Optional[str] | ||
| type: str | ||
|
|
||
|
|
||
| def iter_risk_indicator_table_entries(categories) -> Iterator[RiskIndicatorTableEntry]: | ||
| for category in categories: | ||
| for subcategory in category.subcategories: | ||
| for indicator, indicator_type in itertools.chain( | ||
| ((i, "standard") for i in subcategory.standard_indicators), | ||
| ((i, "custom") for i in subcategory.custom_indicators), | ||
| ): | ||
| yield RiskIndicatorTableEntry( | ||
| id=indicator.id, | ||
| name=indicator.name, | ||
| description=indicator.description, | ||
| category_name=category.name, | ||
| category_id=category.id, | ||
| category_description=category.description, | ||
| subcategory_name=subcategory.name, | ||
| subcategory_id=subcategory.id, | ||
| subcategory_description=subcategory.description, | ||
| type=indicator_type, | ||
| ) |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # SPDX-FileCopyrightText: 2022-present Code42 Software <integrations@code42.com> | ||
| # | ||
| # SPDX-License-Identifier: MIT | ||
| __version__ = "2.11.0" | ||
| __version__ = "2.12.0" |
This file contains hidden or 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 hidden or 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,84 @@ | ||
| from _incydr_sdk.enums import SortDirection | ||
| from _incydr_sdk.risk_indicator_categories.models import ( | ||
| RiskIndicatorCategoriesResponsePage, | ||
| ) | ||
| from _incydr_sdk.risk_indicator_categories.models import RiskIndicatorCategory | ||
| from _incydr_sdk.risk_indicator_categories.models import RiskIndicatorSubcategory | ||
|
|
||
|
|
||
| class RiskIndicatorCategories: | ||
| def __init__(self, parent): | ||
| self._parent = parent | ||
| self._v1 = None | ||
|
|
||
| @property | ||
| def v1(self): | ||
| if self._v1 is None: | ||
| self._v1 = RiskIndicatorCategoriesV1(self._parent) | ||
| return self._v1 | ||
|
|
||
|
|
||
| class RiskIndicatorCategoriesV1: | ||
| """ | ||
| Client for `/v1/risk-indicator-categories` endpoints. | ||
|
|
||
| Usage example: | ||
|
|
||
| >>> import incydr | ||
| >>> client = incydr.Client(**kwargs) | ||
| >>> client.risk_indicators.v1.list_categories() | ||
| """ | ||
|
|
||
| def __init__(self, parent): | ||
| self._parent = parent | ||
|
|
||
| def list_categories( | ||
| self, active: bool = None, sort_direction: SortDirection = None | ||
| ) -> RiskIndicatorCategoriesResponsePage: | ||
| """ | ||
| Returns all risk indicator categories, including their subcategories and associated risk indicators. | ||
| Filter results by passing the appropriate parameters: | ||
|
|
||
| **Parameters**: | ||
|
|
||
| * **active**: `bool` - When provided, returns only those risk indicators which match the provided value (true or false). When not provided, returns both. | ||
| * **sort_direction**: `SortDirection` - The order in which to sort the returned list. | ||
|
|
||
| **Returns**: A [`RiskIndicatorCategoriesResponsePage`][riskindicatorcategoriesresponsepage-model] object. | ||
| """ | ||
| response = self._parent.session.get( | ||
| "/v1/risk-indicator-categories", | ||
| params={"isActive": active, "sort_direction": sort_direction}, | ||
| ) | ||
| return RiskIndicatorCategoriesResponsePage.parse_response(response) | ||
|
|
||
| def get_category(self, id: str) -> RiskIndicatorCategory: | ||
| """ | ||
| Returns a single risk indicator category, including its subcategories and associated risk indicators. | ||
|
|
||
| **Parameters**: | ||
|
|
||
| * **id**: `str` - The unique ID of the category you wish to retrieve. | ||
|
|
||
| **Returns**: A [`RiskIndicatorCategory`][riskindicatorcategory-model] object. | ||
| """ | ||
| response = self._parent.session.get(f"/v1/risk-indicator-categories/{id}") | ||
| return RiskIndicatorCategory.parse_response(response) | ||
|
|
||
| def get_subcategory( | ||
| self, category_id: str, subcategory_id: str | ||
| ) -> RiskIndicatorSubcategory: | ||
| """ | ||
| Returns a single risk indicator category, including its subcategories and associated risk indicators. | ||
|
|
||
| **Parameters**: | ||
|
|
||
| * **category_id**: `str` - The unique ID of the category in which the subcategory lives. | ||
| * **subcategory_id**: `str` - The unique ID of the subcategory you wish to retrieve. | ||
|
|
||
| **Returns**: A [`RiskIndicatorSubcategory`][riskindicatorsubcategory-model] object. | ||
| """ | ||
| response = self._parent.session.get( | ||
| f"/v1/risk-indicator-categories/{category_id}/subcategories/{subcategory_id}" | ||
| ) | ||
| return RiskIndicatorSubcategory.parse_response(response) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this say something like: