Skip to content

v0.25.0

Compare
Choose a tag to compare
@stephenplusplus stephenplusplus released this 01 Dec 19:21

Updating

$ npm install gcloud@0.25

⚠️ Breaking Changes

Creating a BigQuery table: parameters changed!

Previously:

dataset.createTable({
  id: 'new-table-id',
  // ...
}, function(err, table, apiResponse) {});

Now:

dataset.createTable('new-table-id', [options], function(err, table, apiResponse) {});
Compute Engine operations are now event emitters

#921, #939

Previously:

operation.onComplete(function(err, metadata) {
  // metadata is the result of the operation.
});

Now:

operation.on('complete', function(metadata) {
  // `metadata` is the result of the operation.
});

Also, we now parse the results of the operation and consider an operation failure an error. Listen for the error event to catch these errors, as well as anything else that might go wrong during an API call.

operation.on('error', function(err) {
  // The operation may have failed.
});

🎈 New methods available! 🎉

#928, #931, #932, #942, #943, #944, #945, #946

All* of our APIs have new methods that might be more useful for you! Our paradigm so far has looked like this:

Service (e.g. BigQuery, Storage)
|_ Object (e.g. a BigQuery dataset, a Storage bucket)

An object can typically be created or "gotten"-- a vague term to describe two things, depending on your use case:

  1. Simply reference an object. This has no async side effects.

    var gcs = gcloud.storage();
    var bucket = storage.bucket('i-know-this-bucket-exists');
  2. Get information about an object.

    var gcs = gcloud.storage();
    var bucket = storage.bucket('i-know-this-bucket-exists');
    
    bucket.getMetadata(function(err, metadata) {
    // `metadata` contains information about this bucket.
    });

There was a bit of confusion around this, though. Like, is that really the only way to check if something exists? Seeing if there was an error with a 404 returned? What if I want to get a bucket, otherwise have it created?

Check out the examples below to see some before and afters with these use cases in mind.

Previously:

function createTopic() {
  pubsub.createTopic('new-topic-name', function(err, topic, apiResponse) {
    // Topic created!
  });
}

function doesBucketExist() {
  bucket.getMetadata(function(err, apiResponse) {
    if (err.code === 404) {
      // Bucket doesn't exist!
    }
  });
}

function getDataset() {
  dataset.getMetadata(function(err, metadata, apiResponse) {
    // dataset.metadata is populated.
  });
}

function getOrCreateDataset() {
  dataset.getMetadata(function(err) {
    if (err && err.code === 404) {
      bigQuery.createDataset(dataset.name, function(err, dataset) {
        // Dataset created!
      });
    }
  });
}

Now:

function createTopic() {
  topic.create(function(err, topic, apiResponse) {
    // Topic created!
  });
}

function doesBucketExist() {
  bucket.exists(function(err, exists) {
    if (exists) {
      // Bucket exists!
    }
  });
}

function getDataset() {
  dataset.get(function(err, dataset, apiResponse) {
    // dataset.metadata is populated.
  });
}

function getOrCreateDataset() {
  dataset.get({ autoCreate: true }, function(err, dataset, apiResponse) {
    // Dataset exists and is ready to use!
  });
}

NOTE The old methods are still supported and will continue to be.

* All except Datastore. For now.

Fixes

  • Compute (#922, #929): Get a disk's device name when detaching it.
  • Datastore (#936, #940): Don't require auth when using a local Datastore server.

Features

  • Core (#923): Return better API errors.
  • Compute (#927, #930): When creating a VM, default the created disk to delete automatically when the VM is deleted.
  • BigQuery (#941, #948): Allow configuration of a dataset when created.
  • Pub/Sub (#949, #951): Allow configuration of a subscription when created.

Thank you!

This release is, well, huge. And an equal-sized thank you needs to be sent to the folks that helped us catch bugs and improve this library for the rest of us. In no specific order, please high five these people next time you pass them in the halls:

If you catch any regressions, please open an issue. See the Contributing guide for how to get started.