Skip to content

Commit 2f35bec

Browse files
yoshi-automationbusunkim96
authored andcommitted
Add lookup signal (via synth). (googleapis#8487)
1 parent 65e0512 commit 2f35bec

File tree

10 files changed

+659
-179
lines changed

10 files changed

+659
-179
lines changed

irm/google/cloud/irm_v1alpha2/gapic/incident_service_client.py

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import google.api_core.grpc_helpers
2929
import google.api_core.page_iterator
3030
import google.api_core.path_template
31+
import google.api_core.protobuf_helpers
3132
import grpc
3233

3334
from google.cloud.irm_v1alpha2.gapic import enums
@@ -1305,7 +1306,68 @@ def search_signals(
13051306
Args:
13061307
parent (str): The resource name of the hosting Stackdriver project which requested
13071308
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"
13091371
page_size (int): The maximum number of resources contained in the
13101372
underlying API response. If page streaming is performed per-
13111373
resource, this parameter does not affect the return value. If page
@@ -1445,6 +1507,73 @@ def get_signal(
14451507
request, retry=retry, timeout=timeout, metadata=metadata
14461508
)
14471509

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+
14481577
def update_signal(
14491578
self,
14501579
signal,

irm/google/cloud/irm_v1alpha2/gapic/incident_service_client_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
"retry_codes_name": "idempotent",
8383
"retry_params_name": "default",
8484
},
85+
"LookupSignal": {
86+
"timeout_millis": 60000,
87+
"retry_codes_name": "idempotent",
88+
"retry_params_name": "default",
89+
},
8590
"UpdateSignal": {
8691
"timeout_millis": 60000,
8792
"retry_codes_name": "non_idempotent",

irm/google/cloud/irm_v1alpha2/gapic/transports/incident_service_grpc_transport.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,19 @@ def get_signal(self):
277277
"""
278278
return self._stubs["incident_service_stub"].GetSignal
279279

280+
@property
281+
def lookup_signal(self):
282+
"""Return the gRPC stub for :meth:`IncidentServiceClient.lookup_signal`.
283+
284+
Finds a signal by other unique IDs.
285+
286+
Returns:
287+
Callable: A callable which accepts the appropriate
288+
deserialized request object and returns a
289+
deserialized response object.
290+
"""
291+
return self._stubs["incident_service_stub"].LookupSignal
292+
280293
@property
281294
def update_signal(self):
282295
"""Return the gRPC stub for :meth:`IncidentServiceClient.update_signal`.

irm/google/cloud/irm_v1alpha2/proto/incidents.proto

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2018 Google LLC.
1+
// Copyright 2019 Google LLC.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,8 +18,6 @@ syntax = "proto3";
1818
package google.cloud.irm.v1alpha2;
1919

2020
import "google/api/annotations.proto";
21-
import "google/monitoring/v3/metric_service.proto";
22-
import "google/protobuf/duration.proto";
2321
import "google/protobuf/timestamp.proto";
2422

2523
option cc_enable_arenas = true;
@@ -103,7 +101,10 @@ message Signal {
103101
// Immutable.
104102
string title = 6;
105103

106-
// Content type string, for example, 'text/plain' or'text/html'.
104+
// Content type string. 'text/plain' is currently the only supported content
105+
// type for Signals created via the API. Signals created by Stackdriver
106+
// Alerting support 'text/html' as well. Immutable for Signals created by
107+
// Stackdriver Alerting.
107108
string content_type = 7;
108109

109110
// Full message of the signal.
@@ -134,6 +135,10 @@ message Annotation {
134135

135136
// Content of the annotation. Immutable.
136137
string content = 4;
138+
139+
// Content type of the annotation, for example, 'text/plain'
140+
// or 'text/markdown'. Immutable.
141+
string content_type = 5;
137142
}
138143

139144
// A tag by a user.
@@ -149,7 +154,7 @@ message Tag {
149154
// Synopsis is a summary of an incident and it contains a textual content,
150155
// an author and a last updated timestamp.
151156
message Synopsis {
152-
// Content type string, for example, 'text/plain' or 'text/html'.
157+
// Content type string, for example, 'text/plain' or 'text/markdown'.
153158
string content_type = 1;
154159

155160
// Textual content of the synopsis. It can be plain text or markdown as

0 commit comments

Comments
 (0)