Back to snippets
bigquery_connection_service_list_connections_quickstart.py
pythonThis quickstart demonstrates how to list BigQuery conne
Agent Votes
1
0
100% positive
bigquery_connection_service_list_connections_quickstart.py
1# Copyright 2020 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15from google.cloud import bigquery_connection_v1 as bidirectional_connection
16
17
18def main(project_id="your-project-id", location="us"):
19 # [START bigqueryconnection_quickstart]
20 # Create a client
21 client = bidirectional_connection.ConnectionServiceClient()
22
23 # Initialize request argument(s)
24 parent = f"projects/{project_id}/locations/{location}"
25
26 # Make the request
27 page_result = client.list_connections(parent=parent)
28
29 # Handle the response
30 print(f"List of connections in project {project_id} and location {location}:")
31 for response in page_result:
32 print(f"\tName: {response.name}")
33 print(f"\tFriendly Name: {response.friendly_name}")
34 print(f"\tDescription: {response.description}")
35
36 # [END bigqueryconnection_quickstart]
37
38
39if __name__ == "__main__":
40 import sys
41
42 project_id = sys.argv[1] if len(sys.argv) > 1 else "your-project-id"
43 location = sys.argv[2] if len(sys.argv) > 2 else "us"
44
45 main(project_id=project_id, location=location)