Skip to content

Commit 1c687c1

Browse files
feat: add support for cmek settings; undeprecate resource name helper methods; bump copyright year to 2020 (#22)
1 parent 5bbe5de commit 1c687c1

22 files changed

+1570
-437
lines changed

google/cloud/logging_v2/gapic/config_service_v2_client.py

Lines changed: 218 additions & 73 deletions
Large diffs are not rendered by default.

google/cloud/logging_v2/gapic/config_service_v2_client_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"retry_codes": {
55
"idempotent": ["DEADLINE_EXCEEDED", "INTERNAL", "UNAVAILABLE"],
66
"non_idempotent": [],
7+
"idempotent2": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
78
},
89
"retry_params": {
910
"default": {
@@ -76,6 +77,16 @@
7677
"retry_codes_name": "idempotent",
7778
"retry_params_name": "default",
7879
},
80+
"GetCmekSettings": {
81+
"timeout_millis": 60000,
82+
"retry_codes_name": "idempotent2",
83+
"retry_params_name": "default",
84+
},
85+
"UpdateCmekSettings": {
86+
"timeout_millis": 60000,
87+
"retry_codes_name": "non_idempotent",
88+
"retry_params_name": "default",
89+
},
7990
},
8091
}
8192
}

google/cloud/logging_v2/gapic/enums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

google/cloud/logging_v2/gapic/logging_service_v2_client.py

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -79,24 +79,14 @@ def from_service_account_file(cls, filename, *args, **kwargs):
7979

8080
@classmethod
8181
def billing_path(cls, billing_account):
82-
"""DEPRECATED. Return a fully-qualified billing string."""
83-
warnings.warn(
84-
"Resource name helper functions are deprecated.",
85-
PendingDeprecationWarning,
86-
stacklevel=1,
87-
)
82+
"""Return a fully-qualified billing string."""
8883
return google.api_core.path_template.expand(
8984
"billingAccounts/{billing_account}", billing_account=billing_account,
9085
)
9186

