github.com/apache/beam/sdks/v2@v2.48.2/python/apache_beam/io/gcp/resource_identifiers.py (about) 1 # 2 # Licensed to the Apache Software Foundation (ASF) under one or more 3 # contributor license agreements. See the NOTICE file distributed with 4 # this work for additional information regarding copyright ownership. 5 # The ASF licenses this file to You under the Apache License, Version 2.0 6 # (the "License"); you may not use this file except in compliance with 7 # the License. You may obtain a copy of the License at 8 # 9 # http://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 18 """Helper functions to generate resource labels strings for GCP entitites 19 20 These can be used on MonitoringInfo 'resource' labels. 21 22 See example entities: 23 https://s.apache.org/beam-gcp-debuggability 24 25 For GCP entities, populate the RESOURCE label with the aip.dev/122 format: 26 https://google.aip.dev/122 27 28 If an official GCP format does not exist, try to use the following format. 29 //whatever.googleapis.com/parents/{parentId}/whatevers/{whateverId} 30 """ 31 32 33 def BigQueryTable(project_id, dataset_id, table_id): 34 return '//bigquery.googleapis.com/projects/%s/datasets/%s/tables/%s' % ( 35 project_id, dataset_id, table_id) 36 37 38 def GoogleCloudStorageBucket(bucket_id): 39 return '//storage.googleapis.com/buckets/%s' % bucket_id 40 41 42 def DatastoreNamespace(project_id, namespace_id): 43 return '//bigtable.googleapis.com/projects/%s/namespaces/%s' % ( 44 project_id, namespace_id) 45 46 47 def SpannerTable(project_id, database_id, table_id): 48 return '//spanner.googleapis.com/projects/%s/topics/%s/tables/%s' % ( 49 project_id, database_id, table_id) 50 51 52 def SpannerSqlQuery(project_id, query_name): 53 return '//spanner.googleapis.com/projects/%s/queries/%s' % ( 54 project_id, query_name) 55 56 57 def BigtableTable(project_id, instance_id, table_id): 58 return '//bigtable.googleapis.com/projects/%s/instances/%s/tables/%s' % ( 59 project_id, instance_id, table_id)