Comments (6)
From @stephenplusplus on June 7, 2017 12:24
Thanks for the request! I wasn't familiar with Storage logging before this, so please excuse any incorrect assumptions I might make.
I believe you are requesting that we allow you to make requests to these endpoints-- #1630 actually is about allowing requests to go to a custom-defined host, but the URL path after would stay the same. However, we do have a method, request()
, that expects the same arguments as the npm request module, but we handle the authentication and basic plumbing. It is not an officially documented method, however, so there isn't a guarantee it will always work.
I went over the doc, and tried to match the raw HTTP requests they're making to our Storage methods:
var gcs = require('@google-cloud/storage')(...)
var bucket = gcs.bucket('my-bucket')
// POST /storage/v1/b/example-logs-bucket/acl
// Host: www.googleapis.com
// {
// "entity": "[email protected]",
// "role": "WRITER"
// }
bucket.acl.writers.addGroup('[email protected]', function() {})
// PATCH /storage/v1/b/example-bucket
// Host: www.googleapis.com
// {
// "logging": {
// "logBucket": "example-logs-bucket",
// "logObjectPrefix": "log_object_prefix"
// }
// }
bucket.setMetadata({
logging: {
logBucket: bucket.name,
logObjectPrefix: 'log_object_prefix'
}
}, function(err, apiResponse) {})
// GET /storage/v1/b/example-bucket?fields=logging
// Host: www.googleapis.com
bucket.getMetadata(function(err, metadata) {
// metadata.logging === logging configuration
})
// Getting logs:
bucket.getFiles({ prefix: 'log_object_prefix' }, function(err, files) {
// files === log files
})
We could consider adding a method to make enabling logging easier, i.e. bucket.enableLogging({ prefix: 'custom-prefix' })
. Did I miss anything you're looking for?
from nodejs-storage.
From @chrishiestand on June 16, 2017 0:56
Oops, guess I didn't look at these API calls closely enough to see that they map onto existing functions. Your solution looks like it will work just fine, thank you very much for taking the time to map those.
I don't think that it is necessary to add a convenience method, though if not it would be good to document these steps somewhere in the google-cloud-node docs https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/v0.55.0/storage - and funny enough, the easiest way to document it might be to add a convenience method?
from nodejs-storage.
@lukesneeringer Can we close this?
from nodejs-storage.
Hi thanks for pinging @JustinBeckwith,
The library supports this feature but isn't documented as a snippet.
However, the steps to enable Audit Logs requires multiple steps, I think it'd be helpful to create a small helper method to enables Access Logs. I'll file a FR request against the backlog to get it prioritized from the GCS team.
The helper method would be similar to what @stephenplusplus proposed with the small difference to allow a different log bucket to be used:
bucket.enableLogging({ logBucket: 'logs-bucket', prefix: 'custom-prefix' });
logBucket
doesn't need to be the same bucket as bucket.name
/example-bucket
.
from nodejs-storage.
@frankyn did anything end up happening with the upstream feature request?
from nodejs-storage.
On an internal list but not scheduled this quarter.
from nodejs-storage.
Related Issues (20)
- Unable to generate signedUrl when using WIF under GKE HOT 11
- File.from picks up incorrect bucket name from passed URL HOT 3
- FR: Support HNS enablement in bucket metadata
- CreateBucketRequest type is misaligned with JSON API
- storage HMAC keys: should get metadata for an HMAC key failed HOT 2
- storage HMAC keys: should make the key INACTIVE failed HOT 2
- tests: move HMAC system tests to use emulator
- storage bucket hierarchical namespace: should create a bucket without hierarchical namespace enabled (explicit) failed HOT 1
- Missing interface's property HOT 4
- storage HMAC keys: should delete the key failed
- Signed URL prefix HOT 1
- preconditions not working HOT 2
- File.save sometimes returns a Promise that never rejects or resolves HOT 10
- storage HMAC keys: should delete the key failed HOT 2
- File.save() with a Uint8Array fails HOT 9
- Methods that perform a fetch should throw any socket errors directly (ECONNRESET) HOT 12
- storage HMAC keys: should make the key INACTIVE failed HOT 4
- chore: remove internalTooling from eslint ignores once >= node 16
- How to set destination while using uploadManyFiles in TransferManager HOT 4
- Unhandled Error in startResumableUpload_ Function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-storage.