def main(project_id: str = "your-project-id", location: str = "US") -> None:
    """Prints details and summary information about connections for a given admin project and location"""
    client = bq_connection.ConnectionServiceClient()
    print(
        f"List of connections in project {project_id} in location {location}")
    req = bq_connection.ListConnectionsRequest(
        parent=client.common_location_path(project_id, location))
    for connection in client.list_connections(request=req):
        print(f"\tConnection {connection.friendly_name} ({connection.name})")
Ejemplo n.º 2
0
def sample_delete_connection():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = bigquery_connection_v1.DeleteConnectionRequest(
        name="name_value", )

    # Make the request
    client.delete_connection(request=request)
Ejemplo n.º 3
0
def sample_set_iam_policy():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = iam_policy_pb2.SetIamPolicyRequest(resource="resource_value", )

    # Make the request
    response = client.set_iam_policy(request=request)

    # Handle the response
    print(response)
def sample_get_connection():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = bigquery_connection_v1.GetConnectionRequest(name="name_value", )

    # Make the request
    response = client.get_connection(request=request)

    # Handle the response
    print(response)
Ejemplo n.º 5
0
def sample_create_connection():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = bigquery_connection_v1.CreateConnectionRequest(
        parent="parent_value", )

    # Make the request
    response = client.create_connection(request=request)

    # Handle the response
    print(response)
Ejemplo n.º 6
0
def sample_test_iam_permissions():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = iam_policy_pb2.TestIamPermissionsRequest(
        resource="resource_value",
        permissions=['permissions_value_1', 'permissions_value_2'],
    )

    # Make the request
    response = client.test_iam_permissions(request=request)

    # Handle the response
    print(response)
def create_mysql_connection(
    project_id: str,
    location: str,
    cloud_sql_properties: bq_connection.CloudSqlProperties,
) -> None:
    connection = bq_connection.types.Connection(
        {"cloud_sql": cloud_sql_properties})
    client = bq_connection.ConnectionServiceClient()
    parent = client.common_location_path(project_id, location)
    request = bq_connection.CreateConnectionRequest({
        "parent": parent,
        "connection": connection
    })
    response = client.create_connection(request)
    print(f"Created connection successfully: {response.name}")
def sample_list_connections():
    # Create a client
    client = bigquery_connection_v1.ConnectionServiceClient()

    # Initialize request argument(s)
    request = bigquery_connection_v1.ListConnectionsRequest(
        parent="parent_value",
        page_size=951,
    )

    # Make the request
    page_result = client.list_connections(request=request)

    # Handle the response
    for response in page_result:
        print(response)