From 4bc1c34d9c7cc6edbd4cea2c5bef037fb56ab05f Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 15:39:11 -0300 Subject: [PATCH 01/10] ADD sample for create fileset entry quickstart --- .../CreateFilesetEntryQuickStart.java | 171 ++++++++++++++++++ .../example/datacatalog/CreateEntryTests.java | 103 ++++++++--- 2 files changed, 253 insertions(+), 21 deletions(-) create mode 100644 datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java new file mode 100644 index 00000000000..581c1a075d1 --- /dev/null +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java @@ -0,0 +1,171 @@ +/* + * Copyright 2019 Google Inc. + * + * 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. + */ + +package com.example.datacatalog; + +// [START datacatalog_create_fileset_quickstart_tag] + +import com.google.api.gax.rpc.AlreadyExistsException; +import com.google.api.gax.rpc.NotFoundException; +import com.google.api.gax.rpc.PermissionDeniedException; +import com.google.cloud.datacatalog.ColumnSchema; +import com.google.cloud.datacatalog.CreateEntryRequest; +import com.google.cloud.datacatalog.CreateEntryGroupRequest; +import com.google.cloud.datacatalog.Entry; +import com.google.cloud.datacatalog.EntryName; +import com.google.cloud.datacatalog.EntryGroup; +import com.google.cloud.datacatalog.EntryGroupName; +import com.google.cloud.datacatalog.EntryType; +import com.google.cloud.datacatalog.GcsFilesetSpec; +import com.google.cloud.datacatalog.LocationName; +import com.google.cloud.datacatalog.Schema; +import com.google.cloud.datacatalog.v1beta1.DataCatalogClient; +import java.io.IOException; + +import java.io.IOException; + +public class CreateFilesetEntryQuickStart { + + public static void createEntry() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project-id"; + String entryGroupId = "fileset_entry_group"; + String entryId = "fileset_entry_id"; + createEntry(projectId, entryGroupId, entryId); + } + + // Create Fileset Entry. + public static void createEntry(String projectId, String entryGroupId, String entryId) { + // Currently, Data Catalog stores metadata in the us-central1 region. + String location = "us-central1"; + + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. + try (DataCatalogClient dataCatalogClient = DataCatalogClient.create()) { + + // 1. Environment cleanup: delete pre-existing data. + // Delete any pre-existing Entry with the same name + // that will be used in step 3. + try { + dataCatalogClient.deleteEntry( + EntryName.of(projectId, location, entryGroupId, entryId).toString()); + } catch (PermissionDeniedException | NotFoundException e) { + // PermissionDeniedException and NotFoundException are thrown if + // Entry does not exist. + System.out.println("Entry does not exist."); + } + + // Delete any pre-existing Entry Group with the same name + // that will be used in step 2. + try { + dataCatalogClient.deleteEntryGroup( + EntryGroupName.of(projectId, location, entryGroupId).toString()); + } catch (PermissionDeniedException | NotFoundException e) { + // PermissionDeniedException and NotFoundException are thrown if + // Entry Group does not exist. + System.out.println("Entry Group does not exist."); + } + + // 2. Create an Entry Group. + // Construct the EntryGroup for the EntryGroup request. + EntryGroup entryGroup = + EntryGroup.newBuilder() + .setDisplayName("My Fileset Entry Group") + .setDescription("This Entry Group consists of ....") + .build(); + + // Construct the EntryGroup request to be sent by the client. + CreateEntryGroupRequest entryGroupRequest = CreateEntryGroupRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setEntryGroupId(entryGroupId) + .setEntryGroup(entryGroup) + .build(); + + // Use the client to send the API request. + EntryGroup entryGroupResponse = dataCatalogClient.createEntryGroup(entryGroupRequest); + + System.out.printf("\nEntry Group created with name: %s\n", entryGroupResponse.getName()); + + // 3. Create a Fileset Entry. + // Construct the Entry for the Entry request. + Entry entry = + Entry.newBuilder() + .setDisplayName("My Fileset") + .setDescription("This fileset consists of ....") + .setGcsFilesetSpec( + GcsFilesetSpec.newBuilder().addFilePatterns("gs://my_bucket/*").build()) + .setSchema( + Schema.newBuilder() + .addColumns( + ColumnSchema.newBuilder() + .setColumn("first_name") + .setDescription("First name") + .setMode("REQUIRED") + .setType("STRING") + .build()) + .addColumns( + ColumnSchema.newBuilder() + .setColumn("last_name") + .setDescription("Last name") + .setMode("REQUIRED") + .setType("STRING") + .build()) + .addColumns( + ColumnSchema.newBuilder() + .setColumn("addresses") + .setDescription("Addresses") + .setMode("REPEATED") + .setType("RECORD") + .addSubcolumns( + ColumnSchema.newBuilder() + .setColumn("city") + .setDescription("City") + .setMode("NULLABLE") + .setType("STRING") + .build()) + .addSubcolumns( + ColumnSchema.newBuilder() + .setColumn("state") + .setDescription("State") + .setMode("NULLABLE") + .setType("STRING") + .build()) + .build()) + .build()) + .setType(EntryType.FILESET) + .build(); + + // Construct the Entry request to be sent by the client. + CreateEntryRequest entryRequest = CreateEntryRequest.newBuilder() + .setParent(entryGroupResponse.getName()) + .setEntryId(entryId) + .setEntry(entry) + .build(); + + // Use the client to send the API request. + Entry entryResponse = dataCatalogClient.createEntry(entryRequest); + + System.out.printf("\nEntry created with name: %s\n", entryResponse.getName()); + } catch (AlreadyExistsException | IOException e) { + // AlreadyExistsException's are thrown if EntryGroup or Entry already exists. + // IOException's are thrown when unable to create the DataCatalogClient, + // for example an invalid Service Account path. + System.out.println("Error in create entry process:\n" + e.toString()); + } + } +} +// [END datacatalog_create_fileset_quickstart_tag] \ No newline at end of file diff --git a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java index 2651606c89c..5342749d518 100644 --- a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java +++ b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java @@ -17,12 +17,15 @@ package com.example.datacatalog; import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; import com.google.cloud.datacatalog.EntryGroupName; import com.google.cloud.datacatalog.EntryName; import com.google.cloud.datacatalog.v1beta1.DataCatalogClient; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import org.hamcrest.CoreMatchers; import org.junit.After; @@ -32,21 +35,19 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup}. */ +/** Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup} + * and {@link CreateFilesetEntryQuickStart}. */ @RunWith(JUnit4.class) public class CreateEntryTests { private ByteArrayOutputStream bout; - private static String ENTRY_GROUP_ID_NO_CHILDREN = - "entry_group_no_children_" + UUID.randomUUID().toString().substring(0, 8); - private static String PARENT_ENTRY_GROUP_ID = - "fileset_entry_group_parent_" + UUID.randomUUID().toString().substring(0, 8); - private static String ENTRY_ID = - "fileset_entry_id_" + UUID.randomUUID().toString().substring(0, 8); private static String LOCATION = "us-central1"; private static String PROJECT_ID = System.getenv().get("GOOGLE_CLOUD_PROJECT"); + private static List entryGroupsPendingDeletion = new ArrayList<>(); + private static List entriesPendingDeletion = new ArrayList<>(); + @Before public void setUp() { bout = new ByteArrayOutputStream(); @@ -62,13 +63,18 @@ public void tearDown() { @AfterClass public static void tearDownClass() { try (DataCatalogClient dataCatalogClient = DataCatalogClient.create()) { - dataCatalogClient.deleteEntryGroup( - EntryGroupName.of(PROJECT_ID, LOCATION, ENTRY_GROUP_ID_NO_CHILDREN).toString()); - - dataCatalogClient.deleteEntry( - EntryName.of(PROJECT_ID, LOCATION, PARENT_ENTRY_GROUP_ID, ENTRY_ID).toString()); - dataCatalogClient.deleteEntryGroup( - EntryGroupName.of(PROJECT_ID, LOCATION, PARENT_ENTRY_GROUP_ID).toString()); + // Must delete Entries before deleting the Entry Group. + if (entriesPendingDeletion.isEmpty() || entryGroupsPendingDeletion.isEmpty()){ + fail("Something went wrong, no entries were generated"); + } + + for (String entryName: entriesPendingDeletion) { + dataCatalogClient.deleteEntry(entryName); + } + + for (String entryGroupName: entryGroupsPendingDeletion) { + dataCatalogClient.deleteEntryGroup(entryGroupName); + } } catch (Exception e) { System.out.println("Error in cleaning up test data:\n" + e.toString()); } @@ -76,31 +82,86 @@ public static void tearDownClass() { @Test public void testCreateFilesetEntry() { + String entryGroupId = "fileset_entry_group_parent_" + getUUID8Chars(); + String entryId = "fileset_entry_id_" + getUUID8Chars(); + // Must create a Entry Group before creating the entry. - CreateEntryGroup.createEntryGroup(PROJECT_ID, PARENT_ENTRY_GROUP_ID); - CreateFilesetEntry.createEntry(PROJECT_ID, PARENT_ENTRY_GROUP_ID, ENTRY_ID); + CreateEntryGroup.createEntryGroup(PROJECT_ID, entryGroupId); + CreateFilesetEntry.createEntry(PROJECT_ID, entryGroupId, entryId); + + // Store names for clean up on teardown + String expectedEntryGroupName = + EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); + entryGroupsPendingDeletion.add(expectedEntryGroupName); + + String expectedEntryName = + EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); + entriesPendingDeletion.add(expectedEntryName); String output = bout.toString(); String entryTemplate = - "Entry created with name: projects/%s/locations/us-central1/entryGroups/%s/entries/%s"; + "Entry created with name: %s"; assertThat( output, CoreMatchers.containsString( - String.format(entryTemplate, PROJECT_ID, PARENT_ENTRY_GROUP_ID, ENTRY_ID))); + String.format(entryTemplate, expectedEntryName))); } @Test public void testCreateEntryGroup() { - CreateEntryGroup.createEntryGroup(PROJECT_ID, ENTRY_GROUP_ID_NO_CHILDREN); + String entry_group_id = "entry_group_no_children_" + getUUID8Chars(); + + CreateEntryGroup.createEntryGroup(PROJECT_ID, entry_group_id); + + // Store names for clean up on teardown + String expectedEntryGroupName = + EntryGroupName.of(PROJECT_ID, LOCATION, entry_group_id).toString(); + entryGroupsPendingDeletion.add(expectedEntryGroupName); + + String output = bout.toString(); + + String entryGroupTemplate = + "Entry Group created with name: %s"; + assertThat( + output, + CoreMatchers.containsString( + String.format(entryGroupTemplate, expectedEntryGroupName))); + } + + @Test + public void testCreateEntryQuickStart() { + String entryGroupId = "fileset_entry_group_parent_" + getUUID8Chars(); + String entryId = "fileset_entry_id_" + getUUID8Chars(); + + CreateFilesetEntryQuickStart.createEntry(PROJECT_ID, entryGroupId, entryId); + + // Store names for clean up on teardown + String expectedEntryGroupName = + EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); + entryGroupsPendingDeletion.add(expectedEntryGroupName); + + String expectedEntryName = + EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); + entriesPendingDeletion.add(expectedEntryName); String output = bout.toString(); + String entryTemplate = + "Entry created with name: %s"; String entryGroupTemplate = - "Entry Group created with name: projects/%s/locations/us-central1/entryGroups/%s"; + "Entry Group created with name: %s"; + assertThat( + output, + CoreMatchers.containsString( + String.format(entryGroupTemplate, expectedEntryGroupName))); assertThat( output, CoreMatchers.containsString( - String.format(entryGroupTemplate, PROJECT_ID, ENTRY_GROUP_ID_NO_CHILDREN))); + String.format(entryTemplate, expectedEntryName))); + } + + private String getUUID8Chars() { + return UUID.randomUUID().toString().substring(0, 8); } } \ No newline at end of file From 9ced693d66348773bab0a981924153c363635295 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 15:41:59 -0300 Subject: [PATCH 02/10] RAN google java format --- .../CreateFilesetEntryQuickStart.java | 30 ++++++------ .../example/datacatalog/CreateEntryTests.java | 46 ++++++++----------- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java index 581c1a075d1..a7e2da37021 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java @@ -22,12 +22,12 @@ import com.google.api.gax.rpc.NotFoundException; import com.google.api.gax.rpc.PermissionDeniedException; import com.google.cloud.datacatalog.ColumnSchema; -import com.google.cloud.datacatalog.CreateEntryRequest; import com.google.cloud.datacatalog.CreateEntryGroupRequest; +import com.google.cloud.datacatalog.CreateEntryRequest; import com.google.cloud.datacatalog.Entry; -import com.google.cloud.datacatalog.EntryName; import com.google.cloud.datacatalog.EntryGroup; import com.google.cloud.datacatalog.EntryGroupName; +import com.google.cloud.datacatalog.EntryName; import com.google.cloud.datacatalog.EntryType; import com.google.cloud.datacatalog.GcsFilesetSpec; import com.google.cloud.datacatalog.LocationName; @@ -35,8 +35,6 @@ import com.google.cloud.datacatalog.v1beta1.DataCatalogClient; import java.io.IOException; -import java.io.IOException; - public class CreateFilesetEntryQuickStart { public static void createEntry() { @@ -89,11 +87,12 @@ public static void createEntry(String projectId, String entryGroupId, String ent .build(); // Construct the EntryGroup request to be sent by the client. - CreateEntryGroupRequest entryGroupRequest = CreateEntryGroupRequest.newBuilder() - .setParent(LocationName.of(projectId, location).toString()) - .setEntryGroupId(entryGroupId) - .setEntryGroup(entryGroup) - .build(); + CreateEntryGroupRequest entryGroupRequest = + CreateEntryGroupRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setEntryGroupId(entryGroupId) + .setEntryGroup(entryGroup) + .build(); // Use the client to send the API request. EntryGroup entryGroupResponse = dataCatalogClient.createEntryGroup(entryGroupRequest); @@ -150,11 +149,12 @@ public static void createEntry(String projectId, String entryGroupId, String ent .build(); // Construct the Entry request to be sent by the client. - CreateEntryRequest entryRequest = CreateEntryRequest.newBuilder() - .setParent(entryGroupResponse.getName()) - .setEntryId(entryId) - .setEntry(entry) - .build(); + CreateEntryRequest entryRequest = + CreateEntryRequest.newBuilder() + .setParent(entryGroupResponse.getName()) + .setEntryId(entryId) + .setEntry(entry) + .build(); // Use the client to send the API request. Entry entryResponse = dataCatalogClient.createEntry(entryRequest); @@ -168,4 +168,4 @@ public static void createEntry(String projectId, String entryGroupId, String ent } } } -// [END datacatalog_create_fileset_quickstart_tag] \ No newline at end of file +// [END datacatalog_create_fileset_quickstart_tag] diff --git a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java index 5342749d518..84f899b17b1 100644 --- a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java +++ b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java @@ -35,8 +35,10 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup} - * and {@link CreateFilesetEntryQuickStart}. */ +/** + * Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup} and {@link + * CreateFilesetEntryQuickStart}. + */ @RunWith(JUnit4.class) public class CreateEntryTests { @@ -64,15 +66,15 @@ public void tearDown() { public static void tearDownClass() { try (DataCatalogClient dataCatalogClient = DataCatalogClient.create()) { // Must delete Entries before deleting the Entry Group. - if (entriesPendingDeletion.isEmpty() || entryGroupsPendingDeletion.isEmpty()){ + if (entriesPendingDeletion.isEmpty() || entryGroupsPendingDeletion.isEmpty()) { fail("Something went wrong, no entries were generated"); } - for (String entryName: entriesPendingDeletion) { + for (String entryName : entriesPendingDeletion) { dataCatalogClient.deleteEntry(entryName); } - for (String entryGroupName: entryGroupsPendingDeletion) { + for (String entryGroupName : entryGroupsPendingDeletion) { dataCatalogClient.deleteEntryGroup(entryGroupName); } } catch (Exception e) { @@ -94,18 +96,14 @@ public void testCreateFilesetEntry() { EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); entryGroupsPendingDeletion.add(expectedEntryGroupName); - String expectedEntryName = - EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); + String expectedEntryName = EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); entriesPendingDeletion.add(expectedEntryName); String output = bout.toString(); - String entryTemplate = - "Entry created with name: %s"; + String entryTemplate = "Entry created with name: %s"; assertThat( - output, - CoreMatchers.containsString( - String.format(entryTemplate, expectedEntryName))); + output, CoreMatchers.containsString(String.format(entryTemplate, expectedEntryName))); } @Test @@ -121,12 +119,10 @@ public void testCreateEntryGroup() { String output = bout.toString(); - String entryGroupTemplate = - "Entry Group created with name: %s"; + String entryGroupTemplate = "Entry Group created with name: %s"; assertThat( output, - CoreMatchers.containsString( - String.format(entryGroupTemplate, expectedEntryGroupName))); + CoreMatchers.containsString(String.format(entryGroupTemplate, expectedEntryGroupName))); } @Test @@ -141,27 +137,21 @@ public void testCreateEntryQuickStart() { EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); entryGroupsPendingDeletion.add(expectedEntryGroupName); - String expectedEntryName = - EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); + String expectedEntryName = EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); entriesPendingDeletion.add(expectedEntryName); String output = bout.toString(); - String entryTemplate = - "Entry created with name: %s"; - String entryGroupTemplate = - "Entry Group created with name: %s"; + String entryTemplate = "Entry created with name: %s"; + String entryGroupTemplate = "Entry Group created with name: %s"; assertThat( output, - CoreMatchers.containsString( - String.format(entryGroupTemplate, expectedEntryGroupName))); + CoreMatchers.containsString(String.format(entryGroupTemplate, expectedEntryGroupName))); assertThat( - output, - CoreMatchers.containsString( - String.format(entryTemplate, expectedEntryName))); + output, CoreMatchers.containsString(String.format(entryTemplate, expectedEntryName))); } private String getUUID8Chars() { return UUID.randomUUID().toString().substring(0, 8); } -} \ No newline at end of file +} From 08d40cf8d9aadaa88b53421e579f5e26b3ba0404 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 15:43:30 -0300 Subject: [PATCH 03/10] CHANGE exception comment --- .../com/example/datacatalog/CreateFilesetEntryQuickStart.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java index a7e2da37021..dbdf1a4c66a 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java @@ -62,7 +62,7 @@ public static void createEntry(String projectId, String entryGroupId, String ent dataCatalogClient.deleteEntry( EntryName.of(projectId, location, entryGroupId, entryId).toString()); } catch (PermissionDeniedException | NotFoundException e) { - // PermissionDeniedException and NotFoundException are thrown if + // PermissionDeniedException or NotFoundException are thrown if // Entry does not exist. System.out.println("Entry does not exist."); } @@ -73,7 +73,7 @@ public static void createEntry(String projectId, String entryGroupId, String ent dataCatalogClient.deleteEntryGroup( EntryGroupName.of(projectId, location, entryGroupId).toString()); } catch (PermissionDeniedException | NotFoundException e) { - // PermissionDeniedException and NotFoundException are thrown if + // PermissionDeniedException or NotFoundException are thrown if // Entry Group does not exist. System.out.println("Entry Group does not exist."); } From 3a1460ba1493699d31b2a56b1c0ef37c5b9160c6 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 15:47:48 -0300 Subject: [PATCH 04/10] FIX lint issues --- .../example/datacatalog/CreateEntryTests.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java index 84f899b17b1..eaf0d49c433 100644 --- a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java +++ b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java @@ -84,8 +84,8 @@ public static void tearDownClass() { @Test public void testCreateFilesetEntry() { - String entryGroupId = "fileset_entry_group_parent_" + getUUID8Chars(); - String entryId = "fileset_entry_id_" + getUUID8Chars(); + String entryGroupId = "fileset_entry_group_parent_" + getUuid8Chars(); + String entryId = "fileset_entry_id_" + getUuid8Chars(); // Must create a Entry Group before creating the entry. CreateEntryGroup.createEntryGroup(PROJECT_ID, entryGroupId); @@ -108,13 +108,13 @@ public void testCreateFilesetEntry() { @Test public void testCreateEntryGroup() { - String entry_group_id = "entry_group_no_children_" + getUUID8Chars(); + String entryGroupId = "entry_group_no_children_" + getUuid8Chars(); - CreateEntryGroup.createEntryGroup(PROJECT_ID, entry_group_id); + CreateEntryGroup.createEntryGroup(PROJECT_ID, entryGroupId); // Store names for clean up on teardown String expectedEntryGroupName = - EntryGroupName.of(PROJECT_ID, LOCATION, entry_group_id).toString(); + EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); entryGroupsPendingDeletion.add(expectedEntryGroupName); String output = bout.toString(); @@ -127,8 +127,8 @@ public void testCreateEntryGroup() { @Test public void testCreateEntryQuickStart() { - String entryGroupId = "fileset_entry_group_parent_" + getUUID8Chars(); - String entryId = "fileset_entry_id_" + getUUID8Chars(); + String entryGroupId = "fileset_entry_group_parent_" + getUuid8Chars(); + String entryId = "fileset_entry_id_" + getUuid8Chars(); CreateFilesetEntryQuickStart.createEntry(PROJECT_ID, entryGroupId, entryId); @@ -151,7 +151,7 @@ public void testCreateEntryQuickStart() { output, CoreMatchers.containsString(String.format(entryTemplate, expectedEntryName))); } - private String getUUID8Chars() { + private String getUuid8Chars() { return UUID.randomUUID().toString().substring(0, 8); } } From f6a4c02ac5799196409ca0ab26e9f13bcfb387bc Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 19:05:49 -0300 Subject: [PATCH 05/10] Split quickstart into a new folder --- .../example/datacatalog/CreateEntryTests.java | 29 +---- datacatalog/quickstart/README.md | 31 +++++ datacatalog/quickstart/build.gradle | 41 +++++++ datacatalog/quickstart/pom.xml | 59 +++++++++ .../CreateFilesetEntryQuickStart.java | 0 .../CreateFilesetEntryQuickStartTests.java | 113 ++++++++++++++++++ 6 files changed, 245 insertions(+), 28 deletions(-) create mode 100644 datacatalog/quickstart/README.md create mode 100644 datacatalog/quickstart/build.gradle create mode 100644 datacatalog/quickstart/pom.xml rename datacatalog/{cloud-client => quickstart}/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java (100%) create mode 100644 datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java diff --git a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java index eaf0d49c433..13c792cad90 100644 --- a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java +++ b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java @@ -36,8 +36,7 @@ import org.junit.runners.JUnit4; /** - * Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup} and {@link - * CreateFilesetEntryQuickStart}. + * Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup}. */ @RunWith(JUnit4.class) public class CreateEntryTests { @@ -125,32 +124,6 @@ public void testCreateEntryGroup() { CoreMatchers.containsString(String.format(entryGroupTemplate, expectedEntryGroupName))); } - @Test - public void testCreateEntryQuickStart() { - String entryGroupId = "fileset_entry_group_parent_" + getUuid8Chars(); - String entryId = "fileset_entry_id_" + getUuid8Chars(); - - CreateFilesetEntryQuickStart.createEntry(PROJECT_ID, entryGroupId, entryId); - - // Store names for clean up on teardown - String expectedEntryGroupName = - EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); - entryGroupsPendingDeletion.add(expectedEntryGroupName); - - String expectedEntryName = EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); - entriesPendingDeletion.add(expectedEntryName); - - String output = bout.toString(); - - String entryTemplate = "Entry created with name: %s"; - String entryGroupTemplate = "Entry Group created with name: %s"; - assertThat( - output, - CoreMatchers.containsString(String.format(entryGroupTemplate, expectedEntryGroupName))); - assertThat( - output, CoreMatchers.containsString(String.format(entryTemplate, expectedEntryName))); - } - private String getUuid8Chars() { return UUID.randomUUID().toString().substring(0, 8); } diff --git a/datacatalog/quickstart/README.md b/datacatalog/quickstart/README.md new file mode 100644 index 00000000000..f4128e2c4b0 --- /dev/null +++ b/datacatalog/quickstart/README.md @@ -0,0 +1,31 @@ +# Getting Started with Data Catalog and the Google Cloud Client libraries + + +Open in Cloud Shell + +[Data Catalog][datacatalog] is a fully managed and scalable metadata management service that empowers organizations +to quickly discover, manage, and understand all their data in Google Cloud. +This sample Java application demonstrates how to access the Data Catalog API using +the [Google Cloud Client Library for Java][google-cloud-java]. + +[datacatalog]: https://cloud.google.com/data-catalog/ +[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java + +## Quickstart + +#### Setup +- Install [Maven](http://maven.apache.org/). +- [Enable](https://console.cloud.google.com/apis/api/datacatalog.googleapis.com/overview) Data Catalog API. +- Set up [authentication](https://cloud.google.com/docs/authentication/getting-started). + +#### Build +- Build your project with: +``` + mvn clean package -DskipTests +``` + +#### Testing +Run the test with Maven. +``` + mvn verify +``` diff --git a/datacatalog/quickstart/build.gradle b/datacatalog/quickstart/build.gradle new file mode 100644 index 00000000000..7c37191be55 --- /dev/null +++ b/datacatalog/quickstart/build.gradle @@ -0,0 +1,41 @@ +// Copyright 2019 Google Inc. +// +// 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. + +apply plugin: 'java' + +repositories { + mavenCentral() +} + +dependencies { + compile group: 'com.google.cloud', name: 'google-cloud-datacatalog-quickstart', version:'0.28.0-alpha' + + testCompile group: 'com.google.truth', name: 'truth', version:'0.42' + testCompile group: 'junit', name: 'junit', version:'4.13-beta-2' +} + +test { + useJUnit() + testLogging.showStandardStreams = true + beforeTest { descriptor -> + logger.lifecycle("test: " + descriptor + " Running") + } + + onOutput { descriptor, event -> + logger.lifecycle("test: " + descriptor + ": " + event.message ) + } + afterTest { descriptor, result -> + logger.lifecycle("test: " + descriptor + ": " + result ) + } +} diff --git a/datacatalog/quickstart/pom.xml b/datacatalog/quickstart/pom.xml new file mode 100644 index 00000000000..7c5a38c93a5 --- /dev/null +++ b/datacatalog/quickstart/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + com.example.datacatalog + datacatalog-google-cloud-quickstart + jar + + + + com.google.cloud.samples + shared-configuration + 1.0.11 + + + + 1.8 + 1.8 + + + + + com.google.cloud + google-cloud-datacatalog + 0.29.0-alpha + + + + + junit + junit + 4.13-beta-3 + test + + + com.google.truth + truth + 1.0 + test + + + diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java b/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java similarity index 100% rename from datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java rename to datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java diff --git a/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java new file mode 100644 index 00000000000..75d2f116627 --- /dev/null +++ b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java @@ -0,0 +1,113 @@ +/* + * Copyright 2019 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. + */ + +package com.example.datacatalog; + +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import com.google.cloud.datacatalog.EntryGroupName; +import com.google.cloud.datacatalog.EntryName; +import com.google.cloud.datacatalog.v1beta1.DataCatalogClient; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import org.hamcrest.CoreMatchers; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * Integration (system) tests for {CreateFilesetEntryQuickStart}. + */ +@RunWith(JUnit4.class) +public class CreateFilesetEntryQuickStartTests { + + private ByteArrayOutputStream bout; + + private static String LOCATION = "us-central1"; + private static String PROJECT_ID = System.getenv().get("GOOGLE_CLOUD_PROJECT"); + + private static List entryGroupsPendingDeletion = new ArrayList<>(); + private static List entriesPendingDeletion = new ArrayList<>(); + + @Before + public void setUp() { + bout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(bout)); + } + + @After + public void tearDown() { + System.setOut(null); + bout.reset(); + } + + @AfterClass + public static void tearDownClass() { + try (DataCatalogClient dataCatalogClient = DataCatalogClient.create()) { + // Must delete Entries before deleting the Entry Group. + if (entriesPendingDeletion.isEmpty() || entryGroupsPendingDeletion.isEmpty()) { + fail("Something went wrong, no entries were generated"); + } + + for (String entryName : entriesPendingDeletion) { + dataCatalogClient.deleteEntry(entryName); + } + + for (String entryGroupName : entryGroupsPendingDeletion) { + dataCatalogClient.deleteEntryGroup(entryGroupName); + } + } catch (Exception e) { + System.out.println("Error in cleaning up test data:\n" + e.toString()); + } + } + + @Test + public void testCreateEntryQuickStart() { + String entryGroupId = "fileset_entry_group_parent_" + getUuid8Chars(); + String entryId = "fileset_entry_id_" + getUuid8Chars(); + + CreateFilesetEntryQuickStart.createEntry(PROJECT_ID, entryGroupId, entryId); + + // Store names for clean up on teardown + String expectedEntryGroupName = + EntryGroupName.of(PROJECT_ID, LOCATION, entryGroupId).toString(); + entryGroupsPendingDeletion.add(expectedEntryGroupName); + + String expectedEntryName = EntryName.of(PROJECT_ID, LOCATION, entryGroupId, entryId).toString(); + entriesPendingDeletion.add(expectedEntryName); + + String output = bout.toString(); + + String entryTemplate = "Entry created with name: %s"; + String entryGroupTemplate = "Entry Group created with name: %s"; + assertThat( + output, + CoreMatchers.containsString(String.format(entryGroupTemplate, expectedEntryGroupName))); + assertThat( + output, CoreMatchers.containsString(String.format(entryTemplate, expectedEntryName))); + } + + private String getUuid8Chars() { + return UUID.randomUUID().toString().substring(0, 8); + } +} From b0981abe20a75799dda3593f0b88df1db920eb87 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 19:11:23 -0300 Subject: [PATCH 06/10] Rename files since class name will appear on samples --- ...eFilesetEntryQuickStart.java => CreateFilesetEntry.java} | 2 +- ...tryQuickStartTests.java => CreateFilesetEntryTests.java} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename datacatalog/quickstart/src/main/java/com/example/datacatalog/{CreateFilesetEntryQuickStart.java => CreateFilesetEntry.java} (99%) rename datacatalog/quickstart/src/test/java/com/example/datacatalog/{CreateFilesetEntryQuickStartTests.java => CreateFilesetEntryTests.java} (94%) diff --git a/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java b/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java similarity index 99% rename from datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java rename to datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index dbdf1a4c66a..51ea5f1e735 100644 --- a/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntryQuickStart.java +++ b/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -35,7 +35,7 @@ import com.google.cloud.datacatalog.v1beta1.DataCatalogClient; import java.io.IOException; -public class CreateFilesetEntryQuickStart { +public class CreateFilesetEntry { public static void createEntry() { // TODO(developer): Replace these variables before running the sample. diff --git a/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java similarity index 94% rename from datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java rename to datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java index 75d2f116627..784d86b85c0 100644 --- a/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryQuickStartTests.java +++ b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java @@ -36,10 +36,10 @@ import org.junit.runners.JUnit4; /** - * Integration (system) tests for {CreateFilesetEntryQuickStart}. + * Integration (system) tests for {@link CreateFilesetEntry}. */ @RunWith(JUnit4.class) -public class CreateFilesetEntryQuickStartTests { +public class CreateFilesetEntryTests { private ByteArrayOutputStream bout; @@ -86,7 +86,7 @@ public void testCreateEntryQuickStart() { String entryGroupId = "fileset_entry_group_parent_" + getUuid8Chars(); String entryId = "fileset_entry_id_" + getUuid8Chars(); - CreateFilesetEntryQuickStart.createEntry(PROJECT_ID, entryGroupId, entryId); + CreateFilesetEntry.createEntry(PROJECT_ID, entryGroupId, entryId); // Store names for clean up on teardown String expectedEntryGroupName = From 19c9a257504ca5605104d842674e01ff954c972c Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 13 Nov 2019 19:16:10 -0300 Subject: [PATCH 07/10] Ran java formatter --- .../main/java/com/example/datacatalog/CreateEntryGroup.java | 1 - .../main/java/com/example/datacatalog/CreateFilesetEntry.java | 3 ++- .../test/java/com/example/datacatalog/CreateEntryTests.java | 4 +--- .../java/com/example/datacatalog/CreateFilesetEntryTests.java | 4 +--- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java index 4e1e4e2519b..17451ec06d9 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java @@ -69,4 +69,3 @@ public static void createEntryGroup(String projectId, String entryGroupId) { } } } -// [END datacatalog_create_entry_group_tag] \ No newline at end of file diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index b8c59214005..38b2b23a981 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -1,3 +1,4 @@ +// [END datacatalog_create_entry_group_tag] /* * Copyright 2019 Google Inc. * @@ -115,4 +116,4 @@ public static void createEntry(String projectId, String entryGroupId, String ent } } } -// [END datacatalog_create_fileset_tag] \ No newline at end of file +// [END datacatalog_create_fileset_tag] diff --git a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java index 13c792cad90..04a312e9e7b 100644 --- a/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java +++ b/datacatalog/cloud-client/src/test/java/com/example/datacatalog/CreateEntryTests.java @@ -35,9 +35,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** - * Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup}. - */ +/** Integration (system) tests for {@link CreateFilesetEntry} and {@link CreateEntryGroup}. */ @RunWith(JUnit4.class) public class CreateEntryTests { diff --git a/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java index 784d86b85c0..760f6ef24d9 100644 --- a/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java +++ b/datacatalog/quickstart/src/test/java/com/example/datacatalog/CreateFilesetEntryTests.java @@ -35,9 +35,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** - * Integration (system) tests for {@link CreateFilesetEntry}. - */ +/** Integration (system) tests for {@link CreateFilesetEntry}. */ @RunWith(JUnit4.class) public class CreateFilesetEntryTests { From 11646ea3bd0f8f8999e4d5efe49cb2a2cdaf79ca Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 27 Nov 2019 09:03:29 -0300 Subject: [PATCH 08/10] revert region tags change --- .../src/main/java/com/example/datacatalog/CreateEntryGroup.java | 1 + .../main/java/com/example/datacatalog/CreateFilesetEntry.java | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java index 17451ec06d9..707d840de1d 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java @@ -69,3 +69,4 @@ public static void createEntryGroup(String projectId, String entryGroupId) { } } } +// [END datacatalog_create_entry_group_tag] diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index 38b2b23a981..740d2dd0336 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -1,4 +1,3 @@ -// [END datacatalog_create_entry_group_tag] /* * Copyright 2019 Google Inc. * From faca3b7bd7c6ab031a85be38134dfcf1bc48ccb0 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Wed, 27 Nov 2019 09:05:50 -0300 Subject: [PATCH 09/10] remove extra space --- .../src/main/java/com/example/datacatalog/CreateEntryGroup.java | 2 +- .../main/java/com/example/datacatalog/CreateFilesetEntry.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java index 707d840de1d..4e1e4e2519b 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateEntryGroup.java @@ -69,4 +69,4 @@ public static void createEntryGroup(String projectId, String entryGroupId) { } } } -// [END datacatalog_create_entry_group_tag] +// [END datacatalog_create_entry_group_tag] \ No newline at end of file diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index 740d2dd0336..b8c59214005 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -115,4 +115,4 @@ public static void createEntry(String projectId, String entryGroupId, String ent } } } -// [END datacatalog_create_fileset_tag] +// [END datacatalog_create_fileset_tag] \ No newline at end of file From 4760778b6a2476c9eabefcedc6959d9b708c8023 Mon Sep 17 00:00:00 2001 From: mesmacosta Date: Thu, 5 Dec 2019 10:36:51 -0300 Subject: [PATCH 10/10] change to real bucket name --- .../main/java/com/example/datacatalog/CreateFilesetEntry.java | 2 +- .../main/java/com/example/datacatalog/CreateFilesetEntry.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index b8c59214005..a7df34604da 100644 --- a/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java +++ b/datacatalog/cloud-client/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -54,7 +54,7 @@ public static void createEntry(String projectId, String entryGroupId, String ent .setDisplayName("My Fileset") .setDescription("This fileset consists of ....") .setGcsFilesetSpec( - GcsFilesetSpec.newBuilder().addFilePatterns("gs://my_bucket/*").build()) + GcsFilesetSpec.newBuilder().addFilePatterns("gs://cloud-samples-data/*").build()) .setSchema( Schema.newBuilder() .addColumns( diff --git a/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java b/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java index 51ea5f1e735..90ac49add0e 100644 --- a/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java +++ b/datacatalog/quickstart/src/main/java/com/example/datacatalog/CreateFilesetEntry.java @@ -106,7 +106,7 @@ public static void createEntry(String projectId, String entryGroupId, String ent .setDisplayName("My Fileset") .setDescription("This fileset consists of ....") .setGcsFilesetSpec( - GcsFilesetSpec.newBuilder().addFilePatterns("gs://my_bucket/*").build()) + GcsFilesetSpec.newBuilder().addFilePatterns("gs://cloud-samples-data/*").build()) .setSchema( Schema.newBuilder() .addColumns(