Skip to content

Commit

Permalink
feat: ListFunctions now include metadata which indicates whether a fu…
Browse files Browse the repository at this point in the history
…nction is a `GEN_1` or `GEN_2` function (#263)

* feat: ListFunctions now include metadata which indicates whether a function is a `GEN_1` or `GEN_2` function

PiperOrigin-RevId: 535193873

Source-Link: googleapis/googleapis@d6b7eb5

Source-Link: googleapis/googleapis-gen@822ccd0
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODIyY2NkMDljYzFlOWY4YTRhYjAxMjVjYzkzZWZmZTI2YWI4ODJjMSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed May 25, 2023
1 parent 33f58ac commit d63450a
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
ListFunctionsResponse,
ListRuntimesRequest,
ListRuntimesResponse,
LocationMetadata,
OperationMetadata,
RepoSource,
SecretEnvVar,
Expand Down Expand Up @@ -68,6 +69,7 @@
"ListFunctionsResponse",
"ListRuntimesRequest",
"ListRuntimesResponse",
"LocationMetadata",
"OperationMetadata",
"RepoSource",
"SecretEnvVar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ListFunctionsResponse,
ListRuntimesRequest,
ListRuntimesResponse,
LocationMetadata,
OperationMetadata,
RepoSource,
SecretEnvVar,
Expand Down Expand Up @@ -59,6 +60,7 @@
"ListFunctionsResponse",
"ListRuntimesRequest",
"ListRuntimesResponse",
"LocationMetadata",
"OperationMetadata",
"RepoSource",
"SecretEnvVar",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"ListRuntimesRequest",
"ListRuntimesResponse",
"OperationMetadata",
"LocationMetadata",
"Stage",
},
)
Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand All @@ -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]):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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():
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit d63450a

Please sign in to comment.