Skip to content

Commit 8af66de

Browse files
jmdobryalexander-fenster
authored andcommitted
Upgrade repo-tools and regenerate scaffolding. (#21)
* Upgrade repo-tools and regenerate scaffolding. * make lint task work in circleci
1 parent b7b613e commit 8af66de

File tree

8 files changed

+14107
-13
lines changed

8 files changed

+14107
-13
lines changed

packages/google-cloud-bigquery-datatransfer/.circleci/config.yml

+9
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ jobs:
113113
npm link
114114
environment:
115115
NPM_CONFIG_PREFIX: /home/node/.npm-global
116+
- run:
117+
name: Link the module being tested to the samples.
118+
command: |
119+
cd samples/
120+
npm link ../
121+
npm install
122+
cd ..
123+
environment:
124+
NPM_CONFIG_PREFIX: /home/node/.npm-global
116125
- run:
117126
name: Run linting.
118127
command: npm run lint

packages/google-cloud-bigquery-datatransfer/.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
.nyc_output
55
docs/
66
out/
7+
build/
78
system-test/secrets.js
89
system-test/*key.json
910
*.lock
10-
*-lock.js*
11+
.DS_Store
12+
google-cloud-logging-winston-*.tgz
13+
google-cloud-logging-bunyan-*.tgz

packages/google-cloud-bigquery-datatransfer/README.md

+53-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,58 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
5959

6060
npm install --save @google-cloud/bigquery-data-transfer
6161

62+
### Using the client library
63+
64+
```javascript
65+
66+
if (
67+
!process.env.GCLOUD_PROJECT ||
68+
!process.env.GOOGLE_APPLICATION_CREDENTIALS
69+
) {
70+
throw new Error(
71+
'Usage: GCLOUD_PROJECT=<project_id> GOOGLE_APPLICATION_CREDENTIALS=<path to key json file> node #{$0}'
72+
);
73+
}
74+
75+
const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer');
76+
77+
const client = new bigqueryDataTransfer.v1.DataTransferServiceClient({
78+
// optional auth parameters.
79+
});
80+
const projectId = process.env.GCLOUD_PROJECT;
81+
82+
// Iterate over all elements.
83+
const formattedParent = client.locationPath(projectId, 'us-central1');
84+
85+
client.listDataSources({parent: formattedParent}).then(responses => {
86+
const resources = responses[0];
87+
for (let i = 0; i < resources.length; i += 1) {
88+
console.log(resources[i]);
89+
}
90+
});
91+
92+
const options = {autoPaginate: false};
93+
const callback = responses => {
94+
// The actual resources in a response.
95+
const resources = responses[0];
96+
// The next request if the response shows that there are more responses.
97+
const nextRequest = responses[1];
98+
// The actual response object, if necessary.
99+
// const rawResponse = responses[2];
100+
for (let i = 0; i < resources.length; i += 1) {
101+
console.log(resources[i]);
102+
}
103+
if (nextRequest) {
104+
// Fetch the next page.
105+
return client.listDataSources(nextRequest, options).then(callback);
106+
}
107+
};
108+
client.listDataSources({parent: formattedParent}, options).then(callback);
109+
110+
client.listDataSourcesStream({parent: formattedParent}).on('data', element => {
111+
console.log(element);
112+
});
113+
```
62114

63115

64116
The [BigQuery Data Transfer Service Node.js Client API Reference][client-docs] documentation
@@ -88,4 +140,4 @@ See [LICENSE](https://github.com/googleapis/nodejs-bigquery-data-transfer/blob/m
88140

89141
[client-docs]: https://cloud.google.com/nodejs/docs/reference/bigquery-data-transfer/latest/
90142
[product-docs]: https://cloud.google.com/bigquery/docs/reference/datatransfer/rest/
91-
[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png
143+
[shell_img]: //gstatic.com/cloudssh/images/open-btn.png

0 commit comments

Comments
 (0)