Giter Club home page Giter Club logo

Comments (6)

lukesneeringer avatar lukesneeringer commented on August 15, 2024

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.

lukesneeringer avatar lukesneeringer commented on August 15, 2024

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.

fhinkel avatar fhinkel commented on August 15, 2024

@lukesneeringer Can we close this?

from nodejs-storage.

frankyn avatar frankyn commented on August 15, 2024

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.

stephenplusplus avatar stephenplusplus commented on August 15, 2024

@frankyn did anything end up happening with the upstream feature request?

from nodejs-storage.

frankyn avatar frankyn commented on August 15, 2024

On an internal list but not scheduled this quarter.

from nodejs-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.