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(monitoring): un-deprecate resource name helpers, add 2.7 sunset warning; bump copyright year to 2020; use templated noxfile (via synth) #10047

Merged
merged 4 commits into from
Jan 30, 2020
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
4 changes: 2 additions & 2 deletions monitoring/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
u"google-cloud-monitoring Documentation",
author,
"manual",
),
)
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -320,7 +320,7 @@
"google-cloud-monitoring",
"GAPIC library for the {metadata.shortName} v3 service",
"APIs",
),
)
]

# Documents to append as an appendix to all manuals.
Expand Down
2 changes: 1 addition & 1 deletion monitoring/google/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion monitoring/google/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion monitoring/google/cloud/monitoring.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
13 changes: 12 additions & 1 deletion monitoring/google/cloud/monitoring_v3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,6 +16,8 @@


from __future__ import absolute_import
import sys
import warnings

from google.cloud.monitoring_v3 import types
from google.cloud.monitoring_v3.gapic import alert_policy_service_client
Expand All @@ -29,6 +31,15 @@
from google.cloud.monitoring_v3.gapic import uptime_check_service_client


if sys.version_info[:2] == (2, 7):
message = (
"A future version of this library will drop support for Python 2.7."
"More details about Python 2 support for Google Cloud Client Libraries"
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
)
warnings.warn(message, DeprecationWarning)


class AlertPolicyServiceClient(alert_policy_service_client.AlertPolicyServiceClient):
__doc__ = alert_policy_service_client.AlertPolicyServiceClient.__doc__
enums = enums
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,7 +44,7 @@


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-monitoring",
"google-cloud-monitoring"
).version


