Skip to content

Commit bf437e6

Browse files
author
Suganth Sadaiyappan
committed
Fix PR comments
1 parent 857f823 commit bf437e6

File tree

11 files changed

+210
-148
lines changed

11 files changed

+210
-148
lines changed

docs/getting_started.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ Examples
278278

279279
Create, query, update, and delete some results
280280

281-
.. literalinclude:: ../examples/result/results.py
281+
.. literalinclude:: ../examples/testmonitor/results.py
282+
:language: python
283+
:linenos:
284+
285+
Create, update, query, and delete steps
286+
287+
.. literalinclude:: ../examples/testmonitor/steps.py
282288
:language: python
283289
:linenos:

examples/testmonitor/steps.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from nisystemlink.clients.testmonitor import TestMonitorClient
22
from nisystemlink.clients.testmonitor.models import (
3-
CreateMultipleStepsRequest,
43
CreateResultRequest,
54
CreateStepRequest,
65
NamedValue,
@@ -9,9 +8,9 @@
98
Status,
109
StepField,
1110
StepIdResultIdPair,
12-
UpdateMultipleStepsRequest,
1311
UpdateStepRequest,
1412
)
13+
from nisystemlink.clients.testmonitor.models._step_data import Measurement, StepData
1514

1615

1716
def create_test_result():
@@ -64,7 +63,7 @@ def create_test_result():
6463
]
6564

6665
# Create the steps
67-
create_response = client.create_steps(CreateMultipleStepsRequest(steps=step_requests))
66+
create_response = client.create_steps(steps=step_requests)
6867
created_steps = create_response.steps
6968
print(create_response)
7069

@@ -86,16 +85,27 @@ def create_test_result():
8685

8786
# update the name of a step
8887
update_response = client.update_steps(
89-
UpdateMultipleStepsRequest(
90-
steps=[
91-
UpdateStepRequest(
92-
step_id=step.step_id,
93-
result_id=step.result_id,
94-
name="updated name",
95-
)
96-
for step in created_steps
97-
]
98-
)
88+
steps=[
89+
UpdateStepRequest(
90+
step_id=step.step_id,
91+
result_id=step.result_id,
92+
data=StepData(
93+
text="My output string",
94+
parameters=[
95+
Measurement(
96+
name="Temperature",
97+
status=Status.PASSED(),
98+
measurement="35",
99+
lowLimit="30",
100+
highLimit="40",
101+
units="C",
102+
comparisonType="Numeric",
103+
)
104+
],
105+
),
106+
)
107+
for step in created_steps
108+
]
99109
)
100110

101111
# delete all steps at once
@@ -106,7 +116,7 @@ def create_test_result():
106116
]
107117
)
108118

109-
create_response = client.create_steps(CreateMultipleStepsRequest(steps=step_requests))
119+
create_response = client.create_steps(steps=step_requests)
110120
created_steps = create_response.steps
111121

112122
# delete steps one by one

