|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright 2019 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# DO NOT EDIT! This is a generated sample ("Request", "datacatalog_get_entry") |
| 18 | + |
| 19 | +# To install the latest published package dependency, execute the following: |
| 20 | +# pip install google-cloud-datacatalog |
| 21 | + |
| 22 | +# sample-metadata |
| 23 | +# title: |
| 24 | +# description: Get Entry |
| 25 | +# 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]"] |
| 26 | +import sys |
| 27 | + |
| 28 | +# [START datacatalog_get_entry] |
| 29 | + |
| 30 | +from google.cloud import datacatalog_v1beta1 |
| 31 | +from google.cloud.datacatalog_v1beta1 import enums |
| 32 | + |
| 33 | + |
| 34 | +def sample_get_entry(project_id, location_id, entry_group_id, entry_id): |
| 35 | + """ |
| 36 | + Get Entry |
| 37 | +
|
| 38 | + Args: |
| 39 | + project_id Your Google Cloud project ID |
| 40 | + location_id Google Cloud region, e.g. us-central1 |
| 41 | + entry_group_id ID of the Entry Group, e.g. @bigquery, @pubsub, my_entry_group |
| 42 | + entry_id ID of the Entry |
| 43 | + """ |
| 44 | + |
| 45 | + client = datacatalog_v1beta1.DataCatalogClient() |
| 46 | + |
| 47 | + # project_id = '[Google Cloud Project ID]' |
| 48 | + # location_id = '[Google Cloud Location ID]' |
| 49 | + # entry_group_id = '[Entry Group ID]' |
| 50 | + # entry_id = '[Entry ID]' |
| 51 | + name = client.entry_path(project_id, location_id, entry_group_id, entry_id) |
| 52 | + |
| 53 | + response = client.get_entry(name) |
| 54 | + entry = response |
| 55 | + print(u"Entry name: {}".format(entry.name)) |
| 56 | + print(u"Entry type: {}".format(enums.EntryType(entry.type).name)) |
| 57 | + print(u"Linked resource: {}".format(entry.linked_resource)) |
| 58 | + |
| 59 | + |
| 60 | +# [END datacatalog_get_entry] |
| 61 | + |
| 62 | + |
| 63 | +def main(): |
| 64 | + import argparse |
| 65 | + |
| 66 | + parser = argparse.ArgumentParser() |
| 67 | + parser.add_argument("--project_id", type=str, default="[Google Cloud Project ID]") |
| 68 | + parser.add_argument("--location_id", type=str, default="[Google Cloud Location ID]") |
| 69 | + parser.add_argument("--entry_group_id", type=str, default="[Entry Group ID]") |
| 70 | + parser.add_argument("--entry_id", type=str, default="[Entry ID]") |
| 71 | + args = parser.parse_args() |
| 72 | + |
| 73 | + sample_get_entry( |
| 74 | + args.project_id, args.location_id, args.entry_group_id, args.entry_id |
| 75 | + ) |
| 76 | + |
| 77 | + |
| 78 | +if __name__ == "__main__": |
| 79 | + main() |
0 commit comments