From d260e79d147be1a2575c7e9c52eb932578d361d5 Mon Sep 17 00:00:00 2001 From: Alexander Fenster Date: Fri, 15 Dec 2017 16:27:02 -0800 Subject: [PATCH] Releasing new library (#2) * Releasing version 0.1.0 --- .../.appveyor.yml | 20 ++ .../.circleci/config.yml | 173 +++++++++++++++ .../.circleci/key.json.enc | Bin 0 -> 2368 bytes .../.cloud-repo-tools.json | 7 + .../.eslintignore | 3 + .../.eslintrc.yml | 13 ++ .../.gitignore | 10 + .../.jsdoc.js | 45 ++++ .../google-cloud-bigquery-datatransfer/.nycrc | 26 +++ .../.prettierignore | 3 + .../.prettierrc | 8 + .../CODE_OF_CONDUCT.md | 43 ++++ .../CONTRIBUTORS | 7 + .../LICENSE | 202 ++++++++++++++++++ .../README.md | 122 ++++++++--- .../package.json | 53 +++-- .../samples/.eslintrc.yml | 3 + .../samples/quickstart.js | 63 ++++++ .../smoke-test/.eslintrc.yml | 6 + .../data_transfer_service_smoke_test.js | 94 ++++++++ .../src/index.js | 18 +- .../src/v1/data_transfer_service_client.js | 174 +++++++-------- .../system-test/.eslintrc.yml | 6 + .../test/.eslintrc.yml | 5 + .../test/gapic-v1.js | 197 ++++++++++++----- 25 files changed, 1100 insertions(+), 201 deletions(-) create mode 100644 packages/google-cloud-bigquery-datatransfer/.appveyor.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/.circleci/config.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/.circleci/key.json.enc create mode 100644 packages/google-cloud-bigquery-datatransfer/.cloud-repo-tools.json create mode 100644 packages/google-cloud-bigquery-datatransfer/.eslintignore create mode 100644 packages/google-cloud-bigquery-datatransfer/.eslintrc.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/.gitignore create mode 100644 packages/google-cloud-bigquery-datatransfer/.jsdoc.js create mode 100644 packages/google-cloud-bigquery-datatransfer/.nycrc create mode 100644 packages/google-cloud-bigquery-datatransfer/.prettierignore create mode 100644 packages/google-cloud-bigquery-datatransfer/.prettierrc create mode 100644 packages/google-cloud-bigquery-datatransfer/CODE_OF_CONDUCT.md create mode 100644 packages/google-cloud-bigquery-datatransfer/CONTRIBUTORS create mode 100644 packages/google-cloud-bigquery-datatransfer/LICENSE create mode 100644 packages/google-cloud-bigquery-datatransfer/samples/.eslintrc.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/samples/quickstart.js create mode 100644 packages/google-cloud-bigquery-datatransfer/smoke-test/.eslintrc.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/smoke-test/data_transfer_service_smoke_test.js create mode 100644 packages/google-cloud-bigquery-datatransfer/system-test/.eslintrc.yml create mode 100644 packages/google-cloud-bigquery-datatransfer/test/.eslintrc.yml diff --git a/packages/google-cloud-bigquery-datatransfer/.appveyor.yml b/packages/google-cloud-bigquery-datatransfer/.appveyor.yml new file mode 100644 index 00000000000..24082152655 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/.appveyor.yml @@ -0,0 +1,20 @@ +environment: + matrix: + - nodejs_version: 8 + +install: + - ps: Install-Product node $env:nodejs_version + - npm install -g npm # Force using the latest npm to get dedupe during install + - set PATH=%APPDATA%\npm;%PATH% + - npm install --force --ignore-scripts + +test_script: + - node --version + - npm --version + - npm rebuild + - npm test + +build: off + +matrix: + fast_finish: true diff --git a/packages/google-cloud-bigquery-datatransfer/.circleci/config.yml b/packages/google-cloud-bigquery-datatransfer/.circleci/config.yml new file mode 100644 index 00000000000..a2733a90b92 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/.circleci/config.yml @@ -0,0 +1,173 @@ +--- +# "Include" for unit tests definition. +unit_tests: &unit_tests + steps: + - checkout + - run: + name: Install modules and dependencies. + command: npm install + - run: + name: Run unit tests. + command: npm test + - run: + name: Submit coverage data to codecov. + command: node_modules/.bin/codecov + when: always + +version: 2.0 +workflows: + version: 2 + tests: + jobs: + - node4: + filters: + tags: + only: /.*/ + - node6: + filters: + tags: + only: /.*/ + - node7: + filters: + tags: + only: /.*/ + - node8: + filters: + tags: + only: /.*/ + - node9: + filters: + tags: + only: /.*/ + - lint: + requires: + - node4 + - node6 + - node7 + - node8 + - node9 + filters: + tags: + only: /.*/ + - docs: + requires: + - node4 + - node6 + - node7 + - node8 + - node9 + filters: + tags: + only: /.*/ + - system_tests: + requires: + - lint + - docs + filters: + branches: + only: master + tags: + only: /^v[\d.]+$/ + - publish_npm: + requires: + - system_tests + filters: + branches: + ignore: /.*/ + tags: + only: /^v[\d.]+$/ + +jobs: + node4: + docker: + - image: node:4 + steps: + - checkout + - run: + name: Install modules and dependencies. + command: npm install --unsafe-perm + - run: + name: Run unit tests. + command: npm test + - run: + name: Submit coverage data to codecov. + command: node_modules/.bin/codecov + when: always + node6: + docker: + - image: node:6 + <<: *unit_tests + node7: + docker: + - image: node:7 + <<: *unit_tests + node8: + docker: + - image: node:8 + <<: *unit_tests + node9: + docker: + - image: node:9 + <<: *unit_tests + + lint: + docker: + - image: node:8 + steps: + - checkout + - run: + name: Install modules and dependencies. + command: | + npm install + npm link + - run: + name: Run linting. + command: npm run lint + + docs: + docker: + - image: node:8 + steps: + - checkout + - run: + name: Install modules and dependencies. + command: npm install + - run: + name: Build documentation. + command: npm run docs + + system_tests: + docker: + - image: node:8 + steps: + - checkout + - run: + name: Decrypt credentials. + command: | + openssl aes-256-cbc -d -in .circleci/key.json.enc \ + -out .circleci/key.json \ + -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" + - run: + name: Install modules and dependencies. + command: npm install + - run: + name: Run system tests. + command: npm run system-test + environment: + GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json + - run: + name: Remove unencrypted key. + command: rm .circleci/key.json + when: always + + publish_npm: + docker: + - image: node:8 + steps: + - checkout + - run: + name: Set NPM authentication. + command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + - run: + name: Publish the module to npm. + command: npm publish --access=public diff --git a/packages/google-cloud-bigquery-datatransfer/.circleci/key.json.enc b/packages/google-cloud-bigquery-datatransfer/.circleci/key.json.enc new file mode 100644 index 0000000000000000000000000000000000000000..619ae47d1d8c9e22c069a7203bc7a1f7a75cc515 GIT binary patch literal 2368 zcmV-G3BUGJVQh3|WM5w+l55KD%gV0k#*}#t)LdlIsqs{@GZ}zDsXK52+L%!t(*_|o z&o^40nn!a&Mf#6Fdi+-zig4tZz=&ClgLQ`~COm5K0xp8#lE3P;c6%=ia_mm#t2bf+#vN$gp%~jq8zVlV0#ino_N6kr!{+ zCh4Ww14-m{jE`GbQEOE)vi^L9z?nymZLF`U10L@YzNL+c%sW=j&2 zD}c3-nTKds;EZKlb+7ORu(&_+`f$g#qUhB#WB!Lc4IXtGpQ zYIUw+TH30uDqYt19iV4ir__;?-5?hQjB2hR$fRh!Y#i&vz6EPAPu*lbcr-{LeagWU zx9T;aWm{#z^;O%(GG>l2TaO0g7W6R5t}K`|n{nb-Zpv9{Sl1H52Q=5i$XSU(Yy6et zS-aXDn)l^HJyRV9J6nS;lSg1{t|s~dH*N747prhQ{rvC48X=x|QHzTzfxCa!3_@$0!99DL8|RPQIr5r?v-mV)4z1#{QNciMKwpVzGWK>%UO1%U#t}1?sYLSu(|VEqi~&4Q^v!X)5%_D_#Tb@6A{w!Jo*=q=-eR_gclt5 zFn_7n?*Z}=cL*g=!2$uNd;G@B!d_S>9F)v8^f$;Vdxxw;@jG=cT)w?kC$M_WcN`Vh zi9ftNIeb%^T9RSqGSA~ID$5M&7j||$yqoLP*Qd!2I!dB)GCmGO++F}S zuNbJKKmmNY01$&76ITXl&mv%6AAU!6ayd7VbI#OUeoN++%ipF?B-DIYkrmyx?fqr{ zA$V^4$DXSyeK5Y!S%hfF@hMr9jhD9(4105}ddQ+i$2QBc6Q#ap5|cR;^_ z2cl0gzqz=8pvTGM3|(eD8Pj^#J--t4uVn7u2fuDJ<2GAw+8Z!L;9T*@BY_TZ+q=a& zxgi=H48v%IXio8d%uXCB;PdoGO;(UvYj{?s;H)OkkLI1SJZkKxW_GNbu2sm!>-arX zQYx1zlT!hYUq26NP_kTiT?^Hwy;HR&5#;eDlZ!lX!R2jxfQ|Wli^_+l0osRhcx`dE zc>R1&v($VnfeaZrZpP5|R5x}P?kYuzjF18zwP~HVFSbcRGXsWE`S29cbzHLxDxfeF z4fk%u%bc3>7^hF*IXZu+-fdUdgk^vbqJcmQVNqg9LkN;~v8bK)&Y&owpV`|-uGbFd zY#8a-z+H{Gg}lRg+LHED$Uq;fZt_kyyJZz`3Q6RJ{mZvw$fIS_h70A(!nxC(rO;#_ zH6N<|7`b)hq}?39x^G1<_H{Xntuk0TM;phBwNw3yCXrw@#W6mborF}9qiUexA6{65 zXGn5T_@@+x?F;D2Os^%J5Iv@OM3>8Gc5x}8jItDrA-fd3tQ{vo*!KO@yiy{yZRx!&cJkQT9dPRg`eUM)%LNyciMx`cTU z-qURdy1+VE&b%2n)@ftJsWmzw@D>*5cU4%S|Xm7nw4ijbk2V0 z-a2gTSx$%h3ImH{aYJ49mU5S3X|T)SCs`2J(4s22{J+-XF+2elFzU}-Mz~A5ZHvor zyVqG~o4g3YZ?Gd0X3aLXbZ*QK$jcM&M}dz*BDW)e;N@2$o^VNJHRk@>($#=Tr{K-% zoAw?spi=IpeXLT47X-qR8%?DxN+yp=891tXsI9C?$h|)HiK(`z=l9R&nO2CBm^%vC zF3Kmr;t&P1`~e~8pv4gOQZ*JAF&qvYD8`v2JS|lfTwNeZpL9f$V%NQvu5}+m8@shP z{h=@XJ>3vqi)POLan4Dt(j|1q+r-c1iw{Lb^2ElH7OcDmX3%D||LXI>k)(}-r*}$N z844bTAGa|B687qMiwse*PEQJi6r-2cG%e03A4eY-?2}d9#qxYBQ%C);ndH@vmII9> ziA9Z3IwCbWo_br)NnwtZJjS?w7&q-NQ;;Rc`j^=d7^xnLhoRn_4HHES(G7`q@_&{* z$F#K~tg$ZEW&j0Z6~H^Nna9-dS)U+O%@!hJVdLnbyXsU)r-MHhfn) +# +Ethan Bao +ethanbao diff --git a/packages/google-cloud-bigquery-datatransfer/LICENSE b/packages/google-cloud-bigquery-datatransfer/LICENSE new file mode 100644 index 00000000000..7a4a3ea2424 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/google-cloud-bigquery-datatransfer/README.md b/packages/google-cloud-bigquery-datatransfer/README.md index 1b1c1da868d..514288ecbf0 100644 --- a/packages/google-cloud-bigquery-datatransfer/README.md +++ b/packages/google-cloud-bigquery-datatransfer/README.md @@ -1,31 +1,91 @@ -# Node.js Client for BigQuery Data Transfer API ([Alpha](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning)) - -[BigQuery Data Transfer API][Product Documentation]: -Transfers data from partner SaaS applications to Google BigQuery on a -scheduled, managed basis. -- [Client Library Documentation][] -- [Product Documentation][] - -## Quick Start -In order to use this library, you first need to go through the following -steps: - -1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) -2. [Enable the BigQuery Data Transfer API.](https://console.cloud.google.com/apis/api/bigquerydatatransfer) -3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication) - -### Installation -``` -$ npm install --save datatransfer -``` - -### Next Steps -- Read the [Client Library Documentation][] for BigQuery Data Transfer API - to see other available methods on the client. -- Read the [BigQuery Data Transfer API Product documentation][Product Documentation] - to learn more about the product and see How-to Guides. -- View this [repository's main README](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/README.md) - to see the full list of Cloud APIs that we cover. - -[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/bigquerydatatransfer -[Product Documentation]: https://cloud.google.com/bigquerydatatransfer \ No newline at end of file +Google Cloud Platform logo + +# [Google BigQuery Data Transfer Service: Node.js Client](https://github.com/GoogleCloudPlatform/google-cloud-node) + +[![release level](https://img.shields.io/badge/release%20level-alpha-orange.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![CircleCI](https://img.shields.io/circleci/project/github/GoogleCloudPlatform/google-cloud-node.svg?style=flat)](https://circleci.com/gh/GoogleCloudPlatform/google-cloud-node) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/GoogleCloudPlatform/google-cloud-node?branch=master&svg=true)](https://ci.appveyor.com/project/GoogleCloudPlatform/google-cloud-node) +[![codecov](https://img.shields.io/codecov/c/github/GoogleCloudPlatform/google-cloud-node/master.svg?style=flat)](https://codecov.io/gh/GoogleCloudPlatform/google-cloud-node) + +> Node.js idiomatic client for [BigQuery Data Transfer Service][product-docs]. + +The [BigQuery Data Transfer Service](https://cloud.google.com/bigquery/docs/reference/datatransfer/rest/) transfers data from partner SaaS applications to Google BigQuery on a scheduled, managed basis. + + +* [BigQuery Data Transfer Service Node.js Client API Reference][client-docs] +* [github.com/GoogleCloudPlatform/google-cloud-node](https://github.com/GoogleCloudPlatform/google-cloud-node) +* [BigQuery Data Transfer Service Documentation][product-docs] + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + * [Using the client library](#using-the-client-library) +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart + +### Before you begin + +1. Select or create a Cloud Platform project. + + [Go to the projects page][projects] + +1. Enable billing for your project. + + [Enable billing][billing] + +1. Enable the Google BigQuery Data Transfer Service API. + + [Enable the API][enable_api] + +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=bigquerydatatransfer.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started + +### Installing the client library + + npm install --save @google-cloud/bigquery-data-transfer + + + +The [BigQuery Data Transfer Service Node.js Client API Reference][client-docs] documentation +also contains samples. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + +This library is considered to be in **alpha**. This means it is still a +work-in-progress and under active development. Any release is subject to +backwards-incompatible changes at any time. + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/LICENSE) + +[client-docs]: https://cloud.google.com/nodejs/docs/reference/datatransfer/latest/ +[product-docs]: https://cloud.google.com/bigquery/docs/reference/datatransfer/rest/ +[shell_img]: http://gstatic.com/cloudssh/images/open-btn.png diff --git a/packages/google-cloud-bigquery-datatransfer/package.json b/packages/google-cloud-bigquery-datatransfer/package.json index 31cf147bb77..5e961b951ef 100644 --- a/packages/google-cloud-bigquery-datatransfer/package.json +++ b/packages/google-cloud-bigquery-datatransfer/package.json @@ -1,9 +1,13 @@ { - "repository": "GoogleCloudPlatform/google-cloud-node", - "name": "datatransfer", - "version": "0.7.1", - "author": "Google Inc", + "name": "@google-cloud/bigquery-data-transfer", "description": "BigQuery Data Transfer API client for Node.js", + "version": "0.1.0", + "license": "Apache-2.0", + "author": "Google Inc", + "engines": { + "node": ">=4.0.0" + }, + "repository": "googleapis/nodejs-bigquery-data-transfer", "main": "src/index.js", "files": [ "protos", @@ -24,21 +28,42 @@ "bigquerydatatransfer", "BigQuery Data Transfer API" ], + "contributors": [ + "Ethan Bao ", + "ethanbao " + ], + "scripts": { + "test": "repo-tools test run --cmd npm -- run cover", + "generate-scaffolding": "repo-tools generate all", + "generate-scaffolding-samples": "repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json", + "cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", + "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", + "test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts", + "lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/ smoke-test/", + "prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js smoke-test/*.js", + "docs": "repo-tools exec -- jsdoc -c .jsdoc.js", + "system-test": "repo-tools test run --cmd mocha -- system-test/*.js smoke-test/*.js --no-timeouts" + }, "dependencies": { "google-gax": "^0.14.2", "lodash.merge": "^4.6.0" }, "devDependencies": { - "mocha": "^3.2.0", + "@google-cloud/nodejs-repo-tools": "^2.1.3", + "async": "^2.6.0", + "codecov": "^3.0.0", + "eslint": "^4.13.1", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-node": "^5.2.1", + "eslint-plugin-prettier": "^2.3.1", + "extend": "^3.0.1", + "ink-docstrap": "^1.3.2", + "intelli-espower-loader": "^1.0.1", + "jsdoc": "^3.5.5", + "mocha": "^3.5.3", + "nyc": "^11.3.0", + "power-assert": "^1.4.4", + "prettier": "^1.9.2", "through2": "^2.0.3" - }, - "scripts": { - "publish-module": "node ../../scripts/publish.js bigquerydatatransfer", - "smoke-test": "mocha smoke-test/*.js --timeout 5000", - "test": "mocha test/*.js" - }, - "license": "Apache-2.0", - "engines": { - "node": ">=4.0.0" } } diff --git a/packages/google-cloud-bigquery-datatransfer/samples/.eslintrc.yml b/packages/google-cloud-bigquery-datatransfer/samples/.eslintrc.yml new file mode 100644 index 00000000000..282535f55f6 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/.eslintrc.yml @@ -0,0 +1,3 @@ +--- +rules: + no-console: off diff --git a/packages/google-cloud-bigquery-datatransfer/samples/quickstart.js b/packages/google-cloud-bigquery-datatransfer/samples/quickstart.js new file mode 100644 index 00000000000..a4763b564e6 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/samples/quickstart.js @@ -0,0 +1,63 @@ +// Copyright 2017, Google LLC All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const bigqueryDataTransfer = require('../src'); + +if ( + !process.env.GCLOUD_PROJECT || + !process.env.GOOGLE_APPLICATION_CREDENTIALS +) { + throw new Error( + 'Usage: GCLOUD_PROJECT= GOOGLE_APPLICATION_CREDENTIALS= node #{$0}' + ); +} +var projectId = process.env.GCLOUD_PROJECT; + +var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ + // optional auth parameters. +}); + +// Iterate over all elements. +var formattedParent = client.locationPath(projectId, 'us-central1'); + +client.listDataSources({parent: formattedParent}).then(responses => { + var resources = responses[0]; + for (let i = 0; i < resources.length; i += 1) { + console.log(resources[i]); + } +}); + +var options = {autoPaginate: false}; +var callback = responses => { + // The actual resources in a response. + var resources = responses[0]; + // The next request if the response shows that there are more responses. + var nextRequest = responses[1]; + // The actual response object, if necessary. + // var rawResponse = responses[2]; + for (let i = 0; i < resources.length; i += 1) { + console.log(resources[i]); + } + if (nextRequest) { + // Fetch the next page. + return client.listDataSources(nextRequest, options).then(callback); + } +}; +client.listDataSources({parent: formattedParent}, options).then(callback); + +client.listDataSourcesStream({parent: formattedParent}).on('data', element => { + console.log(element); +}); diff --git a/packages/google-cloud-bigquery-datatransfer/smoke-test/.eslintrc.yml b/packages/google-cloud-bigquery-datatransfer/smoke-test/.eslintrc.yml new file mode 100644 index 00000000000..2e6882e46d2 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/smoke-test/.eslintrc.yml @@ -0,0 +1,6 @@ +--- +env: + mocha: true +rules: + node/no-unpublished-require: off + no-console: off diff --git a/packages/google-cloud-bigquery-datatransfer/smoke-test/data_transfer_service_smoke_test.js b/packages/google-cloud-bigquery-datatransfer/smoke-test/data_transfer_service_smoke_test.js new file mode 100644 index 00000000000..651a293a1d7 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/smoke-test/data_transfer_service_smoke_test.js @@ -0,0 +1,94 @@ +// Copyright 2017, Google LLC All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +describe('DataTransferServiceSmokeTest', () => { + if (!process.env.GCLOUD_PROJECT) { + throw new Error('Usage: GCLOUD_PROJECT= node #{$0}'); + } + var projectId = process.env.GCLOUD_PROJECT; + + it('successfully makes a call to the service using promises', done => { + const bigqueryDataTransfer = require('../src'); + + var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ + // optional auth parameters. + }); + + // Iterate over all elements. + var formattedParent = client.locationPath(projectId, 'us-central1'); + + client + .listDataSources({parent: formattedParent}) + .then(responses => { + var resources = responses[0]; + for (let i = 0; i < resources.length; i += 1) { + console.log(resources[i]); + } + }) + .then(done) + .catch(done); + }); + + it('successfully makes a call to the service using callbacks', done => { + const bigqueryDataTransfer = require('../src'); + + var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ + // optional auth parameters. + }); + + // Or obtain the paged response. + var formattedParent = client.locationPath(projectId, 'us-central1'); + + var options = {autoPaginate: false}; + var callback = responses => { + // The actual resources in a response. + var resources = responses[0]; + // The next request if the response shows that there are more responses. + var nextRequest = responses[1]; + // The actual response object, if necessary. + // var rawResponse = responses[2]; + for (let i = 0; i < resources.length; i += 1) { + console.log(resources[i]); + } + if (nextRequest) { + // Fetch the next page. + return client.listDataSources(nextRequest, options).then(callback); + } + }; + client + .listDataSources({parent: formattedParent}, options) + .then(callback) + .then(done) + .catch(done); + }); + + it('successfully makes a call to the service using streaming', done => { + const bigqueryDataTransfer = require('../src'); + + var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ + // optional auth parameters. + }); + + var formattedParent = client.locationPath(projectId, 'us-central1'); + client + .listDataSourcesStream({parent: formattedParent}) + .on('data', element => { + console.log(element); + }) + .on('error', done) + .on('end', done); + }); +}); diff --git a/packages/google-cloud-bigquery-datatransfer/src/index.js b/packages/google-cloud-bigquery-datatransfer/src/index.js index 66f84d8a893..d7c209f5cdd 100644 --- a/packages/google-cloud-bigquery-datatransfer/src/index.js +++ b/packages/google-cloud-bigquery-datatransfer/src/index.js @@ -19,10 +19,10 @@ * @namespace google.cloud */ /** - * @namespace google.cloud.datatransfer + * @namespace google.cloud.bigquery-data-transfer */ /** - * @namespace google.cloud.datatransfer.v1 + * @namespace google.cloud.bigquery-data-transfer.v1 */ 'use strict'; @@ -33,7 +33,7 @@ const gapic = Object.freeze({ }); /** - * The `datatransfer` package has the following named exports: + * The `@google-cloud/bigquery-data-transfer` package has the following named exports: * * - `DataTransferServiceClient` - Reference to * {@link v1.DataTransferServiceClient} @@ -42,20 +42,20 @@ const gapic = Object.freeze({ * - `DataTransferServiceClient` - Reference to * {@link v1.DataTransferServiceClient} * - * @module {object} datatransfer - * @alias nodejs-datatransfer + * @module {object} @google-cloud/bigquery-data-transfer + * @alias nodejs-bigquery-data-transfer * * @example Install the client library with npm: - * npm install --save datatransfer + * npm install --save @google-cloud/bigquery-data-transfer * * @example Import the client library: - * const datatransfer = require('datatransfer'); + * const bigquery-data-transfer = require('@google-cloud/bigquery-data-transfer'); * * @example Create a client that uses Application Default Credentials (ADC): - * const client = new datatransfer.DataTransferServiceClient(); + * const client = new bigquery-data-transfer.DataTransferServiceClient(); * * @example Create a client with explicit credentials: - * const client = new datatransfer.DataTransferServiceClient({ + * const client = new bigquery-data-transfer.DataTransferServiceClient({ * projectId: 'your-project-id', * keyFilename: '/path/to/keyfile.json', * }); diff --git a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.js b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.js index 2bf40528f75..b4a1f0600ea 100644 --- a/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.js +++ b/packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.js @@ -103,9 +103,7 @@ class DataTransferServiceClient { // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this._pathTemplates = { - projectPathTemplate: new gax.PathTemplate( - 'projects/{project}' - ), + projectPathTemplate: new gax.PathTemplate('projects/{project}'), locationPathTemplate: new gax.PathTemplate( 'projects/{project}/locations/{location}' ), @@ -268,9 +266,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -334,9 +332,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -422,9 +420,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -444,7 +442,7 @@ class DataTransferServiceClient { request, options ); - }; + } /** * Creates a new data transfer configuration. @@ -492,9 +490,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -567,9 +565,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -617,9 +615,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -659,9 +657,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -726,9 +724,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -816,9 +814,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -838,7 +836,7 @@ class DataTransferServiceClient { request, options ); - }; + } /** * Creates transfer runs for a time range [range_start_time, range_end_time]. @@ -874,9 +872,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -928,9 +926,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -972,9 +970,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1041,9 +1039,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1138,9 +1136,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1160,7 +1158,7 @@ class DataTransferServiceClient { request, options ); - }; + } /** * Returns user facing log messages for the data transfer run. @@ -1206,9 +1204,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1299,9 +1297,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1321,7 +1319,7 @@ class DataTransferServiceClient { request, options ); - }; + } /** * Returns true if valid credentials exist for the given data source and @@ -1349,9 +1347,9 @@ class DataTransferServiceClient { * * @example * - * const datatransfer = require('datatransfer.v1'); + * const bigqueryDataTransfer = require('@google-cloud/bigquery-data-transfer'); * - * var client = new datatransfer.v1.DataTransferServiceClient({ + * var client = new bigqueryDataTransfer.v1.DataTransferServiceClient({ * // optional auth parameters. * }); * @@ -1507,9 +1505,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromProjectName(projectName) { - return this._pathTemplates.projectPathTemplate - .match(projectName) - .project; + return this._pathTemplates.projectPathTemplate.match(projectName).project; } /** @@ -1520,9 +1516,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromLocationName(locationName) { - return this._pathTemplates.locationPathTemplate - .match(locationName) - .project; + return this._pathTemplates.locationPathTemplate.match(locationName).project; } /** @@ -1533,8 +1527,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the location. */ matchLocationFromLocationName(locationName) { - return this._pathTemplates.locationPathTemplate - .match(locationName) + return this._pathTemplates.locationPathTemplate.match(locationName) .location; } @@ -1546,9 +1539,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromLocationDataSourceName(locationDataSourceName) { - return this._pathTemplates.locationDataSourcePathTemplate - .match(locationDataSourceName) - .project; + return this._pathTemplates.locationDataSourcePathTemplate.match( + locationDataSourceName + ).project; } /** @@ -1559,9 +1552,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the location. */ matchLocationFromLocationDataSourceName(locationDataSourceName) { - return this._pathTemplates.locationDataSourcePathTemplate - .match(locationDataSourceName) - .location; + return this._pathTemplates.locationDataSourcePathTemplate.match( + locationDataSourceName + ).location; } /** @@ -1572,9 +1565,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the data_source. */ matchDataSourceFromLocationDataSourceName(locationDataSourceName) { - return this._pathTemplates.locationDataSourcePathTemplate - .match(locationDataSourceName) - .data_source; + return this._pathTemplates.locationDataSourcePathTemplate.match( + locationDataSourceName + ).data_source; } /** @@ -1585,9 +1578,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromLocationTransferConfigName(locationTransferConfigName) { - return this._pathTemplates.locationTransferConfigPathTemplate - .match(locationTransferConfigName) - .project; + return this._pathTemplates.locationTransferConfigPathTemplate.match( + locationTransferConfigName + ).project; } /** @@ -1598,9 +1591,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the location. */ matchLocationFromLocationTransferConfigName(locationTransferConfigName) { - return this._pathTemplates.locationTransferConfigPathTemplate - .match(locationTransferConfigName) - .location; + return this._pathTemplates.locationTransferConfigPathTemplate.match( + locationTransferConfigName + ).location; } /** @@ -1610,10 +1603,12 @@ class DataTransferServiceClient { * A fully-qualified path representing a location_transfer_config resources. * @returns {String} - A string representing the transfer_config. */ - matchTransferConfigFromLocationTransferConfigName(locationTransferConfigName) { - return this._pathTemplates.locationTransferConfigPathTemplate - .match(locationTransferConfigName) - .transfer_config; + matchTransferConfigFromLocationTransferConfigName( + locationTransferConfigName + ) { + return this._pathTemplates.locationTransferConfigPathTemplate.match( + locationTransferConfigName + ).transfer_config; } /** @@ -1624,8 +1619,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromLocationRunName(locationRunName) { - return this._pathTemplates.locationRunPathTemplate - .match(locationRunName) + return this._pathTemplates.locationRunPathTemplate.match(locationRunName) .project; } @@ -1637,8 +1631,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the location. */ matchLocationFromLocationRunName(locationRunName) { - return this._pathTemplates.locationRunPathTemplate - .match(locationRunName) + return this._pathTemplates.locationRunPathTemplate.match(locationRunName) .location; } @@ -1650,8 +1643,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the transfer_config. */ matchTransferConfigFromLocationRunName(locationRunName) { - return this._pathTemplates.locationRunPathTemplate - .match(locationRunName) + return this._pathTemplates.locationRunPathTemplate.match(locationRunName) .transfer_config; } @@ -1663,8 +1655,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the run. */ matchRunFromLocationRunName(locationRunName) { - return this._pathTemplates.locationRunPathTemplate - .match(locationRunName) + return this._pathTemplates.locationRunPathTemplate.match(locationRunName) .run; } @@ -1676,8 +1667,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromDataSourceName(dataSourceName) { - return this._pathTemplates.dataSourcePathTemplate - .match(dataSourceName) + return this._pathTemplates.dataSourcePathTemplate.match(dataSourceName) .project; } @@ -1689,8 +1679,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the data_source. */ matchDataSourceFromDataSourceName(dataSourceName) { - return this._pathTemplates.dataSourcePathTemplate - .match(dataSourceName) + return this._pathTemplates.dataSourcePathTemplate.match(dataSourceName) .data_source; } @@ -1702,9 +1691,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromTransferConfigName(transferConfigName) { - return this._pathTemplates.transferConfigPathTemplate - .match(transferConfigName) - .project; + return this._pathTemplates.transferConfigPathTemplate.match( + transferConfigName + ).project; } /** @@ -1715,9 +1704,9 @@ class DataTransferServiceClient { * @returns {String} - A string representing the transfer_config. */ matchTransferConfigFromTransferConfigName(transferConfigName) { - return this._pathTemplates.transferConfigPathTemplate - .match(transferConfigName) - .transfer_config; + return this._pathTemplates.transferConfigPathTemplate.match( + transferConfigName + ).transfer_config; } /** @@ -1728,9 +1717,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the project. */ matchProjectFromRunName(runName) { - return this._pathTemplates.runPathTemplate - .match(runName) - .project; + return this._pathTemplates.runPathTemplate.match(runName).project; } /** @@ -1741,9 +1728,7 @@ class DataTransferServiceClient { * @returns {String} - A string representing the transfer_config. */ matchTransferConfigFromRunName(runName) { - return this._pathTemplates.runPathTemplate - .match(runName) - .transfer_config; + return this._pathTemplates.runPathTemplate.match(runName).transfer_config; } /** @@ -1754,11 +1739,8 @@ class DataTransferServiceClient { * @returns {String} - A string representing the run. */ matchRunFromRunName(runName) { - return this._pathTemplates.runPathTemplate - .match(runName) - .run; + return this._pathTemplates.runPathTemplate.match(runName).run; } } - module.exports = DataTransferServiceClient; diff --git a/packages/google-cloud-bigquery-datatransfer/system-test/.eslintrc.yml b/packages/google-cloud-bigquery-datatransfer/system-test/.eslintrc.yml new file mode 100644 index 00000000000..2e6882e46d2 --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/system-test/.eslintrc.yml @@ -0,0 +1,6 @@ +--- +env: + mocha: true +rules: + node/no-unpublished-require: off + no-console: off diff --git a/packages/google-cloud-bigquery-datatransfer/test/.eslintrc.yml b/packages/google-cloud-bigquery-datatransfer/test/.eslintrc.yml new file mode 100644 index 00000000000..73f7bbc946f --- /dev/null +++ b/packages/google-cloud-bigquery-datatransfer/test/.eslintrc.yml @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + node/no-unpublished-require: off diff --git a/packages/google-cloud-bigquery-datatransfer/test/gapic-v1.js b/packages/google-cloud-bigquery-datatransfer/test/gapic-v1.js index ca34f5ca15e..f2d26977b2f 100644 --- a/packages/google-cloud-bigquery-datatransfer/test/gapic-v1.js +++ b/packages/google-cloud-bigquery-datatransfer/test/gapic-v1.js @@ -16,7 +16,7 @@ const assert = require('assert'); -const datatransferModule = require('../src'); +const bigqueryDataTransferModule = require('../src'); var FAKE_STATUS_CODE = 1; var error = new Error(); @@ -25,13 +25,17 @@ error.code = FAKE_STATUS_CODE; describe('DataTransferServiceClient', () => { describe('getDataSource', () => { it('invokes getDataSource without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationDataSourcePath('[PROJECT]', '[LOCATION]', '[DATA_SOURCE]'); + var formattedName = client.locationDataSourcePath( + '[PROJECT]', + '[LOCATION]', + '[DATA_SOURCE]' + ); var request = { name: formattedName, }; @@ -78,13 +82,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes getDataSource with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationDataSourcePath('[PROJECT]', '[LOCATION]', '[DATA_SOURCE]'); + var formattedName = client.locationDataSourcePath( + '[PROJECT]', + '[LOCATION]', + '[DATA_SOURCE]' + ); var request = { name: formattedName, }; @@ -107,7 +115,7 @@ describe('DataTransferServiceClient', () => { describe('listDataSources', () => { it('invokes listDataSources without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -128,7 +136,11 @@ describe('DataTransferServiceClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listDataSources = (actualRequest, options, callback) => { + client._innerApiCalls.listDataSources = ( + actualRequest, + options, + callback + ) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.dataSources); }; @@ -141,7 +153,7 @@ describe('DataTransferServiceClient', () => { }); it('invokes listDataSources with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -170,7 +182,7 @@ describe('DataTransferServiceClient', () => { describe('createTransferConfig', () => { it('invokes createTransferConfig without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -219,7 +231,7 @@ describe('DataTransferServiceClient', () => { }); it('invokes createTransferConfig with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -250,7 +262,7 @@ describe('DataTransferServiceClient', () => { describe('updateTransferConfig', () => { it('invokes updateTransferConfig without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -299,7 +311,7 @@ describe('DataTransferServiceClient', () => { }); it('invokes updateTransferConfig with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -330,19 +342,25 @@ describe('DataTransferServiceClient', () => { describe('deleteTransferConfig', () => { it('invokes deleteTransferConfig without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedName = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { name: formattedName, }; // Mock Grpc layer - client._innerApiCalls.deleteTransferConfig = mockSimpleGrpcMethod(request); + client._innerApiCalls.deleteTransferConfig = mockSimpleGrpcMethod( + request + ); client.deleteTransferConfig(request, err => { assert.ifError(err); @@ -351,13 +369,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes deleteTransferConfig with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedName = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { name: formattedName, }; @@ -379,13 +401,17 @@ describe('DataTransferServiceClient', () => { describe('getTransferConfig', () => { it('invokes getTransferConfig without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedName = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { name: formattedName, }; @@ -426,13 +452,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes getTransferConfig with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedName = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { name: formattedName, }; @@ -455,7 +485,7 @@ describe('DataTransferServiceClient', () => { describe('listTransferConfigs', () => { it('invokes listTransferConfigs without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -476,7 +506,11 @@ describe('DataTransferServiceClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listTransferConfigs = (actualRequest, options, callback) => { + client._innerApiCalls.listTransferConfigs = ( + actualRequest, + options, + callback + ) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.transferConfigs); }; @@ -489,7 +523,7 @@ describe('DataTransferServiceClient', () => { }); it('invokes listTransferConfigs with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); @@ -518,13 +552,17 @@ describe('DataTransferServiceClient', () => { describe('scheduleTransferRuns', () => { it('invokes scheduleTransferRuns without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedParent = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var startTime = {}; var endTime = {}; var request = { @@ -550,13 +588,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes scheduleTransferRuns with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedParent = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var startTime = {}; var endTime = {}; var request = { @@ -583,13 +625,18 @@ describe('DataTransferServiceClient', () => { describe('getTransferRun', () => { it('invokes getTransferRun without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedName = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { name: formattedName, }; @@ -622,13 +669,18 @@ describe('DataTransferServiceClient', () => { }); it('invokes getTransferRun with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedName = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { name: formattedName, }; @@ -651,13 +703,18 @@ describe('DataTransferServiceClient', () => { describe('deleteTransferRun', () => { it('invokes deleteTransferRun without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedName = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { name: formattedName, }; @@ -672,13 +729,18 @@ describe('DataTransferServiceClient', () => { }); it('invokes deleteTransferRun with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedName = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { name: formattedName, }; @@ -700,13 +762,17 @@ describe('DataTransferServiceClient', () => { describe('listTransferRuns', () => { it('invokes listTransferRuns without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedParent = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { parent: formattedParent, }; @@ -721,7 +787,11 @@ describe('DataTransferServiceClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listTransferRuns = (actualRequest, options, callback) => { + client._innerApiCalls.listTransferRuns = ( + actualRequest, + options, + callback + ) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.transferRuns); }; @@ -734,13 +804,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes listTransferRuns with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationTransferConfigPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]'); + var formattedParent = client.locationTransferConfigPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]' + ); var request = { parent: formattedParent, }; @@ -763,13 +837,18 @@ describe('DataTransferServiceClient', () => { describe('listTransferLogs', () => { it('invokes listTransferLogs without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedParent = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { parent: formattedParent, }; @@ -784,7 +863,11 @@ describe('DataTransferServiceClient', () => { }; // Mock Grpc layer - client._innerApiCalls.listTransferLogs = (actualRequest, options, callback) => { + client._innerApiCalls.listTransferLogs = ( + actualRequest, + options, + callback + ) => { assert.deepStrictEqual(actualRequest, request); callback(null, expectedResponse.transferMessages); }; @@ -797,13 +880,18 @@ describe('DataTransferServiceClient', () => { }); it('invokes listTransferLogs with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedParent = client.locationRunPath('[PROJECT]', '[LOCATION]', '[TRANSFER_CONFIG]', '[RUN]'); + var formattedParent = client.locationRunPath( + '[PROJECT]', + '[LOCATION]', + '[TRANSFER_CONFIG]', + '[RUN]' + ); var request = { parent: formattedParent, }; @@ -826,13 +914,17 @@ describe('DataTransferServiceClient', () => { describe('checkValidCreds', () => { it('invokes checkValidCreds without error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationDataSourcePath('[PROJECT]', '[LOCATION]', '[DATA_SOURCE]'); + var formattedName = client.locationDataSourcePath( + '[PROJECT]', + '[LOCATION]', + '[DATA_SOURCE]' + ); var request = { name: formattedName, }; @@ -857,13 +949,17 @@ describe('DataTransferServiceClient', () => { }); it('invokes checkValidCreds with error', done => { - var client = new datatransferModule.v1.DataTransferServiceClient({ + var client = new bigqueryDataTransferModule.v1.DataTransferServiceClient({ credentials: {client_email: 'bogus', private_key: 'bogus'}, projectId: 'bogus', }); // Mock request - var formattedName = client.locationDataSourcePath('[PROJECT]', '[LOCATION]', '[DATA_SOURCE]'); + var formattedName = client.locationDataSourcePath( + '[PROJECT]', + '[LOCATION]', + '[DATA_SOURCE]' + ); var request = { name: formattedName, }; @@ -883,7 +979,6 @@ describe('DataTransferServiceClient', () => { }); }); }); - }); function mockSimpleGrpcMethod(expectedRequest, response, error) {