nisystemlink/clients/testmonitor/_test_monitor_client.py

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,21 @@ def delete_results(
198198
"""
199199
...
200200

201-
@post("steps")
201+
@post(
202+
"steps",
203+
args=[Field("steps"), Field("updateResultTotalTime")],
204+
)
202205
def create_steps(
203-
self, steps: models.CreateMultipleStepsRequest
206+
self,
207+
steps: List[models.CreateStepRequest],
208+
update_result_total_time: Optional[bool] = False,
204209
) -> models.CreateStepsPartialSuccess:
205210
"""Creates one or more steps.
206211
207212
Args:
208213
steps: A list of steps to create.
214+
update_result_total_time: Determine test result total time from the step total times.
215+
Defaults to False.
209216
210217
Returns:
211218
A list of steps that were successfully created and ones that failed to be created.
@@ -235,6 +242,33 @@ def delete_steps(
235242
"""
236243
...
237244

245+
@delete(
246+
"results/{resultId}/steps/{stepId}",
247+
args=[Path("resultId"), Path("stepId"), Query("updateResultTotalTime")],
248+
)
249+
def delete_step(
250+
self,
251+
result_id: str,
252+
step_id: str,
253+
update_result_total_time: Optional[bool] = False,
254+
) -> None:
255+
"""Deletes a single step.
256+
257+
Args:
258+
result_id: The resultId of the step to delete.
259+
step_id: The stepId of the step to delete.
260+
update_result_total_time: Determine test result total time from the step total times.
261+
Defaults to False.
262+
263+
Returns:
264+
None
265+
266+
Raises:
267+
ApiException: if unable to communicate with the `/nitestmonitor` service or if there are
268+
invalid arguments.
269+
"""
270+
...
271+
238272
@post("query-steps")
239273
def query_steps(self, query: models.QueryStepsRequest) -> models.PagedSteps:
240274
"""Queries for steps that match the filters.
@@ -251,9 +285,21 @@ def query_steps(self, query: models.QueryStepsRequest) -> models.PagedSteps:
251285
"""
252286
...
253287

254-
@post("update-steps")
288+
@post(
289+
"update-steps",
290+
args=[
291+
Field("steps"),
292+
Field("updateResultTotalTime"),
293+
Field("replaceKeywords"),
294+
Field("replaceProperties"),
295+
],
296+
)
255297
def update_steps(
256-
self, steps: models.UpdateMultipleStepsRequest
298+
self,
299+
steps: List[models.UpdateStepRequest],
300+
update_result_total_time: Optional[bool] = False,
301+
replace_keywords: Optional[bool] = False,
302+
replace_properties: Optional[bool] = False,
257303
) -> models.UpdateStepsPartialSuccess:
258304
"""Updates one or more steps.
259305
@@ -262,6 +308,12 @@ def update_steps(
262308
Args:
263309
steps: a list of steps that are to be updated. Must include the global ID and
264310
each step being updated must match the version currently on the server.
311+
update_result_total_time: Determine test result total time from the step total times.
312+
Defaults to False.
313+
replace_keywords: Replace with existing keywords instead of merging them.
314+
Defaults to False.
315+
replace_properties: Replace with existing properties instead of merging them.
316+
Defaults to False.
265317
266318
Returns
267319
A list of steps that were successfully updated and a list of ones that were not along
@@ -316,33 +368,6 @@ def get_step(self, result_id: str, step_id: str) -> models.Step:
316368
"""
317369
...
318370

319-
@delete(
320-
"results/{resultId}/steps/{stepId}",
321-
args=[Path("resultId"), Path("stepId"), Query("updateResultTotalTime")],
322-
)
323-
def delete_step(
324-
self,
325-
result_id: str,
326-
step_id: str,
327-
update_result_total_time: Optional[bool] = False,
328-
) -> None:
329-
"""Deletes a single step.
330-
331-
Args:
332-
result_id: The resultId of the step to delete.
333-
step_id: The stepId of the step to delete.
334-
update_result_total_time: Determine test result total time from the step total times.
335-
Defaults to False.
336-
337-
Returns:
338-
None
339-
340-
Raises:
341-
ApiException: if unable to communicate with the `/nitestmonitor` service or if there are
342-
invalid arguments.
343-
"""
344-
...
345-
346371
@returns.json # type: ignore
347372
@post("query-step-values")
348373
def query_step_values(self, query: models.QueryStepValuesRequest) -> List[str]:

nisystemlink/clients/testmonitor/models/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from ._api_info import Operation, V2Operations, ApiInfo
2+
from ._named_value import NamedValue
23
from ._result import Result
34
from ._status import StatusType, Status
4-
from ._step import Step, NamedValue, StepData
5+
from ._step import Step
6+
from ._step_data import Measurement, StepData
57
from ._paged_results import PagedResults
68
from ._paged_steps import PagedSteps
79
from ._delete_results_partial_success import DeleteResultsPartialSuccess
@@ -11,9 +13,9 @@
1113
from ._update_results_partial_success import UpdateResultsPartialSuccess
1214
from ._update_steps_partial_success import UpdateStepsPartialSuccess
1315
from ._create_result_request import CreateResultRequest
14-
from ._create_steps_request import CreateMultipleStepsRequest, CreateStepRequest
16+
from ._create_steps_request import CreateStepRequest
1517
from ._update_result_request import UpdateResultRequest
16-
from ._update_steps_request import UpdateMultipleStepsRequest, UpdateStepRequest
18+
from ._update_steps_request import UpdateStepRequest
1719
from ._query_results_request import (
1820
QueryResultsRequest,
1921
QueryResultValuesRequest,
@@ -26,7 +28,6 @@
2628
StepOrderBy,
2729
StepField,
2830
StepProjection,
29-
StepResponseFormat,
3031
)
3132

3233
# flake8: noqa

nisystemlink/clients/testmonitor/models/_create_steps_request.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
from typing import Dict, List, Optional
33

44
from nisystemlink.clients.core._uplink._json_model import JsonModel
5-
from nisystemlink.clients.testmonitor.models._step import (
6-
NamedValue,
7-
Status,
8-
StepData,
9-
)
5+
from nisystemlink.clients.testmonitor.models._named_value import NamedValue
6+
from nisystemlink.clients.testmonitor.models._step import Status
7+
from nisystemlink.clients.testmonitor.models._step_data import StepData
108

119

1210
class BaseStepRequest(JsonModel):
@@ -56,11 +54,3 @@ class CreateStepRequest(BaseStepRequest):
5654

5755
children: Optional[List["CreateStepRequest"]] = None
5856
"""Nested child steps."""
59-
60-
61-
class CreateMultipleStepsRequest(JsonModel):
62-
steps: List[CreateStepRequest]
63-
"""List of test steps to create."""
64-
65-
update_result_total_time: Optional[bool] = None
66-
"""Determine test result total time from the test step total times."""
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
3+
from nisystemlink.clients.core._uplink._json_model import JsonModel
4+
5+
6+
class NamedValue(JsonModel):
7+
name: str
8+
"""The name of the value."""
9+
10+
value: Any
11+
"""The value."""

nisystemlink/clients/testmonitor/models/_query_steps_request.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import List, Optional
33

44
from nisystemlink.clients.core._uplink._json_model import JsonModel
5+
from nisystemlink.clients.core._uplink._with_paging import WithPaging
56

67

78
class StepOrderBy(str, Enum):
@@ -67,13 +68,6 @@ class StepProjection(str, Enum):
6768
PROPERTIES = "PROPERTIES"
6869

6970

70-
class StepResponseFormat(str, Enum):
71-
"""An enumeration of response formats for step queries."""
72-
73-
JSON = "JSON"
74-
CSV = "CSV"
75-
76-
7771
class QueryStepsBase(JsonModel):
7872
filter: Optional[str] = None
7973
"""The step query filter in Dynamic Linq format."""
@@ -89,7 +83,7 @@ class QueryStepsBase(JsonModel):
8983
"""
9084

9185

92-
class QueryStepsRequest(QueryStepsBase):
86+
class QueryStepsRequest(QueryStepsBase, WithPaging):
9387
order_by: Optional[StepOrderBy] = None
9488
"""Specifies the fields to use to sort the steps."""
9589

@@ -99,15 +93,6 @@ class QueryStepsRequest(QueryStepsBase):
9993
take: Optional[int] = None
10094
"""Maximum number of steps to return in the current API response."""
10195

102-
continuation_token: Optional[str] = None
103-
"""Allows users to continue the query at the next step that matches the given criteria.
104-
105-
To retrieve the next page of steps, pass the continuation token from the previous
106-
page in the next request. The service responds with the next page of data and provides a new
107-
continuation token. To paginate results, continue sending requests with the newest continuation
108-
token provided in each response.
109-
"""
110-
11196
return_count: Optional[bool] = None
11297
"""If true, the response will include a count of all steps matching the filter.
11398
@@ -129,12 +114,9 @@ class QueryStepsRequest(QueryStepsBase):
129114
all step fields will be returned.
130115
"""
131116

132-
response_format: Optional[StepResponseFormat] = None
133-
"""Enum indicating the expected response format (CSV or JSON)."""
134-
135117

136118
class QueryStepValuesRequest(QueryStepsBase):
137-
field: Optional[StepField] = None
119+
field: StepField
138120
"""The step field to return for this query."""
139121

140122
starts_with: Optional[str] = None

nisystemlink/clients/testmonitor/models/_step.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
from datetime import datetime
2-
from typing import Any, Dict, List, Optional
2+
from typing import Dict, List, Optional
33

44
from nisystemlink.clients.core._uplink._json_model import JsonModel
5+
from nisystemlink.clients.testmonitor.models._named_value import NamedValue
56
from nisystemlink.clients.testmonitor.models._status import Status
6-
7-
8-
class NamedValue(JsonModel):
9-
name: str
10-
"""The name of the value."""
11-
12-
value: Any
13-
"""The value."""
14-
15-
16-
class StepData(JsonModel):
17-
text: Optional[str] = None
18-
"""Text string describing the output data."""
19-
20-
parameters: Optional[List[dict[str, Optional[str]]]] = None
21-
"""List of properties objects."""
7+
from nisystemlink.clients.testmonitor.models._step_data import StepData
228

239

2410
class Step(JsonModel):

0 commit comments

Comments
 (0)