Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [google-cloud-monitoring] Added Synthetic Monitor targets to Uptime data model #12575

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
from google.cloud.monitoring_v3.types.uptime import (
GroupResourceType,
InternalChecker,
SyntheticMonitorTarget,
UptimeCheckConfig,
UptimeCheckIp,
UptimeCheckRegion,
Expand Down Expand Up @@ -296,6 +297,7 @@
"UpdateSnoozeRequest",
"SpanContext",
"InternalChecker",
"SyntheticMonitorTarget",
"UptimeCheckConfig",
"UptimeCheckIp",
"GroupResourceType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.19.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
from .types.uptime import (
GroupResourceType,
InternalChecker,
SyntheticMonitorTarget,
UptimeCheckConfig,
UptimeCheckIp,
UptimeCheckRegion,
Expand Down Expand Up @@ -261,6 +262,7 @@
"Snooze",
"SnoozeServiceClient",
"SpanContext",
"SyntheticMonitorTarget",
"TextLocator",
"TimeInterval",
"TimeSeries",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "2.19.4" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class UptimeCheckServiceAsyncClient:
_DEFAULT_ENDPOINT_TEMPLATE = UptimeCheckServiceClient._DEFAULT_ENDPOINT_TEMPLATE
_DEFAULT_UNIVERSE = UptimeCheckServiceClient._DEFAULT_UNIVERSE

function_path = staticmethod(UptimeCheckServiceClient.function_path)
parse_function_path = staticmethod(UptimeCheckServiceClient.parse_function_path)
uptime_check_config_path = staticmethod(
UptimeCheckServiceClient.uptime_check_config_path
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,28 @@ def transport(self) -> UptimeCheckServiceTransport:
"""
return self._transport

@staticmethod
def function_path(
project: str,
location: str,
function: str,
) -> str:
"""Returns a fully-qualified function string."""
return "projects/{project}/locations/{location}/functions/{function}".format(
project=project,
location=location,
function=function,
)

@staticmethod
def parse_function_path(path: str) -> Dict[str, str]:
"""Parses a function path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/functions/(?P<function>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def uptime_check_config_path(
project: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
from .uptime import (
GroupResourceType,
InternalChecker,
SyntheticMonitorTarget,
UptimeCheckConfig,
UptimeCheckIp,
UptimeCheckRegion,
Expand Down Expand Up @@ -222,6 +223,7 @@
"UpdateSnoozeRequest",
"SpanContext",
"InternalChecker",
"SyntheticMonitorTarget",
"UptimeCheckConfig",
"UptimeCheckIp",
"GroupResourceType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"UptimeCheckRegion",
"GroupResourceType",
"InternalChecker",
"SyntheticMonitorTarget",
"UptimeCheckConfig",
"UptimeCheckIp",
},
Expand Down Expand Up @@ -188,6 +189,52 @@ class State(proto.Enum):
)


class SyntheticMonitorTarget(proto.Message):
r"""Describes a Synthetic Monitor to be invoked by Uptime.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
cloud_function_v2 (google.cloud.monitoring_v3.types.SyntheticMonitorTarget.CloudFunctionV2Target):
Target a Synthetic Monitor GCFv2 instance.

This field is a member of `oneof`_ ``target``.
"""

class CloudFunctionV2Target(proto.Message):
r"""A Synthetic Monitor deployed to a Cloud Functions V2
instance.

Attributes:
name (str):
Required. Fully qualified GCFv2 resource name i.e.
``projects/{project}/locations/{location}/functions/{function}``
Required.
cloud_run_revision (google.api.monitored_resource_pb2.MonitoredResource):
Output only. The ``cloud_run_revision`` Monitored Resource
associated with the GCFv2. The Synthetic Monitor execution
results (metrics, logs, and spans) are reported against this
Monitored Resource. This field is output only.
"""

name: str = proto.Field(
proto.STRING,
number=1,
)
cloud_run_revision: monitored_resource_pb2.MonitoredResource = proto.Field(
proto.MESSAGE,
number=2,
message=monitored_resource_pb2.MonitoredResource,
)

cloud_function_v2: CloudFunctionV2Target = proto.Field(
proto.MESSAGE,
number=1,
oneof="target",
message=CloudFunctionV2Target,
)


class UptimeCheckConfig(proto.Message):
r"""This message configures which resources and services to
monitor for availability.
Expand All @@ -201,8 +248,8 @@ class UptimeCheckConfig(proto.Message):

Attributes:
name (str):
A unique resource name for this Uptime check configuration.
The format is:
Identifier. A unique resource name for this Uptime check
configuration. The format is:

::

Expand Down Expand Up @@ -234,6 +281,10 @@ class UptimeCheckConfig(proto.Message):
The group resource associated with the
configuration.

This field is a member of `oneof`_ ``resource``.
synthetic_monitor (google.cloud.monitoring_v3.types.SyntheticMonitorTarget):
Specifies a Synthetic Monitor to invoke.

This field is a member of `oneof`_ ``resource``.
http_check (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck):
Contains information needed to make an HTTP
Expand Down Expand Up @@ -361,6 +412,8 @@ class PingConfig(proto.Message):
class HttpCheck(proto.Message):
r"""Information involved in an HTTP/HTTPS Uptime check request.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
request_method (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.RequestMethod):
The HTTP request method to use for the check. If set to
Expand All @@ -381,8 +434,9 @@ class HttpCheck(proto.Message):
host (specified within the ``monitored_resource``) and
``path`` to construct the full URL.
auth_info (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.BasicAuthentication):
The authentication information. Optional when
creating an HTTP check; defaults to empty.
The authentication information. Optional when creating an
HTTP check; defaults to empty. Do not set both
``auth_method`` and ``auth_info``.
mask_headers (bool):
Boolean specifying whether to encrypt the header
information. Encryption should be specified for any headers
Expand Down Expand Up @@ -453,6 +507,12 @@ class HttpCheck(proto.Message):
ping_config (google.cloud.monitoring_v3.types.UptimeCheckConfig.PingConfig):
Contains information needed to add pings to
an HTTP check.
service_agent_authentication (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication):
If specified, Uptime will generate and attach an OIDC JWT
token for the Monitoring service agent service account as an
``Authorization`` header in the HTTP request when probing.

This field is a member of `oneof`_ ``auth_method``.
"""

class RequestMethod(proto.Enum):
Expand Down Expand Up @@ -580,6 +640,36 @@ class StatusClass(proto.Enum):
enum="UptimeCheckConfig.HttpCheck.ResponseStatusCode.StatusClass",
)

class ServiceAgentAuthentication(proto.Message):
r"""Contains information needed for generating an `OpenID Connect
token <https://developers.google.com/identity/protocols/OpenIDConnect>`__.
The OIDC token will be generated for the Monitoring service agent
service account.

Attributes:
type_ (google.cloud.monitoring_v3.types.UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType):
Type of authentication.
"""

class ServiceAgentAuthenticationType(proto.Enum):
r"""Type of authentication.

Values:
SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED (0):
Default value, will result in OIDC
Authentication.
OIDC_TOKEN (1):
OIDC Authentication
"""
SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED = 0
OIDC_TOKEN = 1

type_: "UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType" = proto.Field(
proto.ENUM,
number=1,
enum="UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication.ServiceAgentAuthenticationType",
)

request_method: "UptimeCheckConfig.HttpCheck.RequestMethod" = proto.Field(
proto.ENUM,
number=8,
Expand Down Expand Up @@ -640,6 +730,12 @@ class StatusClass(proto.Enum):
number=12,
message="UptimeCheckConfig.PingConfig",
)
service_agent_authentication: "UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication" = proto.Field(
proto.MESSAGE,
number=14,
oneof="auth_method",
message="UptimeCheckConfig.HttpCheck.ServiceAgentAuthentication",
)

class TcpCheck(proto.Message):
r"""Information required for a TCP Uptime check request.
Expand Down Expand Up @@ -816,6 +912,12 @@ class JsonPathMatcherOption(proto.Enum):
oneof="resource",
message=ResourceGroup,
)
synthetic_monitor: "SyntheticMonitorTarget" = proto.Field(
proto.MESSAGE,
number=21,
oneof="resource",
message="SyntheticMonitorTarget",
)
http_check: HttpCheck = proto.Field(
proto.MESSAGE,
number=5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-monitoring",
"version": "2.19.4"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Loading
Loading