Skip to content
Permalink
Browse files
feat: add support for cmek settings; undeprecate resource name helper…
… methods; bump copyright year to 2020 (#22)
  • Loading branch information
yoshi-automation committed Feb 19, 2020
1 parent 5bbe5de commit 1c687c168cdc1f5ebc74d2380ad87335a42209a2

Large diffs are not rendered by default.

@@ -4,6 +4,7 @@
"retry_codes": {
"idempotent": ["DEADLINE_EXCEEDED", "INTERNAL", "UNAVAILABLE"],
"non_idempotent": [],
"idempotent2": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
},
"retry_params": {
"default": {
@@ -76,6 +77,16 @@
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"GetCmekSettings": {
"timeout_millis": 60000,
"retry_codes_name": "idempotent2",
"retry_params_name": "default",
},
"UpdateCmekSettings": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
},
}
}
@@ -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.
@@ -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.
@@ -79,24 +79,14 @@ def from_service_account_file(cls, filename, *args, **kwargs):

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

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

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

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

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

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

@classmethod
def organization_log_path(cls, organization, log):
"""DEPRECATED. Return a fully-qualified organization_log string."""
warnings.warn(
"Resource name helper functions are deprecated.",
PendingDeprecationWarning,
stacklevel=1,
)
"""Return a fully-qualified organization_log string."""
return google.api_core.path_template.expand(
"organizations/{organization}/logs/{log}",
organization=organization,
@@ -165,12 +130,7 @@ def organization_log_path(cls, organization, log):

@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,
)
@@ -296,10 +256,10 @@ def delete_log(
metadata=None,
):
"""
Deletes all the log entries in a log.
The log reappears if it receives new entries.
Log entries written shortly before the delete operation might not be
deleted.
Deletes all the log entries in a log. The log reappears if it receives new
entries. Log entries written shortly before the delete operation might not
be deleted. Entries received after the delete operation with a timestamp
before the operation will be deleted.
Example:
>>> from google.cloud import logging_v2
@@ -573,7 +533,7 @@ def list_log_entries(
Example: ``"my-project-1A"``.
filter_ (str): Optional. A filter that chooses which log entries to return. See
`Advanced Logs
Filters <https://cloud.google.com/logging/docs/view/advanced_filters>`__.
Queries <https://cloud.google.com/logging/docs/view/advanced-queries>`__.
Only log entries that match the filter are returned. An empty filter
matches all log entries in the resources listed in ``resource_names``.
Referencing a parent resource that is not listed in ``resource_names``
@@ -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.
@@ -81,58 +81,33 @@ def from_service_account_file(cls, filename, *args, **kwargs):

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

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

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

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

@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,
)
@@ -377,7 +352,7 @@ def get_log_metric(
>>> response = client.get_log_metric(metric_name)
Args:
metric_name (str): The resource name of the desired metric:
metric_name (str): Required. The resource name of the desired metric:
::
@@ -454,14 +429,15 @@ def create_log_metric(
>>> response = client.create_log_metric(parent, metric)
Args:
parent (str): The resource name of the project in which to create the metric:
parent (str): Required. The resource name of the project in which to create the
metric:
::
"projects/[PROJECT_ID]"
The new metric must be provided in the request.
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): The new logs-based metric, which must not have an identifier that
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): Required. The new logs-based metric, which must not have an identifier that
already exists.
If a dict is provided, it must be of the same form as the protobuf
@@ -540,7 +516,7 @@ def update_log_metric(
>>> response = client.update_log_metric(metric_name, metric)
Args:
metric_name (str): The resource name of the metric to update:
metric_name (str): Required. The resource name of the metric to update:
::
@@ -549,7 +525,7 @@ def update_log_metric(
The updated metric must be provided in the request and it's ``name``
field must be the same as ``[METRIC_ID]`` If the metric does not exist
in ``[PROJECT_ID]``, then a new metric is created.
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): The updated metric.
metric (Union[dict, ~google.cloud.logging_v2.types.LogMetric]): Required. The updated metric.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.logging_v2.types.LogMetric`
@@ -623,7 +599,7 @@ def delete_log_metric(
>>> client.delete_log_metric(metric_name)
Args:
metric_name (str): The resource name of the metric to delete:
metric_name (str): Required. The resource name of the metric to delete:
::
@@ -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.
@@ -255,3 +255,52 @@ def delete_exclusion(self):
deserialized response object.
"""
return self._stubs["config_service_v2_stub"].DeleteExclusion

@property
def get_cmek_settings(self):
"""Return the gRPC stub for :meth:`ConfigServiceV2Client.get_cmek_settings`.
Gets the Logs Router CMEK settings for the given resource.
Note: CMEK for the Logs Router can currently only be configured for GCP
organizations. Once configured, it applies to all projects and folders
in the GCP organization.
See `Enabling CMEK for Logs
Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
for more information.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["config_service_v2_stub"].GetCmekSettings

@property
def update_cmek_settings(self):
"""Return the gRPC stub for :meth:`ConfigServiceV2Client.update_cmek_settings`.
Updates the Logs Router CMEK settings for the given resource.
Note: CMEK for the Logs Router can currently only be configured for GCP
organizations. Once configured, it applies to all projects and folders
in the GCP organization.
``UpdateCmekSettings`` will fail if 1) ``kms_key_name`` is invalid, or
2) the associated service account does not have the required
``roles/cloudkms.cryptoKeyEncrypterDecrypter`` role assigned for the
key, or
3) access to the key is disabled.
See `Enabling CMEK for Logs
Router <https://cloud.google.com/logging/docs/routing/managed-encryption>`__
for more information.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["config_service_v2_stub"].UpdateCmekSettings
@@ -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.
@@ -117,10 +117,10 @@ def channel(self):
def delete_log(self):
"""Return the gRPC stub for :meth:`LoggingServiceV2Client.delete_log`.
Deletes all the log entries in a log.
The log reappears if it receives new entries.
Log entries written shortly before the delete operation might not be
deleted.
Deletes all the log entries in a log. The log reappears if it receives new
entries. Log entries written shortly before the delete operation might not
be deleted. Entries received after the delete operation with a timestamp
before the operation will be deleted.
Returns:
Callable: A callable which accepts the appropriate
@@ -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.

0 comments on commit 1c687c1

Please sign in to comment.