Skip to content

Commit

Permalink
Fixed code as requested in the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TetyanaYahodska committed Dec 27, 2024
2 parents 55ba406 + 0795de2 commit 7dca8a1
Show file tree
Hide file tree
Showing 190 changed files with 13,047 additions and 2,175 deletions.
8 changes: 3 additions & 5 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,17 @@
# DEE Platform Ops (DEEPO)
/errorreporting @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/monitoring @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/opencensus @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/trace @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers

# Cloud SDK Databases & Data Analytics teams
# ---* Cloud Native DB
/bigtable @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes
/bigtable @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-native-db-dpes @GoogleCloudPlatform/bigtable-eng
/memorystore @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/spanner @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/api-spanner-java
# ---* Cloud Storage
/storage @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-storage-dpes
/storage-transfer @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-storage-dpes
# ---* Infra DB
/cloud-sql @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/infra-db-sdk
/cloud-sql @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-sql-connectors

# Data & AI
/aiplatform @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/text-embedding
Expand All @@ -81,7 +79,7 @@
/speech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/talent @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/texttospeech @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/translate @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers @GoogleCloudPlatform/cloud-ml-translate-dev
/video @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers
/vision @GoogleCloudPlatform/java-samples-reviewers @yoshi-approver @GoogleCloudPlatform/cloud-samples-reviewers

