diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 894fb6b..b8edda5 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:f62c53736eccb0c4934a3ea9316e0d57696bb49c1a7c86c726e9bb8a2f87dadf + digest: sha256:2e247c7bf5154df7f98cce087a20ca7605e236340c7d6d1a14447e5c06791bd6 diff --git a/.kokoro/requirements.in b/.kokoro/requirements.in index cbd7e77..ec867d9 100644 --- a/.kokoro/requirements.in +++ b/.kokoro/requirements.in @@ -1,10 +1,10 @@ gcp-docuploader -gcp-releasetool +gcp-releasetool>=1.10.5 # required for compatibility with cryptography>=39.x importlib-metadata typing-extensions twine wheel setuptools -nox +nox>=2022.11.21 # required to remove dependency on py charset-normalizer<3 click<8.1.0 diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 096e480..66a2172 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: # # pip-compile --allow-unsafe --generate-hashes requirements.in # @@ -154,9 +154,9 @@ gcp-docuploader==0.6.4 \ --hash=sha256:01486419e24633af78fd0167db74a2763974765ee8078ca6eb6964d0ebd388af \ --hash=sha256:70861190c123d907b3b067da896265ead2eeb9263969d6955c9e0bb091b5ccbf # via -r requirements.in -gcp-releasetool==1.10.0 \ - --hash=sha256:72a38ca91b59c24f7e699e9227c90cbe4dd71b789383cb0164b088abae294c83 \ - --hash=sha256:8c7c99320208383d4bb2b808c6880eb7a81424afe7cdba3c8d84b25f4f0e097d +gcp-releasetool==1.10.5 \ + --hash=sha256:174b7b102d704b254f2a26a3eda2c684fd3543320ec239baf771542a2e58e109 \ + --hash=sha256:e29d29927fe2ca493105a82958c6873bb2b90d503acac56be2c229e74de0eec9 # via -r requirements.in google-api-core==2.10.2 \ --hash=sha256:10c06f7739fe57781f87523375e8e1a3a4674bf6392cd6131a3222182b971320 \ @@ -335,9 +335,9 @@ more-itertools==9.0.0 \ --hash=sha256:250e83d7e81d0c87ca6bd942e6aeab8cc9daa6096d12c5308f3f92fa5e5c1f41 \ --hash=sha256:5a6257e40878ef0520b1803990e3e22303a41b5714006c32a3fd8304b26ea1ab # via jaraco-classes -nox==2022.8.7 \ - --hash=sha256:1b894940551dc5c389f9271d197ca5d655d40bdc6ccf93ed6880e4042760a34b \ - --hash=sha256:96cca88779e08282a699d672258ec01eb7c792d35bbbf538c723172bce23212c +nox==2022.11.21 \ + --hash=sha256:0e41a990e290e274cb205a976c4c97ee3c5234441a8132c8c3fd9ea3c22149eb \ + --hash=sha256:e21c31de0711d1274ca585a2c5fde36b1aa962005ba8e9322bf5eeed16dcd684 # via -r requirements.in packaging==21.3 \ --hash=sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb \ @@ -380,10 +380,6 @@ protobuf==3.20.3 \ # gcp-docuploader # gcp-releasetool # google-api-core -py==1.11.0 \ - --hash=sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719 \ - --hash=sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378 - # via nox pyasn1==0.4.8 \ --hash=sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d \ --hash=sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba diff --git a/.release-please-manifest.json b/.release-please-manifest.json index cf198b9..a09efe7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.11.0" + ".": "1.12.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 3511e8b..30c3e33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [1.12.0](https://github.com/googleapis/python-functions/compare/v1.11.0...v1.12.0) (2023-03-23) + + +### Features + +* Add `available_cpu` field ([af189a0](https://github.com/googleapis/python-functions/commit/af189a0b5f2ef5c29f017cb4265f0011074ce366)) +* Add `kms_key_name` field to ServiceConfig (the CMEK use case) ([af189a0](https://github.com/googleapis/python-functions/commit/af189a0b5f2ef5c29f017cb4265f0011074ce366)) +* Add `max_instance_request_concurrency` field ([af189a0](https://github.com/googleapis/python-functions/commit/af189a0b5f2ef5c29f017cb4265f0011074ce366)) +* Add `security_level` field ([af189a0](https://github.com/googleapis/python-functions/commit/af189a0b5f2ef5c29f017cb4265f0011074ce366)) + + +### Documentation + +* Fix formatting of request arg in docstring ([#259](https://github.com/googleapis/python-functions/issues/259)) ([8befe21](https://github.com/googleapis/python-functions/commit/8befe21b1d7bc16112f17fe32c1280ae7fa52ce2)) + ## [1.11.0](https://github.com/googleapis/python-functions/compare/v1.10.1...v1.11.0) (2023-02-16) diff --git a/google/cloud/functions/gapic_version.py b/google/cloud/functions/gapic_version.py index 98fb3f5..7138f21 100644 --- a/google/cloud/functions/gapic_version.py +++ b/google/cloud/functions/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.0" # {x-release-please-version} +__version__ = "1.12.0" # {x-release-please-version} diff --git a/google/cloud/functions_v1/gapic_version.py b/google/cloud/functions_v1/gapic_version.py index 98fb3f5..7138f21 100644 --- a/google/cloud/functions_v1/gapic_version.py +++ b/google/cloud/functions_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.0" # {x-release-please-version} +__version__ = "1.12.0" # {x-release-please-version} diff --git a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py b/google/cloud/functions_v1/services/cloud_functions_service/async_client.py index d5431f2..1daf0e0 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/async_client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/async_client.py @@ -276,8 +276,7 @@ async def sample_list_functions(): Args: request (Optional[Union[google.cloud.functions_v1.types.ListFunctionsRequest, dict]]): - The request object. Request for the `ListFunctions` - method. + The request object. Request for the ``ListFunctions`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -379,8 +378,7 @@ async def sample_get_function(): Args: request (Optional[Union[google.cloud.functions_v1.types.GetFunctionRequest, dict]]): - The request object. Request for the `GetFunction` - method. + The request object. Request for the ``GetFunction`` method. name (:class:`str`): Required. The name of the function which details should be obtained. @@ -504,8 +502,7 @@ async def sample_create_function(): Args: request (Optional[Union[google.cloud.functions_v1.types.CreateFunctionRequest, dict]]): - The request object. Request for the `CreateFunction` - method. + The request object. Request for the ``CreateFunction`` method. location (:class:`str`): Required. The project and location in which the function should be created, specified in the format @@ -632,8 +629,7 @@ async def sample_update_function(): Args: request (Optional[Union[google.cloud.functions_v1.types.UpdateFunctionRequest, dict]]): - The request object. Request for the `UpdateFunction` - method. + The request object. Request for the ``UpdateFunction`` method. function (:class:`google.cloud.functions_v1.types.CloudFunction`): Required. New version of the function. @@ -764,8 +760,7 @@ async def sample_delete_function(): Args: request (Optional[Union[google.cloud.functions_v1.types.DeleteFunctionRequest, dict]]): - The request object. Request for the `DeleteFunction` - method. + The request object. Request for the ``DeleteFunction`` method. name (:class:`str`): Required. The name of the function which should be deleted. @@ -899,8 +894,7 @@ async def sample_call_function(): Args: request (Optional[Union[google.cloud.functions_v1.types.CallFunctionRequest, dict]]): - The request object. Request for the `CallFunction` - method. + The request object. Request for the ``CallFunction`` method. name (:class:`str`): Required. The name of the function to be called. @@ -1033,8 +1027,7 @@ async def sample_generate_upload_url(): Args: request (Optional[Union[google.cloud.functions_v1.types.GenerateUploadUrlRequest, dict]]): - The request object. Request of `GenerateSourceUploadUrl` - method. + The request object. Request of ``GenerateSourceUploadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1115,8 +1108,7 @@ async def sample_generate_download_url(): Args: request (Optional[Union[google.cloud.functions_v1.types.GenerateDownloadUrlRequest, dict]]): - The request object. Request of `GenerateDownloadUrl` - method. + The request object. Request of ``GenerateDownloadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1195,8 +1187,7 @@ async def sample_set_iam_policy(): Args: request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]): - The request object. Request message for `SetIamPolicy` - method. + The request object. Request message for ``SetIamPolicy`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1340,8 +1331,7 @@ async def sample_get_iam_policy(): Args: request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]): - The request object. Request message for `GetIamPolicy` - method. + The request object. Request message for ``GetIamPolicy`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1486,8 +1476,7 @@ async def sample_test_iam_permissions(): Args: request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]): - The request object. Request message for - `TestIamPermissions` method. + The request object. Request message for ``TestIamPermissions`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. diff --git a/google/cloud/functions_v1/services/cloud_functions_service/client.py b/google/cloud/functions_v1/services/cloud_functions_service/client.py index 6c441f2..aae4545 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/client.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/client.py @@ -540,8 +540,7 @@ def sample_list_functions(): Args: request (Union[google.cloud.functions_v1.types.ListFunctionsRequest, dict]): - The request object. Request for the `ListFunctions` - method. + The request object. Request for the ``ListFunctions`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -634,8 +633,7 @@ def sample_get_function(): Args: request (Union[google.cloud.functions_v1.types.GetFunctionRequest, dict]): - The request object. Request for the `GetFunction` - method. + The request object. Request for the ``GetFunction`` method. name (str): Required. The name of the function which details should be obtained. @@ -749,8 +747,7 @@ def sample_create_function(): Args: request (Union[google.cloud.functions_v1.types.CreateFunctionRequest, dict]): - The request object. Request for the `CreateFunction` - method. + The request object. Request for the ``CreateFunction`` method. location (str): Required. The project and location in which the function should be created, specified in the format @@ -877,8 +874,7 @@ def sample_update_function(): Args: request (Union[google.cloud.functions_v1.types.UpdateFunctionRequest, dict]): - The request object. Request for the `UpdateFunction` - method. + The request object. Request for the ``UpdateFunction`` method. function (google.cloud.functions_v1.types.CloudFunction): Required. New version of the function. @@ -999,8 +995,7 @@ def sample_delete_function(): Args: request (Union[google.cloud.functions_v1.types.DeleteFunctionRequest, dict]): - The request object. Request for the `DeleteFunction` - method. + The request object. Request for the ``DeleteFunction`` method. name (str): Required. The name of the function which should be deleted. @@ -1124,8 +1119,7 @@ def sample_call_function(): Args: request (Union[google.cloud.functions_v1.types.CallFunctionRequest, dict]): - The request object. Request for the `CallFunction` - method. + The request object. Request for the ``CallFunction`` method. name (str): Required. The name of the function to be called. @@ -1258,8 +1252,7 @@ def sample_generate_upload_url(): Args: request (Union[google.cloud.functions_v1.types.GenerateUploadUrlRequest, dict]): - The request object. Request of `GenerateSourceUploadUrl` - method. + The request object. Request of ``GenerateSourceUploadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1341,8 +1334,7 @@ def sample_generate_download_url(): Args: request (Union[google.cloud.functions_v1.types.GenerateDownloadUrlRequest, dict]): - The request object. Request of `GenerateDownloadUrl` - method. + The request object. Request of ``GenerateDownloadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1422,8 +1414,7 @@ def sample_set_iam_policy(): Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): - The request object. Request message for `SetIamPolicy` - method. + The request object. Request message for ``SetIamPolicy`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1566,8 +1557,7 @@ def sample_get_iam_policy(): Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): - The request object. Request message for `GetIamPolicy` - method. + The request object. Request message for ``GetIamPolicy`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1711,8 +1701,7 @@ def sample_test_iam_permissions(): Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): - The request object. Request message for - `TestIamPermissions` method. + The request object. Request message for ``TestIamPermissions`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. diff --git a/google/cloud/functions_v1/services/cloud_functions_service/transports/rest.py b/google/cloud/functions_v1/services/cloud_functions_service/transports/rest.py index 1308f5f..aa8771b 100644 --- a/google/cloud/functions_v1/services/cloud_functions_service/transports/rest.py +++ b/google/cloud/functions_v1/services/cloud_functions_service/transports/rest.py @@ -17,7 +17,7 @@ import dataclasses import json # type: ignore import re -from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings from google.api_core import ( @@ -557,7 +557,7 @@ class _CallFunction(CloudFunctionsServiceRestStub): def __hash__(self): return hash("CallFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -652,7 +652,7 @@ class _CreateFunction(CloudFunctionsServiceRestStub): def __hash__(self): return hash("CreateFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -748,7 +748,7 @@ class _DeleteFunction(CloudFunctionsServiceRestStub): def __hash__(self): return hash("DeleteFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1007,7 +1007,7 @@ class _GetFunction(CloudFunctionsServiceRestStub): def __hash__(self): return hash("GetFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1097,7 +1097,7 @@ class _GetIamPolicy(CloudFunctionsServiceRestStub): def __hash__(self): return hash("GetIamPolicy") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1171,7 +1171,8 @@ def __call__( "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", - "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", + "expression": "request.time < + timestamp('2020-10-01T00:00:00.000Z')", } } ], @@ -1332,7 +1333,7 @@ class _SetIamPolicy(CloudFunctionsServiceRestStub): def __hash__(self): return hash("SetIamPolicy") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1406,7 +1407,8 @@ def __call__( "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", - "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", + "expression": "request.time < + timestamp('2020-10-01T00:00:00.000Z')", } } ], @@ -1501,7 +1503,7 @@ class _TestIamPermissions(CloudFunctionsServiceRestStub): def __hash__(self): return hash("TestIamPermissions") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1598,7 +1600,7 @@ class _UpdateFunction(CloudFunctionsServiceRestStub): def __hash__(self): return hash("UpdateFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): diff --git a/google/cloud/functions_v1/types/functions.py b/google/cloud/functions_v1/types/functions.py index 87110d3..e55ff91 100644 --- a/google/cloud/functions_v1/types/functions.py +++ b/google/cloud/functions_v1/types/functions.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from __future__ import annotations + from typing import MutableMapping, MutableSequence from google.protobuf import duration_pb2 # type: ignore diff --git a/google/cloud/functions_v1/types/operations.py b/google/cloud/functions_v1/types/operations.py index d8ff803..0b3f565 100644 --- a/google/cloud/functions_v1/types/operations.py +++ b/google/cloud/functions_v1/types/operations.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from __future__ import annotations + from typing import MutableMapping, MutableSequence from google.protobuf import any_pb2 # type: ignore diff --git a/google/cloud/functions_v2/gapic_version.py b/google/cloud/functions_v2/gapic_version.py index 98fb3f5..7138f21 100644 --- a/google/cloud/functions_v2/gapic_version.py +++ b/google/cloud/functions_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.0" # {x-release-please-version} +__version__ = "1.12.0" # {x-release-please-version} diff --git a/google/cloud/functions_v2/services/function_service/async_client.py b/google/cloud/functions_v2/services/function_service/async_client.py index 336a7ba..492b4c6 100644 --- a/google/cloud/functions_v2/services/function_service/async_client.py +++ b/google/cloud/functions_v2/services/function_service/async_client.py @@ -80,6 +80,8 @@ class FunctionServiceAsyncClient: parse_channel_path = staticmethod(FunctionServiceClient.parse_channel_path) connector_path = staticmethod(FunctionServiceClient.connector_path) parse_connector_path = staticmethod(FunctionServiceClient.parse_connector_path) + crypto_key_path = staticmethod(FunctionServiceClient.crypto_key_path) + parse_crypto_key_path = staticmethod(FunctionServiceClient.parse_crypto_key_path) function_path = staticmethod(FunctionServiceClient.function_path) parse_function_path = staticmethod(FunctionServiceClient.parse_function_path) repository_path = staticmethod(FunctionServiceClient.repository_path) @@ -286,8 +288,7 @@ async def sample_get_function(): Args: request (Optional[Union[google.cloud.functions_v2.types.GetFunctionRequest, dict]]): - The request object. Request for the `GetFunction` - method. + The request object. Request for the ``GetFunction`` method. name (:class:`str`): Required. The name of the function which details should be obtained. @@ -392,8 +393,7 @@ async def sample_list_functions(): Args: request (Optional[Union[google.cloud.functions_v2.types.ListFunctionsRequest, dict]]): - The request object. Request for the `ListFunctions` - method. + The request object. Request for the ``ListFunctions`` method. parent (:class:`str`): Required. The project and location from which the function should be listed, specified in the format @@ -519,8 +519,7 @@ async def sample_create_function(): Args: request (Optional[Union[google.cloud.functions_v2.types.CreateFunctionRequest, dict]]): - The request object. Request for the `CreateFunction` - method. + The request object. Request for the ``CreateFunction`` method. parent (:class:`str`): Required. The project and location in which the function should be created, specified in the format @@ -656,8 +655,7 @@ async def sample_update_function(): Args: request (Optional[Union[google.cloud.functions_v2.types.UpdateFunctionRequest, dict]]): - The request object. Request for the `UpdateFunction` - method. + The request object. Request for the ``UpdateFunction`` method. function (:class:`google.cloud.functions_v2.types.Function`): Required. New version of the function. @@ -789,8 +787,7 @@ async def sample_delete_function(): Args: request (Optional[Union[google.cloud.functions_v2.types.DeleteFunctionRequest, dict]]): - The request object. Request for the `DeleteFunction` - method. + The request object. Request for the ``DeleteFunction`` method. name (:class:`str`): Required. The name of the function which should be deleted. @@ -933,8 +930,7 @@ async def sample_generate_upload_url(): Args: request (Optional[Union[google.cloud.functions_v2.types.GenerateUploadUrlRequest, dict]]): - The request object. Request of `GenerateSourceUploadUrl` - method. + The request object. Request of ``GenerateSourceUploadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1016,8 +1012,7 @@ async def sample_generate_download_url(): Args: request (Optional[Union[google.cloud.functions_v2.types.GenerateDownloadUrlRequest, dict]]): - The request object. Request of `GenerateDownloadUrl` - method. + The request object. Request of ``GenerateDownloadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1096,8 +1091,7 @@ async def sample_list_runtimes(): Args: request (Optional[Union[google.cloud.functions_v2.types.ListRuntimesRequest, dict]]): - The request object. Request for the `ListRuntimes` - method. + The request object. Request for the ``ListRuntimes`` method. parent (:class:`str`): Required. The project and location from which the runtimes should be listed, specified in the format diff --git a/google/cloud/functions_v2/services/function_service/client.py b/google/cloud/functions_v2/services/function_service/client.py index 7145e8c..3af86c3 100644 --- a/google/cloud/functions_v2/services/function_service/client.py +++ b/google/cloud/functions_v2/services/function_service/client.py @@ -259,6 +259,30 @@ def parse_connector_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def crypto_key_path( + project: str, + location: str, + key_ring: str, + crypto_key: str, + ) -> str: + """Returns a fully-qualified crypto_key string.""" + return "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + + @staticmethod + def parse_crypto_key_path(path: str) -> Dict[str, str]: + """Parses a crypto_key path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def function_path( project: str, @@ -674,8 +698,7 @@ def sample_get_function(): Args: request (Union[google.cloud.functions_v2.types.GetFunctionRequest, dict]): - The request object. Request for the `GetFunction` - method. + The request object. Request for the ``GetFunction`` method. name (str): Required. The name of the function which details should be obtained. @@ -780,8 +803,7 @@ def sample_list_functions(): Args: request (Union[google.cloud.functions_v2.types.ListFunctionsRequest, dict]): - The request object. Request for the `ListFunctions` - method. + The request object. Request for the ``ListFunctions`` method. parent (str): Required. The project and location from which the function should be listed, specified in the format @@ -907,8 +929,7 @@ def sample_create_function(): Args: request (Union[google.cloud.functions_v2.types.CreateFunctionRequest, dict]): - The request object. Request for the `CreateFunction` - method. + The request object. Request for the ``CreateFunction`` method. parent (str): Required. The project and location in which the function should be created, specified in the format @@ -1044,8 +1065,7 @@ def sample_update_function(): Args: request (Union[google.cloud.functions_v2.types.UpdateFunctionRequest, dict]): - The request object. Request for the `UpdateFunction` - method. + The request object. Request for the ``UpdateFunction`` method. function (google.cloud.functions_v2.types.Function): Required. New version of the function. @@ -1177,8 +1197,7 @@ def sample_delete_function(): Args: request (Union[google.cloud.functions_v2.types.DeleteFunctionRequest, dict]): - The request object. Request for the `DeleteFunction` - method. + The request object. Request for the ``DeleteFunction`` method. name (str): Required. The name of the function which should be deleted. @@ -1321,8 +1340,7 @@ def sample_generate_upload_url(): Args: request (Union[google.cloud.functions_v2.types.GenerateUploadUrlRequest, dict]): - The request object. Request of `GenerateSourceUploadUrl` - method. + The request object. Request of ``GenerateSourceUploadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1405,8 +1423,7 @@ def sample_generate_download_url(): Args: request (Union[google.cloud.functions_v2.types.GenerateDownloadUrlRequest, dict]): - The request object. Request of `GenerateDownloadUrl` - method. + The request object. Request of ``GenerateDownloadUrl`` method. retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1486,8 +1503,7 @@ def sample_list_runtimes(): Args: request (Union[google.cloud.functions_v2.types.ListRuntimesRequest, dict]): - The request object. Request for the `ListRuntimes` - method. + The request object. Request for the ``ListRuntimes`` method. parent (str): Required. The project and location from which the runtimes should be listed, specified in the format diff --git a/google/cloud/functions_v2/services/function_service/transports/rest.py b/google/cloud/functions_v2/services/function_service/transports/rest.py index 8ffa475..2500123 100644 --- a/google/cloud/functions_v2/services/function_service/transports/rest.py +++ b/google/cloud/functions_v2/services/function_service/transports/rest.py @@ -17,7 +17,7 @@ import dataclasses import json # type: ignore import re -from typing import Callable, Dict, List, Optional, Sequence, Tuple, Union +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings from google.api_core import ( @@ -329,7 +329,7 @@ def pre_list_locations( self, request: locations_pb2.ListLocationsRequest, metadata: Sequence[Tuple[str, str]], - ) -> locations_pb2.ListLocationsResponse: + ) -> Tuple[locations_pb2.ListLocationsRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_locations Override in a subclass to manipulate the request or metadata @@ -338,7 +338,7 @@ def pre_list_locations( return request, metadata def post_list_locations( - self, response: locations_pb2.ListLocationsRequest + self, response: locations_pb2.ListLocationsResponse ) -> locations_pb2.ListLocationsResponse: """Post-rpc interceptor for list_locations @@ -352,7 +352,7 @@ def pre_get_iam_policy( self, request: iam_policy_pb2.GetIamPolicyRequest, metadata: Sequence[Tuple[str, str]], - ) -> policy_pb2.Policy: + ) -> Tuple[iam_policy_pb2.GetIamPolicyRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_iam_policy Override in a subclass to manipulate the request or metadata @@ -360,9 +360,7 @@ def pre_get_iam_policy( """ return request, metadata - def post_get_iam_policy( - self, response: iam_policy_pb2.GetIamPolicyRequest - ) -> policy_pb2.Policy: + def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: """Post-rpc interceptor for get_iam_policy Override in a subclass to manipulate the response @@ -375,7 +373,7 @@ def pre_set_iam_policy( self, request: iam_policy_pb2.SetIamPolicyRequest, metadata: Sequence[Tuple[str, str]], - ) -> policy_pb2.Policy: + ) -> Tuple[iam_policy_pb2.SetIamPolicyRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for set_iam_policy Override in a subclass to manipulate the request or metadata @@ -383,9 +381,7 @@ def pre_set_iam_policy( """ return request, metadata - def post_set_iam_policy( - self, response: iam_policy_pb2.SetIamPolicyRequest - ) -> policy_pb2.Policy: + def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: """Post-rpc interceptor for set_iam_policy Override in a subclass to manipulate the response @@ -398,7 +394,7 @@ def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, metadata: Sequence[Tuple[str, str]], - ) -> iam_policy_pb2.TestIamPermissionsResponse: + ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -407,7 +403,7 @@ def pre_test_iam_permissions( return request, metadata def post_test_iam_permissions( - self, response: iam_policy_pb2.TestIamPermissionsRequest + self, response: iam_policy_pb2.TestIamPermissionsResponse ) -> iam_policy_pb2.TestIamPermissionsResponse: """Post-rpc interceptor for test_iam_permissions @@ -421,7 +417,7 @@ def pre_get_operation( self, request: operations_pb2.GetOperationRequest, metadata: Sequence[Tuple[str, str]], - ) -> operations_pb2.Operation: + ) -> Tuple[operations_pb2.GetOperationRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for get_operation Override in a subclass to manipulate the request or metadata @@ -430,7 +426,7 @@ def pre_get_operation( return request, metadata def post_get_operation( - self, response: operations_pb2.GetOperationRequest + self, response: operations_pb2.Operation ) -> operations_pb2.Operation: """Post-rpc interceptor for get_operation @@ -444,7 +440,7 @@ def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, metadata: Sequence[Tuple[str, str]], - ) -> operations_pb2.ListOperationsResponse: + ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -453,7 +449,7 @@ def pre_list_operations( return request, metadata def post_list_operations( - self, response: operations_pb2.ListOperationsRequest + self, response: operations_pb2.ListOperationsResponse ) -> operations_pb2.ListOperationsResponse: """Post-rpc interceptor for list_operations @@ -610,7 +606,7 @@ class _CreateFunction(FunctionServiceRestStub): def __hash__(self): return hash("CreateFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -706,7 +702,7 @@ class _DeleteFunction(FunctionServiceRestStub): def __hash__(self): return hash("DeleteFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -793,7 +789,7 @@ class _GenerateDownloadUrl(FunctionServiceRestStub): def __hash__(self): return hash("GenerateDownloadUrl") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -890,7 +886,7 @@ class _GenerateUploadUrl(FunctionServiceRestStub): def __hash__(self): return hash("GenerateUploadUrl") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -987,7 +983,7 @@ class _GetFunction(FunctionServiceRestStub): def __hash__(self): return hash("GetFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1077,7 +1073,7 @@ class _ListFunctions(FunctionServiceRestStub): def __hash__(self): return hash("ListFunctions") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1163,7 +1159,7 @@ class _ListRuntimes(FunctionServiceRestStub): def __hash__(self): return hash("ListRuntimes") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): @@ -1249,7 +1245,7 @@ class _UpdateFunction(FunctionServiceRestStub): def __hash__(self): return hash("UpdateFunction") - __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, str] = {} + __REQUIRED_FIELDS_DEFAULT_VALUES: Dict[str, Any] = {} @classmethod def _get_unset_required_fields(cls, message_dict): diff --git a/google/cloud/functions_v2/types/functions.py b/google/cloud/functions_v2/types/functions.py index bd848b3..5d10ea4 100644 --- a/google/cloud/functions_v2/types/functions.py +++ b/google/cloud/functions_v2/types/functions.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from __future__ import annotations + from typing import MutableMapping, MutableSequence from google.protobuf import any_pb2 # type: ignore @@ -81,8 +83,8 @@ class Function(proto.Message): unique globally and match pattern ``projects/*/locations/*/functions/*`` environment (google.cloud.functions_v2.types.Environment): - Describe whether the function is gen1 or - gen2. + Describe whether the function is 1st Gen or + 2nd Gen. description (str): User-provided description of a function. build_config (google.cloud.functions_v2.types.BuildConfig): @@ -106,6 +108,15 @@ class Function(proto.Message): state_messages (MutableSequence[google.cloud.functions_v2.types.StateMessage]): Output only. State Messages for this Cloud Function. + kms_key_name (str): + Resource name of a KMS crypto key (managed by the user) used + to encrypt/decrypt function resources. + + It must match the pattern + ``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}``. + url (str): + Output only. The deployed url for the + function. """ class State(proto.Enum): @@ -185,6 +196,14 @@ class State(proto.Enum): number=9, message="StateMessage", ) + kms_key_name: str = proto.Field( + proto.STRING, + number=25, + ) + url: str = proto.Field( + proto.STRING, + number=14, + ) class StateMessage(proto.Message): @@ -453,13 +472,23 @@ class BuildConfig(proto.Message): environment_variables (MutableMapping[str, str]): User-provided build-time environment variables for the function + docker_registry (google.cloud.functions_v2.types.BuildConfig.DockerRegistry): + Optional. Docker Registry to use for this deployment. This + configuration is only applicable to 1st Gen functions, 2nd + Gen functions can only use Artifact Registry. + + If ``docker_repository`` field is specified, this field will + be automatically set as ``ARTIFACT_REGISTRY``. If + unspecified, it currently defaults to + ``CONTAINER_REGISTRY``. This field may be overridden by the + backend for eligible deployments. docker_repository (str): - Optional. User managed repository created in Artifact - Registry optionally with a customer managed encryption key. - This is the repository to which the function docker image - will be pushed after it is built by Cloud Build. If - unspecified, GCF will create and use a repository named - 'gcf-artifacts' for every deployed region. + User managed repository created in Artifact Registry + optionally with a customer managed encryption key. This is + the repository to which the function docker image will be + pushed after it is built by Cloud Build. If unspecified, GCF + will create and use a repository named 'gcf-artifacts' for + every deployed region. It must match the pattern ``projects/{project}/locations/{location}/repositories/{repository}``. @@ -469,6 +498,27 @@ class BuildConfig(proto.Message): 'DOCKER'. """ + class DockerRegistry(proto.Enum): + r"""Docker Registry to use for storing function Docker images. + + Values: + DOCKER_REGISTRY_UNSPECIFIED (0): + Unspecified. + CONTAINER_REGISTRY (1): + Docker images will be stored in multi-regional Container + Registry repositories named ``gcf``. + ARTIFACT_REGISTRY (2): + Docker images will be stored in regional Artifact Registry + repositories. By default, GCF will create and use + repositories named ``gcf-artifacts`` in every region in + which a function is deployed. But the repository to use can + also be specified by the user using the + ``docker_repository`` field. + """ + DOCKER_REGISTRY_UNSPECIFIED = 0 + CONTAINER_REGISTRY = 1 + ARTIFACT_REGISTRY = 2 + build: str = proto.Field( proto.STRING, number=1, @@ -500,6 +550,11 @@ class BuildConfig(proto.Message): proto.STRING, number=6, ) + docker_registry: DockerRegistry = proto.Field( + proto.ENUM, + number=10, + enum=DockerRegistry, + ) docker_repository: str = proto.Field( proto.STRING, number=7, @@ -509,6 +564,7 @@ class BuildConfig(proto.Message): class ServiceConfig(proto.Message): r"""Describes the Service being deployed. Currently Supported : Cloud Run (fully managed). + Next tag: 23 Attributes: service (str): @@ -528,6 +584,13 @@ class ServiceConfig(proto.Message): See https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go a full description. + available_cpu (str): + The number of CPUs used in a single container + instance. Default value is calculated from + available memory. Supports the same values as + Cloud Run, see + https://cloud.google.com/run/docs/reference/rest/v1/Container#resourcerequirements + Example: "1" indicates 1 vCPU environment_variables (MutableMapping[str, str]): Environment variables that shall be available during function execution. @@ -588,6 +651,16 @@ class ServiceConfig(proto.Message): Secret volumes configuration. revision (str): Output only. The name of service revision. + max_instance_request_concurrency (int): + Sets the maximum number of concurrent + requests that each instance can receive. + Defaults to 1. + security_level (google.cloud.functions_v2.types.ServiceConfig.SecurityLevel): + Security level configure whether the function + only accepts https. This configuration is only + applicable to 1st Gen functions with Http + trigger. By default https is optional for 1st + Gen functions; 2nd Gen functions are https ONLY. """ class VpcConnectorEgressSettings(proto.Enum): @@ -635,6 +708,33 @@ class IngressSettings(proto.Enum): ALLOW_INTERNAL_ONLY = 2 ALLOW_INTERNAL_AND_GCLB = 3 + class SecurityLevel(proto.Enum): + r"""Available security level settings. + + This enforces security protocol on function URL. + + Security level is only ocnfigurable for 1st Gen functions, If + unspecified, SECURE_OPTIONAL will be used. 2nd Gen functions are + SECURE_ALWAYS ONLY. + + Values: + SECURITY_LEVEL_UNSPECIFIED (0): + Unspecified. + SECURE_ALWAYS (1): + Requests for a URL that match this handler + that do not use HTTPS are automatically + redirected to the HTTPS URL with the same path. + Query parameters are reserved for the redirect. + SECURE_OPTIONAL (2): + Both HTTP and HTTPS requests with URLs that + match the handler succeed without redirects. The + application can examine the request to determine + which protocol was used and respond accordingly. + """ + SECURITY_LEVEL_UNSPECIFIED = 0 + SECURE_ALWAYS = 1 + SECURE_OPTIONAL = 2 + service: str = proto.Field( proto.STRING, number=1, @@ -647,6 +747,10 @@ class IngressSettings(proto.Enum): proto.STRING, number=13, ) + available_cpu: str = proto.Field( + proto.STRING, + number=22, + ) environment_variables: MutableMapping[str, str] = proto.MapField( proto.STRING, proto.STRING, @@ -700,6 +804,15 @@ class IngressSettings(proto.Enum): proto.STRING, number=18, ) + max_instance_request_concurrency: int = proto.Field( + proto.INT32, + number=20, + ) + security_level: SecurityLevel = proto.Field( + proto.ENUM, + number=21, + enum=SecurityLevel, + ) class SecretEnvVar(proto.Message): @@ -979,8 +1092,11 @@ class ListFunctionsRequest(proto.Message): reachable locations along with the names of any unreachable locations. page_size (int): - Maximum number of functions to return per - call. + Maximum number of functions to return per call. The largest + allowed page_size is 1,000, if the page_size is omitted or + specified as greater than 1,000 then it will be replaced as + 1,000. The size of the list response can be less than + specified when used with filters. page_token (str): The value returned by the last ``ListFunctionsResponse``; indicates that this is a continuation of a prior @@ -1134,12 +1250,34 @@ class GenerateUploadUrlRequest(proto.Message): Required. The project and location in which the Google Cloud Storage signed URL should be generated, specified in the format ``projects/*/locations/*``. + kms_key_name (str): + Resource name of a KMS crypto key (managed by the user) used + to encrypt/decrypt function source code objects in + intermediate Cloud Storage buckets. When you generate an + upload url and upload your source code, it gets copied to an + intermediate Cloud Storage bucket. The source code is then + copied to a versioned directory in the sources bucket in the + consumer project during the function deployment. + + It must match the pattern + ``projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}``. + + The Google Cloud Functions service account + (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) + must be granted the role 'Cloud KMS CryptoKey + Encrypter/Decrypter + (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the + Key/KeyRing/Project/Organization (least access preferred). """ parent: str = proto.Field( proto.STRING, number=1, ) + kms_key_name: str = proto.Field( + proto.STRING, + number=2, + ) class GenerateUploadUrlResponse(proto.Message): diff --git a/samples/generated_samples/snippet_metadata_google.cloud.functions.v1.json b/samples/generated_samples/snippet_metadata_google.cloud.functions.v1.json index 43e22c7..0d45d5a 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.functions.v1.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.functions.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-functions", - "version": "1.11.0" + "version": "1.12.0" }, "snippets": [ { diff --git a/samples/generated_samples/snippet_metadata_google.cloud.functions.v2.json b/samples/generated_samples/snippet_metadata_google.cloud.functions.v2.json index 8d633e2..1ab1619 100644 --- a/samples/generated_samples/snippet_metadata_google.cloud.functions.v2.json +++ b/samples/generated_samples/snippet_metadata_google.cloud.functions.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-functions", - "version": "1.11.0" + "version": "1.12.0" }, "snippets": [ { diff --git a/scripts/fixup_functions_v2_keywords.py b/scripts/fixup_functions_v2_keywords.py index e957319..57e685f 100644 --- a/scripts/fixup_functions_v2_keywords.py +++ b/scripts/fixup_functions_v2_keywords.py @@ -42,7 +42,7 @@ class functionsCallTransformer(cst.CSTTransformer): 'create_function': ('parent', 'function', 'function_id', ), 'delete_function': ('name', ), 'generate_download_url': ('name', ), - 'generate_upload_url': ('parent', ), + 'generate_upload_url': ('parent', 'kms_key_name', ), 'get_function': ('name', ), 'list_functions': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ), 'list_runtimes': ('parent', 'filter', ), diff --git a/setup.py b/setup.py index 793dbf8..d3dc33e 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ "proto-plus >= 1.22.0, <2.0.0dev", "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", - "grpc-google-iam-v1 >= 0.12.4, < 1.0.0dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/python-functions" diff --git a/tests/unit/gapic/functions_v2/test_function_service.py b/tests/unit/gapic/functions_v2/test_function_service.py index 7d7f0eb..8b2726d 100644 --- a/tests/unit/gapic/functions_v2/test_function_service.py +++ b/tests/unit/gapic/functions_v2/test_function_service.py @@ -768,6 +768,8 @@ def test_get_function(request_type, transport: str = "grpc"): environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, + kms_key_name="kms_key_name_value", + url="url_value", ) response = client.get_function(request) @@ -782,6 +784,8 @@ def test_get_function(request_type, transport: str = "grpc"): assert response.environment == functions.Environment.GEN_1 assert response.description == "description_value" assert response.state == functions.Function.State.ACTIVE + assert response.kms_key_name == "kms_key_name_value" + assert response.url == "url_value" def test_get_function_empty_call(): @@ -822,6 +826,8 @@ async def test_get_function_async( environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, + kms_key_name="kms_key_name_value", + url="url_value", ) ) response = await client.get_function(request) @@ -837,6 +843,8 @@ async def test_get_function_async( assert response.environment == functions.Environment.GEN_1 assert response.description == "description_value" assert response.state == functions.Function.State.ACTIVE + assert response.kms_key_name == "kms_key_name_value" + assert response.url == "url_value" @pytest.mark.asyncio @@ -2686,6 +2694,8 @@ def test_get_function_rest(request_type): environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, + kms_key_name="kms_key_name_value", + url="url_value", ) # Wrap the value into a proper Response obj @@ -2704,6 +2714,8 @@ def test_get_function_rest(request_type): assert response.environment == functions.Environment.GEN_1 assert response.description == "description_value" assert response.state == functions.Function.State.ACTIVE + assert response.kms_key_name == "kms_key_name_value" + assert response.url == "url_value" def test_get_function_rest_required_fields(request_type=functions.GetFunctionRequest): @@ -3316,12 +3328,14 @@ def test_create_function_rest(request_type): }, "worker_pool": "worker_pool_value", "environment_variables": {}, + "docker_registry": 1, "docker_repository": "docker_repository_value", }, "service_config": { "service": "service_value", "timeout_seconds": 1621, "available_memory": "available_memory_value", + "available_cpu": "available_cpu_value", "environment_variables": {}, "max_instance_count": 1922, "min_instance_count": 1920, @@ -3348,6 +3362,8 @@ def test_create_function_rest(request_type): } ], "revision": "revision_value", + "max_instance_request_concurrency": 3436, + "security_level": 1, }, "event_trigger": { "trigger": "trigger_value", @@ -3371,6 +3387,8 @@ def test_create_function_rest(request_type): "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], + "kms_key_name": "kms_key_name_value", + "url": "url_value", } request = request_type(**request_init) @@ -3586,12 +3604,14 @@ def test_create_function_rest_bad_request( }, "worker_pool": "worker_pool_value", "environment_variables": {}, + "docker_registry": 1, "docker_repository": "docker_repository_value", }, "service_config": { "service": "service_value", "timeout_seconds": 1621, "available_memory": "available_memory_value", + "available_cpu": "available_cpu_value", "environment_variables": {}, "max_instance_count": 1922, "min_instance_count": 1920, @@ -3618,6 +3638,8 @@ def test_create_function_rest_bad_request( } ], "revision": "revision_value", + "max_instance_request_concurrency": 3436, + "security_level": 1, }, "event_trigger": { "trigger": "trigger_value", @@ -3641,6 +3663,8 @@ def test_create_function_rest_bad_request( "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], + "kms_key_name": "kms_key_name_value", + "url": "url_value", } request = request_type(**request_init) @@ -3767,12 +3791,14 @@ def test_update_function_rest(request_type): }, "worker_pool": "worker_pool_value", "environment_variables": {}, + "docker_registry": 1, "docker_repository": "docker_repository_value", }, "service_config": { "service": "service_value", "timeout_seconds": 1621, "available_memory": "available_memory_value", + "available_cpu": "available_cpu_value", "environment_variables": {}, "max_instance_count": 1922, "min_instance_count": 1920, @@ -3799,6 +3825,8 @@ def test_update_function_rest(request_type): } ], "revision": "revision_value", + "max_instance_request_concurrency": 3436, + "security_level": 1, }, "event_trigger": { "trigger": "trigger_value", @@ -3822,6 +3850,8 @@ def test_update_function_rest(request_type): "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], + "kms_key_name": "kms_key_name_value", + "url": "url_value", } request = request_type(**request_init) @@ -4026,12 +4056,14 @@ def test_update_function_rest_bad_request( }, "worker_pool": "worker_pool_value", "environment_variables": {}, + "docker_registry": 1, "docker_repository": "docker_repository_value", }, "service_config": { "service": "service_value", "timeout_seconds": 1621, "available_memory": "available_memory_value", + "available_cpu": "available_cpu_value", "environment_variables": {}, "max_instance_count": 1922, "min_instance_count": 1920, @@ -4058,6 +4090,8 @@ def test_update_function_rest_bad_request( } ], "revision": "revision_value", + "max_instance_request_concurrency": 3436, + "security_level": 1, }, "event_trigger": { "trigger": "trigger_value", @@ -4081,6 +4115,8 @@ def test_update_function_rest_bad_request( "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], + "kms_key_name": "kms_key_name_value", + "url": "url_value", } request = request_type(**request_init) @@ -5810,10 +5846,41 @@ def test_parse_connector_path(): assert expected == actual -def test_function_path(): +def test_crypto_key_path(): project = "cuttlefish" location = "mussel" - function = "winkle" + key_ring = "winkle" + crypto_key = "nautilus" + expected = "projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}".format( + project=project, + location=location, + key_ring=key_ring, + crypto_key=crypto_key, + ) + actual = FunctionServiceClient.crypto_key_path( + project, location, key_ring, crypto_key + ) + assert expected == actual + + +def test_parse_crypto_key_path(): + expected = { + "project": "scallop", + "location": "abalone", + "key_ring": "squid", + "crypto_key": "clam", + } + path = FunctionServiceClient.crypto_key_path(**expected) + + # Check that the path construction is reversible. + actual = FunctionServiceClient.parse_crypto_key_path(path) + assert expected == actual + + +def test_function_path(): + project = "whelk" + location = "octopus" + function = "oyster" expected = "projects/{project}/locations/{location}/functions/{function}".format( project=project, location=location, @@ -5825,9 +5892,9 @@ def test_function_path(): def test_parse_function_path(): expected = { - "project": "nautilus", - "location": "scallop", - "function": "abalone", + "project": "nudibranch", + "location": "cuttlefish", + "function": "mussel", } path = FunctionServiceClient.function_path(**expected) @@ -5837,9 +5904,9 @@ def test_parse_function_path(): def test_repository_path(): - project = "squid" - location = "clam" - repository = "whelk" + project = "winkle" + location = "nautilus" + repository = "scallop" expected = ( "projects/{project}/locations/{location}/repositories/{repository}".format( project=project, @@ -5853,9 +5920,9 @@ def test_repository_path(): def test_parse_repository_path(): expected = { - "project": "octopus", - "location": "oyster", - "repository": "nudibranch", + "project": "abalone", + "location": "squid", + "repository": "clam", } path = FunctionServiceClient.repository_path(**expected) @@ -5865,9 +5932,9 @@ def test_parse_repository_path(): def test_service_path(): - project = "cuttlefish" - location = "mussel" - service = "winkle" + project = "whelk" + location = "octopus" + service = "oyster" expected = "projects/{project}/locations/{location}/services/{service}".format( project=project, location=location, @@ -5879,9 +5946,9 @@ def test_service_path(): def test_parse_service_path(): expected = { - "project": "nautilus", - "location": "scallop", - "service": "abalone", + "project": "nudibranch", + "location": "cuttlefish", + "service": "mussel", } path = FunctionServiceClient.service_path(**expected) @@ -5891,8 +5958,8 @@ def test_parse_service_path(): def test_topic_path(): - project = "squid" - topic = "clam" + project = "winkle" + topic = "nautilus" expected = "projects/{project}/topics/{topic}".format( project=project, topic=topic, @@ -5903,8 +5970,8 @@ def test_topic_path(): def test_parse_topic_path(): expected = { - "project": "whelk", - "topic": "octopus", + "project": "scallop", + "topic": "abalone", } path = FunctionServiceClient.topic_path(**expected) @@ -5914,9 +5981,9 @@ def test_parse_topic_path(): def test_trigger_path(): - project = "oyster" - location = "nudibranch" - trigger = "cuttlefish" + project = "squid" + location = "clam" + trigger = "whelk" expected = "projects/{project}/locations/{location}/triggers/{trigger}".format( project=project, location=location, @@ -5928,9 +5995,9 @@ def test_trigger_path(): def test_parse_trigger_path(): expected = { - "project": "mussel", - "location": "winkle", - "trigger": "nautilus", + "project": "octopus", + "location": "oyster", + "trigger": "nudibranch", } path = FunctionServiceClient.trigger_path(**expected) @@ -5940,9 +6007,9 @@ def test_parse_trigger_path(): def test_worker_pool_path(): - project = "scallop" - location = "abalone" - worker_pool = "squid" + project = "cuttlefish" + location = "mussel" + worker_pool = "winkle" expected = ( "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( project=project, @@ -5956,9 +6023,9 @@ def test_worker_pool_path(): def test_parse_worker_pool_path(): expected = { - "project": "clam", - "location": "whelk", - "worker_pool": "octopus", + "project": "nautilus", + "location": "scallop", + "worker_pool": "abalone", } path = FunctionServiceClient.worker_pool_path(**expected) @@ -5968,7 +6035,7 @@ def test_parse_worker_pool_path(): def test_common_billing_account_path(): - billing_account = "oyster" + billing_account = "squid" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -5978,7 +6045,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "nudibranch", + "billing_account": "clam", } path = FunctionServiceClient.common_billing_account_path(**expected) @@ -5988,7 +6055,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "cuttlefish" + folder = "whelk" expected = "folders/{folder}".format( folder=folder, ) @@ -5998,7 +6065,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "mussel", + "folder": "octopus", } path = FunctionServiceClient.common_folder_path(**expected) @@ -6008,7 +6075,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "winkle" + organization = "oyster" expected = "organizations/{organization}".format( organization=organization, ) @@ -6018,7 +6085,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "nautilus", + "organization": "nudibranch", } path = FunctionServiceClient.common_organization_path(**expected) @@ -6028,7 +6095,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "scallop" + project = "cuttlefish" expected = "projects/{project}".format( project=project, ) @@ -6038,7 +6105,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "abalone", + "project": "mussel", } path = FunctionServiceClient.common_project_path(**expected) @@ -6048,8 +6115,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "squid" - location = "clam" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}".format( project=project, location=location, @@ -6060,8 +6127,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "scallop", + "location": "abalone", } path = FunctionServiceClient.common_location_path(**expected)