Skip to content

Commit 25e126a

Browse files
feat: [google-cloud-monitoring] Added Synthetic Monitor targets to Uptime data model (#12575)
- [ ] Regenerate this pull request now. BEGIN_COMMIT_OVERRIDE feat: Added Synthetic Monitor targets to Uptime data model feat: Added ServiceAgentAuthentication auth method for Uptime docs: Updated comments accordingly END_COMMIT_OVERRIDE PiperOrigin-RevId: 625075445 Source-Link: googleapis/googleapis@90db3b0 Source-Link: googleapis/googleapis-gen@d55c82c Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLW1vbml0b3JpbmcvLk93bEJvdC55YW1sIiwiaCI6ImQ1NWM4MmNhMWMxMjBkY2Q0NmY3ZDlhMWNkMmRjNmVkZjg0NzUxNGYifQ== --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 5ad80de commit 25e126a

File tree

10 files changed

+181
-23
lines changed

10 files changed

+181
-23
lines changed

packages/google-cloud-monitoring/google/cloud/monitoring/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
from google.cloud.monitoring_v3.types.uptime import (
175175
GroupResourceType,
176176
InternalChecker,
177+
SyntheticMonitorTarget,
177178
UptimeCheckConfig,
178179
UptimeCheckIp,
179180
UptimeCheckRegion,
@@ -296,6 +297,7 @@
296297
"UpdateSnoozeRequest",
297298
"SpanContext",
298299
"InternalChecker",
300+
"SyntheticMonitorTarget",
299301
"UptimeCheckConfig",
300302
"UptimeCheckIp",
301303
"GroupResourceType",

packages/google-cloud-monitoring/google/cloud/monitoring/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.19.4" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring/google/cloud/monitoring_v3/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
from .types.uptime import (
148148
GroupResourceType,
149149
InternalChecker,
150+
SyntheticMonitorTarget,
150151
UptimeCheckConfig,
151152
UptimeCheckIp,
152153
UptimeCheckRegion,
@@ -261,6 +262,7 @@
261262
"Snooze",
262263
"SnoozeServiceClient",
263264
"SpanContext",
265+
"SyntheticMonitorTarget",
264266
"TextLocator",
265267
"TimeInterval",
266268
"TimeSeries",

packages/google-cloud-monitoring/google/cloud/monitoring_v3/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.19.4" # {x-release-please-version}
16+
__version__ = "0.0.0" # {x-release-please-version}

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/async_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class UptimeCheckServiceAsyncClient:
7474
_DEFAULT_ENDPOINT_TEMPLATE = UptimeCheckServiceClient._DEFAULT_ENDPOINT_TEMPLATE
7575
_DEFAULT_UNIVERSE = UptimeCheckServiceClient._DEFAULT_UNIVERSE
7676

77+
function_path = staticmethod(UptimeCheckServiceClient.function_path)
78+
parse_function_path = staticmethod(UptimeCheckServiceClient.parse_function_path)
7779
uptime_check_config_path = staticmethod(
7880
UptimeCheckServiceClient.uptime_check_config_path
7981
)

packages/google-cloud-monitoring/google/cloud/monitoring_v3/services/uptime_check_service/client.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,28 @@ def transport(self) -> UptimeCheckServiceTransport:
192192
"""
193193
return self._transport
194194

195+
@staticmethod
196+
def function_path(
197+
project: str,
198+
location: str,
199+
function: str,
200+
) -> str:
201+
"""Returns a fully-qualified function string."""
202+
return "projects/{project}/locations/{location}/functions/{function}".format(
203+
project=project,
204+
location=location,
205+
function=function,
206+
)
207+
208+
@staticmethod
209+
def parse_function_path(path: str) -> Dict[str, str]:
210+
"""Parses a function path into its component segments."""
211+
m = re.match(
212+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/functions/(?P<function>.+?)$",
213+
path,
214+
)
215+
return m.groupdict() if m else {}
216+
195217
@staticmethod
196218
def uptime_check_config_path(
197219
project: str,

packages/google-cloud-monitoring/google/cloud/monitoring_v3/types/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
from .uptime import (
117117
GroupResourceType,
118118
InternalChecker,
119+
SyntheticMonitorTarget,
119120
UptimeCheckConfig,
120121
UptimeCheckIp,
121122
UptimeCheckRegion,
@@ -222,6 +223,7 @@
222223
"UpdateSnoozeRequest",
223224
"SpanContext",
224225
"InternalChecker",
226+
"SyntheticMonitorTarget",
225227
"UptimeCheckConfig",
226228
"UptimeCheckIp",
227229
"GroupResourceType",

packages/google-cloud-monitoring/google/cloud/monitoring_v3/types/uptime.py

Lines changed: 106 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"UptimeCheckRegion",
2828
"GroupResourceType",
2929
"InternalChecker",
30+
"SyntheticMonitorTarget",
3031
"UptimeCheckConfig",
3132
"UptimeCheckIp",
3233
},
@@ -188,6 +189,52 @@ class State(proto.Enum):
188189
)
189190

190191

192+
class SyntheticMonitorTarget(proto.Message):
193+
r"""Describes a Synthetic Monitor to be invoked by Uptime.
194+
195+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
196+
197+
Attributes:
198+
cloud_function_v2 (google.cloud.monitoring_v3.types.SyntheticMonitorTarget.CloudFunctionV2Target):
199+
Target a Synthetic Monitor GCFv2 instance.
200+
201+
This field is a member of `oneof`_ ``target``.
202+
"""
203+
204+
class CloudFunctionV2Target(proto.Message):
205+
r"""A Synthetic Monitor deployed to a Cloud Functions V2
206+
instance.
207+
208+
Attributes:
209+
name (str):
210+
Required. Fully qualified GCFv2 resource name i.e.
211+
``projects/{project}/locations/{location}/functions/{function}``
212+
Required.
213+
cloud_run_revision (google.api.monitored_resource_pb2.MonitoredResource):
214+
Output only. The ``cloud_run_revision`` Monitored Resource
215+
associated with the GCFv2. The Synthetic Monitor execution
216+
results (metrics, logs, and spans) are reported against this
217+
Monitored Resource. This field is output only.
218+
"""
219+
220+
name: str = proto.Field(
221+
proto.STRING,
222+
number=1,
223+
)
224+
cloud_run_revision: monitored_resource_pb2.MonitoredResource = proto.Field(
225+
proto.MESSAGE,
226+
number=2,
227+
message=monitored_resource_pb2.MonitoredResource,
228+
)
229+
230+
cloud_function_v2: CloudFunctionV2Target = proto.Field(
231+
proto.MESSAGE,
232+
number=1,
233+
oneof="target",
234+
message=CloudFunctionV2Target,
235+
)
236+
237+
191238
class UptimeCheckConfig(proto.Message):
192239
r"""This message configures which resources and services to
193240
monitor for availability.
@@ -201,8 +248,8 @@ class UptimeCheckConfig(proto.Message):
201248
202249
Attributes:
203250
name (str):
204-
A unique resource name for this Uptime check configuration.
205-
The format is:
251+
Identifier. A unique resource name for this Uptime check
252+
configuration. The format is:
206253
207254
::
208255
@@ -234,6 +281,10 @@ class UptimeCheckConfig(proto.Message):
234281
The group resource associated with the
235282
configuration.
236283
284+
This field is a member of `oneof`_ ``resource``.
285+
synthetic_monitor (google.cloud.monitoring_v3.types.SyntheticMonitorTarget):
286+
Specifies a Synthetic Monitor to invoke.
287+
237288
This field is a member of `oneof`_ ``resource``.
238289
http_check (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck):
239290
Contains information needed to make an HTTP
@@ -361,6 +412,8 @@ class PingConfig(proto.Message):
361412
class HttpCheck(proto.Message):
362413
r"""Information involved in an HTTP/HTTPS Uptime check request.
363414
415+
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
416+
364417
Attributes:
365418
request_method (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.RequestMethod):
366419
The HTTP request method to use for the check. If set to
@@ -381,8 +434,9 @@ class HttpCheck(proto.Message):
381434
host (specified within the ``monitored_resource``) and
382435
``path`` to construct the full URL.
383436
auth_info (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.BasicAuthentication):
384-
The authentication information. Optional when
385-
creating an HTTP check; defaults to empty.
437+
The authentication information. Optional when creating an
438+
HTTP check; defaults to empty. Do not set both
439+
``auth_method`` and ``auth_info``.
386440
mask_headers (bool):
387441
Boolean specifying whether to encrypt the header
388442
information. Encryption should be specified for any headers
@@ -453,6 +507,12 @@ class HttpCheck(proto.Message):
453507
ping_config (google.cloud.monitoring_v3.types.UptimeCheckConfig.PingConfig):
454508
Contains information needed to add pings to
455509
an HTTP check.
510+
service_agent_authentication (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication):
511+
If specified, Uptime will generate and attach an OIDC JWT
512+
token for the Monitoring service agent service account as an
513+
``Authorization`` header in the HTTP request when probing.
514+
515+
This field is a member of `oneof`_ ``auth_method``.
456516
"""
457517

458518
class RequestMethod(proto.Enum):
@@ -580,6 +640,36 @@ class StatusClass(proto.Enum):
580640
enum="UptimeCheckConfig.HttpCheck.ResponseStatusCode.StatusClass",
581641
)
582642

643+
class ServiceAgentAuthentication(proto.Message):
644+
r"""Contains information needed for generating an `OpenID Connect
645+
token <https://developers.google.com/identity/protocols/OpenIDConnect>`__.
646+
The OIDC token will be generated for the Monitoring service agent
647+
service account.
648+
649+
Attributes:
650+
type_ (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType):
651+
Type of authentication.
652+
"""
653+
654+
class ServiceAgentAuthenticationType(proto.Enum):
655+
r"""Type of authentication.
656+
657+
Values:
658+
SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED (0):
659+
Default value, will result in OIDC
660+
Authentication.
661+
OIDC_TOKEN (1):
662+
OIDC Authentication
663+
"""
664+
SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED = 0
665+
OIDC_TOKEN = 1
666+
667+
type_: "UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType" = proto.Field(
668+
proto.ENUM,
669+
number=1,
670+
enum="UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType",
671+
)
672+
583673
request_method: "UptimeCheckConfig.HttpCheck.RequestMethod" = proto.Field(
584674
proto.ENUM,
585675
number=8,
@@ -640,6 +730,12 @@ class StatusClass(proto.Enum):
640730
number=12,
641731
message="UptimeCheckConfig.PingConfig",
642732
)
733+
service_agent_authentication: "UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication" = proto.Field(
734+
proto.MESSAGE,
735+
number=14,
736+
oneof="auth_method",
737+
message="UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication",
738+
)
643739

644740
class TcpCheck(proto.Message):
645741
r"""Information required for a TCP Uptime check request.
@@ -816,6 +912,12 @@ class JsonPathMatcherOption(proto.Enum):
816912
oneof="resource",
817913
message=ResourceGroup,
818914
)
915+
synthetic_monitor: "SyntheticMonitorTarget" = proto.Field(
916+
proto.MESSAGE,
917+
number=21,
918+
oneof="resource",
919+
message="SyntheticMonitorTarget",
920+
)
819921
http_check: HttpCheck = proto.Field(
820922
proto.MESSAGE,
821923
number=5,

packages/google-cloud-monitoring/samples/generated_samples/snippet_metadata_google.monitoring.v3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
],
99
"language": "PYTHON",
1010
"name": "google-cloud-monitoring",
11-
"version": "2.19.4"
11+
"version": "0.1.0"
1212
},
1313
"snippets": [
1414
{

0 commit comments

Comments
 (0)