définir le point de terminaison du service
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Cet exemple montre comment définir un autre point de terminaison lorsque vous utilisez les bibliothèques clientes BigQuery.
Exemple de code
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page demonstrates how to configure an alternate endpoint when utilizing the BigQuery client libraries in both Go and Node.js.\u003c/p\u003e\n"],["\u003cp\u003eThe Go code sample illustrates the use of \u003ccode\u003ebigquery.NewClient\u003c/code\u003e with \u003ccode\u003eoption.WithEndpoint\u003c/code\u003e to set a custom endpoint.\u003c/p\u003e\n"],["\u003cp\u003eThe Node.js code sample shows how to create a BigQuery client with a specific API endpoint using the \u003ccode\u003eapiEndpoint\u003c/code\u003e configuration.\u003c/p\u003e\n"],["\u003cp\u003eBoth code samples are referencing the client libraries and require authentication by setting up Application Default Credentials.\u003c/p\u003e\n"]]],[],null,["# set the service endpoint\n\nThis sample demonstrates how to set an alternate endpoint when using the BigQuery client libraries.\n\nCode sample\n-----------\n\n### Go\n\n\nBefore trying this sample, follow the Go setup instructions in the\n[BigQuery quickstart using\nclient libraries](/bigquery/docs/quickstarts/quickstart-client-libraries).\n\n\nFor more information, see the\n[BigQuery Go API\nreference documentation](https://godoc.org/cloud.google.com/go/bigquery).\n\n\nTo authenticate to BigQuery, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for client libraries](/bigquery/docs/authentication#client-libs).\n\n import (\n \t\"context\"\n \t\"fmt\"\n\n \t\"cloud.google.com/go/bigquery\"\n \t\"google.golang.org/api/option\"\n )\n\n // setClientEndpoint creates a bigquery.Client pointing\n // to a specific endpoint.\n func setClientEndpoint(endpoint, projectID string) (*bigquery.Client, error) {\n \t// projectID := \"my-project-id\"\n \t// endpoint := \"https://bigquery.googleapis.com/bigquery/v2/\n \tctx := context.Background()\n \tclient, err := bigquery.NewClient(ctx, projectID, option.WithEndpoint(endpoint))\n \tif err != nil {\n \t\treturn nil, fmt.Errorf(\"bigquery.NewClient: %w\", err)\n \t}\n \tdefer client.Close()\n\n \treturn client, nil\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[BigQuery quickstart using\nclient libraries](/bigquery/docs/quickstarts/quickstart-client-libraries).\n\n\nFor more information, see the\n[BigQuery Node.js API\nreference documentation](https://googleapis.dev/nodejs/bigquery/latest/index.html).\n\n\nTo authenticate to BigQuery, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for client libraries](/bigquery/docs/authentication#client-libs).\n\n // Import the Google Cloud client library\n const {BigQuery} = require('https://cloud.google.com/nodejs/docs/reference/bigquery/latest/overview.html');\n\n function setClientEndpoint() {\n // Create a bigquery client pointing to a specific endpoint\n\n /**\n * TODO(developer): Uncomment the following line of code and fill in your region before running the sample.\n */\n // const region = 'my-region';\n\n const bigquery = new https://cloud.google.com/nodejs/docs/reference/bigquery/latest/bigquery/bigquery.html({\n apiEndpoint: `${region}-bigquery.googleapis.com`,\n });\n\n console.log('API Endpoint:');\n console.log(bigquery.apiEndpoint);\n }\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigquery)."]]