From f5ad704564cf8e9a46b572b7d778ffd5b5450e27 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 22 Jul 2019 10:32:52 -0700 Subject: [PATCH] Add get_entry sample (via synth). (#8725) --- .../samples/v1beta1/datacatalog_get_entry.py | 79 +++++++++++++++++++ datacatalog/synth.metadata | 6 +- 2 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 datacatalog/samples/v1beta1/datacatalog_get_entry.py diff --git a/datacatalog/samples/v1beta1/datacatalog_get_entry.py b/datacatalog/samples/v1beta1/datacatalog_get_entry.py new file mode 100644 index 000000000000..5b5775bd7a96 --- /dev/null +++ b/datacatalog/samples/v1beta1/datacatalog_get_entry.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +# +# 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 +# +# https://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. + +# DO NOT EDIT! This is a generated sample ("Request", "datacatalog_get_entry") + +# To install the latest published package dependency, execute the following: +# pip install google-cloud-datacatalog + +# sample-metadata +# title: +# description: Get Entry +# usage: python3 samples/v1beta1/datacatalog_get_entry.py [--project_id "[Google Cloud Project ID]"] [--location_id "[Google Cloud Location ID]"] [--entry_group_id "[Entry Group ID]"] [--entry_id "[Entry ID]"] +import sys + +# [START datacatalog_get_entry] + +from google.cloud import datacatalog_v1beta1 +from google.cloud.datacatalog_v1beta1 import enums + + +def sample_get_entry(project_id, location_id, entry_group_id, entry_id): + """ + Get Entry + + Args: + project_id Your Google Cloud project ID + location_id Google Cloud region, e.g. us-central1 + entry_group_id ID of the Entry Group, e.g. @bigquery, @pubsub, my_entry_group + entry_id ID of the Entry + """ + + client = datacatalog_v1beta1.DataCatalogClient() + + # project_id = '[Google Cloud Project ID]' + # location_id = '[Google Cloud Location ID]' + # entry_group_id = '[Entry Group ID]' + # entry_id = '[Entry ID]' + name = client.entry_path(project_id, location_id, entry_group_id, entry_id) + + response = client.get_entry(name) + entry = response + print(u"Entry name: {}".format(entry.name)) + print(u"Entry type: {}".format(enums.EntryType(entry.type).name)) + print(u"Linked resource: {}".format(entry.linked_resource)) + + +# [END datacatalog_get_entry] + + +def main(): + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument("--project_id", type=str, default="[Google Cloud Project ID]") + parser.add_argument("--location_id", type=str, default="[Google Cloud Location ID]") + parser.add_argument("--entry_group_id", type=str, default="[Entry Group ID]") + parser.add_argument("--entry_id", type=str, default="[Entry ID]") + args = parser.parse_args() + + sample_get_entry( + args.project_id, args.location_id, args.entry_group_id, args.entry_id + ) + + +if __name__ == "__main__": + main() diff --git a/datacatalog/synth.metadata b/datacatalog/synth.metadata index 12b15de5f630..8cd590d7dd2c 100644 --- a/datacatalog/synth.metadata +++ b/datacatalog/synth.metadata @@ -1,5 +1,5 @@ { - "updateTime": "2019-07-19T12:16:42.822949Z", + "updateTime": "2019-07-20T12:17:02.340446Z", "sources": [ { "generator": { @@ -12,8 +12,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f78612e8d008b9678252da84c035da12e92c0093", - "internalRef": "258869625" + "sha": "184ab77f4cee62332f8f9a689c70c9bea441f836", + "internalRef": "259048326" } }, {