// Returns an authorized API client by discovering the Cloud IoT Core API with // the provided API key. const getClient = async () => { const authClient = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); const discoveryUrl = `${DISCOVERY_API}?version=${API_VERSION}`; google.options({ auth: authClient, }); try { return google.discoverAPI(discoveryUrl); } catch (err) { console.log('Error during API discovery.', err); } }
// [END healthcare_patch_hl7v2_store] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
function main( projectId = process.env.GCLOUD_PROJECT, cloudRegion = 'us-central1' ) { // [START healthcare_list_datasets] const {google} = require('googleapis'); const healthcare = google.healthcare('v1beta1'); async function listDatasets() { const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth}); // TODO(developer): uncomment these lines before running the sample // const cloudRegion = 'us-central1'; // const projectId = 'adjective-noun-123'; const parent = `projects/${projectId}/locations/${cloudRegion}`; const request = {parent}; const dataset = await healthcare.projects.locations.datasets.list(request); console.log(dataset.data); } listDatasets(); // [END healthcare_list_datasets] }
// Acquires credentials google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(auth => { // Instantiates an authorized client const cloudkms = google.cloudkms({ version: 'v1', auth, }); const request = { parent: `projects/${projectId}/locations/${location}`, }; // Lists key rings cloudkms.projects.locations.keyRings.list(request, (err, result) => { if (err) { console.error(err); return; } const keyRings = result.data.keyRings || []; if (keyRings.length) { console.log('Key rings:'); keyRings.forEach(keyRing => console.log(keyRing.name)); } else { console.log(`No key rings found.`); } }); });
const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], });
const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], });
function main( projectId = process.env.GCLOUD_PROJECT, cloudRegion = 'us-central1', datasetId ) { // [START healthcare_delete_dataset] const {google} = require('googleapis'); const healthcare = google.healthcare('v1beta1'); async function deleteDataset() { const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth}); // TODO(developer): uncomment these lines before running the sample // const cloudRegion = 'us-central1'; // const projectId = 'adjective-noun-123'; // const datasetId = 'my-dataset'; const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`; const request = {name: parent}; await healthcare.projects.locations.datasets.delete(request); console.log(`Deleted dataset: ${datasetId}`); } deleteDataset(); // [END healthcare_delete_dataset] }
const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], });
function main( projectId = process.env.GCLOUD_PROJECT, cloudRegion = 'us-central1', datasetId ) { // [START healthcare_get_dataset] const {google} = require('googleapis'); const healthcare = google.healthcare('v1beta1'); async function getDataset() { const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth}); // TODO(developer): uncomment these lines before running the sample // const cloudRegion = 'us-central1'; // const projectId = 'adjective-noun-123'; // const datasetId = 'my-dataset'; const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`; const request = {name: parent}; const dataset = await healthcare.projects.locations.datasets.get(request); console.log(dataset.data); } getDataset(); // [END healthcare_get_dataset] }
const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], });
function main( projectId = process.env.GCLOUD_PROJECT, cloudRegion = 'us-central1', datasetId ) { // [START healthcare_create_dataset] const {google} = require('googleapis'); const healthcare = google.healthcare('v1beta1'); async function createDataset() { const auth = await google.auth.getClient({ scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth}); // TODO(developer): uncomment these lines before running the sample // const cloudRegion = 'us-central1'; // const projectId = 'adjective-noun-123'; // const datasetId = 'my-dataset'; const parent = `projects/${projectId}/locations/${cloudRegion}`; const request = {parent, datasetId}; await healthcare.projects.locations.datasets.create(request); console.log(`Created dataset: ${datasetId}`); } createDataset(); // [END healthcare_create_dataset] }
// Returns an authorized API client by discovering the Cloud IoT Core API with // the provided API key. const getClient = async serviceAccountJson => { // the getClient method looks for the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS // environment variables if serviceAccountJson is not passed in const authClient = await google.auth.getClient({ keyFilename: serviceAccountJson, scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); const discoveryUrl = `${DISCOVERY_API}?version=${API_VERSION}`; google.options({ auth: authClient, }); try { return google.discoverAPI(discoveryUrl); } catch (err) { console.log('Error during API discovery.', err); } }
// [END healthcare_patch_hl7v2_message] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
// [END healthcare_get_fhir_store_metadata] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }
// [END healthcare_export_dicom_instance_gcs] // Returns an authorized API client by discovering the Healthcare API with // the provided API key. // [START healthcare_get_client] function getClient(apiKey, serviceAccountJson, cb) { const API_VERSION = 'v1alpha'; const DISCOVERY_API = 'https://healthcare.googleapis.com/$discovery/rest'; google.auth .getClient({scopes: ['https://www.googleapis.com/auth/cloud-platform']}) .then(authClient => { const discoveryUrl = `${DISCOVERY_API}?labels=CHC_ALPHA&version=${API_VERSION}&key=${apiKey}`; google.options({auth: authClient}); google .discoverAPI(discoveryUrl) .then(client => { cb(client); }) .catch(err => { console.error(err); }); }); }