definir o endpoint do serviço
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Veja neste exemplo como configurar um endpoint alternativo ao usar as bibliotecas de cliente do BigQuery.
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","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)."]]