Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Data Catalog createEntry samples and tests. #1638

Merged

Conversation

mesmacosta
Copy link
Contributor

I would like to add samples for Data Catalog create_entry method, released on 0.28.0-alpha google-cloud-datacatalog version.

@mesmacosta mesmacosta requested a review from a team October 22, 2019 21:02
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 22, 2019
@kurtisvg
Copy link
Contributor

I would like to add samples for Data Catalog create_entry method, released on 0.28.0-alpha google-cloud-datacatalog version.

Are these samples being authored with the intent to include them as part of our docs somewhere? or are you just writing them because you thought the current set of samples is missing this functionality?

@mesmacosta
Copy link
Contributor Author

Hi @kurtisvg,

yes, they are being authored with the intent to include them as part of google docs.

And also the current set of samples is missing this functionality.

try {
dataCatalogClient.deleteEntry(
EntryName.of(projectId, location, entryGroupId, entryId).toString());
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't catch Exception - you should catch the specific error being thrown and show the user how to handle it correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, will add new PRs for delete methods.

// Delete any pre-existing Entry Group with the same name
// that will be used in step 2.
try {
dataCatalogClient.deleteEntryGroup(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as comments above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, will add new PRs for delete methods.

System.out.printf("\nEntry created with name: %s\n", entryResponse.getName());


} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Exception is too broad as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, also now explaining what could cause the exceptions.


private static String PROJECT_ID = System.getenv().get("GOOGLE_CLOUD_PROJECT");
private static String LOCATION = "us-central1";
private static String ENTRY_GROUP_ID = "fileset_entry_group";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should probably use a randomly generated UUID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed, using only the first 8 chars from UUID, since hyphens are not supported on those IDs.

Entry entry = Entry.newBuilder()
.setDisplayName("My Fileset")
.setDescription("This fileset consists of ....")
.setGcsFilesetSpec(GcsFilesetSpec.newBuilder().addFilePatterns("gs://my_bucket/*")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we try to prioritize splitting between different syntactic levels, and remain consistent:

              .setGcsFilesetSpec(
                  GcsFilesetSpec.newBuilder().addFilePatterns("gs://my_bucket/*").build())

Or, if the line is too long:

              .setGcsFilesetSpec(
                  GcsFilesetSpec.newBuilder()
                     .addFilePatterns("gs://my_bucket/*")
                     .build())

You can use google-java-format to format the entire file at once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran google-java-format, could you check?

@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 23, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 23, 2019
@mesmacosta mesmacosta requested a review from kurtisvg October 23, 2019 20:15
@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 23, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 23, 2019
@mesmacosta mesmacosta requested a review from kurtisvg October 24, 2019 19:40
@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019

/** Integration (system) tests for {@link CreateEntryGroup}. */
@RunWith(JUnit4.class)
@SuppressWarnings("checkstyle:abbreviationaswordinname")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this line? We should try to avoid suppression style checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@mesmacosta mesmacosta requested a review from kurtisvg October 25, 2019 18:27
@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@mesmacosta mesmacosta requested a review from kurtisvg October 25, 2019 21:46
@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
Copy link
Contributor

@kurtisvg kurtisvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once tests pass

@kurtisvg kurtisvg added the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Oct 25, 2019
@mesmacosta mesmacosta requested a review from kurtisvg October 26, 2019 12:32
@kurtisvg
Copy link
Contributor

Hi @mesmacosta,

This already has my approval. Do you need me to merge it for you?

@mesmacosta
Copy link
Contributor Author

Yes @kurtisvg, can you do that?

@kurtisvg kurtisvg merged commit ce81ede into GoogleCloudPlatform:master Oct 26, 2019
@mesmacosta mesmacosta deleted the task/add-create-fileset-entry branch October 28, 2019 13:00
bradmiro pushed a commit that referenced this pull request Dec 2, 2019
* Add Data Catalog createEntry samples and tests

* Change second column name

* Code review changes

* Change region tag for the correct one

* Removed tag from region tag since this sample does not tag the entry

* ADD method overload to show parameter values examples

* Code review changes

* Code review changes

* Code review and checkstyle changes

* Clean up in a safer order
charlieyu1996 pushed a commit that referenced this pull request Nov 11, 2022
* Add Data Catalog createEntry samples and tests

* Change second column name

* Code review changes

* Change region tag for the correct one

* Removed tag from region tag since this sample does not tag the entry

* ADD method overload to show parameter values examples

* Code review changes

* Code review changes

* Code review and checkstyle changes

* Clean up in a safer order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants