({projectId, keyFilename})
| 48 | }; |
| 49 | |
| 50 | const authCloudExplicit = async ({projectId, keyFilename}) => { |
| 51 | // [START auth_cloud_explicit] |
| 52 | // Imports the Google Cloud client library. |
| 53 | const {Storage} = require('@google-cloud/storage'); |
| 54 | |
| 55 | // Instantiates a client. Explicitly use service account credentials by |
| 56 | // specifying the private key file. All clients in google-cloud-node have this |
| 57 | // helper, see https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/docs/authentication.md |
| 58 | // const projectId = 'project-id' |
| 59 | // const keyFilename = '/path/to/keyfile.json' |
| 60 | const storage = new Storage({projectId, keyFilename}); |
| 61 | |
| 62 | // Makes an authenticated API request. |
| 63 | async function listBuckets() { |
| 64 | try { |
| 65 | const [buckets] = await storage.getBuckets(); |
| 66 | |
| 67 | console.log('Buckets:'); |
| 68 | buckets.forEach(bucket => { |
| 69 | console.log(bucket.name); |
| 70 | }); |
| 71 | } catch (err) { |
| 72 | console.error('ERROR:', err); |
| 73 | } |
| 74 | } |
| 75 | listBuckets(); |
| 76 | // [END auth_cloud_explicit] |
| 77 | }; |
| 78 | |
| 79 | const cli = require('yargs') |
| 80 | .demand(1) |
nothing calls this directly
no test coverage detected