|
28 | 28 | import google.api_core.grpc_helpers |
29 | 29 | import google.api_core.page_iterator |
30 | 30 | import google.api_core.path_template |
| 31 | +import google.api_core.protobuf_helpers |
31 | 32 | import grpc |
32 | 33 |
|
33 | 34 | from google.cloud.irm_v1alpha2.gapic import enums |
@@ -1305,7 +1306,68 @@ def search_signals( |
1305 | 1306 | Args: |
1306 | 1307 | parent (str): The resource name of the hosting Stackdriver project which requested |
1307 | 1308 | incidents belong to. |
1308 | | - query (str): Query to specify which signals should be returned. |
| 1309 | + query (str): An expression that defines which signals to return. |
| 1310 | +
|
| 1311 | + Search atoms can be used to match certain specific fields. Otherwise, |
| 1312 | + plain text will match text fields in the signal. |
| 1313 | +
|
| 1314 | + Search atoms: |
| 1315 | +
|
| 1316 | + - ``start`` - (timestamp) The time the signal was created. |
| 1317 | + - ``title`` - The title of the signal. |
| 1318 | + - ``signal_state`` - ``open`` or ``closed``. State of the signal. |
| 1319 | + (e.g., ``signal_state:open``) |
| 1320 | +
|
| 1321 | + Timestamp formats: |
| 1322 | +
|
| 1323 | + - yyyy-MM-dd - an absolute date, treated as a calendar-day-wide window. |
| 1324 | + In other words, the "<" operator will match dates before that date, |
| 1325 | + the ">" operator will match dates after that date, and the ":" |
| 1326 | + operator will match the entire day. |
| 1327 | + - yyyy-MM-ddTHH:mm - Same as above, but with minute resolution. |
| 1328 | + - yyyy-MM-ddTHH:mm:ss - Same as above, but with second resolution. |
| 1329 | + - Nd (e.g. 7d) - a relative number of days ago, treated as a moment in |
| 1330 | + time (as opposed to a day-wide span) a multiple of 24 hours ago (as |
| 1331 | + opposed to calendar days). In the case of daylight savings time, it |
| 1332 | + will apply the current timezone to both ends of the range. Note that |
| 1333 | + exact matching (e.g. ``start:7d``) is unlikely to be useful because |
| 1334 | + that would only match signals created precisely at a particular |
| 1335 | + instant in time. |
| 1336 | +
|
| 1337 | + The absolute timestamp formats (everything starting with a year) can |
| 1338 | + optionally be followed with a UTC offset in +/-hh:mm format. Also, the |
| 1339 | + 'T' separating dates and times can optionally be replaced with a space. |
| 1340 | + Note that any timestamp containing a space or colon will need to be |
| 1341 | + quoted. |
| 1342 | +
|
| 1343 | + Examples: |
| 1344 | +
|
| 1345 | + - ``foo`` - matches signals containing the word "foo" |
| 1346 | + - ``"foo bar"`` - matches signals containing the phrase "foo bar" |
| 1347 | + - ``foo bar`` or ``foo AND bar`` - matches signals containing the words |
| 1348 | + "foo" and "bar" |
| 1349 | + - ``foo -bar`` or ``foo AND NOT bar`` - matches signals containing the |
| 1350 | + word "foo" but not the word "bar" |
| 1351 | + - ``foo OR bar`` - matches signals containing the word "foo" or the |
| 1352 | + word "bar" |
| 1353 | + - ``start>2018-11-28`` - matches signals which started after November |
| 1354 | + 11, 2018. |
| 1355 | + - ``start<=2018-11-28`` - matches signals which started on or before |
| 1356 | + November 11, 2018. |
| 1357 | + - ``start:2018-11-28`` - matches signals which started on November 11, |
| 1358 | +
|
| 1359 | + 2018. |
| 1360 | +
|
| 1361 | + - ``start>"2018-11-28 01:02:03+04:00"`` - matches signals which started |
| 1362 | + after November 11, 2018 at 1:02:03 AM according to the UTC+04 time |
| 1363 | + zone. |
| 1364 | + - ``start>7d`` - matches signals which started after the point in time |
| 1365 | + 7*24 hours ago |
| 1366 | + - ``start>180d`` - similar to 7d, but likely to cross the daylight |
| 1367 | + savings time boundary, so the end time will be 1 hour different from |
| 1368 | + "now." |
| 1369 | + - ``foo AND start>90d AND stage<resolved`` - unresolved signals from |
| 1370 | + the past 90 days containing the word "foo" |
1309 | 1371 | page_size (int): The maximum number of resources contained in the |
1310 | 1372 | underlying API response. If page streaming is performed per- |
1311 | 1373 | resource, this parameter does not affect the return value. If page |
@@ -1445,6 +1507,73 @@ def get_signal( |
1445 | 1507 | request, retry=retry, timeout=timeout, metadata=metadata |
1446 | 1508 | ) |
1447 | 1509 |
|
| 1510 | + def lookup_signal( |
| 1511 | + self, |
| 1512 | + cscc_finding=None, |
| 1513 | + stackdriver_notification_id=None, |
| 1514 | + retry=google.api_core.gapic_v1.method.DEFAULT, |
| 1515 | + timeout=google.api_core.gapic_v1.method.DEFAULT, |
| 1516 | + metadata=None, |
| 1517 | + ): |
| 1518 | + """ |
| 1519 | + Finds a signal by other unique IDs. |
| 1520 | +
|
| 1521 | + Example: |
| 1522 | + >>> from google.cloud import irm_v1alpha2 |
| 1523 | + >>> |
| 1524 | + >>> client = irm_v1alpha2.IncidentServiceClient() |
| 1525 | + >>> |
| 1526 | + >>> response = client.lookup_signal() |
| 1527 | +
|
| 1528 | + Args: |
| 1529 | + cscc_finding (str): Full resource name of the CSCC finding id this signal refers to (e.g. |
| 1530 | + "organizations/abc/sources/123/findings/xyz") |
| 1531 | + stackdriver_notification_id (str): The ID from the Stackdriver Alerting notification. |
| 1532 | + retry (Optional[google.api_core.retry.Retry]): A retry object used |
| 1533 | + to retry requests. If ``None`` is specified, requests will not |
| 1534 | + be retried. |
| 1535 | + timeout (Optional[float]): The amount of time, in seconds, to wait |
| 1536 | + for the request to complete. Note that if ``retry`` is |
| 1537 | + specified, the timeout applies to each individual attempt. |
| 1538 | + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata |
| 1539 | + that is provided to the method. |
| 1540 | +
|
| 1541 | + Returns: |
| 1542 | + A :class:`~google.cloud.irm_v1alpha2.types.Signal` instance. |
| 1543 | +
|
| 1544 | + Raises: |
| 1545 | + google.api_core.exceptions.GoogleAPICallError: If the request |
| 1546 | + failed for any reason. |
| 1547 | + google.api_core.exceptions.RetryError: If the request failed due |
| 1548 | + to a retryable error and retry attempts failed. |
| 1549 | + ValueError: If the parameters are invalid. |
| 1550 | + """ |
| 1551 | + # Wrap the transport method to add retry and timeout logic. |
| 1552 | + if "lookup_signal" not in self._inner_api_calls: |
| 1553 | + self._inner_api_calls[ |
| 1554 | + "lookup_signal" |
| 1555 | + ] = google.api_core.gapic_v1.method.wrap_method( |
| 1556 | + self.transport.lookup_signal, |
| 1557 | + default_retry=self._method_configs["LookupSignal"].retry, |
| 1558 | + default_timeout=self._method_configs["LookupSignal"].timeout, |
| 1559 | + client_info=self._client_info, |
| 1560 | + ) |
| 1561 | + |
| 1562 | + # Sanity check: We have some fields which are mutually exclusive; |
| 1563 | + # raise ValueError if more than one is sent. |
| 1564 | + google.api_core.protobuf_helpers.check_oneof( |
| 1565 | + cscc_finding=cscc_finding, |
| 1566 | + stackdriver_notification_id=stackdriver_notification_id, |
| 1567 | + ) |
| 1568 | + |
| 1569 | + request = incidents_service_pb2.LookupSignalRequest( |
| 1570 | + cscc_finding=cscc_finding, |
| 1571 | + stackdriver_notification_id=stackdriver_notification_id, |
| 1572 | + ) |
| 1573 | + return self._inner_api_calls["lookup_signal"]( |
| 1574 | + request, retry=retry, timeout=timeout, metadata=metadata |
| 1575 | + ) |
| 1576 | + |
1448 | 1577 | def update_signal( |
1449 | 1578 | self, |
1450 | 1579 | signal, |
|
0 commit comments