Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
irataxy committed Sep 11, 2024
1 parent 0ca1215 commit 0cc6c9e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
23 changes: 16 additions & 7 deletions aml-ai/listLocations.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

'use strict';

const main = (projectId = process.env.GOOGLE_CLOUD_PROJECT) => {
const main = async () => {
// [START antimoneylaunderingai_list_locations]
// Import google-auth-library for authentication.
const {GoogleAuth} = require('google-auth-library');
Expand All @@ -25,17 +25,26 @@ const main = (projectId = process.env.GOOGLE_CLOUD_PROJECT) => {
scopes: 'https://www.googleapis.com/auth/cloud-platform',
headers: {'Content-Type': 'application/json; charset=utf-8'},
});
// TODO(developer): uncomment these lines before running the sample
// const projectId = 'my-project-id';
// TODO(developer): update the project ID as needed
const projectId = process.env.GOOGLE_CLOUD_PROJECT;
const url = `https://financialservices.googleapis.com/v1/projects/${projectId}/locations`;
const client = await auth.getClient();
const response = await client.request({url, method: 'GET'});
let response;
try {
response = await client.request({url, method: 'GET'});
} catch (err) {
throw new Error(`API request failed: ${err}`);
}

console.log(JSON.stringify(response.data));
};

listLocations();
return await listLocations();
// [END antimoneylaunderingai_list_locations]
};

// node listLocations.js <projectId>
main(...process.argv.slice(2));
// node listLocations.js
main().catch(err => {
console.log(err);
process.exitCode = 1;
});
3 changes: 1 addition & 2 deletions aml-ai/system-test/aml-ai.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ const cwd = path.join(__dirname, '..');
const {execSync} = require('child_process');
const {it} = require('mocha');

const projectId = process.env.GCLOUD_PROJECT;
const cloudRegion = 'us-central1';

it('should get the AML AI API locations', () => {
const output = execSync(`node listLocations.js ${projectId}`, {cwd});
const output = execSync('node listLocations.js', {cwd});
assert.ok(output.includes(cloudRegion));
});

0 comments on commit 0cc6c9e

Please sign in to comment.