Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Last active October 22, 2019 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MylesBorins/abd31cbee43a0925319970837bf3a41a to your computer and use it in GitHub Desktop.
Save MylesBorins/abd31cbee43a0925319970837bf3a41a to your computer and use it in GitHub Desktop.
List Projects w/ googleapis
/*!
* Copyright 2019 Google LLC. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { google } = require('googleapis');
const functions = google.cloudfunctions('v1');
async function main() {
// Get service account from https://console.developers.google.com/apis/credentials
// export GOOGLE_APPLICATION_CREDENTIAL=/full/path/to/credentials.json
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
const projectId = await auth.getProjectId();
const client = await auth.getClient();
const res = await functions.projects.locations.functions.list({
parent: `projects/${projectId}/locations/-`,
auth: client
});
console.log(res.data);
}
main().catch(console.error);
{
"name": "list-functions",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"googleapis": "^44.0.0"
},
"license": "Apache-2.0"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment