Update connection metadata

Update the metadata for an existing connection.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.cloud.bigquery.connection.v1.Connection;importcom.google.cloud.bigquery.connection.v1.ConnectionName;importcom.google.cloud.bigquery.connection.v1.UpdateConnectionRequest;importcom.google.cloud.bigqueryconnection.v1.ConnectionServiceClient;importcom.google.protobuf.FieldMask;importcom.google.protobuf.util.FieldMaskUtil;importjava.io.IOException;// Sample to update connectionpublicclassUpdateConnection{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.StringprojectId="MY_PROJECT_ID";Stringlocation="MY_LOCATION";StringconnectionId="MY_CONNECTION_ID";Stringdescription="MY_DESCRIPTION";Connectionconnection=Connection.newBuilder().setDescription(description).build();updateConnection(projectId,location,connectionId,connection);}staticvoidupdateConnection(StringprojectId,Stringlocation,StringconnectionId,Connectionconnection)throwsIOException{try(ConnectionServiceClientclient=ConnectionServiceClient.create()){ConnectionNamename=ConnectionName.of(projectId,location,connectionId);FieldMaskupdateMask=FieldMaskUtil.fromString("description");UpdateConnectionRequestrequest=UpdateConnectionRequest.newBuilder().setName(name.toString()).setConnection(connection).setUpdateMask(updateMask).build();Connectionresponse=client.updateConnection(request);System.out.println("Connection updated successfully :"+response.getDescription());}}}

What's next

To search and filter code samples for other Google Cloud products, see theGoogle Cloud sample browser.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.