Skip to content

Commit

Permalink
feat: [cloudfunctions] add available_cpu field (#9231)
Browse files Browse the repository at this point in the history
* feat: add `available_cpu ` field
feat: add `kms_key_name` field to ServiceConfig (the CMEK use case)
feat: add `max_instance_request_concurrency` field
feat: add `security_level` field

PiperOrigin-RevId: 516979219

Source-Link: googleapis/googleapis@650f7cd

Source-Link: googleapis/googleapis-gen@3c4d23f
Copy-Tag: eyJwIjoiamF2YS1mdW5jdGlvbnMvLk93bEJvdC55YW1sIiwiaCI6IjNjNGQyM2ZkNzY2ZWRkYjJjNzI2YjQwZDIzZWYwMTI5NzRhMzI1MWYifQ==

* 🦉 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 Mar 16, 2023
1 parent 2aa1056 commit 8e44284
Show file tree
Hide file tree
Showing 33 changed files with 3,069 additions and 619 deletions.
2 changes: 0 additions & 2 deletions java-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Java idiomatic client for [Cloud Functions][product-docs].

If you are using Maven, add this to your pom.xml file:

<!--- {x-version-update-start:google-cloud-functions:released} -->

```xml
<dependency>
Expand All @@ -35,7 +34,6 @@ If you are using SBT, add this to your dependencies:
```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-functions" % "2.14.0"
```
<!--- {x-version-update-end} -->

## Authentication

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static com.google.cloud.functions.v1.CloudFunctionsServiceClient.ListFunctionsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -47,6 +48,7 @@
import com.google.cloud.functions.v1.ListFunctionsResponse;
import com.google.cloud.functions.v1.OperationMetadataV1;
import com.google.cloud.functions.v1.UpdateFunctionRequest;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
Expand Down Expand Up @@ -559,7 +561,18 @@ protected HttpJsonCloudFunctionsServiceStub(
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.<String, HttpRule>builder()
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder().setGet("/v1/{name=operations/*}").build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder().setGet("/v1/operations").build())
.build());

HttpJsonCallSettings<ListFunctionsRequest, ListFunctionsResponse>
listFunctionsTransportSettings =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,9 @@ public final UnaryCallable<DeleteFunctionRequest, Operation> deleteFunctionCalla
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* GenerateUploadUrlResponse response = functionServiceClient.generateUploadUrl(request);
* }
Expand Down Expand Up @@ -1040,6 +1043,9 @@ public final GenerateUploadUrlResponse generateUploadUrl(GenerateUploadUrlReques
* GenerateUploadUrlRequest request =
* GenerateUploadUrlRequest.newBuilder()
* .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
* .setKmsKeyName(
* CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
* .toString())
* .build();
* ApiFuture<GenerateUploadUrlResponse> future =
* functionServiceClient.generateUploadUrlCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.cloud.functions.v2.FunctionServiceClient.ListFunctionsPagedResponse;
import static com.google.cloud.functions.v2.FunctionServiceClient.ListLocationsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -50,6 +51,7 @@
import com.google.cloud.functions.v2.UpdateFunctionRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
Expand Down Expand Up @@ -594,7 +596,22 @@ protected HttpJsonFunctionServiceStub(
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.<String, HttpRule>builder()
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v2/{name=projects/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v2/{name=projects/*/locations/*}/operations")
.build())
.build());

HttpJsonCallSettings<GetFunctionRequest, Function> getFunctionTransportSettings =
HttpJsonCallSettings.<GetFunctionRequest, Function>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.cloud.functions.v2alpha.FunctionServiceClient.ListFunctionsPagedResponse;
import static com.google.cloud.functions.v2alpha.FunctionServiceClient.ListLocationsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -50,6 +51,7 @@
import com.google.cloud.functions.v2alpha.UpdateFunctionRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
Expand Down Expand Up @@ -595,7 +597,22 @@ protected HttpJsonFunctionServiceStub(
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.<String, HttpRule>builder()
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v2alpha/{name=projects/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v2alpha/{name=projects/*/locations/*}/operations")
.build())
.build());

HttpJsonCallSettings<GetFunctionRequest, Function> getFunctionTransportSettings =
HttpJsonCallSettings.<GetFunctionRequest, Function>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.google.cloud.functions.v2beta.FunctionServiceClient.ListFunctionsPagedResponse;
import static com.google.cloud.functions.v2beta.FunctionServiceClient.ListLocationsPagedResponse;

import com.google.api.HttpRule;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.core.BackgroundResource;
Expand Down Expand Up @@ -50,6 +51,7 @@
import com.google.cloud.functions.v2beta.UpdateFunctionRequest;
import com.google.cloud.location.ListLocationsRequest;
import com.google.cloud.location.ListLocationsResponse;
import com.google.common.collect.ImmutableMap;
import com.google.iam.v1.GetIamPolicyRequest;
import com.google.iam.v1.Policy;
import com.google.iam.v1.SetIamPolicyRequest;
Expand Down Expand Up @@ -595,7 +597,22 @@ protected HttpJsonFunctionServiceStub(
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.<String, HttpRule>builder()
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v2beta/{name=projects/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v2beta/{name=projects/*/locations/*}/operations")
.build())
.build());

HttpJsonCallSettings<GetFunctionRequest, Function> getFunctionTransportSettings =
HttpJsonCallSettings.<GetFunctionRequest, Function>newBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ public void getFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
mockService.addResponse(expectedResponse);

Expand Down Expand Up @@ -161,6 +165,10 @@ public void getFunctionTest2() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
mockService.addResponse(expectedResponse);

Expand Down Expand Up @@ -313,6 +321,10 @@ public void createFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -374,6 +386,10 @@ public void createFunctionTest2() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -435,6 +451,10 @@ public void updateFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand All @@ -455,6 +475,10 @@ public void updateFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
FieldMask updateMask = FieldMask.newBuilder().build();

Expand Down Expand Up @@ -495,6 +519,10 @@ public void updateFunctionExceptionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateFunctionAsync(function, updateMask).get();
Expand Down Expand Up @@ -605,6 +633,9 @@ public void generateUploadUrlTest() throws Exception {
GenerateUploadUrlRequest request =
GenerateUploadUrlRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.build();

GenerateUploadUrlResponse actualResponse = client.generateUploadUrl(request);
Expand Down Expand Up @@ -636,6 +667,9 @@ public void generateUploadUrlExceptionTest() throws Exception {
GenerateUploadUrlRequest request =
GenerateUploadUrlRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.build();
client.generateUploadUrl(request);
Assert.fail("No exception raised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public void getFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
mockFunctionService.addResponse(expectedResponse);

Expand Down Expand Up @@ -164,6 +168,10 @@ public void getFunctionTest2() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
mockFunctionService.addResponse(expectedResponse);

Expand Down Expand Up @@ -298,6 +306,10 @@ public void createFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -358,6 +370,10 @@ public void createFunctionTest2() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -418,6 +434,10 @@ public void updateFunctionTest() throws Exception {
.setUpdateTime(Timestamp.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.addAllStateMessages(new ArrayList<StateMessage>())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setUrl("url116079")
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -558,6 +578,9 @@ public void generateUploadUrlTest() throws Exception {
GenerateUploadUrlRequest request =
GenerateUploadUrlRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.build();

GenerateUploadUrlResponse actualResponse = client.generateUploadUrl(request);
Expand All @@ -568,6 +591,7 @@ public void generateUploadUrlTest() throws Exception {
GenerateUploadUrlRequest actualRequest = ((GenerateUploadUrlRequest) actualRequests.get(0));

Assert.assertEquals(request.getParent(), actualRequest.getParent());
Assert.assertEquals(request.getKmsKeyName(), actualRequest.getKmsKeyName());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -583,6 +607,9 @@ public void generateUploadUrlExceptionTest() throws Exception {
GenerateUploadUrlRequest request =
GenerateUploadUrlRequest.newBuilder()
.setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
.setKmsKeyName(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.build();
client.generateUploadUrl(request);
Assert.fail("No exception raised");
Expand Down

0 comments on commit 8e44284

Please sign in to comment.