-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbigquery.tables.list.snippet.json
1 lines (1 loc) · 7.1 KB
/
bigquery.tables.list.snippet.json
1
{"metadata":{"apiName":"bigquery","apiVersion":"v2","fragmentGenerationVersion":"0.1","generatedOn":"1-21-2016"},"code_fragment":{"Java":"// Autogenerated example code for bigquery.tables.list\r\n\r\n// PRE-REQUISITES:\r\n// ---------------\r\n// 1. If not already done, enable bigquery Api and check quota for your project at\r\n// https://console.developers.google.com/apis/api/bigquery/quotas \r\n// 2. To install the client library on maven or gradle, check installation instructions at \r\n// https://github.com/google/google-api-java-client. \r\n// On other build systems, you can add the jar files to your project from \r\n// https://developers.google.com/resources/api-libraries/download/bigquery/v2/java\r\n// 3. This sample uses Application Default Credentials for Auth. If not already done, install gcloud CLI from \r\n// https://cloud.google.com/sdk/ and run 'gcloud auth login'\r\n\r\nimport com.google.api.client.googleapis.auth.oauth2.GoogleCredential;\r\nimport com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;\r\nimport com.google.api.client.http.HttpTransport;\r\nimport com.google.api.client.json.JsonFactory;\r\nimport com.google.api.client.json.jackson2.JacksonFactory;\r\nimport com.google.api.services.bigquery.Bigquery;\r\nimport com.google.api.services.bigquery.model.*;\r\n\r\nimport java.io.IOException;\r\nimport java.security.GeneralSecurityException;\r\nimport java.util.Collections;\r\n\r\npublic class BigquerySample {\r\n\tpublic static void main(String[] args) throws IOException, GeneralSecurityException {\r\n\t\t// Authentication is provided by gcloud tool when running locally\r\n\t\t// and by built-in service accounts when running on GAE, GCE or GKE.\r\n\t\tGoogleCredential credential = GoogleCredential.getApplicationDefault();\r\n\t\t\t \r\n\t\t// The createScopedRequired method returns true when running on GAE or a local developer\r\n\t\t// machine. In that case, the desired scopes must be passed in manually. When the code is\r\n\t\t// running in GCE, GKE or a Managed VM, the scopes are pulled from the GCE metadata server.\r\n\t\t// See https://developers.google.com/identity/protocols/application-default-credentials for more information.\r\n\t\tif (credential.createScopedRequired()) {\r\n\t\t\tcredential = credential.createScoped(Collections.singletonList(\"https://www.googleapis.com/auth/cloud-platform\"));\r\n\t\t}\r\n\t\t\t\t\r\n\t\tHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();\r\n\t\tJsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); \r\n\t\tBigquery bigqueryService = new Bigquery.Builder(httpTransport, jsonFactory, credential)\r\n\t\t\t.setApplicationName(\"Google Cloud Platform Sample\")\r\n\t\t\t.build();\r\n\r\n\t\tTableList response;\r\n\t\tBigquery.Tables.List request = bigqueryService.tables().list(\"example-project\", \"example-datasetId\");\r\n\t\tdo {\r\n\t\t\tresponse = request.execute();\r\n\t\t\tif(response.getTables() == null)\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tfor (Object item : response.getTables()){\r\n\t\t\t\t// Add your code to process the item object\r\n\t\t\t}\r\n\r\n\t\t\trequest.setPageToken(response.getNextPageToken());\r\n\t\t} while (null != response.getNextPageToken());\r\n\t}\r\n}","Python":"# Autogenerated example code for bigquery.tables.list\r\n\r\n# PRE-REQUISITES:\r\n# ---------------\r\n# 1. If not already done, enable bigquery Api and check quota for your project at\r\n# https://console.developers.google.com/apis/api/bigquery/quotas \r\n# 2. Install python client library for Google APIs using 'pip install --upgrade google-api-python-client'.\r\n# 3. This sample uses Application Default Credentials for Auth. If not already done, install gcloud CLI from \r\n# https://cloud.google.com/sdk/ and run 'gcloud auth login'\r\n\r\n\r\nfrom apiclient import discovery\r\nfrom oauth2client.client import GoogleCredentials\r\nimport json\r\n\r\n# Authentication is provided by gcloud tool when running locally\r\n# and by built-in service accounts when running on GAE, GCE or GKE.\r\n# See https://developers.google.com/identity/protocols/application-default-credentials\r\n# for more information.\r\ncredentials = GoogleCredentials.get_application_default()\r\n\r\n# Construct the service object for interacting with the Compute API -\r\n# the 'bigquery' service, at version 'v2'.\r\n# You can browse other available api services and versions here:\r\n# https://developers.google.com/api-client-library/python/apis/\r\nservice = discovery.build('bigquery', 'v2', credentials=credentials)\r\n\r\nrequest = service.tables().list(projectId=\"example-project\", datasetId=\"example-datasetId\")\r\nwhile request:\r\n response = request.execute()\r\n # Add code to process instance\r\n print(json.dumps(response, indent=2))\r\n request = service.tables().list_next(request, response)","Go":null,"NodeJs":null,"C#":"// Autogenerated example code for bigquery.tables.list\r\n\r\n// PRE-REQUISITES:\r\n// ---------------\r\n// 1. If not already done, enable bigquery Api and check quota for your project at\r\n// https://console.developers.google.com/apis/api/bigquery/quotas \r\n// 2. Use the nuget package manager to install the package Google.Apis.bigquery.v2\r\n// 3. This sample uses Application Default Credentials for Auth. If not already done, install gcloud CLI from \r\n// https://cloud.google.com/sdk/ and run 'gcloud auth login'\r\n\r\nusing Google.Apis.Bigquery.v2;\r\nusing Google.Apis.Bigquery.v2.Data;\r\nusing Google.Apis.Auth.OAuth2;\r\nusing Google.Apis.Services;\r\nusing System;\r\n\r\nclass BigquerySample\r\n{\r\n static void Main()\r\n {\r\n // Authentication is provided by gcloud tool when running locally\r\n // and by built-in service accounts when running on GAE, GCE or GKE.\r\n GoogleCredential credential = GoogleCredential.GetApplicationDefaultAsync().Result;\r\n\r\n // The createScopedRequired method returns true when running on GAE or a local developer\r\n // machine. In that case, the desired scopes must be passed in manually. When the code is\r\n // running in GCE, GKE or a Managed VM, the scopes are pulled from the GCE metadata server.\r\n // See https://developers.google.com/identity/protocols/application-default-credentials for more information.\r\n if (credential.IsCreateScopedRequired)\r\n {\r\n credential = credential.CreateScoped(new[] { \"https://www.googleapis.com/auth/cloud-platform\" });\r\n }\r\n\r\n var bigqueryService = new BigqueryService(new BaseClientService.Initializer() { HttpClientInitializer = credential });\r\n\r\n TableList response;\r\n var request = bigqueryService.Tables.List(\"example-project\", \"example-datasetId\");\r\n do\r\n {\r\n response = request.Execute();\r\n if (response.Tables == null)\r\n continue;\r\n\r\n foreach (var item in response.Tables)\r\n {\r\n // Add your code to process the item object\r\n }\r\n\r\n request.PageToken = response.NextPageToken;\r\n } while (response.NextPageToken != null);\r\n }\r\n}","Ruby":null,"PHP":null}}