}); google.options({auth, headers: {'Content-Type': 'application/fhir+json'}});
google.options({auth, headers: {'Content-Type': 'application/json-patch+json'}});
}; google.options({auth, headers: {'Content-Type': 'application/fhir+json'}});
// 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); } }
/** * @return {Promise} Credentials set globally */ const _setAuthCredential = async () => { const res = await auth.getApplicationDefault(); let client = res.credential; if (client.hasScopes && !client.hasScopes()) { client = client.createScoped([ 'https://www.googleapis.com/auth/cloud-billing', 'https://www.googleapis.com/auth/cloud-platform', ]); } // Set credential globally for all requests google.options({ auth: client, }); }
// [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); }); }); }
scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth});
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] }
scopes: ['https://www.googleapis.com/auth/cloud-platform'], }); google.options({auth});
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] }
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] }
// 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_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_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); }); }); }
// [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); }); }); }