Expand Down Expand Up @@ -90,12 +90,7 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def alert_policy_path(cls, project, alert_policy):
"""DEPRECATED. Return a fully-qualified alert_policy string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified alert_policy string."""
return google.api_core.path_template.expand(
"projects/{project}/alertPolicies/{alert_policy}",
project=project,
Expand All @@ -104,12 +99,7 @@ def alert_policy_path(cls, project, alert_policy):

@classmethod
def alert_policy_condition_path(cls, project, alert_policy, condition):
"""DEPRECATED. Return a fully-qualified alert_policy_condition string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified alert_policy_condition string."""
return google.api_core.path_template.expand(
"projects/{project}/alertPolicies/{alert_policy}/conditions/{condition}",
project=project,
Expand All @@ -119,14 +109,9 @@ def alert_policy_condition_path(cls, project, alert_policy, condition):

@classmethod
def project_path(cls, project):
"""DEPRECATED. Return a fully-qualified project string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project,
"projects/{project}", project=project
)

def __init__(
Expand Down Expand Up @@ -216,12 +201,12 @@ def __init__(
self.transport = transport
else:
self.transport = alert_policy_service_grpc_transport.AlertPolicyServiceGrpcTransport(
address=api_endpoint, channel=channel, credentials=credentials,
address=api_endpoint, channel=channel, credentials=credentials
)

if client_info is None:
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION,
gapic_version=_GAPIC_LIBRARY_VERSION
)
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
Expand All @@ -232,7 +217,7 @@ def __init__(
# (Ordinarily, these are the defaults specified in the `*_config.py`
# file next to this one.)
self._method_configs = google.api_core.gapic_v1.config.parse_method_configs(
client_config["interfaces"][self._INTERFACE_NAME],
client_config["interfaces"][self._INTERFACE_NAME]
)

# Save a dictionary of cached API call functions.
Expand Down Expand Up @@ -337,7 +322,7 @@ def list_alert_policies(
)

request = alert_service_pb2.ListAlertPoliciesRequest(
name=name, filter=filter_, order_by=order_by, page_size=page_size,
name=name, filter=filter_, order_by=order_by, page_size=page_size
)
if metadata is None:
metadata = []
Expand Down Expand Up @@ -423,7 +408,7 @@ def get_alert_policy(
client_info=self._client_info,
)

request = alert_service_pb2.GetAlertPolicyRequest(name=name,)
request = alert_service_pb2.GetAlertPolicyRequest(name=name)
if metadata is None:
metadata = []
metadata = list(metadata)
Expand Down Expand Up @@ -513,7 +498,7 @@ def create_alert_policy(
)

request = alert_service_pb2.CreateAlertPolicyRequest(
name=name, alert_policy=alert_policy,
name=name, alert_policy=alert_policy
)
if metadata is None:
metadata = []
Expand Down Expand Up @@ -587,7 +572,7 @@ def delete_alert_policy(
client_info=self._client_info,
)

request = alert_service_pb2.DeleteAlertPolicyRequest(name=name,)
request = alert_service_pb2.DeleteAlertPolicyRequest(name=name)
if metadata is None:
metadata = []
metadata = list(metadata)
Expand Down Expand Up @@ -696,7 +681,7 @@ def update_alert_policy(
)

request = alert_service_pb2.UpdateAlertPolicyRequest(
alert_policy=alert_policy, update_mask=update_mask,
alert_policy=alert_policy, update_mask=update_mask
)
if metadata is None:
metadata = []
Expand Down
2 changes: 1 addition & 1 deletion monitoring/google/cloud/monitoring_v3/gapic/enums.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
38 changes: 14 additions & 24 deletions monitoring/google/cloud/monitoring_v3/gapic/group_service_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@


_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution(
"google-cloud-monitoring",
"google-cloud-monitoring"
).version


Expand Down Expand Up @@ -95,26 +95,16 @@ def from_service_account_file(cls, filename, *args, **kwargs):

@classmethod
def group_path(cls, project, group):
"""DEPRECATED. Return a fully-qualified group string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified group string."""
return google.api_core.path_template.expand(
"projects/{project}/groups/{group}", project=project, group=group,
"projects/{project}/groups/{group}", project=project, group=group
)

@classmethod
def project_path(cls, project):
"""DEPRECATED. Return a fully-qualified project string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified project string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project,
"projects/{project}", project=project
)

def __init__(
Expand Down Expand Up @@ -204,12 +194,12 @@ def __init__(
self.transport = transport
else:
self.transport = group_service_grpc_transport.GroupServiceGrpcTransport(
address=api_endpoint, channel=channel, credentials=credentials,
address=api_endpoint, channel=channel, credentials=credentials
)

if client_info is None:
client_info = google.api_core.gapic_v1.client_info.ClientInfo(
gapic_version=_GAPIC_LIBRARY_VERSION,
gapic_version=_GAPIC_LIBRARY_VERSION
)
else:
client_info.gapic_version = _GAPIC_LIBRARY_VERSION
Expand All @@ -220,7 +210,7 @@ def __init__(
# (Ordinarily, these are the defaults specified in the `*_config.py`
# file next to this one.)
self._method_configs = google.api_core.gapic_v1.config.parse_method_configs(
client_config["interfaces"][self._INTERFACE_NAME],
client_config["interfaces"][self._INTERFACE_NAME]
)

# Save a dictionary of cached API call functions.
Expand Down Expand Up @@ -419,7 +409,7 @@ def get_group(
client_info=self._client_info,
)

request = group_service_pb2.GetGroupRequest(name=name,)
request = group_service_pb2.GetGroupRequest(name=name)
if metadata is None:
metadata = []
metadata = list(metadata)
Expand Down Expand Up @@ -504,7 +494,7 @@ def create_group(
)

request = group_service_pb2.CreateGroupRequest(
name=name, group=group, validate_only=validate_only,
name=name, group=group, validate_only=validate_only
)
if metadata is None:
metadata = []
Expand Down Expand Up @@ -587,7 +577,7 @@ def update_group(
)

request = group_service_pb2.UpdateGroupRequest(
group=group, validate_only=validate_only,
group=group, validate_only=validate_only
)
if metadata is None:
metadata = []
Expand Down Expand Up @@ -662,7 +652,7 @@ def delete_group(
client_info=self._client_info,
)

request = group_service_pb2.DeleteGroupRequest(name=name, recursive=recursive,)
request = group_service_pb2.DeleteGroupRequest(name=name, recursive=recursive)
if metadata is None:
metadata = []
metadata = list(metadata)
Expand Down Expand Up @@ -776,7 +766,7 @@ def list_group_members(
)

request = group_service_pb2.ListGroupMembersRequest(
name=name, page_size=page_size, filter=filter_, interval=interval,
name=name, page_size=page_size, filter=filter_, interval=interval
)
if metadata is None:
metadata = []
Expand Down
Loading