9287
@classmethod
9388
def billing_log_path(cls, billing_account, log):
94-
"""DEPRECATED. Return a fully-qualified billing_log string."""
95-
warnings.warn(
96-
"Resource name helper functions are deprecated.",
97-
PendingDeprecationWarning,
98-
stacklevel=1,
99-
)
89+
"""Return a fully-qualified billing_log string."""
10090
return google.api_core.path_template.expand(
10191
"billingAccounts/{billing_account}/logs/{log}",
10292
billing_account=billing_account,
@@ -105,58 +95,33 @@ def billing_log_path(cls, billing_account, log):
10595

10696
@classmethod
10797
def folder_path(cls, folder):
108-
"""DEPRECATED. Return a fully-qualified folder string."""
109-
warnings.warn(
110-
"Resource name helper functions are deprecated.",
111-
PendingDeprecationWarning,
112-
stacklevel=1,
113-
)
98+
"""Return a fully-qualified folder string."""
11499
return google.api_core.path_template.expand("folders/{folder}", folder=folder,)
115100

116101
@classmethod
117102
def folder_log_path(cls, folder, log):
118-
"""DEPRECATED. Return a fully-qualified folder_log string."""
119-
warnings.warn(
120-
"Resource name helper functions are deprecated.",
121-
PendingDeprecationWarning,
122-
stacklevel=1,
123-
)
103+
"""Return a fully-qualified folder_log string."""
124104
return google.api_core.path_template.expand(
125105
"folders/{folder}/logs/{log}", folder=folder, log=log,
126106
)
127107

128108
@classmethod
129109
def log_path(cls, project, log):
130-
"""DEPRECATED. Return a fully-qualified log string."""
131-
warnings.warn(
132-
"Resource name helper functions are deprecated.",
133-
PendingDeprecationWarning,
134-
stacklevel=1,
135-
)
110+
"""Return a fully-qualified log string."""
136111
return google.api_core.path_template.expand(
137112
"projects/{project}/logs/{log}", project=project, log=log,
138113
)
139114

140115
@classmethod
141116
def organization_path(cls, organization):
142-
"""DEPRECATED. Return a fully-qualified organization string."""
143-
warnings.warn(
144-
"Resource name helper functions are deprecated.",
145-
PendingDeprecationWarning,
146-
stacklevel=1,
147-
)
117+
"""Return a fully-qualified organization string."""
148118
return google.api_core.path_template.expand(
149119
"organizations/{organization}", organization=organization,
150120
)
151121

152122
@classmethod
153123
def organization_log_path(cls, organization, log):
154-
"""DEPRECATED. Return a fully-qualified organization_log string."""
155-
warnings.warn(
156-
"Resource name helper functions are deprecated.",
157-
PendingDeprecationWarning,
158-
stacklevel=1,
159-
)
124+
"""Return a fully-qualified organization_log string."""
160125
return google.api_core.path_template.expand(
161126
"organizations/{organization}/logs/{log}",
162127
organization=organization,
@@ -165,12 +130,7 @@ def organization_log_path(cls, organization, log):
165130

166131
@classmethod
167132
def project_path(cls, project):
168-
"""DEPRECATED. Return a fully-qualified project string."""
169-
warnings.warn(
170-
"Resource name helper functions are deprecated.",
171-
PendingDeprecationWarning,
172-
stacklevel=1,
173-
)
133+
"""Return a fully-qualified project string."""
174134
return google.api_core.path_template.expand(
175135
"projects/{project}", project=project,
176136
)
@@ -296,10 +256,10 @@ def delete_log(
296256
metadata=None,
297257
):
298258
"""
299-
Deletes all the log entries in a log.
300-
The log reappears if it receives new entries.
301-
Log entries written shortly before the delete operation might not be
302-
deleted.
259+
Deletes all the log entries in a log. The log reappears if it receives new
260+
entries. Log entries written shortly before the delete operation might not
261+
be deleted. Entries received after the delete operation with a timestamp
262+
before the operation will be deleted.
303263
304264
Example:
305265
>>> from google.cloud import logging_v2
@@ -573,7 +533,7 @@ def list_log_entries(
573533
Example: ``"my-project-1A"``.
574534
filter_ (str): Optional. A filter that chooses which log entries to return. See
575535
`Advanced Logs
576-
Filters <https://cloud.google.com/logging/docs/view/advanced_filters>`__.
536+
Queries <https://cloud.google.com/logging/docs/view/advanced-queries>`__.
577537
Only log entries that match the filter are returned. An empty filter
578538
matches all log entries in the resources listed in ``resource_names``.
579539
Referencing a parent resource that is not listed in ``resource_names``

google/cloud/logging_v2/gapic/metrics_service_v2_client.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -81,58 +81,33 @@ def from_service_account_file(cls, filename, *args, **kwargs):
8181

8282
@classmethod
8383
def billing_path(cls, billing_account):
84-
"""DEPRECATED. Return a fully-qualified billing string."""
85-
warnings.warn(
86-
"Resource name helper functions are deprecated.",
87-
PendingDeprecationWarning,
88-
stacklevel=1,
89-
)
84+
"""Return a fully-qualified billing string."""
9085
return google.api_core.path_template.expand(
9186
"billingAccounts/{billing_account}", billing_account=billing_account,
9287
)
9388

9489
@classmethod
9590
def folder_path(cls, folder):
96-
"""DEPRECATED. Return a fully-qualified folder string."""
97-
warnings.warn(
98-
"Resource name helper functions are deprecated.",
99-
PendingDeprecationWarning,
100-
stacklevel=1,
101-
)
91+
"""Return a fully-qualified folder string."""
10292
return google.api_core.path_template.expand("folders/{folder}", folder=folder,)
10393

10494
@classmethod
10595
def metric_path(cls, project, metric):
106-
"""DEPRECATED. Return a fully-qualified metric string."""
107-
warnings.warn(
108-
"Resource name helper functions are deprecated.",
109-
PendingDeprecationWarning,
110-
stacklevel=1,
111-
)
96+
"""Return a fully-qualified metric string."""
11297
return google.api_core.path_template.expand(
11398
"projects/{project}/metrics/{metric}", project=project, metric=metric,
11499
)
115100

116101
@classmethod
117102
def organization_path(cls, organization):
118-
"""DEPRECATED. Return a fully-qualified organization string."""
119-
warnings.warn(
120-
"Resource name helper functions are deprecated.",
121-
PendingDeprecationWarning,
122-
stacklevel=1,
123-
)
103+
"""Return a fully-qualified organization string."""
124104
return google.api_core.path_template.expand(
125105
"organizations/{organization}", organization=organization,
126106
)
127107

128108
@classmethod
129109
def project_path(cls, project):
130-
"""DEPRECATED. Return a fully-qualified project string."""
131-
warnings.warn(
132-
"Resource name helper functions are deprecated.",
133-
PendingDeprecationWarning,
134-
stacklevel=1,
135-
)
110+
"""Return a fully-qualified project string."""
136111
return google.api_core.path_template.expand(
137112
"projects/{project}", project=project,
138113
)
@@ -377,7 +352,7 @@ def get_log_metric(
377352
>>> response = client.get_log_metric(metric_name)
378353
379354
Args:
380-
metric_name (str): The resource name of the desired metric:
355+
metric_name (str): Required. The resource name of the desired metric:
381356
382357
::
383358
@@ -454,14 +429,15 @@ def create_log_metric(
454429
>>> response = client.create_log_metric(parent, metric)
455430
456431
Args:
457-
parent (str): The resource name of the project in which to create the metric:
432+
parent (str): Required. The resource name of the project in which to create the
433+
metric:
458434
459435
::
460436
461437
"projects/[PROJECT_ID]"
462438
463439
The new metric must be provided in the request.
464-
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): The new logs-based metric, which must not have an identifier that
440+
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): Required. The new logs-based metric, which must not have an identifier that
465441
already exists.
466442
467443
If a dict is provided, it must be of the same form as the protobuf
@@ -540,7 +516,7 @@ def update_log_metric(
540516
>>> response = client.update_log_metric(metric_name, metric)
541517
542518
Args:
543-
metric_name (str): The resource name of the metric to update:
519+
metric_name (str): Required. The resource name of the metric to update:
544520
545521
::
546522
@@ -549,7 +525,7 @@ def update_log_metric(
549525
The updated metric must be provided in the request and it's ``name``
550526
field must be the same as ``[METRIC_ID]`` If the metric does not exist
551527
in ``[PROJECT_ID]``, then a new metric is created.
552-
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): The updated metric.
528+
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): Required. The updated metric.
553529
554530
If a dict is provided, it must be of the same form as the protobuf
555531
message :class:`~google.cloud.logging_v2.types.LogMetric`
@@ -623,7 +599,7 @@ def delete_log_metric(
623599
>>> client.delete_log_metric(metric_name)
624600
625601
Args:
626-
metric_name (str): The resource name of the metric to delete:
602+
metric_name (str): Required. The resource name of the metric to delete:
627603
628604
::
629605

google/cloud/logging_v2/gapic/transports/config_service_v2_grpc_transport.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -255,3 +255,52 @@ def delete_exclusion(self):
255255
deserialized response object.
256256
"""
257257
return self._stubs["config_service_v2_stub"].DeleteExclusion
258+
259+
@property
260+
def get_cmek_settings(self):
261+
"""Return the gRPC stub for :meth:`ConfigServiceV2Client.get_cmek_settings`.
262+
263+
Gets the Logs Router CMEK settings for the given resource.
264+
265+
Note: CMEK for the Logs Router can currently only be configured for GCP
266+
organizations. Once configured, it applies to all projects and folders
267+
in the GCP organization.
268+
269+
See `Enabling CMEK for Logs
270+
Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
271+
for more information.
272+
273+
Returns:
274+
Callable: A callable which accepts the appropriate
275+
deserialized request object and returns a
276+
deserialized response object.
277+
"""
278+
return self._stubs["config_service_v2_stub"].GetCmekSettings
279+
280+
@property
281+
def update_cmek_settings(self):
282+
"""Return the gRPC stub for :meth:`ConfigServiceV2Client.update_cmek_settings`.
283+
284+
Updates the Logs Router CMEK settings for the given resource.
285+
286+
Note: CMEK for the Logs Router can currently only be configured for GCP
287+
organizations. Once configured, it applies to all projects and folders
288+
in the GCP organization.
289+
290+
``UpdateCmekSettings`` will fail if 1) ``kms_key_name`` is invalid, or
291+
2) the associated service account does not have the required
292+
``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for the
293+
key, or
294+
295+
3) access to the key is disabled.
296+
297+
See `Enabling CMEK for Logs
298+
Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
299+
for more information.
300+
301+
Returns:
302+
Callable: A callable which accepts the appropriate
303+
deserialized request object and returns a
304+
deserialized response object.
305+
"""
306+
return self._stubs["config_service_v2_stub"].UpdateCmekSettings

google/cloud/logging_v2/gapic/transports/logging_service_v2_grpc_transport.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -117,10 +117,10 @@ def channel(self):
117117
def delete_log(self):
118118
"""Return the gRPC stub for :meth:`LoggingServiceV2Client.delete_log`.
119119
120-
Deletes all the log entries in a log.
121-
The log reappears if it receives new entries.
122-
Log entries written shortly before the delete operation might not be
123-
deleted.
120+
Deletes all the log entries in a log. The log reappears if it receives new
121+
entries. Log entries written shortly before the delete operation might not
122+
be deleted. Entries received after the delete operation with a timestamp
123+
before the operation will be deleted.
124124
125125
Returns:
126126
Callable: A callable which accepts the appropriate

google/cloud/logging_v2/gapic/transports/metrics_service_v2_grpc_transport.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright 2019 Google LLC
3+
# Copyright 2020 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)