diff --git a/google/cloud/functions_v2/__init__.py b/google/cloud/functions_v2/__init__.py index d9581df..e2e54bb 100644 --- a/google/cloud/functions_v2/__init__.py +++ b/google/cloud/functions_v2/__init__.py @@ -36,6 +36,7 @@ ListFunctionsResponse, ListRuntimesRequest, ListRuntimesResponse, + LocationMetadata, OperationMetadata, RepoSource, SecretEnvVar, @@ -68,6 +69,7 @@ "ListFunctionsResponse", "ListRuntimesRequest", "ListRuntimesResponse", + "LocationMetadata", "OperationMetadata", "RepoSource", "SecretEnvVar", diff --git a/google/cloud/functions_v2/types/__init__.py b/google/cloud/functions_v2/types/__init__.py index 82a10a9..9aeefe7 100644 --- a/google/cloud/functions_v2/types/__init__.py +++ b/google/cloud/functions_v2/types/__init__.py @@ -30,6 +30,7 @@ ListFunctionsResponse, ListRuntimesRequest, ListRuntimesResponse, + LocationMetadata, OperationMetadata, RepoSource, SecretEnvVar, @@ -59,6 +60,7 @@ "ListFunctionsResponse", "ListRuntimesRequest", "ListRuntimesResponse", + "LocationMetadata", "OperationMetadata", "RepoSource", "SecretEnvVar", diff --git a/google/cloud/functions_v2/types/functions.py b/google/cloud/functions_v2/types/functions.py index 5d10ea4..7610d19 100644 --- a/google/cloud/functions_v2/types/functions.py +++ b/google/cloud/functions_v2/types/functions.py @@ -51,6 +51,7 @@ "ListRuntimesRequest", "ListRuntimesResponse", "OperationMetadata", + "LocationMetadata", "Stage", }, ) @@ -82,9 +83,6 @@ class Function(proto.Message): A user-defined name of the function. Function names must be unique globally and match pattern ``projects/*/locations/*/functions/*`` - environment (google.cloud.functions_v2.types.Environment): - 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): @@ -108,15 +106,18 @@ class Function(proto.Message): state_messages (MutableSequence[google.cloud.functions_v2.types.StateMessage]): Output only. State Messages for this Cloud Function. + environment (google.cloud.functions_v2.types.Environment): + Describe whether the function is 1st Gen or + 2nd Gen. + url (str): + Output only. The deployed url for the + function. kms_key_name (str): - Resource name of a KMS crypto key (managed by the user) used - to encrypt/decrypt function resources. + [Preview] 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): @@ -152,11 +153,6 @@ class State(proto.Enum): proto.STRING, number=1, ) - environment: "Environment" = proto.Field( - proto.ENUM, - number=10, - enum="Environment", - ) description: str = proto.Field( proto.STRING, number=2, @@ -196,14 +192,19 @@ class State(proto.Enum): number=9, message="StateMessage", ) - kms_key_name: str = proto.Field( - proto.STRING, - number=25, + environment: "Environment" = proto.Field( + proto.ENUM, + number=10, + enum="Environment", ) url: str = proto.Field( proto.STRING, number=14, ) + kms_key_name: str = proto.Field( + proto.STRING, + number=25, + ) class StateMessage(proto.Message): @@ -473,7 +474,7 @@ class BuildConfig(proto.Message): 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 + Docker Registry to use for this deployment. This configuration is only applicable to 1st Gen functions, 2nd Gen functions can only use Artifact Registry. @@ -564,7 +565,6 @@ class DockerRegistry(proto.Enum): class ServiceConfig(proto.Message): r"""Describes the Service being deployed. Currently Supported : Cloud Run (fully managed). - Next tag: 23 Attributes: service (str): @@ -585,10 +585,9 @@ class ServiceConfig(proto.Message): 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 + [Preview] 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]): @@ -652,9 +651,8 @@ class ServiceConfig(proto.Message): 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. + [Preview] 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 @@ -713,7 +711,7 @@ class SecurityLevel(proto.Enum): This enforces security protocol on function URL. - Security level is only ocnfigurable for 1st Gen functions, If + Security level is only configurable for 1st Gen functions, If unspecified, SECURE_OPTIONAL will be used. 2nd Gen functions are SECURE_ALWAYS ONLY. @@ -1251,9 +1249,9 @@ class GenerateUploadUrlRequest(proto.Message): 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 + [Preview] 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 @@ -1528,6 +1526,22 @@ class OperationMetadata(proto.Message): ) +class LocationMetadata(proto.Message): + r"""Extra GCF specific location information. + + Attributes: + environments (MutableSequence[google.cloud.functions_v2.types.Environment]): + The Cloud Function environments this location + supports. + """ + + environments: MutableSequence["Environment"] = proto.RepeatedField( + proto.ENUM, + number=1, + enum="Environment", + ) + + class Stage(proto.Message): r"""Each Stage of the deployment process diff --git a/tests/unit/gapic/functions_v2/test_function_service.py b/tests/unit/gapic/functions_v2/test_function_service.py index 8b2726d..af0bbf4 100644 --- a/tests/unit/gapic/functions_v2/test_function_service.py +++ b/tests/unit/gapic/functions_v2/test_function_service.py @@ -765,11 +765,11 @@ def test_get_function(request_type, transport: str = "grpc"): # Designate an appropriate return value for the call. call.return_value = functions.Function( name="name_value", - environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, - kms_key_name="kms_key_name_value", + environment=functions.Environment.GEN_1, url="url_value", + kms_key_name="kms_key_name_value", ) response = client.get_function(request) @@ -781,11 +781,11 @@ def test_get_function(request_type, transport: str = "grpc"): # Establish that the response is the type that we expect. assert isinstance(response, functions.Function) assert response.name == "name_value" - 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.environment == functions.Environment.GEN_1 assert response.url == "url_value" + assert response.kms_key_name == "kms_key_name_value" def test_get_function_empty_call(): @@ -823,11 +823,11 @@ async def test_get_function_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( functions.Function( name="name_value", - environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, - kms_key_name="kms_key_name_value", + environment=functions.Environment.GEN_1, url="url_value", + kms_key_name="kms_key_name_value", ) ) response = await client.get_function(request) @@ -840,11 +840,11 @@ async def test_get_function_async( # Establish that the response is the type that we expect. assert isinstance(response, functions.Function) assert response.name == "name_value" - 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.environment == functions.Environment.GEN_1 assert response.url == "url_value" + assert response.kms_key_name == "kms_key_name_value" @pytest.mark.asyncio @@ -2691,11 +2691,11 @@ def test_get_function_rest(request_type): # Designate an appropriate value for the returned response. return_value = functions.Function( name="name_value", - environment=functions.Environment.GEN_1, description="description_value", state=functions.Function.State.ACTIVE, - kms_key_name="kms_key_name_value", + environment=functions.Environment.GEN_1, url="url_value", + kms_key_name="kms_key_name_value", ) # Wrap the value into a proper Response obj @@ -2711,11 +2711,11 @@ def test_get_function_rest(request_type): # Establish that the response is the type that we expect. assert isinstance(response, functions.Function) assert response.name == "name_value" - 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.environment == functions.Environment.GEN_1 assert response.url == "url_value" + assert response.kms_key_name == "kms_key_name_value" def test_get_function_rest_required_fields(request_type=functions.GetFunctionRequest): @@ -3300,7 +3300,6 @@ def test_create_function_rest(request_type): request_init = {"parent": "projects/sample1/locations/sample2"} request_init["function"] = { "name": "name_value", - "environment": 1, "description": "description_value", "build_config": { "build": "build_value", @@ -3387,8 +3386,9 @@ def test_create_function_rest(request_type): "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], - "kms_key_name": "kms_key_name_value", + "environment": 1, "url": "url_value", + "kms_key_name": "kms_key_name_value", } request = request_type(**request_init) @@ -3576,7 +3576,6 @@ def test_create_function_rest_bad_request( request_init = {"parent": "projects/sample1/locations/sample2"} request_init["function"] = { "name": "name_value", - "environment": 1, "description": "description_value", "build_config": { "build": "build_value", @@ -3663,8 +3662,9 @@ def test_create_function_rest_bad_request( "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], - "kms_key_name": "kms_key_name_value", + "environment": 1, "url": "url_value", + "kms_key_name": "kms_key_name_value", } request = request_type(**request_init) @@ -3763,7 +3763,6 @@ def test_update_function_rest(request_type): } request_init["function"] = { "name": "projects/sample1/locations/sample2/functions/sample3", - "environment": 1, "description": "description_value", "build_config": { "build": "build_value", @@ -3850,8 +3849,9 @@ def test_update_function_rest(request_type): "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], - "kms_key_name": "kms_key_name_value", + "environment": 1, "url": "url_value", + "kms_key_name": "kms_key_name_value", } request = request_type(**request_init) @@ -4028,7 +4028,6 @@ def test_update_function_rest_bad_request( } request_init["function"] = { "name": "projects/sample1/locations/sample2/functions/sample3", - "environment": 1, "description": "description_value", "build_config": { "build": "build_value", @@ -4115,8 +4114,9 @@ def test_update_function_rest_bad_request( "state_messages": [ {"severity": 1, "type_": "type__value", "message": "message_value"} ], - "kms_key_name": "kms_key_name_value", + "environment": 1, "url": "url_value", + "kms_key_name": "kms_key_name_value", } request = request_type(**request_init)