-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add helper for getting linked products from a file id
- Loading branch information
1 parent
d60e2af
commit 56f975a
Showing
2 changed files
with
79 additions
and
23 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
nisystemlink/clients/testmonitor/_test_monitor_utilities.py
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,32 @@ | ||
from typing import List | ||
|
||
from nisystemlink.clients.testmonitor._test_monitor_client import TestMonitorClient | ||
from nisystemlink.clients.testmonitor.models._paged_products import PagedProducts | ||
from nisystemlink.clients.testmonitor.models._product import Product | ||
from nisystemlink.clients.testmonitor.models._query_products_request import ( | ||
QueryProductsRequest, | ||
) | ||
|
||
|
||
def get_products_linked_to_file( | ||
client: TestMonitorClient, file_id: str | ||
) -> List[Product]: | ||
"""Gets a list of all the products that are linked to the file. | ||
Args: | ||
`client` : The `TestMonitorClient` to use for the request. | ||
`file_id`: The id of the file to query links for. | ||
Returns: | ||
A list of all the products that are linked to the file with `file_id` | ||
""" | ||
query_request = QueryProductsRequest( | ||
filter=f'fileIds.Contains("{file_id}")', take=100 | ||
) | ||
response: PagedProducts = client.query_products(query_request) | ||
products = response.products | ||
while response.continuation_token: | ||
query_request.continuation_token = response.continuation_token | ||
response = client.query_products(query_request) | ||
products.extend(response.products) | ||
return products |
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