|
1 | 1 | """Implementation of TestMonitor Client"""
|
2 | 2 |
|
3 |
| -from typing import Optional |
| 3 | +from typing import List, Optional |
4 | 4 |
|
5 | 5 | from nisystemlink.clients import core
|
6 | 6 | from nisystemlink.clients.core._uplink._base_client import BaseClient
|
7 |
| -from nisystemlink.clients.core._uplink._methods import get |
| 7 | +from nisystemlink.clients.core._uplink._methods import delete, get, post |
| 8 | +from nisystemlink.clients.testmonitor.models import ( |
| 9 | + CreateResultRequest, |
| 10 | + UpdateResultRequest, |
| 11 | +) |
| 12 | +from uplink import Field, Query, retry, returns |
8 | 13 |
|
9 | 14 | from . import models
|
10 | 15 |
|
11 | 16 |
|
| 17 | +@retry( |
| 18 | + when=retry.when.status([408, 429, 502, 503, 504]), stop=retry.stop.after_attempt(5) |
| 19 | +) |
12 | 20 | class TestMonitorClient(BaseClient):
|
13 | 21 | # prevent pytest from thinking this is a test class
|
14 | 22 | __test__ = False
|
@@ -40,3 +48,152 @@ def api_info(self) -> models.ApiInfo:
|
40 | 48 | ApiException: if unable to communicate with the `ni``/nitestmonitor``` service.
|
41 | 49 | """
|
42 | 50 | ...
|
| 51 | + |
| 52 | + @post("results", args=[Field("results")]) |
| 53 | + def create_results( |
| 54 | + self, results: List[CreateResultRequest] |
| 55 | + ) -> models.CreateResultsPartialSuccess: |
| 56 | + """Creates one or more results and returns errors for failed creations. |
| 57 | +
|
| 58 | + Args: |
| 59 | + results: A list of results to attempt to create. |
| 60 | +
|
| 61 | + Returns: A list of created results, results that failed to create, and errors for |
| 62 | + failures. |
| 63 | +
|
| 64 | + Raises: |
| 65 | + ApiException: if unable to communicate with the ``/nitestmonitor`` service of provided invalid |
| 66 | + arguments. |
| 67 | + """ |
| 68 | + ... |
| 69 | + |
| 70 | + @get( |
| 71 | + "results", |
| 72 | + args=[Query("continuationToken"), Query("take"), Query("returnCount")], |
| 73 | + ) |
| 74 | + def get_results( |
| 75 | + self, |
| 76 | + continuation_token: Optional[str] = None, |
| 77 | + take: Optional[int] = None, |
| 78 | + return_count: Optional[bool] = None, |
| 79 | + ) -> models.PagedResults: |
| 80 | + """Reads a list of results. |
| 81 | +
|
| 82 | + Args: |
| 83 | + continuation_token: The token used to paginate results. |
| 84 | + take: The number of results to get in this request. |
| 85 | + return_count: Whether or not to return the total number of results available. |
| 86 | +
|
| 87 | + Returns: |
| 88 | + A list of results. |
| 89 | +
|
| 90 | + Raises: |
| 91 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service |
| 92 | + or provided an invalid argument. |
| 93 | + """ |
| 94 | + ... |
| 95 | + |
| 96 | + @get("results/{id}") |
| 97 | + def get_result(self, id: str) -> models.Result: |
| 98 | + """Retrieves a single result by id. |
| 99 | +
|
| 100 | + Args: |
| 101 | + id (str): Unique ID of a result. |
| 102 | +
|
| 103 | + Returns: |
| 104 | + The single result matching `id` |
| 105 | +
|
| 106 | + Raises: |
| 107 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service |
| 108 | + or provided an invalid argument. |
| 109 | + """ |
| 110 | + ... |
| 111 | + |
| 112 | + @post("query-results") |
| 113 | + def query_results(self, query: models.QueryResultsRequest) -> models.PagedResults: |
| 114 | + """Queries for results that match the filter. |
| 115 | +
|
| 116 | + Args: |
| 117 | + query : The query contains a DynamicLINQ query string in addition to other details |
| 118 | + about how to filter and return the list of results. |
| 119 | +
|
| 120 | + Returns: |
| 121 | + A paged list of results with a continuation token to get the next page. |
| 122 | +
|
| 123 | + Raises: |
| 124 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service or provided invalid |
| 125 | + arguments. |
| 126 | + """ |
| 127 | + ... |
| 128 | + |
| 129 | + @returns.json # type: ignore |
| 130 | + @post("query-result-values") |
| 131 | + def query_result_values(self, query: models.QueryResultValuesRequest) -> List[str]: |
| 132 | + """Queries for results that match the query and returns a list of the requested field. |
| 133 | +
|
| 134 | + Args: |
| 135 | + query : The query for the fields. |
| 136 | +
|
| 137 | + Returns: |
| 138 | + A list of the values of the queried field. |
| 139 | +
|
| 140 | + Raises: |
| 141 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service or provided |
| 142 | + invalid arguments. |
| 143 | + """ |
| 144 | + ... |
| 145 | + |
| 146 | + @post("update-results", args=[Field("results"), Field("replace")]) |
| 147 | + def update_results( |
| 148 | + self, results: List[UpdateResultRequest], replace: bool = False |
| 149 | + ) -> models.UpdateResultsPartialSuccess: |
| 150 | + """Updates a list of results with optional field replacement. |
| 151 | +
|
| 152 | + Args: |
| 153 | + `results`: A list of results to update. Results are matched for update by id. |
| 154 | + `replace`: Replace the existing fields instead of merging them. Defaults to `False`. |
| 155 | + If this is `True`, then `keywords` and `properties` for the result will be |
| 156 | + replaced by what is in the `results` provided in this request. |
| 157 | + If this is `False`, then the `keywords` and `properties` in this request will |
| 158 | + merge with what is already present in the server resource. |
| 159 | +
|
| 160 | + Returns: A list of updates results, results that failed to update, and errors for |
| 161 | + failures. |
| 162 | +
|
| 163 | + Raises: |
| 164 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service |
| 165 | + or provided an invalid argument. |
| 166 | + """ |
| 167 | + ... |
| 168 | + |
| 169 | + @delete("results/{id}") |
| 170 | + def delete_result(self, id: str) -> None: |
| 171 | + """Deletes a single result by id. |
| 172 | +
|
| 173 | + Args: |
| 174 | + id (str): Unique ID of a result. |
| 175 | +
|
| 176 | + Raises: |
| 177 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service |
| 178 | + or provided an invalid argument. |
| 179 | + """ |
| 180 | + ... |
| 181 | + |
| 182 | + @post("delete-results", args=[Field("ids")]) |
| 183 | + def delete_results( |
| 184 | + self, ids: List[str] |
| 185 | + ) -> Optional[models.DeleteResultsPartialSuccess]: |
| 186 | + """Deletes multiple results. |
| 187 | +
|
| 188 | + Args: |
| 189 | + ids (List[str]): List of unique IDs of results. |
| 190 | +
|
| 191 | + Returns: |
| 192 | + A partial success if any results failed to delete, or None if all |
| 193 | + results were deleted successfully. |
| 194 | +
|
| 195 | + Raises: |
| 196 | + ApiException: if unable to communicate with the ``/nitestmonitor`` Service |
| 197 | + or provided an invalid argument. |
| 198 | + """ |
| 199 | + ... |
0 commit comments