Skip to content

Commit

Permalink
Move storage samples.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Sep 22, 2017
1 parent 7cd93ef commit db7f182
Show file tree
Hide file tree
Showing 25 changed files with 135 additions and 2,565 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,17 @@ amount of data at any time.
View the [Cloud Storage Node.js samples][storage_samples].

[storage_docs]: https://cloud.google.com/storage/docs/
[storage_samples]: storage
[storage_samples]: https://github.com/googleapis/nodejs-storage/tree/master/samples

#### Google Cloud Storage Transfer API

The Google Cloud Storage Transfer API allows you to quickly import online data
into Google Cloud Storage.

View the [Cloud Storage Transfer API Node.js samples][transfer_samples].

[transfer_docs]: https://cloud.google.com/storage/transfer/
[transfer_samples]: storage-transfer

### Big Data

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ deployment:
- node scripts/build "resource"
- node scripts/build "spanner"
- node scripts/build "speech"
- node scripts/build "storage"
- node scripts/build "storage-transfer"
- node scripts/build "trace"
- node scripts/build "translate"
# TODO: This build times out. Does video need more than 10 minutes?
Expand Down
5 changes: 2 additions & 3 deletions scripts/clean
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ const args = process.argv.slice(2);
if (!args.length || args[0] === 'coverage') {
rm('-rf', 'coverage');
} else if (args[0] === 'buckets') {
const NAME_REG_EXP = /^nodejs-docs-samples-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;
const NAME_REG_EXP_2 = /^docs-samples-gae-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;
const NAME_REG_EXP = /^docs-samples-gae-test-[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/;

storage
.getBuckets()
.then(([buckets]) => {
let promise = Promise.resolve();

buckets
.filter((bucket) => NAME_REG_EXP.test(bucket.name) || NAME_REG_EXP_2.test(bucket.name))
.filter((bucket) => NAME_REG_EXP.test(bucket.name))
.forEach((bucket) => {
promise = promise.then(() => {
return bucket.deleteFiles()
Expand Down
68 changes: 68 additions & 0 deletions storage-transfer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>

# Google Cloud Storage Transfer API Node.js Samples

[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-storage-transfer.svg)]()

## Table of Contents

* [Setup](#setup)
* [Samples](#samples)
* [Storage Transfer API](#storage-transfer-api)
* [Running the tests](#running-the-tests)

## Setup

1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
1. Install dependencies:

With **npm**:

npm install

With **yarn**:

yarn install

[prereq]: ../README.md#prerequisites
[run]: ../README.md#how-to-run-a-sample

## Samples

### Storage Transfer API

View the [documentation][transfer_0_docs] or the [source code][transfer_0_code].

__Usage:__ `node transfer.js --help`

```
Commands:
jobs <cmd> [args] Run a job command.
operations <cmd> [args] Run an operation command.
Options:
--help Show help [boolean]
Examples:
node transfer.js jobs --help Show job commands.
node transfer.js operations --help Show operations commands.
For more information, see https://cloud.google.com/storage/transfer
```

[transfer_0_docs]: https://cloud.google.com/storage/transfer
[transfer_0_code]: transfer.js

## Running the tests

1. Set the **GCLOUD_PROJECT** and **GOOGLE_APPLICATION_CREDENTIALS** environment variables.

1. Run the tests:

With **npm**:

npm test

With **yarn**:

yarn test
49 changes: 49 additions & 0 deletions storage-transfer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "nodejs-docs-samples-storage-transfer",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google Inc.",
"repository": {
"type": "git",
"url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git"
},
"engines": {
"node": ">=4"
},
"scripts": {
"lint": "samples lint",
"pretest": "npm run lint",
"unit-test": "samples test run --cmd ava -- -T 20s --verbose test/*.test.js",
"system-test": "samples test run --cmd ava -- -T 20s --verbose system-test/*.test.js",
"test": "npm run unit-test && npm run system-test"
},
"dependencies": {
"@google-cloud/storage": "1.3.0",
"googleapis": "21.3.0",
"moment": "2.18.1",
"safe-buffer": "5.1.1",
"yargs": "9.0.1"
},
"devDependencies": {
"@google-cloud/nodejs-repo-tools": "1.4.17",
"ava": "0.22.0",
"proxyquire": "1.8.0",
"sinon": "3.3.0",
"uuid": "3.1.0"
},
"cloud-repo-tools": {
"requiresKeyFile": true,
"requiresProjectId": true,
"product": "storage",
"samples": [
{
"id": "transfer",
"name": "Storage Transfer API",
"file": "transfer.js",
"docs_link": "https://cloud.google.com/storage/transfer",
"usage": "node transfer.js --help"
}
]
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit db7f182

Please sign in to comment.