Skip to content

Commit cc4dc76

Browse files
author
Priyadarshini Piramanayagam
committed
fix: add updateResultRequest
1 parent 1a4abca commit cc4dc76

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

nisystemlink/clients/result/_result_client.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
from nisystemlink.clients import core
66
from nisystemlink.clients.core._uplink._base_client import BaseClient
77
from nisystemlink.clients.core._uplink._methods import delete, get, post
8-
from nisystemlink.clients.result.models import Result
8+
from nisystemlink.clients.result.models import (
9+
Result,
10+
UpdateResultRequest,
11+
)
912
from uplink import Field, Query, retry, returns
1013

1114
from . import models
@@ -125,8 +128,8 @@ def query_result_values(self, query: models.QueryResultValuesRequest) -> List[st
125128
...
126129

127130
@post("update-results", args=[Field("results"), Field("replace")])
128-
def update_results(
129-
self, results: List[Result], replace: bool = False
131+
def __update_results(
132+
self, results: List[UpdateResultRequest], replace: bool = False
130133
) -> models.ResultsPartialSuccess:
131134
"""Updates a list of results with optional field replacement.
132135
@@ -147,6 +150,37 @@ def update_results(
147150
"""
148151
...
149152

153+
def update_results(
154+
self,
155+
results: List[UpdateResultRequest],
156+
replace: bool = False,
157+
allow_workspace_update: bool = False,
158+
) -> models.ResultsPartialSuccess:
159+
"""Updates a list of results with optional field replacement.
160+
161+
Args:
162+
`results`: A list of results to update. Results are matched for update by id.
163+
`replace`: Replace the existing fields instead of merging them. Defaults to `False`.
164+
If this is `True`, then `keywords` and `properties` for the result will be
165+
replaced by what is in the `results` provided in this request.
166+
If this is `False`, then the `keywords` and `properties` in this request will
167+
merge with what is already present in the server resource.
168+
`allow_workspace_update`: If this is set to `False`, the `workspace` field will be set to None
169+
before updating.
170+
171+
Returns: A list of updates results, results that failed to update, and errors for
172+
failures.
173+
174+
Raises:
175+
ApiException: if unable to communicate with the ``/nitestmonitor`` Service
176+
or provided an invalid argument.
177+
"""
178+
if not allow_workspace_update:
179+
for result in results:
180+
result.workspace = None
181+
182+
return self.__update_results(results, replace)
183+
150184
@delete("results/{id}")
151185
def delete_result(self, id: str) -> None:
152186
"""Deletes a single result by id.

nisystemlink/clients/result/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from ._results_partial_success import ResultsPartialSuccess
33
from ._delete_results_partial_success import DeleteResultsPartialSuccess
44
from ._paged_results import PagedResults
5+
from ._update_result_request import UpdateResultRequest
56
from ._query_results_request import (
67
QueryResultsRequest,
78
ResultField,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from datetime import datetime
2+
from typing import Dict, List, Optional
3+
4+
from nisystemlink.clients.core._uplink._json_model import JsonModel
5+
from nisystemlink.clients.result.models._result import StatusObject
6+
7+
8+
class UpdateResultRequest(JsonModel):
9+
"""Contains information about a result."""
10+
11+
status: StatusObject
12+
"""The status of the result."""
13+
14+
started_at: Optional[datetime]
15+
"""The time that the result started."""
16+
17+
program_name: str
18+
"""The name of the program that generated this result."""
19+
20+
id: Optional[str]
21+
"""The globally unique id of the result."""
22+
23+
system_id: Optional[str]
24+
"""The id of the system that generated this result."""
25+
26+
host_name: Optional[str]
27+
"""The name of the host that generated this result."""
28+
29+
part_number: Optional[str]
30+
"""The part number is the unique identifier of a product within a single org."""
31+
32+
serial_number: Optional[str]
33+
"""The serial number of the system that generated this result."""
34+
35+
total_time_in_seconds: Optional[float]
36+
"""The total time that the result took to run in seconds."""
37+
38+
keywords: Optional[List[str]]
39+
"""A list of keywords that categorize this result."""
40+
41+
properties: Optional[Dict[str, str]]
42+
"""A list of custom properties for this result."""
43+
44+
operator: Optional[str]
45+
"""The operator that ran the result."""
46+
47+
file_ids: Optional[List[str]]
48+
"""A list of file ids that are attached to this result."""
49+
50+
data_table_ids: Optional[List[str]]
51+
"""A list of data table ids that are attached to this result."""
52+
53+
workspace: Optional[str]
54+
"""The id of the workspace that this product belongs to."""

0 commit comments

Comments
 (0)