Expand Down
4 changes: 2 additions & 2 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ assign_issues_by:
- labels:
- 'api: cloudsql'
to:
- GoogleCloudPlatform/infra-db-sdk
- GoogleCloudPlatform/cloud-sql-connectors
- labels:
- 'api: spanner'
to:
Expand Down Expand Up @@ -115,7 +115,7 @@ assign_prs_by:
- labels:
- 'api: cloudsql'
to:
- GoogleCloudPlatform/infra-db-sdk
- GoogleCloudPlatform/cloud-sql-connectors
- labels:
- 'api: spanner'
to:
Expand Down
190 changes: 92 additions & 98 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,142 +1,136 @@
// find legacy configuration at https://github.com/GoogleCloudPlatform/java-docs-samples/blob/91792d4da53a12f96032f4556815f7d91f27257b/renovate.json
{
"extends": [
"config:recommended",
":approveMajorUpdates",
"schedule:earlyMondays",
":ignoreUnstable",
extends: [
'config:recommended',
':approveMajorUpdates',
'schedule:earlyMondays',
':ignoreUnstable',
],
"labels": [
"dependencies",
"automerge"
labels: [
'dependencies',
'automerge',
],
"minimumReleaseAge": "7 days",
"dependencyDashboardLabels": [
"type: process",
minimumReleaseAge: '7 days',
dependencyDashboardLabels: [
'type: process',
],
// discontinue upgrades for java8 code samples
"ignorePaths": ["**/*java8*/**", "**/*java-8*/**"],
"packageRules": [
ignorePaths: [
'**/*java8*/**',
'**/*java-8*/**',
],
packageRules: [
{
"matchCategories": [
"java"
matchCategories: [
'java',
],
addLabels: [
'lang: java',
],
"addLabels": [
"lang: java"
]
},
// TODO: check if auto-merge rules will work at all
{
"matchUpdateTypes": [
"minor",
"patch",
"digest",
"lockFileMaintenance"
matchUpdateTypes: [
'minor',
'patch',
'digest',
'lockFileMaintenance',
],
"automerge": true
automerge: true,
},
{
"matchDepTypes": [
"devDependencies"
matchDepTypes: [
'devDependencies',
],
"automerge": true
automerge: true,
},
// group all Dockerfile dependencies
{
"matchCategories": [
"docker"
],
"matchUpdateTypes": [
"minor",
"patch",
"digest",
"lockFileMaintenance"
],
"groupName": "docker",
"pinDigests": true,
"automerge": true
matchCategories: [
'docker',
],
matchUpdateTypes: [
'minor',
'patch',
'digest',
'lockFileMaintenance',
],
groupName: 'docker',
pinDigests: true,
automerge: true,
},
// group all terraform dependencies for google providers
{
"matchCategories": [
"terraform"
matchCategories: [
'terraform',
],
matchDepTypes: [
'provider',
'required_provider',
],
"matchDepTypes": [
"provider",
"required_provider"
groupName: 'Terraform Google providers',
matchPackageNames: [
'/^google/',
],
"matchPackagePatterns": "^google",
"groupName": "Terraform Google providers",
},
// *** Java dependency rules:
// group *ALL* Java dependencies
{
"matchCategories": [
"java"
matchCategories: [
'java',
],
"matchUpdateTypes": [
"minor",
"patch",
"digest",
"lockFileMaintenance"
matchUpdateTypes: [
'minor',
'patch',
'digest',
'lockFileMaintenance',
],
"groupName": "java",
"automerge": true
groupName: 'java',
automerge: true,
},
// do not allow Spring Boot 3 upgrades yet
{
"matchCategories": [
"java"
matchCategories: [
'java',
],
"matchPackagePatterns": [
"org.springframework.boot"
matchCurrentVersion: '>=2.0.0, <3.0.0',
allowedVersions: '<3',
groupName: 'Spring Boot upgrades for v2',
description: '@akitsch: Spring Boot V3 requires Java 17',
matchPackageNames: [
'/org.springframework.boot/',
],
"matchCurrentVersion": ">=2.0.0, <3.0.0",
"allowedVersions": "<3",
"groupName": "Spring Boot upgrades for v2",
"description": "@akitsch: Spring Boot V3 requires Java 17"
},
// limit micronaut upgrades for versions <= 4
{
"matchPackagePatterns": [
"^io.micronaut"
groupName: 'Micronaut packages',
allowedVersions: '<4',
matchFileNames: [
'appengine-java11/**',
'flexible/java-11/**',
],
"groupName": "Micronaut packages",
"allowedVersions": "<4",
"matchPaths": [
"appengine-java11/**",
"flexible/java-11/**"
description: '@akitsch: Micronaut V4 requires Java 17',
matchPackageNames: [
'/^io.micronaut/',
],
"description": "@akitsch: Micronaut V4 requires Java 17"
},
// disable Scala dependency upgrades
{
"matchPackagePatterns": [
"scala"
enabled: false,
matchPackageNames: [
'/scala/',
],
"enabled": false
},
{
"matchPackagePatterns": [
"^jackson-module-scala"
enabled: false,
matchPackageNames: [
'/^jackson-module-scala/',
],
"enabled": false
},
// disable SQL Spark dependency upgrades
{
"matchPackagePatterns": [
"^spark-sql"
enabled: false,
matchPackageNames: [
'/^spark-sql/',
],
"enabled": false
},
{},
],
"rebaseWhen": "behind-base-branch",
"semanticCommits": "enabled",
"vulnerabilityAlerts": {
"labels": [
"type:security"
rebaseWhen: 'behind-base-branch',
semanticCommits: 'enabled',
vulnerabilityAlerts: {
labels: [
'type:security',
],
"minimumReleaseAge": null
minimumReleaseAge: null,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -430,32 +430,6 @@ public void queryInterface_multipleFilters_printsMatchedEntities() throws Except
assertThat(buf.toString()).doesNotContain("Charlie");
}

@Test
public void queryInterface_singleFilter_returnsMatchedEntities() throws Exception {
// Arrange
Entity a = new Entity("Person", "a");
a.setProperty("height", 100);
Entity b = new Entity("Person", "b");
b.setProperty("height", 150);
Entity c = new Entity("Person", "c");
c.setProperty("height", 300);
datastore.put(ImmutableList.<Entity>of(a, b, c));

// Act
long minHeight = 150;
// [START gae_java8_datastore_interface_2]
Filter heightMinFilter =
new FilterPredicate("height", FilterOperator.GREATER_THAN_OR_EQUAL, minHeight);

Query q = new Query("Person").setFilter(heightMinFilter);
// [END gae_java8_datastore_interface_2]

// Assert
List<Entity> results =
datastore.prepare(q.setKeysOnly()).asList(FetchOptions.Builder.withDefaults());
assertWithMessage("query results").that(results).containsExactly(b, c);
}

@Test
public void queryInterface_orFilter_printsMatchedEntities() throws Exception {
// Arrange
Expand Down
59 changes: 59 additions & 0 deletions auth/src/main/java/UndeleteApiKey.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// [START apikeys_undelete_api_key]
import com.google.api.apikeys.v2.ApiKeysClient;
import com.google.api.apikeys.v2.Key;
import com.google.api.apikeys.v2.UndeleteKeyRequest;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class UndeleteApiKey {

public static void main(String[] args)
throws IOException, ExecutionException, InterruptedException, TimeoutException {
// TODO(developer): Replace these variables before running the sample.
// Project ID or project number of the Google Cloud project.
String projectId = "YOUR_PROJECT_ID";
// The API key id to undelete.
String keyId = "YOUR_KEY_ID";

undeleteApiKey(projectId, keyId);
}

// Undeletes an API key.
public static void undeleteApiKey(String projectId, String keyId)
throws IOException, ExecutionException, InterruptedException, TimeoutException {
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests.
try (ApiKeysClient apiKeysClient = ApiKeysClient.create()) {

// Initialize the undelete request and set the argument.
UndeleteKeyRequest undeleteKeyRequest = UndeleteKeyRequest.newBuilder()
.setName(String.format("projects/%s/locations/global/keys/%s", projectId, keyId))
.build();

// Make the request and wait for the operation to complete.
Key undeletedKey = apiKeysClient.undeleteKeyAsync(undeleteKeyRequest)
.get(3, TimeUnit.MINUTES);

System.out.printf("Successfully undeleted the API key: %s", undeletedKey.getName());
}
}
}
// [END apikeys_undelete_api_key]
Loading

0 comments on commit 7dca8a1

Please sign in to comment.