From 7283369701fd9c447db0ab7469134288dd27ea9b Mon Sep 17 00:00:00 2001 From: Luke Sneeringer Date: Tue, 24 Oct 2017 12:13:22 -0700 Subject: [PATCH] Repo Migration (#4) --- .../.appveyor.yml | 23 + .../.circleci/config.yml | 190 ++++++ .../.circleci/key.json.enc | Bin 0 -> 2384 bytes .../.cloud-repo-tools.json | 16 + .../.eslintignore | 3 + .../.eslintrc.yml | 13 + .../google-cloud-videointelligence/.gitignore | 10 + .../google-cloud-videointelligence/.jsdoc.js | 45 ++ .../google-cloud-videointelligence/.mailmap | 6 + .../google-cloud-videointelligence/.nycrc | 26 + .../.prettierignore | 3 + .../.prettierrc | 8 + .../CODE_OF_CONDUCT.md | 43 ++ .../CONTRIBUTORS | 14 + .../google-cloud-videointelligence/LICENSE | 202 ++++++ .../google-cloud-videointelligence/README.md | 174 +++++- .../package.json | 54 +- .../samples/README.md | 43 +- .../samples/package.json | 34 +- .../samples/quickstart.js | 37 +- .../src/index.js | 203 +++---- .../v1beta1}/doc_video_intelligence.js | 131 ++-- .../protobuf/doc_any.js} | 46 +- .../doc/google/rpc/doc_status.js} | 50 +- .../src/v1beta1/index.js | 47 +- .../video_intelligence_service_client.js | 575 ++++++++++-------- .../v1beta2}/doc_video_intelligence.js | 176 +++--- .../protobuf/doc_any.js} | 46 +- .../protobuf/doc_duration.js} | 42 +- .../doc/google/rpc/doc_status.js} | 50 +- .../src/v1beta2/index.js | 47 +- .../video_intelligence_service_client.js | 555 +++++++++-------- .../test/.eslintrc.yml | 5 + .../test/gapic-v1beta1.js | 155 ++--- .../test/gapic-v1beta2.js | 147 +++-- 35 files changed, 2024 insertions(+), 1195 deletions(-) create mode 100644 packages/google-cloud-videointelligence/.appveyor.yml create mode 100644 packages/google-cloud-videointelligence/.circleci/config.yml create mode 100644 packages/google-cloud-videointelligence/.circleci/key.json.enc create mode 100644 packages/google-cloud-videointelligence/.cloud-repo-tools.json create mode 100644 packages/google-cloud-videointelligence/.eslintignore create mode 100644 packages/google-cloud-videointelligence/.eslintrc.yml create mode 100644 packages/google-cloud-videointelligence/.gitignore create mode 100644 packages/google-cloud-videointelligence/.jsdoc.js create mode 100644 packages/google-cloud-videointelligence/.mailmap create mode 100644 packages/google-cloud-videointelligence/.nycrc create mode 100644 packages/google-cloud-videointelligence/.prettierignore create mode 100644 packages/google-cloud-videointelligence/.prettierrc create mode 100644 packages/google-cloud-videointelligence/CODE_OF_CONDUCT.md create mode 100644 packages/google-cloud-videointelligence/CONTRIBUTORS create mode 100644 packages/google-cloud-videointelligence/LICENSE rename packages/google-cloud-videointelligence/src/v1beta1/doc/{ => google/cloud/videointelligence/v1beta1}/doc_video_intelligence.js (80%) rename packages/google-cloud-videointelligence/src/v1beta1/doc/{doc_google_protobuf_any.js => google/protobuf/doc_any.js} (79%) rename packages/google-cloud-videointelligence/src/{v1beta2/doc/doc_google_rpc_status.js => v1beta1/doc/google/rpc/doc_status.js} (73%) rename packages/google-cloud-videointelligence/src/v1beta2/doc/{ => google/cloud/videointelligence/v1beta2}/doc_video_intelligence.js (78%) rename packages/google-cloud-videointelligence/src/v1beta2/doc/{doc_google_protobuf_any.js => google/protobuf/doc_any.js} (79%) rename packages/google-cloud-videointelligence/src/v1beta2/doc/{doc_google_protobuf_duration.js => google/protobuf/doc_duration.js} (79%) rename packages/google-cloud-videointelligence/src/{v1beta1/doc/doc_google_rpc_status.js => v1beta2/doc/google/rpc/doc_status.js} (73%) create mode 100644 packages/google-cloud-videointelligence/test/.eslintrc.yml diff --git a/packages/google-cloud-videointelligence/.appveyor.yml b/packages/google-cloud-videointelligence/.appveyor.yml new file mode 100644 index 00000000000..babe1d587f4 --- /dev/null +++ b/packages/google-cloud-videointelligence/.appveyor.yml @@ -0,0 +1,23 @@ +environment: + matrix: + - nodejs_version: 4 + - nodejs_version: 6 + - nodejs_version: 7 + - 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-videointelligence/.circleci/config.yml b/packages/google-cloud-videointelligence/.circleci/config.yml new file mode 100644 index 00000000000..6fbbd4edb02 --- /dev/null +++ b/packages/google-cloud-videointelligence/.circleci/config.yml @@ -0,0 +1,190 @@ +--- +# "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: /.*/ + - lint: + requires: + - node4 + - node6 + - node7 + - node8 + filters: + tags: + only: /.*/ + - docs: + requires: + - node4 + - node6 + - node7 + - node8 + filters: + tags: + only: /.*/ + - system_tests: + requires: + - lint + - docs + filters: + branches: + only: master + tags: + only: /^v[\d.]+$/ + - sample_tests: + requires: + - lint + - docs + filters: + branches: + only: master + tags: + only: /^v[\d.]+$/ + - publish_npm: + requires: + - sample_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 + + lint: + docker: + - image: node:8 + steps: + - checkout + - run: + name: Install modules and dependencies. + command: | + npm install + npm link + - run: + name: Link the module being tested to the samples. + command: | + cd samples/ + npm link @google-cloud/video-intelligence + npm install + cd .. + - 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 + + sample_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 and link the module. + command: | + npm install + npm link + - run: + name: Link the module being tested to the samples. + command: | + cd samples/ + npm link @google-cloud/video-intelligence + npm install + cd .. + - run: + name: Run sample tests. + command: npm run samples-test + environment: + GCLOUD_PROJECT: long-door-651 + GOOGLE_APPLICATION_CREDENTIALS: /var/video-intelligence/.circleci/key.json + - run: + name: Remove unencrypted key. + command: rm .circleci/key.json + when: always + working_directory: /var/video-intelligence/ + + 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 diff --git a/packages/google-cloud-videointelligence/.circleci/key.json.enc b/packages/google-cloud-videointelligence/.circleci/key.json.enc new file mode 100644 index 0000000000000000000000000000000000000000..16908802f8f1f41bfa73d56917d8683e03808d04 GIT binary patch literal 2384 zcmV-W39t53VQh3|WM5z8Ly9pySSOYsoda#9D)?wVtt=iIq%u#>yoM@T%oe}}%bO)? zh0!=Z{$A+4?e`wuPs$a`npJ6=LHfHJa`61WK;Un(nT^0-jZYsng>6Uffw%NAuuvbD zu#~P$$=ji+RN0<=f!XR9vRj7`9|Wd{mtS))!Os}h*DG&kMGRha-U|JPmV+Fo1A{HV zNW3$VIsBukIU>ln+_jm#iM$x7a@*ky7}&bR;gbpLOP`g6n_CJMsROE|d$cw(C(EAMgE3siVVZSbvfs3kDmtAIS6cA^5U6lO^W6u;jM>1(~{B}w2CPtTo zAqIN8fo9tevD*nRF5Z+~-w$z3Xj0m2SH7%&|8>z{;O2%N#Ex5ygWtF7u@@-q)hgk< zM-vK8kE_V~JyrZ)~qz|SF;TU~NGNB-oLwji;c!nZMw+VwZrn|A z_OBU>=(4MtrbKp{SBy5=&G>8Rntn>f{tA8r~jB(bb zkvM*bZ|D<`)fI1|p_zSZSd4v7F%>vXS7$J-DL;Q|Sy4qIxT3j@vh0#ojRr#ka=>?D zTk15m@arD3TA}lU$|)qJw-5On`C=Q^<%z}4{`bIsSyDEjCc9b`^Rd#8xvob#-L>L*maYv8J~c z0SR=*4;Rxgz2AH#iy;=KcMcl3;WdWNi#HH;Zq{o>bVis%3{}^`F-3}l`obSdE)^T)#XDbzR4RzYowJ=*6A#8~)wZ|%6 z!%1!BD#XRHAooKlk2(9OV3u8nRA31%uf7{b{xTl*2a6ScqnL%_tZPk<{Nj)E&^g7> zV1Id%MBw=3d3kWOP_ z@p-gkRj-huG$NhC33C}Cus-ueU2(Pzx{DneMe$-5YE`L@nE5hc)HAT>T3%CuXNc=l z2e*+v&Fg_V)~_jf_IP}iTgyJKUc021`JZxZkutgIJgb67p+X6%Fm&BOXrV>(ll|ha zyQRO&3c;2Mb_bxsq;L#JRXE*bTYB)+rhMv;yTZbrxj3MG@H9{h;u!BiOhxDn%d5x} zzA^3PHL?pQlLpR=)Fz4M=pNzVy&ouSAMUVYoQdqVl~O6Gt(v$kv);Z4bq5CH^W5{H z_KB*kzq$#ak^9cOqZYSWwJaomVUSo$bVt9NZ_^^KLLe_+Vh>p%ZABXX$gqFc|AgKX zSUM1$PF!InI-&^MBFA3}=!`T9+AdC00L9LYdJ`kHB8imXj&?lCsf0}LL(k!trLu)P- z|BvG^A zWyr6|Lt3IwQ{%elWnO*uBm(gw+n@g1i5z$0^(FMKP$kCEt{Kc;iVq1>BVR4buV)mB znxuU?`7{-cg@ws>Re)#Y#H-%p^)JY`;)IC{zn|)Xpi0-a`;`i1Y|L@?2LGiPm6F&b znBol^jphZ{x`4L+V6c6M?^HF7SM^d}M6J1ws0*_#%mVIP(p!FDEk8#x34$HF)QXpy ze2WQ=t{xq5xLoH}?lmL>i|&ydbq3yC52KC25=>t@qcp2O&Y?zJq`6b4WC%?7c7x$m zHWNQc%Jzu}jB?Y|tZG#&N$y<6wy1dIch%h8%G#xJS1bBfe^u`|c)s#0B~u^KH+01M zaNOZ^?})ouyJS{8l?TnA;Vru${lanLnkrMzUErQ&=CqsX#Qve13ob4Dac6^&zFJDG zZQQ#_8KESG3AcWS<5>`yk5Y{1h(=_3DY8xdSR<@XY#VS}%x^Xp{V2L{~O-QX))m8uhvN z_s6AlwB&7~R$hHX=<-6V5ilVp&}Q_GT%Oxrq@T%Nqg4(#5?3=?E!H7A91UZ4f%~h3 z&+zy}bW5ZD_r!k;GzMUMLdjFei+;F#+hA!woT9BraEodA9MW#n7}B?Q_TC;N`RFk^ zD$m%5I)UBV|2yhH1pL4ur9^z%IUfZ`Z|@2KRn&;^qqS+0t%AHOA}PyHrr*WVBvgQi zAfr~$65+e$x^a1p8{Zg^J>X3ux_OE_xkV%bNNvp6vd4X8BcH@X##Wt@X zyy7_?0NvkbNk86+y^2{>{F$VZziJ>p!v6$|5CnO0qJd+DfC9Ru?=k-!qF=pB2rcU0 zsV(H_W)wSvjmDO6M@*~`v~zF%oMgD0JVoWJ7*4hLB+jb}sv!SxlFdK1JsR;$ni=yt CYqdWB literal 0 HcmV?d00001 diff --git a/packages/google-cloud-videointelligence/.cloud-repo-tools.json b/packages/google-cloud-videointelligence/.cloud-repo-tools.json new file mode 100644 index 00000000000..6e777da18ad --- /dev/null +++ b/packages/google-cloud-videointelligence/.cloud-repo-tools.json @@ -0,0 +1,16 @@ +{ + "requiresKeyFile": true, + "requiresProjectId": true, + "product": "video", + "client_reference_url": "https://cloud.google.com/nodejs/docs/reference/video-intelligence/latest/", + "release_quality": "beta", + "samples": [ + { + "id": "video", + "name": "Video Intelligence", + "file": "analyze.js", + "docs_link": "https://cloud.google.com/video-intelligence/docs", + "usage": "node analyze.js --help" + } + ] +} diff --git a/packages/google-cloud-videointelligence/.eslintignore b/packages/google-cloud-videointelligence/.eslintignore new file mode 100644 index 00000000000..f6fac98b0a8 --- /dev/null +++ b/packages/google-cloud-videointelligence/.eslintignore @@ -0,0 +1,3 @@ +node_modules/* +samples/node_modules/* +src/**/doc/* diff --git a/packages/google-cloud-videointelligence/.eslintrc.yml b/packages/google-cloud-videointelligence/.eslintrc.yml new file mode 100644 index 00000000000..bed57fbc42c --- /dev/null +++ b/packages/google-cloud-videointelligence/.eslintrc.yml @@ -0,0 +1,13 @@ +--- +extends: + - 'eslint:recommended' + - 'plugin:node/recommended' + - prettier +plugins: + - node + - prettier +rules: + prettier/prettier: error + block-scoped-var: error + eqeqeq: error + no-warning-comments: warn diff --git a/packages/google-cloud-videointelligence/.gitignore b/packages/google-cloud-videointelligence/.gitignore new file mode 100644 index 00000000000..6b80718f261 --- /dev/null +++ b/packages/google-cloud-videointelligence/.gitignore @@ -0,0 +1,10 @@ +**/*.log +**/node_modules +.coverage +.nyc_output +docs/ +out/ +system-test/secrets.js +system-test/*key.json +*.lock +*-lock.js* diff --git a/packages/google-cloud-videointelligence/.jsdoc.js b/packages/google-cloud-videointelligence/.jsdoc.js new file mode 100644 index 00000000000..325fa2866d9 --- /dev/null +++ b/packages/google-cloud-videointelligence/.jsdoc.js @@ -0,0 +1,45 @@ +/*! + * Copyright 2017 Google Inc. 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'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/ink-docstrap/template', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'src' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2017 Google, Inc.', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/video-intelligence', + theme: 'lumen' + } +}; diff --git a/packages/google-cloud-videointelligence/.mailmap b/packages/google-cloud-videointelligence/.mailmap new file mode 100644 index 00000000000..3e8a311c476 --- /dev/null +++ b/packages/google-cloud-videointelligence/.mailmap @@ -0,0 +1,6 @@ +Evawere Ogbe Evawere Ogbe +Gus Class Gus Class +Jason Dobry Jason Dobry +Luke Sneeringer Luke Sneeringer +Stephen Sawchuk Stephen Sawchuk +Stephen Sawchuk Stephen Sawchuk diff --git a/packages/google-cloud-videointelligence/.nycrc b/packages/google-cloud-videointelligence/.nycrc new file mode 100644 index 00000000000..a1a8e6920ce --- /dev/null +++ b/packages/google-cloud-videointelligence/.nycrc @@ -0,0 +1,26 @@ +{ + "report-dir": "./.coverage", + "exclude": [ + "src/*{/*,/**/*}.js", + "src/*/v*/*.js", + "test/**/*.js" + ], + "watermarks": { + "branches": [ + 95, + 100 + ], + "functions": [ + 95, + 100 + ], + "lines": [ + 95, + 100 + ], + "statements": [ + 95, + 100 + ] + } +} diff --git a/packages/google-cloud-videointelligence/.prettierignore b/packages/google-cloud-videointelligence/.prettierignore new file mode 100644 index 00000000000..f6fac98b0a8 --- /dev/null +++ b/packages/google-cloud-videointelligence/.prettierignore @@ -0,0 +1,3 @@ +node_modules/* +samples/node_modules/* +src/**/doc/* diff --git a/packages/google-cloud-videointelligence/.prettierrc b/packages/google-cloud-videointelligence/.prettierrc new file mode 100644 index 00000000000..df6eac07446 --- /dev/null +++ b/packages/google-cloud-videointelligence/.prettierrc @@ -0,0 +1,8 @@ +--- +bracketSpacing: false +printWidth: 80 +semi: true +singleQuote: true +tabWidth: 2 +trailingComma: es5 +useTabs: false diff --git a/packages/google-cloud-videointelligence/CODE_OF_CONDUCT.md b/packages/google-cloud-videointelligence/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..46b2a08ea6d --- /dev/null +++ b/packages/google-cloud-videointelligence/CODE_OF_CONDUCT.md @@ -0,0 +1,43 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, +and in the interest of fostering an open and welcoming community, +we pledge to respect all people who contribute through reporting issues, +posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project +a harassment-free experience for everyone, +regardless of level of experience, gender, gender identity and expression, +sexual orientation, disability, personal appearance, +body size, race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery +* Personal attacks +* Trolling or insulting/derogatory comments +* Public or private harassment +* Publishing other's private information, +such as physical or electronic +addresses, without explicit permission +* Other unethical or unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct. +By adopting this Code of Conduct, +project maintainers commit themselves to fairly and consistently +applying these principles to every aspect of managing this project. +Project maintainers who do not follow or enforce the Code of Conduct +may be permanently removed from the project team. + +This code of conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior +may be reported by opening an issue +or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, +available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) diff --git a/packages/google-cloud-videointelligence/CONTRIBUTORS b/packages/google-cloud-videointelligence/CONTRIBUTORS new file mode 100644 index 00000000000..fafe7606f07 --- /dev/null +++ b/packages/google-cloud-videointelligence/CONTRIBUTORS @@ -0,0 +1,14 @@ +# The names of individuals who have contributed to this project. +# +# Names are formatted as: +# name +# +Ace Nassri +Ali Ijaz Sheikh +Evawere Ogbe +Gus Class +Jason Dobry +Luke Sneeringer +Song Wang +Stephen Sawchuk +Tim Swast diff --git a/packages/google-cloud-videointelligence/LICENSE b/packages/google-cloud-videointelligence/LICENSE new file mode 100644 index 00000000000..7a4a3ea2424 --- /dev/null +++ b/packages/google-cloud-videointelligence/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-videointelligence/README.md b/packages/google-cloud-videointelligence/README.md index 9d338fcd05f..f861f2363cd 100644 --- a/packages/google-cloud-videointelligence/README.md +++ b/packages/google-cloud-videointelligence/README.md @@ -1,25 +1,163 @@ -# Node.js Client for Google Cloud Video Intelligence API ([Beta](https://github.com/GoogleCloudPlatform/google-cloud-node#versioning)) +Google Cloud Platform logo -[Google Cloud Video Intelligence API][Product Documentation]: Google Cloud Video Intelligence API. -- [Client Library Documentation][] -- [Product Documentation][] +# Google Cloud Video Intelligence API: Node.js Client -## Quick Start -In order to use this library, you first need to go through the following steps: +[![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-video-intelligence.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-video-intelligence) +[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/googleapis/nodejs-video-intelligence?branch=master&svg=true)](https://ci.appveyor.com/project/googleapis/nodejs-video-intelligence) +[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-video-intelligence/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-video-intelligence) -1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project) -2. [Enable the Google Cloud Video Intelligence API.](https://console.cloud.google.com/apis/api/video-intelligence) -3. [Setup Authentication.](https://googlecloudplatform.github.io/google-cloud-node/#/docs/google-cloud/master/guides/authentication) +> Node.js idiomatic client for [Video Intelligence API][product-docs]. -### Installation -``` -$ npm install --save @google-cloud/video-intelligence +The [Cloud Video Intelligence API](https://cloud.google.com/video-intelligence) allows developers to use Google video analysis technology as part of their applications. + +* [Video Intelligence API Node.js Client API Reference][client-docs] +* [Video Intelligence API 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) +* [Samples](#samples) +* [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 Cloud Video Intelligence API 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=videointelligence.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started + +### Installing the client library + + npm install --save @google-cloud/video-intelligence + +### Using the client library + +```javascript +// Imports the Google Cloud Video Intelligence library +const Video = require('@google-cloud/video-intelligence'); + +// Instantiates a client +const video = Video(); + +// The GCS filepath of the video to analyze +const gcsUri = 'gs://nodejs-docs-samples-video/quickstart_short.mp4'; + +// Construct request +const request = { + inputUri: gcsUri, + features: ['LABEL_DETECTION'], +}; + +// Execute request +video + .annotateVideo(request) + .then(results => { + const operation = results[0]; + console.log( + 'Waiting for operation to complete... (this may take a few minutes)' + ); + return operation.promise(); + }) + .then(results => { + // Gets annotations for video + const annotations = results[0].annotationResults[0]; + + // Gets labels for video from its annotations + const labels = annotations.segmentLabelAnnotations; + labels.forEach(label => { + console.log(`Label ${label.entity.description} occurs at:`); + label.segments.forEach(segment => { + segment = segment.segment; + if (segment.startTimeOffset.seconds === undefined) { + segment.startTimeOffset.seconds = 0; + } + if (segment.startTimeOffset.nanos === undefined) { + segment.startTimeOffset.nanos = 0; + } + if (segment.endTimeOffset.seconds === undefined) { + segment.endTimeOffset.seconds = 0; + } + if (segment.endTimeOffset.nanos === undefined) { + segment.endTimeOffset.nanos = 0; + } + console.log( + `\tStart: ${segment.startTimeOffset.seconds}` + + `.${(segment.startTimeOffset.nanos / 1e6).toFixed(0)}s` + ); + console.log( + `\tEnd: ${segment.endTimeOffset.seconds}.` + + `${(segment.endTimeOffset.nanos / 1e6).toFixed(0)}s` + ); + }); + }); + }) + .catch(err => { + console.error('ERROR:', err); + }); ``` -### Next Steps -- Read the [Client Library Documentation][] for Google Cloud Video Intelligence API to see other available methods on the client. -- Read the [Google Cloud Video Intelligence 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. +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-video-intelligence/blob/master/samples) directory. The samples' `README.md` +has instructions for running the samples. + +| Sample | Source Code | +| --------------------------- | --------------------------------- | +| Video Intelligence | [source code](https://github.com/googleapis/nodejs-video-intelligence/blob/master/samples/analyze.js) | + +The [Video Intelligence API 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 **beta**. This means it is expected to be +mostly stable while we work toward a general availability release; however, +complete stability is not guaranteed. We will address issues and requests +against beta libraries with a high priority. + +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](.github/CONTRIBUTING.md). + +## License + +Apache Version 2.0 + +See [LICENSE](LICENSE) -[Client Library Documentation]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/video-intelligence -[Product Documentation]: https://cloud.google.com/video-intelligence \ No newline at end of file +[client-docs]: https://cloud.google.com/nodejs/docs/reference/video-intelligence/latest/ +[product-docs]: https://cloud.google.com/video-intelligence diff --git a/packages/google-cloud-videointelligence/package.json b/packages/google-cloud-videointelligence/package.json index f2ee8a7a520..2fadce5e12c 100644 --- a/packages/google-cloud-videointelligence/package.json +++ b/packages/google-cloud-videointelligence/package.json @@ -1,9 +1,13 @@ { - "repository": "GoogleCloudPlatform/google-cloud-node", "name": "@google-cloud/video-intelligence", + "description": "Google Cloud Video Intelligence API client for Node.js", "version": "0.3.2", + "license": "Apache-2.0", "author": "Google Inc", - "description": "Google Cloud Video Intelligence API client for Node.js", + "engines": { + "node": ">=4.0.0" + }, + "repository": "googleapis/nodejs-video-intelligence", "main": "src/index.js", "files": [ "protos", @@ -24,21 +28,47 @@ "video intelligence", "Google Cloud Video Intelligence API" ], + "contributors": [ + "Ace Nassri ", + "Ali Ijaz Sheikh ", + "Evawere Ogbe ", + "Gus Class ", + "Jason Dobry ", + "Luke Sneeringer ", + "Song Wang ", + "Stephen Sawchuk ", + "Tim Swast " + ], + "scripts": { + "cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", + "docs": "repo-tools exec -- jsdoc -c .jsdoc.js", + "generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json", + "lint": "repo-tools lint --cmd eslint -- src/ samples/ test/", + "prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js", + "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", + "test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts", + "test": "repo-tools test run --cmd npm -- run cover" + }, "dependencies": { "extend": "^3.0", "google-gax": "^0.14.2", + "lodash.merge": "^4.6.0", "protobufjs": "^6.8.0" }, "devDependencies": { - "mocha": "^3.2.0" - }, - "scripts": { - "publish-module": "node ../../scripts/publish.js video-intelligence", - "smoke-test": "mocha smoke-test/*.js --timeout 5000", - "test": "mocha test/*.js" - }, - "license": "Apache-2.0", - "engines": { - "node": ">=4.0.0" + "@google-cloud/nodejs-repo-tools": "^2.0.11", + "async": "^2.5.0", + "codecov": "^3.0.0", + "eslint": "^4.9.0", + "eslint-config-prettier": "^2.6.0", + "eslint-plugin-node": "^5.2.1", + "eslint-plugin-prettier": "^2.3.1", + "ink-docstrap": "^1.3.0", + "intelli-espower-loader": "^1.0.1", + "jsdoc": "^3.5.5", + "mocha": "^4.0.1", + "nyc": "^11.2.1", + "power-assert": "^1.4.4", + "prettier": "^1.7.4" } } diff --git a/packages/google-cloud-videointelligence/samples/README.md b/packages/google-cloud-videointelligence/samples/README.md index 05da66feb4f..a78d517bfc8 100644 --- a/packages/google-cloud-videointelligence/samples/README.md +++ b/packages/google-cloud-videointelligence/samples/README.md @@ -1,39 +1,28 @@ Google Cloud Platform logo -# Google Cloud Video Intelligence API Node.js Samples +# Google Cloud Video Intelligence API: Node.js Samples -[![Build](https://storage.googleapis.com/cloud-docs-samples-badges/GoogleCloudPlatform/nodejs-docs-samples/nodejs-docs-samples-videointelligence.svg)]() +[![Build](https://storage.googleapis.com/.svg)]() The [Cloud Video Intelligence API](https://cloud.google.com/video-intelligence) allows developers to use Google video analysis technology as part of their applications. ## Table of Contents -* [Setup](#setup) +* [Before you begin](#before-you-begin) * [Samples](#samples) * [Video Intelligence](#video-intelligence) -* [Running the tests](#running-the-tests) -## Setup +## Before you begin -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 +Before running the samples, make sure you've followed the steps in the +[Before you begin section](../README.md#before-you-begin) of the client +library's README. ## Samples ### Video Intelligence -View the [documentation][video_0_docs] or the [source code][video_0_code]. +View the [source code][video_0_code]. __Usage:__ `node analyze.js --help` @@ -53,7 +42,7 @@ Examples: node analyze.js faces gs://demomaker/larry_sergey_ice_bucket_short.mp4 node analyze.js shots gs://demomaker/sushi.mp4 node analyze.js labels-gcs gs://demomaker/tomatoes.mp4 - node analyze.js labels-file resources/cat.mp4 + node analyze.js labels-file cat.mp4 node analyze.js safe-search gs://demomaker/tomatoes.mp4 For more information, see https://cloud.google.com/video-intelligence/docs @@ -61,17 +50,3 @@ For more information, see https://cloud.google.com/video-intelligence/docs [video_0_docs]: https://cloud.google.com/video-intelligence/docs [video_0_code]: analyze.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 diff --git a/packages/google-cloud-videointelligence/samples/package.json b/packages/google-cloud-videointelligence/samples/package.json index e17c092aa4f..60bbdd3124a 100644 --- a/packages/google-cloud-videointelligence/samples/package.json +++ b/packages/google-cloud-videointelligence/samples/package.json @@ -4,41 +4,23 @@ "private": true, "license": "Apache-2.0", "author": "Google Inc.", - "repository": { - "type": "git", - "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" - }, + "repository": "googleapis/nodejs-video-intelligence", "engines": { - "node": ">=4.3.2" + "node": ">=4.0.0" }, "scripts": { - "lint": "samples lint", - "pretest": "npm run lint", - "test": "samples test run --cmd ava -- -T 5m --verbose system-test/*.test.js" + "ava": "ava -T 20s --verbose test/*.test.js ./system-test/*.test.js", + "cover": "nyc --reporter=lcov --cache ava -T 20s --verbose test/*.test.js ./system-test/*.test.js && nyc report", + "test": "repo-tools test run --cmd ava -- -T 5m --verbose system-test/*.test.js" }, "dependencies": { "@google-cloud/video-intelligence": "^0.3.2", "long": "^3.2.0", "safe-buffer": "5.1.1", - "yargs": "8.0.2" + "yargs": "10.0.3" }, "devDependencies": { - "@google-cloud/nodejs-repo-tools": "1.4.17", - "ava": "0.22.0", - "proxyquire": "1.8.0" - }, - "cloud-repo-tools": { - "requiresKeyFile": true, - "requiresProjectId": true, - "product": "video", - "samples": [ - { - "id": "video", - "name": "Video Intelligence", - "file": "analyze.js", - "docs_link": "https://cloud.google.com/video-intelligence/docs", - "usage": "node analyze.js --help" - } - ] + "@google-cloud/nodejs-repo-tools": "2.0.11", + "ava": "0.22.0" } } diff --git a/packages/google-cloud-videointelligence/samples/quickstart.js b/packages/google-cloud-videointelligence/samples/quickstart.js index bb40eafe9fa..511a62ecc0b 100644 --- a/packages/google-cloud-videointelligence/samples/quickstart.js +++ b/packages/google-cloud-videointelligence/samples/quickstart.js @@ -17,10 +17,10 @@ // [START videointelligence_quickstart] // Imports the Google Cloud Video Intelligence library -const Video = require('@google-cloud/video-intelligence'); +const videoIntelligence = require('@google-cloud/video-intelligence'); -// Instantiates a client -const video = Video(); +// Creates a client +const client = new videoIntelligence.VideoIntelligenceServiceClient(); // The GCS filepath of the video to analyze const gcsUri = 'gs://nodejs-docs-samples-video/quickstart_short.mp4'; @@ -28,25 +28,28 @@ const gcsUri = 'gs://nodejs-docs-samples-video/quickstart_short.mp4'; // Construct request const request = { inputUri: gcsUri, - features: ['LABEL_DETECTION'] + features: ['LABEL_DETECTION'], }; // Execute request -video.annotateVideo(request) - .then((results) => { +client + .annotateVideo(request) + .then(results => { const operation = results[0]; - console.log('Waiting for operation to complete... (this may take a few minutes)'); + console.log( + 'Waiting for operation to complete... (this may take a few minutes)' + ); return operation.promise(); }) - .then((results) => { + .then(results => { // Gets annotations for video const annotations = results[0].annotationResults[0]; // Gets labels for video from its annotations const labels = annotations.segmentLabelAnnotations; - labels.forEach((label) => { + labels.forEach(label => { console.log(`Label ${label.entity.description} occurs at:`); - label.segments.forEach((segment) => { + label.segments.forEach(segment => { segment = segment.segment; if (segment.startTimeOffset.seconds === undefined) { segment.startTimeOffset.seconds = 0; @@ -60,14 +63,18 @@ video.annotateVideo(request) if (segment.endTimeOffset.nanos === undefined) { segment.endTimeOffset.nanos = 0; } - console.log(`\tStart: ${segment.startTimeOffset.seconds}` + - `.${(segment.startTimeOffset.nanos / 1e6).toFixed(0)}s`); - console.log(`\tEnd: ${segment.endTimeOffset.seconds}.` + - `${(segment.endTimeOffset.nanos / 1e6).toFixed(0)}s`); + console.log( + `\tStart: ${segment.startTimeOffset.seconds}` + + `.${(segment.startTimeOffset.nanos / 1e6).toFixed(0)}s` + ); + console.log( + `\tEnd: ${segment.endTimeOffset.seconds}.` + + `${(segment.endTimeOffset.nanos / 1e6).toFixed(0)}s` + ); }); }); }) - .catch((err) => { + .catch(err => { console.error('ERROR:', err); }); // [END videointelligence_quickstart] diff --git a/packages/google-cloud-videointelligence/src/index.js b/packages/google-cloud-videointelligence/src/index.js index 0e8185d6736..33296f32c7b 100644 --- a/packages/google-cloud-videointelligence/src/index.js +++ b/packages/google-cloud-videointelligence/src/index.js @@ -1,137 +1,100 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/*! - * @module video-intelligence - * @name VideoIntelligence +/** + * @namespace google + */ +/** + * @namespace google.protobuf + */ +/** + * @namespace google.rpc + */ +/** + * @namespace google.cloud + */ +/** + * @namespace google.cloud.videointelligence + */ +/** + * @namespace google.cloud.videointelligence.v1beta2 + */ +/** + * @namespace google.cloud.videointelligence.v1beta1 */ 'use strict'; -var extend = require('extend'); -var gapic = { - v1beta1: require('./v1beta1'), +// Import the clients for each version supported by this package. +const gapic = Object.freeze({ v1beta2: require('./v1beta2'), -}; -var gaxGrpc = require('google-gax').grpc(); -var path = require('path'); - -const VERSION = require('../package.json').version; - + v1beta1: require('./v1beta1'), +}); /** - * Create an videoIntelligenceServiceClient with additional helpers for common - * tasks. + * The `@google-cloud/video-intelligence` package has the following named exports: * - * Service that implements Google Cloud Video Intelligence API. + * - `VideoIntelligenceServiceClient` - Reference to + * {@link v1beta2.VideoIntelligenceServiceClient} + * - `v1beta2` - This is used for selecting or pinning a + * particular backend service version. It exports: + * - `VideoIntelligenceServiceClient` - Reference to + * {@link v1beta2.VideoIntelligenceServiceClient} + * - `v1beta1` - This is used for selecting or pinning a + * particular backend service version. It exports: + * - `VideoIntelligenceServiceClient` - Reference to + * {@link v1beta1.VideoIntelligenceServiceClient} * - * @param {object=} options - [Configuration object](#/docs). - * @param {object=} options.credentials - Credentials object. - * @param {string=} options.credentials.client_email - * @param {string=} options.credentials.private_key - * @param {string=} options.email - Account email address. Required when using a - * .pem or .p12 keyFilename. - * @param {string=} options.keyFilename - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option above is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number=} options.port - The port on which to connect to - * the remote host. - * @param {string=} options.projectId - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function=} options.promise - Custom promise module to use instead - * of native Promises. - * @param {string=} options.servicePath - The domain name of the - * API remote host. - */ -function videoIntelligenceV1beta1(options) { - // Define the header options. - options = extend({}, options, { - libName: 'gccl', - libVersion: VERSION - }); - - // Create the client with the provided options. - var client = gapic.v1beta1(options).videoIntelligenceServiceClient(options); - return client; -} - -var v1beta1Protos = {}; - -extend(v1beta1Protos, gaxGrpc.loadProto( - path.join(__dirname, '..', 'protos'), - 'google/cloud/videointelligence/v1beta1/video_intelligence.proto') - .google.cloud.videointelligence.v1beta1); - - -/** - * Create an videoIntelligenceServiceClient with additional helpers for common - * tasks. + * @module {object} @google-cloud/video-intelligence + * @alias nodejs-video-intelligence + * + * @example Install the client library with npm: + * npm install --save @google-cloud/video-intelligence + * + * @example Import the client library: + * const videoIntelligence = require('@google-cloud/video-intelligence'); * - * Service that implements Google Cloud Video Intelligence API. + * @example Create a client that uses Application Default Credentials (ADC): + * const client = new videoIntelligence.VideoIntelligenceServiceClient(); * - * @param {object=} options - [Configuration object](#/docs). - * @param {object=} options.credentials - Credentials object. - * @param {string=} options.credentials.client_email - * @param {string=} options.credentials.private_key - * @param {string=} options.email - Account email address. Required when using a - * .pem or .p12 keyFilename. - * @param {string=} options.keyFilename - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option above is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number=} options.port - The port on which to connect to - * the remote host. - * @param {string=} options.projectId - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {function=} options.promise - Custom promise module to use instead - * of native Promises. - * @param {string=} options.servicePath - The domain name of the - * API remote host. + * @example Create a client with explicit credentials: + * const client = new videoIntelligence.VideoIntelligenceServiceClient({ + * projectId: 'your-project-id', + * keyFilename: '/path/to/keyfile.json', + * }); */ -function videoIntelligenceV1beta2(options) { - // Define the header options. - options = extend({}, options, { - libName: 'gccl', - libVersion: VERSION - }); - // Create the client with the provided options. - var client = gapic.v1beta2(options).videoIntelligenceServiceClient(options); - return client; -} +/** + * @type {object} + * @property {constructor} VideoIntelligenceServiceClient + * Reference to {@link v1beta2.VideoIntelligenceServiceClient} + */ +module.exports = gapic.v1beta2; -var v1beta2Protos = {}; +/** + * @type {object} + * @property {constructor} VideoIntelligenceServiceClient + * Reference to {@link v1beta2.VideoIntelligenceServiceClient} + */ +module.exports.v1beta2 = gapic.v1beta2; -extend(v1beta2Protos, gaxGrpc.loadProto( - path.join(__dirname, '..', 'protos'), - 'google/cloud/videointelligence/v1beta2/video_intelligence.proto') - .google.cloud.videointelligence.v1beta2); +/** + * @type {object} + * @property {constructor} VideoIntelligenceServiceClient + * Reference to {@link v1beta1.VideoIntelligenceServiceClient} + */ +module.exports.v1beta1 = gapic.v1beta1; -module.exports = videoIntelligenceV1beta2; -module.exports.types = v1beta2Protos; -module.exports.v1beta1 = videoIntelligenceV1beta1; -module.exports.v1beta1.types = v1beta1Protos; -module.exports.v1beta2 = videoIntelligenceV1beta2; -module.exports.v1beta2.types = v1beta2Protos; +// Alias `module.exports` as `module.exports.default`, for future-proofing. +module.exports.default = Object.assign({}, module.exports); diff --git a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_video_intelligence.js b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/cloud/videointelligence/v1beta1/doc_video_intelligence.js similarity index 80% rename from packages/google-cloud-videointelligence/src/v1beta1/doc/doc_video_intelligence.js rename to packages/google-cloud-videointelligence/src/v1beta1/doc/google/cloud/videointelligence/v1beta1/doc_video_intelligence.js index d20f31cf39e..91410729ccc 100644 --- a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_video_intelligence.js +++ b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/cloud/videointelligence/v1beta1/doc_video_intelligence.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ - -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Copyright 2017, Google Inc. 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. + +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * Video annotation request. @@ -27,7 +23,7 @@ * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are * supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see + * google.rpc.Code.INVALID_ARGUMENT). For more information, see * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * A video URI may include wildcards in `object-id`, and thus identify * multiple videos. Supported wildcards: '*' to match 0 or more characters; @@ -41,19 +37,19 @@ * @property {number[]} features * Requested video annotation features. * - * The number should be among the values of [Feature]{@link Feature} + * The number should be among the values of [Feature]{@link google.cloud.videointelligence.v1beta1.Feature} * * @property {Object} videoContext * Additional video context and/or feature-specific parameters. * - * This object should have the same structure as [VideoContext]{@link VideoContext} + * This object should have the same structure as [VideoContext]{@link google.cloud.videointelligence.v1beta1.VideoContext} * * @property {string} outputUri * Optional location where the output (in JSON format) should be stored. * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) * URIs are supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see + * google.rpc.Code.INVALID_ARGUMENT). For more information, see * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * * @property {string} locationId @@ -61,7 +57,8 @@ * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region * is specified, a region will be determined based on video file location. * - * @class + * @typedef AnnotateVideoRequest + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.AnnotateVideoRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var AnnotateVideoRequest = { @@ -76,14 +73,14 @@ var AnnotateVideoRequest = { * to be contiguous or span the whole video. If unspecified, each video * is treated as a single segment. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta1.VideoSegment} * * @property {number} labelDetectionMode * If label detection has been requested, what labels should be detected * in addition to video-level labels or segment-level labels. If unspecified, * defaults to `SHOT_MODE`. * - * The number should be among the values of [LabelDetectionMode]{@link LabelDetectionMode} + * The number should be among the values of [LabelDetectionMode]{@link google.cloud.videointelligence.v1beta1.LabelDetectionMode} * * @property {boolean} stationaryCamera * Whether the video has been shot from a stationary (i.e. non-moving) camera. @@ -105,7 +102,8 @@ var AnnotateVideoRequest = { * Model to use for safe search detection. * Supported values: "latest" and "stable" (the default). * - * @class + * @typedef VideoContext + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.VideoContext definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var VideoContext = { @@ -121,7 +119,8 @@ var VideoContext = { * @property {number} endTimeOffset * End offset in microseconds (inclusive). Unset means 0. * - * @class + * @typedef VideoSegment + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.VideoSegment definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var VideoSegment = { @@ -137,7 +136,7 @@ var VideoSegment = { * Otherwise, corresponds to one of `AnnotateSpec.segments` * (if specified) or to shot boundaries (if requested). * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta1.VideoSegment} * * @property {number} confidence * Confidence that the label is accurate. Range: [0, 1]. @@ -145,9 +144,10 @@ var VideoSegment = { * @property {number} level * Label level. * - * The number should be among the values of [LabelLevel]{@link LabelLevel} + * The number should be among the values of [LabelLevel]{@link google.cloud.videointelligence.v1beta1.LabelLevel} * - * @class + * @typedef LabelLocation + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.LabelLocation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var LabelLocation = { @@ -166,9 +166,10 @@ var LabelLocation = { * @property {Object[]} locations * Where the label was detected and with what confidence. * - * This object should have the same structure as [LabelLocation]{@link LabelLocation} + * This object should have the same structure as [LabelLocation]{@link google.cloud.videointelligence.v1beta1.LabelLocation} * - * @class + * @typedef LabelAnnotation + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.LabelAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var LabelAnnotation = { @@ -185,33 +186,34 @@ var LabelAnnotation = { * @property {number} adult * Likelihood of adult content. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta1.Likelihood} * * @property {number} spoof * Likelihood that an obvious modification was made to the original * version to make it appear funny or offensive. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta1.Likelihood} * * @property {number} medical * Likelihood of medical content. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta1.Likelihood} * * @property {number} violent * Likelihood of violent content. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta1.Likelihood} * * @property {number} racy * Likelihood of racy content. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta1.Likelihood} * * @property {number} timeOffset * Video time offset in microseconds. * - * @class + * @typedef SafeSearchAnnotation + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.SafeSearchAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var SafeSearchAnnotation = { @@ -233,7 +235,8 @@ var SafeSearchAnnotation = { * @property {number} top * Top Y coordinate. * - * @class + * @typedef BoundingBox + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.BoundingBox definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var BoundingBox = { @@ -246,12 +249,13 @@ var BoundingBox = { * @property {Object} boundingBox * Bounding box in a frame. * - * This object should have the same structure as [BoundingBox]{@link BoundingBox} + * This object should have the same structure as [BoundingBox]{@link google.cloud.videointelligence.v1beta1.BoundingBox} * * @property {number} timeOffset * Video time offset in microseconds. * - * @class + * @typedef FaceLocation + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.FaceLocation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var FaceLocation = { @@ -269,14 +273,15 @@ var FaceLocation = { * Faces are detected and tracked on a per-video basis * (as opposed to across multiple videos). * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta1.VideoSegment} * * @property {Object[]} locations * Face locations at one frame per second. * - * This object should have the same structure as [FaceLocation]{@link FaceLocation} + * This object should have the same structure as [FaceLocation]{@link google.cloud.videointelligence.v1beta1.FaceLocation} * - * @class + * @typedef FaceAnnotation + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.FaceAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var FaceAnnotation = { @@ -293,30 +298,31 @@ var FaceAnnotation = { * @property {Object[]} labelAnnotations * Label annotations. There is exactly one element for each unique label. * - * This object should have the same structure as [LabelAnnotation]{@link LabelAnnotation} + * This object should have the same structure as [LabelAnnotation]{@link google.cloud.videointelligence.v1beta1.LabelAnnotation} * * @property {Object[]} faceAnnotations * Face annotations. There is exactly one element for each unique face. * - * This object should have the same structure as [FaceAnnotation]{@link FaceAnnotation} + * This object should have the same structure as [FaceAnnotation]{@link google.cloud.videointelligence.v1beta1.FaceAnnotation} * * @property {Object[]} shotAnnotations * Shot annotations. Each shot is represented as a video segment. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta1.VideoSegment} * * @property {Object[]} safeSearchAnnotations * Safe search annotations. * - * This object should have the same structure as [SafeSearchAnnotation]{@link SafeSearchAnnotation} + * This object should have the same structure as [SafeSearchAnnotation]{@link google.cloud.videointelligence.v1beta1.SafeSearchAnnotation} * * @property {Object} error * If set, indicates an error. Note that for a single `AnnotateVideoRequest` * some videos may succeed and some may fail. * - * This object should have the same structure as [google.rpc.Status]{@link external:"google.rpc.Status"} + * This object should have the same structure as [Status]{@link google.rpc.Status} * - * @class + * @typedef VideoAnnotationResults + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.VideoAnnotationResults definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var VideoAnnotationResults = { @@ -331,9 +337,10 @@ var VideoAnnotationResults = { * @property {Object[]} annotationResults * Annotation results for all videos specified in `AnnotateVideoRequest`. * - * This object should have the same structure as [VideoAnnotationResults]{@link VideoAnnotationResults} + * This object should have the same structure as [VideoAnnotationResults]{@link google.cloud.videointelligence.v1beta1.VideoAnnotationResults} * - * @class + * @typedef AnnotateVideoResponse + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.AnnotateVideoResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var AnnotateVideoResponse = { @@ -354,14 +361,15 @@ var AnnotateVideoResponse = { * @property {Object} startTime * Time when the request was received. * - * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"} + * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} * * @property {Object} updateTime * Time of the most recent update. * - * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"} + * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} * - * @class + * @typedef VideoAnnotationProgress + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.VideoAnnotationProgress definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var VideoAnnotationProgress = { @@ -376,9 +384,10 @@ var VideoAnnotationProgress = { * @property {Object[]} annotationProgress * Progress metadata for all videos specified in `AnnotateVideoRequest`. * - * This object should have the same structure as [VideoAnnotationProgress]{@link VideoAnnotationProgress} + * This object should have the same structure as [VideoAnnotationProgress]{@link google.cloud.videointelligence.v1beta1.VideoAnnotationProgress} * - * @class + * @typedef AnnotateVideoProgress + * @memberof google.cloud.videointelligence.v1beta1 * @see [google.cloud.videointelligence.v1beta1.AnnotateVideoProgress definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto} */ var AnnotateVideoProgress = { @@ -389,6 +398,7 @@ var AnnotateVideoProgress = { * Video annotation feature. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta1 */ var Feature = { @@ -422,6 +432,7 @@ var Feature = { * Label level (scope). * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta1 */ var LabelLevel = { @@ -456,6 +467,7 @@ var LabelLevel = { * Label detection mode. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta1 */ var LabelDetectionMode = { @@ -484,6 +496,7 @@ var LabelDetectionMode = { * Bucketized representation of likelihood. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta1 */ var Likelihood = { diff --git a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_protobuf_any.js b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/protobuf/doc_any.js similarity index 79% rename from packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_protobuf_any.js rename to packages/google-cloud-videointelligence/src/v1beta1/doc/google/protobuf/doc_any.js index 92cce16fdae..1e99231c144 100644 --- a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_protobuf_any.js +++ b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/protobuf/doc_any.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * `Any` contains an arbitrary serialized protocol buffer message along with a @@ -93,14 +89,13 @@ * If the embedded message type is well-known and has a custom JSON * representation, that representation will be embedded adding a field * `value` which holds the custom JSON in addition to the `@type` - * field. Example (for message {@link google.protobuf.Duration}): + * field. Example (for message google.protobuf.Duration): * * { * "@type": "type.googleapis.com/google.protobuf.Duration", * "value": "1.212s" * } * - * @external "google.protobuf.Any" * @property {string} typeUrl * A URL/resource name whose content describes the type of the * serialized protocol buffer message. @@ -113,7 +108,7 @@ * qualified name of the type (as in `path/google.protobuf.Duration`). * The name should be in a canonical form (e.g., leading "." is * not accepted). - * * An HTTP GET on the URL must yield a {@link google.protobuf.Type} + * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the * URL, or have them precompiled into a binary to avoid any @@ -127,5 +122,10 @@ * @property {string} value * Must be a valid serialized protocol buffer of the above specified type. * + * @typedef Any + * @memberof google.protobuf * @see [google.protobuf.Any definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/any.proto} - */ \ No newline at end of file + */ +var Any = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; \ No newline at end of file diff --git a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_rpc_status.js b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/rpc/doc_status.js similarity index 73% rename from packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_rpc_status.js rename to packages/google-cloud-videointelligence/src/v1beta1/doc/google/rpc/doc_status.js index e2614e9e2f3..d0b375da9f6 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_rpc_status.js +++ b/packages/google-cloud-videointelligence/src/v1beta1/doc/google/rpc/doc_status.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * The `Status` type defines a logical error model that is suitable for different @@ -31,7 +27,7 @@ * * The `Status` message contains three pieces of data: error code, error message, * and error details. The error code should be an enum value of - * {@link google.rpc.Code}, but it may accept additional error codes if needed. The + * google.rpc.Code, but it may accept additional error codes if needed. The * error message should be a developer-facing English message that helps * developers *understand* and *resolve* the error. If a localized user-facing * error message is needed, put the localized message in the error details or @@ -73,20 +69,24 @@ * - Logging. If some API errors are stored in logs, the message `Status` could * be used directly after any stripping needed for security/privacy reasons. * - * @external "google.rpc.Status" * @property {number} code - * The status code, which should be an enum value of {@link google.rpc.Code}. + * The status code, which should be an enum value of google.rpc.Code. * * @property {string} message * A developer-facing error message, which should be in English. Any * user-facing error message should be localized and sent in the - * {@link google.rpc.Status.details} field, or localized by the client. + * google.rpc.Status.details field, or localized by the client. * * @property {Object[]} details * A list of messages that carry the error details. There is a common set of * message types for APIs to use. * - * This object should have the same structure as [google.protobuf.Any]{@link external:"google.protobuf.Any"} + * This object should have the same structure as [Any]{@link google.protobuf.Any} * + * @typedef Status + * @memberof google.rpc * @see [google.rpc.Status definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto} - */ \ No newline at end of file + */ +var Status = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; \ No newline at end of file diff --git a/packages/google-cloud-videointelligence/src/v1beta1/index.js b/packages/google-cloud-videointelligence/src/v1beta1/index.js index 15dd940809a..56bc66623a3 100644 --- a/packages/google-cloud-videointelligence/src/v1beta1/index.js +++ b/packages/google-cloud-videointelligence/src/v1beta1/index.js @@ -1,34 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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'; - -var videoIntelligenceServiceClient = require('./video_intelligence_service_client'); -var gax = require('google-gax'); -var extend = require('extend'); +// Copyright 2017, Google Inc. 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. -function v1beta1(options) { - options = extend({ - scopes: v1beta1.ALL_SCOPES - }, options); - var gaxGrpc = gax.grpc(options); - return videoIntelligenceServiceClient(gaxGrpc); -} +'use strict'; -v1beta1.GAPIC_VERSION = '0.0.5'; -v1beta1.SERVICE_ADDRESS = videoIntelligenceServiceClient.SERVICE_ADDRESS; -v1beta1.ALL_SCOPES = videoIntelligenceServiceClient.ALL_SCOPES; +const VideoIntelligenceServiceClient = require('./video_intelligence_service_client'); -module.exports = v1beta1; \ No newline at end of file +module.exports.VideoIntelligenceServiceClient = VideoIntelligenceServiceClient; diff --git a/packages/google-cloud-videointelligence/src/v1beta1/video_intelligence_service_client.js b/packages/google-cloud-videointelligence/src/v1beta1/video_intelligence_service_client.js index d404f937988..40fe17b09c5 100644 --- a/packages/google-cloud-videointelligence/src/v1beta1/video_intelligence_service_client.js +++ b/packages/google-cloud-videointelligence/src/v1beta1/video_intelligence_service_client.js @@ -1,299 +1,342 @@ -/* - * Copyright 2017, Google Inc. 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. - * - * EDITING INSTRUCTIONS - * This file was generated from the file - * https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta1/video_intelligence.proto, - * and updates to that file get reflected here through a refresh process. - * For the short term, the refresh process will only be runnable by Google - * engineers. - * - * The only allowed edits are to method and file documentation. A 3-way - * merge preserves those additions if the generated source changes. - */ -/* TODO: introduce line-wrapping so that it never exceeds the limit. */ -/* jscs: disable maximumLineLength */ -'use strict'; - -var configData = require('./video_intelligence_service_client_config'); -var extend = require('extend'); -var gax = require('google-gax'); -var path = require('path'); -var protobuf = require('protobufjs'); +// Copyright 2017, Google Inc. 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. -var SERVICE_ADDRESS = 'videointelligence.googleapis.com'; +'use strict'; -var DEFAULT_SERVICE_PORT = 443; +const gapicConfig = require('./video_intelligence_service_client_config'); +const gax = require('google-gax'); +const merge = require('lodash.merge'); +const path = require('path'); +const protobuf = require('protobufjs'); -var CODE_GEN_NAME_VERSION = 'gapic/0.0.5'; - -/** - * The scopes needed to make gRPC calls to all of the methods defined in - * this service. - */ -var ALL_SCOPES = [ - 'https://www.googleapis.com/auth/cloud-platform' -]; +const VERSION = require('../../package.json').version; /** * Service that implements Google Cloud Video Intelligence API. * - * * @class + * @memberof v1beta1 */ -function VideoIntelligenceServiceClient(gaxGrpc, loadedProtos, opts) { - opts = extend({ - servicePath: SERVICE_ADDRESS, - port: DEFAULT_SERVICE_PORT, - clientConfig: {} - }, opts); +class VideoIntelligenceServiceClient { + /** + * Construct an instance of VideoIntelligenceServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * usaing a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option above is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.servicePath] - The domain name of the + * API remote host. + */ + constructor(opts) { + this._descriptors = {}; - var googleApiClient = [ - 'gl-node/' + process.versions.node - ]; - if (opts.libName && opts.libVersion) { - googleApiClient.push(opts.libName + '/' + opts.libVersion); - } - googleApiClient.push( - CODE_GEN_NAME_VERSION, - 'gax/' + gax.version, - 'grpc/' + gaxGrpc.grpcVersion - ); + // Ensure that options include the service address and port. + opts = Object.assign( + { + clientConfig: {}, + port: this.constructor.port, + servicePath: this.constructor.servicePath, + }, + opts + ); - this.operationsClient = new gax.lro({ - auth: gaxGrpc.auth, - grpc: gaxGrpc.grpc - }).operationsClient(opts); + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = this.constructor.scopes; + var gaxGrpc = gax.grpc(opts); - var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); - protoFilesRoot = protobuf.loadSync( - path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta1/video_intelligence.proto'), - protoFilesRoot); + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth; - var annotateVideoResponse = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta1.AnnotateVideoResponse'); - var annotateVideoMetadata = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta1.AnnotateVideoProgress'); + // Determine the client header string. + var clientHeader = [ + `gl-node/${process.version.node}`, + `grpc/${gaxGrpc.grpcVersion}`, + `gax/${gax.version}`, + `gapic/${VERSION}`, + ]; + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } - this.longrunningDescriptors = { - annotateVideo: new gax.LongrunningDescriptor( - this.operationsClient, - annotateVideoResponse.decode.bind(annotateVideoResponse), - annotateVideoMetadata.decode.bind(annotateVideoMetadata)) - }; + // Load the applicable protos. + var protos = merge( + {}, + gaxGrpc.loadProto( + path.join(__dirname, '..', '..', 'protos'), + 'google/cloud/videointelligence/v1beta1/video_intelligence.proto' + ) + ); + var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); + protoFilesRoot = protobuf.loadSync( + path.join( + __dirname, + '..', + '..', + 'protos', + 'google/cloud/videointelligence/v1beta1/video_intelligence.proto' + ), + protoFilesRoot + ); - var defaults = gaxGrpc.constructSettings( - 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', - configData, - opts.clientConfig, - {'x-goog-api-client': googleApiClient.join(' ')}); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + this.operationsClient = new gax.lro({ + auth: gaxGrpc.auth, + grpc: gaxGrpc.grpc, + }).operationsClient(opts); - var self = this; + var annotateVideoResponse = protoFilesRoot.lookup( + 'google.cloud.videointelligence.v1beta1.AnnotateVideoResponse' + ); + var annotateVideoMetadata = protoFilesRoot.lookup( + 'google.cloud.videointelligence.v1beta1.AnnotateVideoProgress' + ); - this.auth = gaxGrpc.auth; - var videoIntelligenceServiceStub = gaxGrpc.createStub( - loadedProtos.google.cloud.videointelligence.v1beta1.VideoIntelligenceService, - opts); - var videoIntelligenceServiceStubMethods = [ - 'annotateVideo' - ]; - videoIntelligenceServiceStubMethods.forEach(function(methodName) { - self['_' + methodName] = gax.createApiCall( - videoIntelligenceServiceStub.then(function(videoIntelligenceServiceStub) { - return function() { - var args = Array.prototype.slice.call(arguments, 0); - return videoIntelligenceServiceStub[methodName].apply(videoIntelligenceServiceStub, args); - }; - }), - defaults[methodName], - self.longrunningDescriptors[methodName]); - }); -} + this._descriptors.longrunning = { + annotateVideo: new gax.LongrunningDescriptor( + this.operationsClient, + annotateVideoResponse.decode.bind(annotateVideoResponse), + annotateVideoMetadata.decode.bind(annotateVideoMetadata) + ), + }; + // Put together the default options sent with requests. + var defaults = gaxGrpc.constructSettings( + 'google.cloud.videointelligence.v1beta1.VideoIntelligenceService', + gapicConfig, + opts.clientConfig, + {'x-goog-api-client': clientHeader.join(' ')} + ); -/** - * Get the project ID used by this class. - * @param {function(Error, string)} callback - the callback to be called with - * the current project Id. - */ -VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { - return this.auth.getProjectId(callback); -}; + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; -// Service calls + // Put together the "service stub" for + // google.cloud.videointelligence.v1beta1.VideoIntelligenceService. + var videoIntelligenceServiceStub = gaxGrpc.createStub( + protos.google.cloud.videointelligence.v1beta1.VideoIntelligenceService, + opts + ); -/** - * Performs asynchronous video annotation. Progress and results can be - * retrieved through the `google.longrunning.Operations` interface. - * `Operation.metadata` contains `AnnotateVideoProgress` (progress). - * `Operation.response` contains `AnnotateVideoResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.inputUri - * Input video location. Currently, only - * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are - * supported, which must be specified in the following format: - * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see - * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - * A video URI may include wildcards in `object-id`, and thus identify - * multiple videos. Supported wildcards: '*' to match 0 or more characters; - * '?' to match 1 character. If unset, the input video should be embedded - * in the request as `input_content`. If set, `input_content` should be unset. - * @param {number[]} request.features - * Requested video annotation features. - * - * The number should be among the values of [Feature]{@link Feature} - * @param {string=} request.inputContent - * The video data bytes. Encoding: base64. If unset, the input video(s) - * should be specified via `input_uri`. If set, `input_uri` should be unset. - * @param {Object=} request.videoContext - * Additional video context and/or feature-specific parameters. - * - * This object should have the same structure as [VideoContext]{@link VideoContext} - * @param {string=} request.outputUri - * Optional location where the output (in JSON format) should be stored. - * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) - * URIs are supported, which must be specified in the following format: - * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see - * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - * @param {string=} request.locationId - * Optional cloud region where annotation should take place. Supported cloud - * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region - * is specified, a region will be determined based on video file location. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * var videointelligence = require('@google-cloud/videointelligence'); - * - * var client = videointelligence.v1beta1({ - * // optional auth parameters. - * }); - * - * var inputUri = ''; - * var features = []; - * var request = { - * inputUri: inputUri, - * features: features - * }; - * - * // Handle the operation using the promise pattern. - * client.annotateVideo(request).then(function(responses) { - * var operation = responses[0]; - * var initialApiResponse = responses[1]; - * - * // Operation#promise starts polling for the completion of the LRO. - * return operation.promise(); - * }).then(function(responses) { - * // The final result of the operation. - * var result = responses[0]; - * - * // The metadata value of the completed operation. - * var metadata = responses[1]; - * - * // The response of the api call returning the complete operation. - * var finalApiResponse = responses[2]; - * }) - * .catch(function(err) { - * console.error(err); - * }); - * - * var inputUri = ''; - * var features = []; - * var request = { - * inputUri: inputUri, - * features: features - * }; - * - * // Handle the operation using the event emitter pattern. - * client.annotateVideo(request).then(function(responses) { - * var operation = responses[0]; - * var initialApiResponse = responses[1]; - * - * // Adding a listener for the "complete" event starts polling for the - * // completion of the operation. - * operation.on('complete', function(result, metadata, finalApiResponse) { - * // doSomethingWith(result); - * }); - * - * // Adding a listener for the "progress" event causes the callback to be - * // called on any change in metadata when the operation is polled. - * operation.on('progress', function(metadata, apiResponse) { - * // doSomethingWith(metadata) - * }) - * - * // Adding a listener for the "error" event handles any errors found during polling. - * operation.on('error', function(err) { - * // throw(err); - * }) - * }) - * .catch(function(err) { - * console.error(err); - * }); - */ -VideoIntelligenceServiceClient.prototype.annotateVideo = function(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; + // Iterate over each of the methods that the service provides + // and create an API call method for each. + var videoIntelligenceServiceStubMethods = ['annotateVideo']; + for (let methodName of videoIntelligenceServiceStubMethods) { + this._innerApiCalls[methodName] = gax.createApiCall( + videoIntelligenceServiceStub.then( + stub => + function() { + var args = Array.prototype.slice.call(arguments, 0); + return stub[methodName].apply(stub, args); + } + ), + defaults[methodName], + this._descriptors.longrunning[methodName] + ); + } } - if (options === undefined) { - options = {}; + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'videointelligence.googleapis.com'; } - return this._annotateVideo(request, options, callback); -}; + /** + * The port for this API service. + */ + static get port() { + return 443; + } -function VideoIntelligenceServiceClientBuilder(gaxGrpc) { - if (!(this instanceof VideoIntelligenceServiceClientBuilder)) { - return new VideoIntelligenceServiceClientBuilder(gaxGrpc); + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; } - var videoIntelligenceServiceStubProtos = gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos'), 'google/cloud/videointelligence/v1beta1/video_intelligence.proto'); - extend(this, videoIntelligenceServiceStubProtos.google.cloud.videointelligence.v1beta1); + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback) { + return this.auth.getProjectId(callback); + } + // ------------------- + // -- Service calls -- + // ------------------- /** - * Build a new instance of {@link VideoIntelligenceServiceClient}. + * Performs asynchronous video annotation. Progress and results can be + * retrieved through the `google.longrunning.Operations` interface. + * `Operation.metadata` contains `AnnotateVideoProgress` (progress). + * `Operation.response` contains `AnnotateVideoResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.inputUri + * Input video location. Currently, only + * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are + * supported, which must be specified in the following format: + * `gs://bucket-id/object-id` (other URI formats return + * google.rpc.Code.INVALID_ARGUMENT). For more information, see + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + * A video URI may include wildcards in `object-id`, and thus identify + * multiple videos. Supported wildcards: '*' to match 0 or more characters; + * '?' to match 1 character. If unset, the input video should be embedded + * in the request as `input_content`. If set, `input_content` should be unset. + * @param {number[]} request.features + * Requested video annotation features. * - * @param {Object=} opts - The optional parameters. - * @param {String=} opts.servicePath - * The domain name of the API remote host. - * @param {number=} opts.port - * The port on which to connect to the remote host. - * @param {grpc.ClientCredentials=} opts.sslCreds - * A ClientCredentials for use with an SSL-enabled channel. - * @param {Object=} opts.clientConfig - * The customized config to build the call settings. See - * {@link gax.constructSettings} for the format. + * The number should be among the values of [Feature]{@link google.cloud.videointelligence.v1beta1.Feature} + * @param {string} [request.inputContent] + * The video data bytes. Encoding: base64. If unset, the input video(s) + * should be specified via `input_uri`. If set, `input_uri` should be unset. + * @param {Object} [request.videoContext] + * Additional video context and/or feature-specific parameters. + * + * This object should have the same structure as [VideoContext]{@link google.cloud.videointelligence.v1beta1.VideoContext} + * @param {string} [request.outputUri] + * Optional location where the output (in JSON format) should be stored. + * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) + * URIs are supported, which must be specified in the following format: + * `gs://bucket-id/object-id` (other URI formats return + * google.rpc.Code.INVALID_ARGUMENT). For more information, see + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + * @param {string} [request.locationId] + * Optional cloud region where annotation should take place. Supported cloud + * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region + * is specified, a region will be determined based on video file location. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const videointelligence = require('@google-cloud/videointelligence'); + * + * var client = new videointelligence.v1beta1.VideoIntelligenceServiceClient({ + * // optional auth parameters. + * }); + * + * var inputUri = ''; + * var features = []; + * var request = { + * inputUri: inputUri, + * features: features, + * }; + * + * // Handle the operation using the promise pattern. + * client.annotateVideo(request) + * .then(responses => { + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Operation#promise starts polling for the completion of the LRO. + * return operation.promise(); + * }) + * .then(responses => { + * // The final result of the operation. + * var result = responses[0]; + * + * // The metadata value of the completed operation. + * var metadata = responses[1]; + * + * // The response of the api call returning the complete operation. + * var finalApiResponse = responses[2]; + * }) + * .catch(err => { + * console.error(err); + * }); + * + * var inputUri = ''; + * var features = []; + * var request = { + * inputUri: inputUri, + * features: features, + * }; + * + * // Handle the operation using the event emitter pattern. + * client.annotateVideo(request) + * .then(responses => { + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Adding a listener for the "complete" event starts polling for the + * // completion of the operation. + * operation.on('complete', (result, metadata, finalApiResponse) => { + * // doSomethingWith(result); + * }); + * + * // Adding a listener for the "progress" event causes the callback to be + * // called on any change in metadata when the operation is polled. + * operation.on('progress', (metadata, apiResponse) => { + * // doSomethingWith(metadata) + * }); + * + * // Adding a listener for the "error" event handles any errors found during polling. + * operation.on('error', err => { + * // throw(err); + * }); + * }) + * .catch(err => { + * console.error(err); + * }); */ - this.videoIntelligenceServiceClient = function(opts) { - return new VideoIntelligenceServiceClient(gaxGrpc, videoIntelligenceServiceStubProtos, opts); - }; - extend(this.videoIntelligenceServiceClient, VideoIntelligenceServiceClient); + annotateVideo(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + + return this._innerApiCalls.annotateVideo(request, options, callback); + } } -module.exports = VideoIntelligenceServiceClientBuilder; -module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; -module.exports.ALL_SCOPES = ALL_SCOPES; + +module.exports = VideoIntelligenceServiceClient; diff --git a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_video_intelligence.js b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/cloud/videointelligence/v1beta2/doc_video_intelligence.js similarity index 78% rename from packages/google-cloud-videointelligence/src/v1beta2/doc/doc_video_intelligence.js rename to packages/google-cloud-videointelligence/src/v1beta2/doc/google/cloud/videointelligence/v1beta2/doc_video_intelligence.js index 30077bc21ff..2e416956811 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_video_intelligence.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/cloud/videointelligence/v1beta2/doc_video_intelligence.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ - -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Copyright 2017, Google Inc. 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. + +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * Video annotation request. @@ -27,7 +23,7 @@ * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are * supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see + * google.rpc.Code.INVALID_ARGUMENT). For more information, see * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * A video URI may include wildcards in `object-id`, and thus identify * multiple videos. Supported wildcards: '*' to match 0 or more characters; @@ -41,19 +37,19 @@ * @property {number[]} features * Requested video annotation features. * - * The number should be among the values of [Feature]{@link Feature} + * The number should be among the values of [Feature]{@link google.cloud.videointelligence.v1beta2.Feature} * * @property {Object} videoContext * Additional video context and/or feature-specific parameters. * - * This object should have the same structure as [VideoContext]{@link VideoContext} + * This object should have the same structure as [VideoContext]{@link google.cloud.videointelligence.v1beta2.VideoContext} * * @property {string} outputUri * Optional location where the output (in JSON format) should be stored. * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) * URIs are supported, which must be specified in the following format: * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see + * google.rpc.Code.INVALID_ARGUMENT). For more information, see * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). * * @property {string} locationId @@ -61,7 +57,8 @@ * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region * is specified, a region will be determined based on video file location. * - * @class + * @typedef AnnotateVideoRequest + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.AnnotateVideoRequest definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var AnnotateVideoRequest = { @@ -76,29 +73,30 @@ var AnnotateVideoRequest = { * to be contiguous or span the whole video. If unspecified, each video * is treated as a single segment. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta2.VideoSegment} * * @property {Object} labelDetectionConfig * Config for LABEL_DETECTION. * - * This object should have the same structure as [LabelDetectionConfig]{@link LabelDetectionConfig} + * This object should have the same structure as [LabelDetectionConfig]{@link google.cloud.videointelligence.v1beta2.LabelDetectionConfig} * * @property {Object} shotChangeDetectionConfig * Config for SHOT_CHANGE_DETECTION. * - * This object should have the same structure as [ShotChangeDetectionConfig]{@link ShotChangeDetectionConfig} + * This object should have the same structure as [ShotChangeDetectionConfig]{@link google.cloud.videointelligence.v1beta2.ShotChangeDetectionConfig} * * @property {Object} explicitContentDetectionConfig * Config for EXPLICIT_CONTENT_DETECTION. * - * This object should have the same structure as [ExplicitContentDetectionConfig]{@link ExplicitContentDetectionConfig} + * This object should have the same structure as [ExplicitContentDetectionConfig]{@link google.cloud.videointelligence.v1beta2.ExplicitContentDetectionConfig} * * @property {Object} faceDetectionConfig * Config for FACE_DETECTION. * - * This object should have the same structure as [FaceDetectionConfig]{@link FaceDetectionConfig} + * This object should have the same structure as [FaceDetectionConfig]{@link google.cloud.videointelligence.v1beta2.FaceDetectionConfig} * - * @class + * @typedef VideoContext + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.VideoContext definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var VideoContext = { @@ -113,7 +111,7 @@ var VideoContext = { * video-level labels or segment-level labels. * If unspecified, defaults to `SHOT_MODE`. * - * The number should be among the values of [LabelDetectionMode]{@link LabelDetectionMode} + * The number should be among the values of [LabelDetectionMode]{@link google.cloud.videointelligence.v1beta2.LabelDetectionMode} * * @property {boolean} stationaryCamera * Whether the video has been shot from a stationary (i.e. non-moving) camera. @@ -125,7 +123,8 @@ var VideoContext = { * Supported values: "builtin/stable" (the default if unset) and * "builtin/latest". * - * @class + * @typedef LabelDetectionConfig + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.LabelDetectionConfig definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var LabelDetectionConfig = { @@ -140,7 +139,8 @@ var LabelDetectionConfig = { * Supported values: "builtin/stable" (the default if unset) and * "builtin/latest". * - * @class + * @typedef ShotChangeDetectionConfig + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.ShotChangeDetectionConfig definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var ShotChangeDetectionConfig = { @@ -155,7 +155,8 @@ var ShotChangeDetectionConfig = { * Supported values: "builtin/stable" (the default if unset) and * "builtin/latest". * - * @class + * @typedef ExplicitContentDetectionConfig + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.ExplicitContentDetectionConfig definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var ExplicitContentDetectionConfig = { @@ -173,7 +174,8 @@ var ExplicitContentDetectionConfig = { * @property {boolean} includeBoundingBoxes * Whether bounding boxes be included in the face annotation output. * - * @class + * @typedef FaceDetectionConfig + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.FaceDetectionConfig definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var FaceDetectionConfig = { @@ -187,15 +189,16 @@ var FaceDetectionConfig = { * Time-offset, relative to the beginning of the video, * corresponding to the start of the segment (inclusive). * - * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"} + * This object should have the same structure as [Duration]{@link google.protobuf.Duration} * * @property {Object} endTimeOffset * Time-offset, relative to the beginning of the video, * corresponding to the end of the segment (inclusive). * - * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"} + * This object should have the same structure as [Duration]{@link google.protobuf.Duration} * - * @class + * @typedef VideoSegment + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.VideoSegment definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var VideoSegment = { @@ -208,12 +211,13 @@ var VideoSegment = { * @property {Object} segment * Video segment where a label was detected. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta2.VideoSegment} * * @property {number} confidence * Confidence that the label is accurate. Range: [0, 1]. * - * @class + * @typedef LabelSegment + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.LabelSegment definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var LabelSegment = { @@ -227,12 +231,13 @@ var LabelSegment = { * Time-offset, relative to the beginning of the video, corresponding to the * video frame for this location. * - * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"} + * This object should have the same structure as [Duration]{@link google.protobuf.Duration} * * @property {number} confidence * Confidence that the label is accurate. Range: [0, 1]. * - * @class + * @typedef LabelFrame + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.LabelFrame definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var LabelFrame = { @@ -253,7 +258,8 @@ var LabelFrame = { * @property {string} languageCode * Language code for `description` in BCP-47 format. * - * @class + * @typedef Entity + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.Entity definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var Entity = { @@ -266,7 +272,7 @@ var Entity = { * @property {Object} entity * Detected entity. * - * This object should have the same structure as [Entity]{@link Entity} + * This object should have the same structure as [Entity]{@link google.cloud.videointelligence.v1beta2.Entity} * * @property {Object[]} categoryEntities * Common categories for the detected entity. @@ -274,19 +280,20 @@ var Entity = { * cases there might be more than one categories e.g. `Terrier` could also be * a `pet`. * - * This object should have the same structure as [Entity]{@link Entity} + * This object should have the same structure as [Entity]{@link google.cloud.videointelligence.v1beta2.Entity} * * @property {Object[]} segments * All video segments where a label was detected. * - * This object should have the same structure as [LabelSegment]{@link LabelSegment} + * This object should have the same structure as [LabelSegment]{@link google.cloud.videointelligence.v1beta2.LabelSegment} * * @property {Object[]} frames * All video frames where a label was detected. * - * This object should have the same structure as [LabelFrame]{@link LabelFrame} + * This object should have the same structure as [LabelFrame]{@link google.cloud.videointelligence.v1beta2.LabelFrame} * - * @class + * @typedef LabelAnnotation + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.LabelAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var LabelAnnotation = { @@ -300,14 +307,15 @@ var LabelAnnotation = { * Time-offset, relative to the beginning of the video, corresponding to the * video frame for this location. * - * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"} + * This object should have the same structure as [Duration]{@link google.protobuf.Duration} * * @property {number} pornographyLikelihood * Likelihood of the pornography content.. * - * The number should be among the values of [Likelihood]{@link Likelihood} + * The number should be among the values of [Likelihood]{@link google.cloud.videointelligence.v1beta2.Likelihood} * - * @class + * @typedef ExplicitContentFrame + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.ExplicitContentFrame definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var ExplicitContentFrame = { @@ -322,9 +330,10 @@ var ExplicitContentFrame = { * @property {Object[]} frames * All video frames where explicit content was detected. * - * This object should have the same structure as [ExplicitContentFrame]{@link ExplicitContentFrame} + * This object should have the same structure as [ExplicitContentFrame]{@link google.cloud.videointelligence.v1beta2.ExplicitContentFrame} * - * @class + * @typedef ExplicitContentAnnotation + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.ExplicitContentAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var ExplicitContentAnnotation = { @@ -348,7 +357,8 @@ var ExplicitContentAnnotation = { * @property {number} bottom * Bottom Y coordinate. * - * @class + * @typedef NormalizedBoundingBox + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.NormalizedBoundingBox definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var NormalizedBoundingBox = { @@ -361,9 +371,10 @@ var NormalizedBoundingBox = { * @property {Object} segment * Video segment where a face was detected. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta2.VideoSegment} * - * @class + * @typedef FaceSegment + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.FaceSegment definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var FaceSegment = { @@ -378,15 +389,16 @@ var FaceSegment = { * There can be more than one boxes if the same face is detected in multiple * locations within the current frame. * - * This object should have the same structure as [NormalizedBoundingBox]{@link NormalizedBoundingBox} + * This object should have the same structure as [NormalizedBoundingBox]{@link google.cloud.videointelligence.v1beta2.NormalizedBoundingBox} * * @property {Object} timeOffset * Time-offset, relative to the beginning of the video, * corresponding to the video frame for this location. * - * This object should have the same structure as [google.protobuf.Duration]{@link external:"google.protobuf.Duration"} + * This object should have the same structure as [Duration]{@link google.protobuf.Duration} * - * @class + * @typedef FaceFrame + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.FaceFrame definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var FaceFrame = { @@ -402,14 +414,15 @@ var FaceFrame = { * @property {Object[]} segments * All video segments where a face was detected. * - * This object should have the same structure as [FaceSegment]{@link FaceSegment} + * This object should have the same structure as [FaceSegment]{@link google.cloud.videointelligence.v1beta2.FaceSegment} * * @property {Object[]} frames * All video frames where a face was detected. * - * This object should have the same structure as [FaceFrame]{@link FaceFrame} + * This object should have the same structure as [FaceFrame]{@link google.cloud.videointelligence.v1beta2.FaceFrame} * - * @class + * @typedef FaceAnnotation + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.FaceAnnotation definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var FaceAnnotation = { @@ -427,42 +440,43 @@ var FaceAnnotation = { * Label annotations on video level or user specified segment level. * There is exactly one element for each unique label. * - * This object should have the same structure as [LabelAnnotation]{@link LabelAnnotation} + * This object should have the same structure as [LabelAnnotation]{@link google.cloud.videointelligence.v1beta2.LabelAnnotation} * * @property {Object[]} shotLabelAnnotations * Label annotations on shot level. * There is exactly one element for each unique label. * - * This object should have the same structure as [LabelAnnotation]{@link LabelAnnotation} + * This object should have the same structure as [LabelAnnotation]{@link google.cloud.videointelligence.v1beta2.LabelAnnotation} * * @property {Object[]} frameLabelAnnotations * Label annotations on frame level. * There is exactly one element for each unique label. * - * This object should have the same structure as [LabelAnnotation]{@link LabelAnnotation} + * This object should have the same structure as [LabelAnnotation]{@link google.cloud.videointelligence.v1beta2.LabelAnnotation} * * @property {Object[]} faceAnnotations * Face annotations. There is exactly one element for each unique face. * - * This object should have the same structure as [FaceAnnotation]{@link FaceAnnotation} + * This object should have the same structure as [FaceAnnotation]{@link google.cloud.videointelligence.v1beta2.FaceAnnotation} * * @property {Object[]} shotAnnotations * Shot annotations. Each shot is represented as a video segment. * - * This object should have the same structure as [VideoSegment]{@link VideoSegment} + * This object should have the same structure as [VideoSegment]{@link google.cloud.videointelligence.v1beta2.VideoSegment} * * @property {Object} explicitAnnotation * Explicit content annotation. * - * This object should have the same structure as [ExplicitContentAnnotation]{@link ExplicitContentAnnotation} + * This object should have the same structure as [ExplicitContentAnnotation]{@link google.cloud.videointelligence.v1beta2.ExplicitContentAnnotation} * * @property {Object} error * If set, indicates an error. Note that for a single `AnnotateVideoRequest` * some videos may succeed and some may fail. * - * This object should have the same structure as [google.rpc.Status]{@link external:"google.rpc.Status"} + * This object should have the same structure as [Status]{@link google.rpc.Status} * - * @class + * @typedef VideoAnnotationResults + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.VideoAnnotationResults definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var VideoAnnotationResults = { @@ -477,9 +491,10 @@ var VideoAnnotationResults = { * @property {Object[]} annotationResults * Annotation results for all videos specified in `AnnotateVideoRequest`. * - * This object should have the same structure as [VideoAnnotationResults]{@link VideoAnnotationResults} + * This object should have the same structure as [VideoAnnotationResults]{@link google.cloud.videointelligence.v1beta2.VideoAnnotationResults} * - * @class + * @typedef AnnotateVideoResponse + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.AnnotateVideoResponse definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var AnnotateVideoResponse = { @@ -500,14 +515,15 @@ var AnnotateVideoResponse = { * @property {Object} startTime * Time when the request was received. * - * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"} + * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} * * @property {Object} updateTime * Time of the most recent update. * - * This object should have the same structure as [google.protobuf.Timestamp]{@link external:"google.protobuf.Timestamp"} + * This object should have the same structure as [Timestamp]{@link google.protobuf.Timestamp} * - * @class + * @typedef VideoAnnotationProgress + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.VideoAnnotationProgress definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var VideoAnnotationProgress = { @@ -522,9 +538,10 @@ var VideoAnnotationProgress = { * @property {Object[]} annotationProgress * Progress metadata for all videos specified in `AnnotateVideoRequest`. * - * This object should have the same structure as [VideoAnnotationProgress]{@link VideoAnnotationProgress} + * This object should have the same structure as [VideoAnnotationProgress]{@link google.cloud.videointelligence.v1beta2.VideoAnnotationProgress} * - * @class + * @typedef AnnotateVideoProgress + * @memberof google.cloud.videointelligence.v1beta2 * @see [google.cloud.videointelligence.v1beta2.AnnotateVideoProgress definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto} */ var AnnotateVideoProgress = { @@ -535,6 +552,7 @@ var AnnotateVideoProgress = { * Video annotation feature. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta2 */ var Feature = { @@ -568,6 +586,7 @@ var Feature = { * Label detection mode. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta2 */ var LabelDetectionMode = { @@ -596,6 +615,7 @@ var LabelDetectionMode = { * Bucketized representation of likelihood. * * @enum {number} + * @memberof google.cloud.videointelligence.v1beta2 */ var Likelihood = { diff --git a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_any.js b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_any.js similarity index 79% rename from packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_any.js rename to packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_any.js index 92cce16fdae..1e99231c144 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_any.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_any.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * `Any` contains an arbitrary serialized protocol buffer message along with a @@ -93,14 +89,13 @@ * If the embedded message type is well-known and has a custom JSON * representation, that representation will be embedded adding a field * `value` which holds the custom JSON in addition to the `@type` - * field. Example (for message {@link google.protobuf.Duration}): + * field. Example (for message google.protobuf.Duration): * * { * "@type": "type.googleapis.com/google.protobuf.Duration", * "value": "1.212s" * } * - * @external "google.protobuf.Any" * @property {string} typeUrl * A URL/resource name whose content describes the type of the * serialized protocol buffer message. @@ -113,7 +108,7 @@ * qualified name of the type (as in `path/google.protobuf.Duration`). * The name should be in a canonical form (e.g., leading "." is * not accepted). - * * An HTTP GET on the URL must yield a {@link google.protobuf.Type} + * * An HTTP GET on the URL must yield a google.protobuf.Type * value in binary format, or produce an error. * * Applications are allowed to cache lookup results based on the * URL, or have them precompiled into a binary to avoid any @@ -127,5 +122,10 @@ * @property {string} value * Must be a valid serialized protocol buffer of the above specified type. * + * @typedef Any + * @memberof google.protobuf * @see [google.protobuf.Any definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/any.proto} - */ \ No newline at end of file + */ +var Any = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; \ No newline at end of file diff --git a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_duration.js b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_duration.js similarity index 79% rename from packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_duration.js rename to packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_duration.js index d4c9bfee517..6b107097540 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/doc/doc_google_protobuf_duration.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/protobuf/doc_duration.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * A Duration represents a signed, fixed-length span of time represented @@ -79,7 +75,6 @@ * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 * microsecond should be expressed in JSON format as "3.000001s". * - * @external "google.protobuf.Duration" * @property {number} seconds * Signed seconds of the span of time. Must be from -315,576,000,000 * to +315,576,000,000 inclusive. Note: these bounds are computed from: @@ -93,5 +88,10 @@ * of the same sign as the `seconds` field. Must be from -999,999,999 * to +999,999,999 inclusive. * + * @typedef Duration + * @memberof google.protobuf * @see [google.protobuf.Duration definition in proto format]{@link https://github.com/google/protobuf/blob/master/src/google/protobuf/duration.proto} - */ \ No newline at end of file + */ +var Duration = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; \ No newline at end of file diff --git a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_rpc_status.js b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/rpc/doc_status.js similarity index 73% rename from packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_rpc_status.js rename to packages/google-cloud-videointelligence/src/v1beta2/doc/google/rpc/doc_status.js index e2614e9e2f3..d0b375da9f6 100644 --- a/packages/google-cloud-videointelligence/src/v1beta1/doc/doc_google_rpc_status.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/doc/google/rpc/doc_status.js @@ -1,23 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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. -/* - * Note: this file is purely for documentation. Any contents are not expected - * to be loaded as the JS file. - */ +// Note: this file is purely for documentation. Any contents are not expected +// to be loaded as the JS file. /** * The `Status` type defines a logical error model that is suitable for different @@ -31,7 +27,7 @@ * * The `Status` message contains three pieces of data: error code, error message, * and error details. The error code should be an enum value of - * {@link google.rpc.Code}, but it may accept additional error codes if needed. The + * google.rpc.Code, but it may accept additional error codes if needed. The * error message should be a developer-facing English message that helps * developers *understand* and *resolve* the error. If a localized user-facing * error message is needed, put the localized message in the error details or @@ -73,20 +69,24 @@ * - Logging. If some API errors are stored in logs, the message `Status` could * be used directly after any stripping needed for security/privacy reasons. * - * @external "google.rpc.Status" * @property {number} code - * The status code, which should be an enum value of {@link google.rpc.Code}. + * The status code, which should be an enum value of google.rpc.Code. * * @property {string} message * A developer-facing error message, which should be in English. Any * user-facing error message should be localized and sent in the - * {@link google.rpc.Status.details} field, or localized by the client. + * google.rpc.Status.details field, or localized by the client. * * @property {Object[]} details * A list of messages that carry the error details. There is a common set of * message types for APIs to use. * - * This object should have the same structure as [google.protobuf.Any]{@link external:"google.protobuf.Any"} + * This object should have the same structure as [Any]{@link google.protobuf.Any} * + * @typedef Status + * @memberof google.rpc * @see [google.rpc.Status definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto} - */ \ No newline at end of file + */ +var Status = { + // This is for documentation. Actual contents will be loaded by gRPC. +}; \ No newline at end of file diff --git a/packages/google-cloud-videointelligence/src/v1beta2/index.js b/packages/google-cloud-videointelligence/src/v1beta2/index.js index 64f694bddd1..56bc66623a3 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/index.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/index.js @@ -1,34 +1,19 @@ -/* - * Copyright 2017, Google Inc. 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'; - -var videoIntelligenceServiceClient = require('./video_intelligence_service_client'); -var gax = require('google-gax'); -var extend = require('extend'); +// Copyright 2017, Google Inc. 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. -function v1beta2(options) { - options = extend({ - scopes: v1beta2.ALL_SCOPES - }, options); - var gaxGrpc = gax.grpc(options); - return videoIntelligenceServiceClient(gaxGrpc); -} +'use strict'; -v1beta2.GAPIC_VERSION = '0.0.5'; -v1beta2.SERVICE_ADDRESS = videoIntelligenceServiceClient.SERVICE_ADDRESS; -v1beta2.ALL_SCOPES = videoIntelligenceServiceClient.ALL_SCOPES; +const VideoIntelligenceServiceClient = require('./video_intelligence_service_client'); -module.exports = v1beta2; \ No newline at end of file +module.exports.VideoIntelligenceServiceClient = VideoIntelligenceServiceClient; diff --git a/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.js b/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.js index fecd7239eb4..8f883d670e5 100644 --- a/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.js +++ b/packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.js @@ -1,289 +1,332 @@ -/* - * Copyright 2017, Google Inc. 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. - * - * EDITING INSTRUCTIONS - * This file was generated from the file - * https://github.com/googleapis/googleapis/blob/master/google/cloud/videointelligence/v1beta2/video_intelligence.proto, - * and updates to that file get reflected here through a refresh process. - * For the short term, the refresh process will only be runnable by Google - * engineers. - * - * The only allowed edits are to method and file documentation. A 3-way - * merge preserves those additions if the generated source changes. - */ -/* TODO: introduce line-wrapping so that it never exceeds the limit. */ -/* jscs: disable maximumLineLength */ -'use strict'; - -var configData = require('./video_intelligence_service_client_config'); -var extend = require('extend'); -var gax = require('google-gax'); -var path = require('path'); -var protobuf = require('protobufjs'); +// Copyright 2017, Google Inc. 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. -var SERVICE_ADDRESS = 'videointelligence.googleapis.com'; - -var DEFAULT_SERVICE_PORT = 443; +'use strict'; -var CODE_GEN_NAME_VERSION = 'gapic/0.0.5'; +const gapicConfig = require('./video_intelligence_service_client_config'); +const gax = require('google-gax'); +const merge = require('lodash.merge'); +const path = require('path'); +const protobuf = require('protobufjs'); -/** - * The scopes needed to make gRPC calls to all of the methods defined in - * this service. - */ -var ALL_SCOPES = [ - 'https://www.googleapis.com/auth/cloud-platform' -]; +const VERSION = require('../../package.json').version; /** * Service that implements Google Cloud Video Intelligence API. * - * * @class + * @memberof v1beta2 */ -function VideoIntelligenceServiceClient(gaxGrpc, loadedProtos, opts) { - opts = extend({ - servicePath: SERVICE_ADDRESS, - port: DEFAULT_SERVICE_PORT, - clientConfig: {} - }, opts); +class VideoIntelligenceServiceClient { + /** + * Construct an instance of VideoIntelligenceServiceClient. + * + * @param {object} [options] - The configuration object. See the subsequent + * parameters for more details. + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * usaing a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option above is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {function} [options.promise] - Custom promise module to use instead + * of native Promises. + * @param {string} [options.servicePath] - The domain name of the + * API remote host. + */ + constructor(opts) { + this._descriptors = {}; - var googleApiClient = [ - 'gl-node/' + process.versions.node - ]; - if (opts.libName && opts.libVersion) { - googleApiClient.push(opts.libName + '/' + opts.libVersion); - } - googleApiClient.push( - CODE_GEN_NAME_VERSION, - 'gax/' + gax.version, - 'grpc/' + gaxGrpc.grpcVersion - ); + // Ensure that options include the service address and port. + opts = Object.assign( + { + clientConfig: {}, + port: this.constructor.port, + servicePath: this.constructor.servicePath, + }, + opts + ); - this.operationsClient = new gax.lro({ - auth: gaxGrpc.auth, - grpc: gaxGrpc.grpc - }).operationsClient(opts); + // Create a `gaxGrpc` object, with any grpc-specific options + // sent to the client. + opts.scopes = this.constructor.scopes; + var gaxGrpc = gax.grpc(opts); - var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); - protoFilesRoot = protobuf.loadSync( - path.join(__dirname, '..', '..', 'protos', 'google/cloud/videointelligence/v1beta2/video_intelligence.proto'), - protoFilesRoot); + // Save the auth object to the client, for use by other methods. + this.auth = gaxGrpc.auth; - var annotateVideoResponse = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta2.AnnotateVideoResponse'); - var annotateVideoMetadata = protoFilesRoot.lookup('google.cloud.videointelligence.v1beta2.AnnotateVideoProgress'); + // Determine the client header string. + var clientHeader = [ + `gl-node/${process.version.node}`, + `grpc/${gaxGrpc.grpcVersion}`, + `gax/${gax.version}`, + `gapic/${VERSION}`, + ]; + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } - this.longrunningDescriptors = { - annotateVideo: new gax.LongrunningDescriptor( - this.operationsClient, - annotateVideoResponse.decode.bind(annotateVideoResponse), - annotateVideoMetadata.decode.bind(annotateVideoMetadata)) - }; + // Load the applicable protos. + var protos = merge( + {}, + gaxGrpc.loadProto( + path.join(__dirname, '..', '..', 'protos'), + 'google/cloud/videointelligence/v1beta2/video_intelligence.proto' + ) + ); + var protoFilesRoot = new gax.grpc.GoogleProtoFilesRoot(); + protoFilesRoot = protobuf.loadSync( + path.join( + __dirname, + '..', + '..', + 'protos', + 'google/cloud/videointelligence/v1beta2/video_intelligence.proto' + ), + protoFilesRoot + ); - var defaults = gaxGrpc.constructSettings( - 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService', - configData, - opts.clientConfig, - {'x-goog-api-client': googleApiClient.join(' ')}); + // This API contains "long-running operations", which return a + // an Operation object that allows for tracking of the operation, + // rather than holding a request open. + this.operationsClient = new gax.lro({ + auth: gaxGrpc.auth, + grpc: gaxGrpc.grpc, + }).operationsClient(opts); - var self = this; + var annotateVideoResponse = protoFilesRoot.lookup( + 'google.cloud.videointelligence.v1beta2.AnnotateVideoResponse' + ); + var annotateVideoMetadata = protoFilesRoot.lookup( + 'google.cloud.videointelligence.v1beta2.AnnotateVideoProgress' + ); - this.auth = gaxGrpc.auth; - var videoIntelligenceServiceStub = gaxGrpc.createStub( - loadedProtos.google.cloud.videointelligence.v1beta2.VideoIntelligenceService, - opts); - var videoIntelligenceServiceStubMethods = [ - 'annotateVideo' - ]; - videoIntelligenceServiceStubMethods.forEach(function(methodName) { - self['_' + methodName] = gax.createApiCall( - videoIntelligenceServiceStub.then(function(videoIntelligenceServiceStub) { - return function() { - var args = Array.prototype.slice.call(arguments, 0); - return videoIntelligenceServiceStub[methodName].apply(videoIntelligenceServiceStub, args); - }; - }), - defaults[methodName], - self.longrunningDescriptors[methodName]); - }); -} + this._descriptors.longrunning = { + annotateVideo: new gax.LongrunningDescriptor( + this.operationsClient, + annotateVideoResponse.decode.bind(annotateVideoResponse), + annotateVideoMetadata.decode.bind(annotateVideoMetadata) + ), + }; + // Put together the default options sent with requests. + var defaults = gaxGrpc.constructSettings( + 'google.cloud.videointelligence.v1beta2.VideoIntelligenceService', + gapicConfig, + opts.clientConfig, + {'x-goog-api-client': clientHeader.join(' ')} + ); -/** - * Get the project ID used by this class. - * @param {function(Error, string)} callback - the callback to be called with - * the current project Id. - */ -VideoIntelligenceServiceClient.prototype.getProjectId = function(callback) { - return this.auth.getProjectId(callback); -}; + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this._innerApiCalls = {}; -// Service calls + // Put together the "service stub" for + // google.cloud.videointelligence.v1beta2.VideoIntelligenceService. + var videoIntelligenceServiceStub = gaxGrpc.createStub( + protos.google.cloud.videointelligence.v1beta2.VideoIntelligenceService, + opts + ); -/** - * Performs asynchronous video annotation. Progress and results can be - * retrieved through the `google.longrunning.Operations` interface. - * `Operation.metadata` contains `AnnotateVideoProgress` (progress). - * `Operation.response` contains `AnnotateVideoResponse` (results). - * - * @param {Object} request - * The request object that will be sent. - * @param {string=} request.inputUri - * Input video location. Currently, only - * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are - * supported, which must be specified in the following format: - * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see - * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - * A video URI may include wildcards in `object-id`, and thus identify - * multiple videos. Supported wildcards: '*' to match 0 or more characters; - * '?' to match 1 character. If unset, the input video should be embedded - * in the request as `input_content`. If set, `input_content` should be unset. - * @param {string=} request.inputContent - * The video data bytes. Encoding: base64. If unset, the input video(s) - * should be specified via `input_uri`. If set, `input_uri` should be unset. - * @param {number[]=} request.features - * Requested video annotation features. - * - * The number should be among the values of [Feature]{@link Feature} - * @param {Object=} request.videoContext - * Additional video context and/or feature-specific parameters. - * - * This object should have the same structure as [VideoContext]{@link VideoContext} - * @param {string=} request.outputUri - * Optional location where the output (in JSON format) should be stored. - * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) - * URIs are supported, which must be specified in the following format: - * `gs://bucket-id/object-id` (other URI formats return - * {@link google.rpc.Code.INVALID_ARGUMENT}). For more information, see - * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). - * @param {string=} request.locationId - * Optional cloud region where annotation should take place. Supported cloud - * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region - * is specified, a region will be determined based on video file location. - * @param {Object=} options - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. - * @param {function(?Error, ?Object)=} callback - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. - * @return {Promise} - The promise which resolves to an array. - * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - * @example - * - * var videoIntelligence = require('@google-cloud/video-intelligence'); - * - * var client = videoIntelligence.v1beta2({ - * // optional auth parameters. - * }); - * - * - * - * // Handle the operation using the promise pattern. - * client.annotateVideo({}).then(function(responses) { - * var operation = responses[0]; - * var initialApiResponse = responses[1]; - * - * // Operation#promise starts polling for the completion of the LRO. - * return operation.promise(); - * }).then(function(responses) { - * // The final result of the operation. - * var result = responses[0]; - * - * // The metadata value of the completed operation. - * var metadata = responses[1]; - * - * // The response of the api call returning the complete operation. - * var finalApiResponse = responses[2]; - * }) - * .catch(function(err) { - * console.error(err); - * }); - * - * - * - * // Handle the operation using the event emitter pattern. - * client.annotateVideo({}).then(function(responses) { - * var operation = responses[0]; - * var initialApiResponse = responses[1]; - * - * // Adding a listener for the "complete" event starts polling for the - * // completion of the operation. - * operation.on('complete', function(result, metadata, finalApiResponse) { - * // doSomethingWith(result); - * }); - * - * // Adding a listener for the "progress" event causes the callback to be - * // called on any change in metadata when the operation is polled. - * operation.on('progress', function(metadata, apiResponse) { - * // doSomethingWith(metadata) - * }) - * - * // Adding a listener for the "error" event handles any errors found during polling. - * operation.on('error', function(err) { - * // throw(err); - * }) - * }) - * .catch(function(err) { - * console.error(err); - * }); - */ -VideoIntelligenceServiceClient.prototype.annotateVideo = function(request, options, callback) { - if (options instanceof Function && callback === undefined) { - callback = options; - options = {}; + // Iterate over each of the methods that the service provides + // and create an API call method for each. + var videoIntelligenceServiceStubMethods = ['annotateVideo']; + for (let methodName of videoIntelligenceServiceStubMethods) { + this._innerApiCalls[methodName] = gax.createApiCall( + videoIntelligenceServiceStub.then( + stub => + function() { + var args = Array.prototype.slice.call(arguments, 0); + return stub[methodName].apply(stub, args); + } + ), + defaults[methodName], + this._descriptors.longrunning[methodName] + ); + } } - if (options === undefined) { - options = {}; + + /** + * The DNS address for this API service. + */ + static get servicePath() { + return 'videointelligence.googleapis.com'; } - return this._annotateVideo(request, options, callback); -}; + /** + * The port for this API service. + */ + static get port() { + return 443; + } -function VideoIntelligenceServiceClientBuilder(gaxGrpc) { - if (!(this instanceof VideoIntelligenceServiceClientBuilder)) { - return new VideoIntelligenceServiceClientBuilder(gaxGrpc); + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + */ + static get scopes() { + return ['https://www.googleapis.com/auth/cloud-platform']; } - var videoIntelligenceServiceStubProtos = gaxGrpc.loadProto( - path.join(__dirname, '..', '..', 'protos'), 'google/cloud/videointelligence/v1beta2/video_intelligence.proto'); - extend(this, videoIntelligenceServiceStubProtos.google.cloud.videointelligence.v1beta2); + /** + * Return the project ID used by this class. + * @param {function(Error, string)} callback - the callback to + * be called with the current project Id. + */ + getProjectId(callback) { + return this.auth.getProjectId(callback); + } + // ------------------- + // -- Service calls -- + // ------------------- /** - * Build a new instance of {@link VideoIntelligenceServiceClient}. + * Performs asynchronous video annotation. Progress and results can be + * retrieved through the `google.longrunning.Operations` interface. + * `Operation.metadata` contains `AnnotateVideoProgress` (progress). + * `Operation.response` contains `AnnotateVideoResponse` (results). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.inputUri] + * Input video location. Currently, only + * [Google Cloud Storage](https://cloud.google.com/storage/) URIs are + * supported, which must be specified in the following format: + * `gs://bucket-id/object-id` (other URI formats return + * google.rpc.Code.INVALID_ARGUMENT). For more information, see + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + * A video URI may include wildcards in `object-id`, and thus identify + * multiple videos. Supported wildcards: '*' to match 0 or more characters; + * '?' to match 1 character. If unset, the input video should be embedded + * in the request as `input_content`. If set, `input_content` should be unset. + * @param {string} [request.inputContent] + * The video data bytes. Encoding: base64. If unset, the input video(s) + * should be specified via `input_uri`. If set, `input_uri` should be unset. + * @param {number[]} [request.features] + * Requested video annotation features. + * + * The number should be among the values of [Feature]{@link google.cloud.videointelligence.v1beta2.Feature} + * @param {Object} [request.videoContext] + * Additional video context and/or feature-specific parameters. * - * @param {Object=} opts - The optional parameters. - * @param {String=} opts.servicePath - * The domain name of the API remote host. - * @param {number=} opts.port - * The port on which to connect to the remote host. - * @param {grpc.ClientCredentials=} opts.sslCreds - * A ClientCredentials for use with an SSL-enabled channel. - * @param {Object=} opts.clientConfig - * The customized config to build the call settings. See - * {@link gax.constructSettings} for the format. + * This object should have the same structure as [VideoContext]{@link google.cloud.videointelligence.v1beta2.VideoContext} + * @param {string} [request.outputUri] + * Optional location where the output (in JSON format) should be stored. + * Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) + * URIs are supported, which must be specified in the following format: + * `gs://bucket-id/object-id` (other URI formats return + * google.rpc.Code.INVALID_ARGUMENT). For more information, see + * [Request URIs](https://cloud.google.com/storage/docs/reference-uris). + * @param {string} [request.locationId] + * Optional cloud region where annotation should take place. Supported cloud + * regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region + * is specified, a region will be determined based on video file location. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See [gax.CallOptions]{@link https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is a [gax.Operation]{@link https://googleapis.github.io/gax-nodejs/Operation} object. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + * @example + * + * const videoIntelligence = require('@google-cloud/video-intelligence'); + * + * var client = new videoIntelligence.v1beta2.VideoIntelligenceServiceClient({ + * // optional auth parameters. + * }); + * + * + * + * // Handle the operation using the promise pattern. + * client.annotateVideo({}) + * .then(responses => { + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Operation#promise starts polling for the completion of the LRO. + * return operation.promise(); + * }) + * .then(responses => { + * // The final result of the operation. + * var result = responses[0]; + * + * // The metadata value of the completed operation. + * var metadata = responses[1]; + * + * // The response of the api call returning the complete operation. + * var finalApiResponse = responses[2]; + * }) + * .catch(err => { + * console.error(err); + * }); + * + * + * + * // Handle the operation using the event emitter pattern. + * client.annotateVideo({}) + * .then(responses => { + * var operation = responses[0]; + * var initialApiResponse = responses[1]; + * + * // Adding a listener for the "complete" event starts polling for the + * // completion of the operation. + * operation.on('complete', (result, metadata, finalApiResponse) => { + * // doSomethingWith(result); + * }); + * + * // Adding a listener for the "progress" event causes the callback to be + * // called on any change in metadata when the operation is polled. + * operation.on('progress', (metadata, apiResponse) => { + * // doSomethingWith(metadata) + * }); + * + * // Adding a listener for the "error" event handles any errors found during polling. + * operation.on('error', err => { + * // throw(err); + * }); + * }) + * .catch(err => { + * console.error(err); + * }); */ - this.videoIntelligenceServiceClient = function(opts) { - return new VideoIntelligenceServiceClient(gaxGrpc, videoIntelligenceServiceStubProtos, opts); - }; - extend(this.videoIntelligenceServiceClient, VideoIntelligenceServiceClient); + annotateVideo(request, options, callback) { + if (options instanceof Function && callback === undefined) { + callback = options; + options = {}; + } + options = options || {}; + + return this._innerApiCalls.annotateVideo(request, options, callback); + } } -module.exports = VideoIntelligenceServiceClientBuilder; -module.exports.SERVICE_ADDRESS = SERVICE_ADDRESS; -module.exports.ALL_SCOPES = ALL_SCOPES; + +module.exports = VideoIntelligenceServiceClient; diff --git a/packages/google-cloud-videointelligence/test/.eslintrc.yml b/packages/google-cloud-videointelligence/test/.eslintrc.yml new file mode 100644 index 00000000000..73f7bbc946f --- /dev/null +++ b/packages/google-cloud-videointelligence/test/.eslintrc.yml @@ -0,0 +1,5 @@ +--- +env: + mocha: true +rules: + node/no-unpublished-require: off diff --git a/packages/google-cloud-videointelligence/test/gapic-v1beta1.js b/packages/google-cloud-videointelligence/test/gapic-v1beta1.js index 2363e93191e..b0316abf1fe 100644 --- a/packages/google-cloud-videointelligence/test/gapic-v1beta1.js +++ b/packages/google-cloud-videointelligence/test/gapic-v1beta1.js @@ -1,118 +1,137 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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'; -var assert = require('assert'); -var videointelligence = require('../src'); +const assert = require('assert'); + +const videointelligenceModule = require('../src'); var FAKE_STATUS_CODE = 1; var error = new Error(); error.code = FAKE_STATUS_CODE; -describe('VideoIntelligenceServiceClient', function() { +describe('VideoIntelligenceServiceClient', () => { describe('annotateVideo', function() { - it('invokes annotateVideo without error', function(done) { - var client = videointelligence.v1beta1(); + it('invokes annotateVideo without error', done => { + var client = new videointelligenceModule.v1beta1 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); // Mock request var inputUri = 'inputUri1707300727'; var features = []; var request = { - inputUri : inputUri, - features : features + inputUri: inputUri, + features: features, }; // Mock response var expectedResponse = {}; // Mock Grpc layer - client._annotateVideo = mockLongRunningGrpcMethod(request, expectedResponse); + client._innerApiCalls.annotateVideo = mockLongRunningGrpcMethod( + request, + expectedResponse + ); - client.annotateVideo(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }).catch(function(err) { - done(err); - }); + client + .annotateVideo(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch(err => { + done(err); + }); }); - it('invokes annotateVideo with error', function(done) { - var client = videointelligence.v1beta1(); + it('invokes annotateVideo with error', done => { + var client = new videointelligenceModule.v1beta1 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); // Mock request var inputUri = 'inputUri1707300727'; var features = []; var request = { - inputUri : inputUri, - features : features + inputUri: inputUri, + features: features, }; // Mock Grpc layer - client._annotateVideo = mockLongRunningGrpcMethod(request, null, error); + client._innerApiCalls.annotateVideo = mockLongRunningGrpcMethod( + request, + null, + error + ); - client.annotateVideo(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.fail(); - }).catch(function(err) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); + client + .annotateVideo(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(() => { + assert.fail(); + }) + .catch(err => { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); }); - it('has longrunning decoder functions', function() { - var client = videointelligence.v1beta1(); - assert(client.longrunningDescriptors.annotateVideo.responseDecoder instanceof Function); - assert(client.longrunningDescriptors.annotateVideo.metadataDecoder instanceof Function); + it('has longrunning decoder functions', () => { + var client = new videointelligenceModule.v1beta1 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert( + client._descriptors.longrunning.annotateVideo.responseDecoder instanceof + Function + ); + assert( + client._descriptors.longrunning.annotateVideo.metadataDecoder instanceof + Function + ); }); }); - }); -function mockSimpleGrpcMethod(expectedRequest, response, error) { - return function(actualRequest, options, callback) { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} - function mockLongRunningGrpcMethod(expectedRequest, response, error) { - return function(request) { + return request => { assert.deepStrictEqual(request, expectedRequest); var mockOperation = { promise: function() { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { if (error) { reject(error); } else { resolve([response]); } }); - } + }, }; return Promise.resolve([mockOperation]); }; diff --git a/packages/google-cloud-videointelligence/test/gapic-v1beta2.js b/packages/google-cloud-videointelligence/test/gapic-v1beta2.js index 07e7c5d25ce..0bd4b429141 100644 --- a/packages/google-cloud-videointelligence/test/gapic-v1beta2.js +++ b/packages/google-cloud-videointelligence/test/gapic-v1beta2.js @@ -1,31 +1,35 @@ -/* - * Copyright 2017, Google Inc. 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. - */ +// Copyright 2017, Google Inc. 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'; -var assert = require('assert'); -var videoIntelligence = require('../src'); +const assert = require('assert'); + +const videoIntelligenceModule = require('../src'); var FAKE_STATUS_CODE = 1; var error = new Error(); error.code = FAKE_STATUS_CODE; -describe('VideoIntelligenceServiceClient', function() { +describe('VideoIntelligenceServiceClient', () => { describe('annotateVideo', function() { - it('invokes annotateVideo without error', function(done) { - var client = videoIntelligence.v1beta2(); + it('invokes annotateVideo without error', done => { + var client = new videoIntelligenceModule.v1beta2 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); // Mock request var request = {}; @@ -34,75 +38,90 @@ describe('VideoIntelligenceServiceClient', function() { var expectedResponse = {}; // Mock Grpc layer - client._annotateVideo = mockLongRunningGrpcMethod(request, expectedResponse); + client._innerApiCalls.annotateVideo = mockLongRunningGrpcMethod( + request, + expectedResponse + ); - client.annotateVideo(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.deepStrictEqual(responses[0], expectedResponse); - done(); - }).catch(function(err) { - done(err); - }); + client + .annotateVideo(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(responses => { + assert.deepStrictEqual(responses[0], expectedResponse); + done(); + }) + .catch(err => { + done(err); + }); }); - it('invokes annotateVideo with error', function(done) { - var client = videoIntelligence.v1beta2(); + it('invokes annotateVideo with error', done => { + var client = new videoIntelligenceModule.v1beta2 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); // Mock request var request = {}; // Mock Grpc layer - client._annotateVideo = mockLongRunningGrpcMethod(request, null, error); + client._innerApiCalls.annotateVideo = mockLongRunningGrpcMethod( + request, + null, + error + ); - client.annotateVideo(request).then(function(responses) { - var operation = responses[0]; - return operation.promise(); - }).then(function(responses) { - assert.fail(); - }).catch(function(err) { - assert(err instanceof Error); - assert.equal(err.code, FAKE_STATUS_CODE); - done(); - }); + client + .annotateVideo(request) + .then(responses => { + var operation = responses[0]; + return operation.promise(); + }) + .then(() => { + assert.fail(); + }) + .catch(err => { + assert(err instanceof Error); + assert.equal(err.code, FAKE_STATUS_CODE); + done(); + }); }); - it('has longrunning decoder functions', function() { - var client = videoIntelligence.v1beta2(); - assert(client.longrunningDescriptors.annotateVideo.responseDecoder instanceof Function); - assert(client.longrunningDescriptors.annotateVideo.metadataDecoder instanceof Function); + it('has longrunning decoder functions', () => { + var client = new videoIntelligenceModule.v1beta2 + .VideoIntelligenceServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert( + client._descriptors.longrunning.annotateVideo.responseDecoder instanceof + Function + ); + assert( + client._descriptors.longrunning.annotateVideo.metadataDecoder instanceof + Function + ); }); }); - }); -function mockSimpleGrpcMethod(expectedRequest, response, error) { - return function(actualRequest, options, callback) { - assert.deepStrictEqual(actualRequest, expectedRequest); - if (error) { - callback(error); - } else if (response) { - callback(null, response); - } else { - callback(null); - } - }; -} - function mockLongRunningGrpcMethod(expectedRequest, response, error) { - return function(request) { + return request => { assert.deepStrictEqual(request, expectedRequest); var mockOperation = { promise: function() { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { if (error) { reject(error); } else { resolve([response]); } }); - } + }, }; return Promise.resolve([mockOperation]); };