├── .appveyor.yml ├── .circleci ├── config.yml └── key.json.enc ├── .cloud-repo-tools.json ├── .eslintignore ├── .eslintrc.yml ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .jsdoc.js ├── .mailmap ├── .nycrc ├── .prettierignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── package.json ├── protos └── google │ ├── api │ ├── annotations.proto │ ├── auth.proto │ ├── backend.proto │ ├── billing.proto │ ├── config_change.proto │ ├── consumer.proto │ ├── context.proto │ ├── control.proto │ ├── distribution.proto │ ├── documentation.proto │ ├── endpoint.proto │ ├── experimental │ │ ├── authorization_config.proto │ │ └── experimental.proto │ ├── http.proto │ ├── httpbody.proto │ ├── label.proto │ ├── log.proto │ ├── logging.proto │ ├── metric.proto │ ├── monitored_resource.proto │ ├── monitoring.proto │ ├── quota.proto │ ├── service.proto │ ├── servicecontrol │ │ └── v1 │ │ │ ├── check_error.proto │ │ │ ├── distribution.proto │ │ │ ├── log_entry.proto │ │ │ ├── metric_value.proto │ │ │ ├── operation.proto │ │ │ └── service_controller.proto │ ├── servicemanagement │ │ └── v1 │ │ │ ├── resources.proto │ │ │ └── servicemanager.proto │ ├── source_info.proto │ ├── system_parameter.proto │ └── usage.proto │ ├── iam │ ├── admin │ │ └── v1 │ │ │ └── iam.proto │ └── v1 │ │ ├── iam_policy.proto │ │ └── policy.proto │ ├── protobuf │ ├── any.proto │ ├── api.proto │ ├── descriptor.proto │ ├── duration.proto │ ├── empty.proto │ ├── field_mask.proto │ ├── source_context.proto │ ├── struct.proto │ ├── timestamp.proto │ ├── type.proto │ ├── util │ │ └── json_format_proto3.proto │ └── wrappers.proto │ └── pubsub │ └── v1 │ └── pubsub.proto ├── samples ├── .eslintrc.yml ├── README.md ├── package.json ├── quickstart.js ├── subscriptions.js ├── system-test │ ├── .eslintrc.yml │ ├── quickstart.test.js │ ├── subscriptions.test.js │ └── topics.test.js └── topics.js ├── src ├── connection-pool.js ├── histogram.js ├── iam.js ├── index.js ├── publisher.js ├── snapshot.js ├── subscription.js ├── topic.js └── v1 │ ├── index.js │ ├── publisher_client.js │ ├── publisher_client_config.json │ ├── subscriber_client.js │ └── subscriber_client_config.json ├── system-test ├── .eslintrc.yml └── pubsub.js └── test ├── .eslintrc.yml ├── connection-pool.js ├── histogram.js ├── iam.js ├── index.js ├── publisher.js ├── snapshot.js ├── subscription.js └── topic.js /.appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | matrix: 3 | - nodejs_version: 8 4 | 5 | install: 6 | - ps: Install-Product node $env:nodejs_version 7 | - npm install -g npm # Force using the latest npm to get dedupe during install 8 | - set PATH=%APPDATA%\npm;%PATH% 9 | - npm install --force --ignore-scripts 10 | 11 | test_script: 12 | - node --version 13 | - npm --version 14 | - npm rebuild 15 | - npm test 16 | 17 | build: off 18 | 19 | matrix: 20 | fast_finish: true 21 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # "Include" for unit tests definition. 3 | unit_tests: &unit_tests 4 | steps: 5 | - checkout 6 | - run: 7 | name: Install modules and dependencies. 8 | command: npm install 9 | - run: 10 | name: Run unit tests. 11 | command: npm test 12 | - run: 13 | name: Submit coverage data to codecov. 14 | command: node_modules/.bin/codecov 15 | when: always 16 | 17 | version: 2.0 18 | workflows: 19 | version: 2 20 | tests: 21 | jobs: 22 | - node4: 23 | filters: 24 | tags: 25 | only: /.*/ 26 | - node6: 27 | filters: 28 | tags: 29 | only: /.*/ 30 | - node7: 31 | filters: 32 | tags: 33 | only: /.*/ 34 | - node8: 35 | filters: 36 | tags: 37 | only: /.*/ 38 | - node9: 39 | filters: 40 | tags: 41 | only: /.*/ 42 | - lint: 43 | requires: 44 | - node4 45 | - node6 46 | - node7 47 | - node8 48 | - node9 49 | filters: 50 | tags: 51 | only: /.*/ 52 | - docs: 53 | requires: 54 | - node4 55 | - node6 56 | - node7 57 | - node8 58 | - node9 59 | filters: 60 | tags: 61 | only: /.*/ 62 | - system_tests: 63 | requires: 64 | - lint 65 | - docs 66 | filters: 67 | branches: 68 | only: master 69 | tags: 70 | only: /^v[\d.]+$/ 71 | - sample_tests: 72 | requires: 73 | - lint 74 | - docs 75 | filters: 76 | branches: 77 | only: master 78 | tags: 79 | only: /^v[\d.]+$/ 80 | - publish_npm: 81 | requires: 82 | - system_tests 83 | - sample_tests 84 | filters: 85 | branches: 86 | ignore: /.*/ 87 | tags: 88 | only: /^v[\d.]+$/ 89 | 90 | jobs: 91 | node4: 92 | docker: 93 | - image: node:4 94 | user: node 95 | steps: 96 | - checkout 97 | - run: 98 | name: Install modules and dependencies. 99 | command: npm install --unsafe-perm 100 | - run: 101 | name: Run unit tests. 102 | command: npm test 103 | - run: 104 | name: Submit coverage data to codecov. 105 | command: node_modules/.bin/codecov 106 | when: always 107 | node6: 108 | docker: 109 | - image: node:6 110 | user: node 111 | <<: *unit_tests 112 | node7: 113 | docker: 114 | - image: node:7 115 | user: node 116 | <<: *unit_tests 117 | node8: 118 | docker: 119 | - image: node:8 120 | user: node 121 | <<: *unit_tests 122 | node9: 123 | docker: 124 | - image: node:9 125 | user: node 126 | <<: *unit_tests 127 | 128 | lint: 129 | docker: 130 | - image: node:8 131 | user: node 132 | steps: 133 | - checkout 134 | - run: 135 | name: Install modules and dependencies. 136 | command: | 137 | mkdir /home/node/.npm-global 138 | npm install 139 | npm link 140 | environment: 141 | NPM_CONFIG_PREFIX: /home/node/.npm-global 142 | - run: 143 | name: Link the module being tested to the samples. 144 | command: | 145 | cd samples/ 146 | npm link @google-cloud/pubsub 147 | npm install 148 | cd .. 149 | environment: 150 | NPM_CONFIG_PREFIX: /home/node/.npm-global 151 | - run: 152 | name: Run linting. 153 | command: npm run lint 154 | environment: 155 | NPM_CONFIG_PREFIX: /home/node/.npm-global 156 | 157 | docs: 158 | docker: 159 | - image: node:8 160 | user: node 161 | steps: 162 | - checkout 163 | - run: 164 | name: Install modules and dependencies. 165 | command: npm install 166 | - run: 167 | name: Build documentation. 168 | command: npm run docs 169 | 170 | sample_tests: 171 | docker: 172 | - image: node:8 173 | user: node 174 | steps: 175 | - checkout 176 | - run: 177 | name: Decrypt credentials. 178 | command: | 179 | openssl aes-256-cbc -d -in .circleci/key.json.enc \ 180 | -out .circleci/key.json \ 181 | -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" 182 | - run: 183 | name: Install and link the module. 184 | command: | 185 | mkdir /home/node/.npm-global 186 | npm install 187 | npm link 188 | environment: 189 | NPM_CONFIG_PREFIX: /home/node/.npm-global 190 | - run: 191 | name: Link the module being tested to the samples. 192 | command: | 193 | cd samples/ 194 | npm link @google-cloud/pubsub 195 | npm install 196 | cd .. 197 | environment: 198 | NPM_CONFIG_PREFIX: /home/node/.npm-global 199 | - run: 200 | name: Run sample tests. 201 | command: npm run samples-test 202 | environment: 203 | GCLOUD_PROJECT: long-door-651 204 | GOOGLE_APPLICATION_CREDENTIALS: /home/node/pubsub-samples/.circleci/key.json 205 | NPM_CONFIG_PREFIX: /home/node/.npm-global 206 | - run: 207 | name: Remove unencrypted key. 208 | command: rm .circleci/key.json 209 | when: always 210 | working_directory: /home/node/pubsub-samples 211 | 212 | system_tests: 213 | docker: 214 | - image: node:8 215 | user: node 216 | steps: 217 | - checkout 218 | - run: 219 | name: Decrypt credentials. 220 | command: | 221 | openssl aes-256-cbc -d -in .circleci/key.json.enc \ 222 | -out .circleci/key.json \ 223 | -k "${SYSTEM_TESTS_ENCRYPTION_KEY}" 224 | - run: 225 | name: Install modules and dependencies. 226 | command: npm install 227 | - run: 228 | name: Run system tests. 229 | command: npm run system-test 230 | environment: 231 | GOOGLE_APPLICATION_CREDENTIALS: .circleci/key.json 232 | - run: 233 | name: Remove unencrypted key. 234 | command: rm .circleci/key.json 235 | when: always 236 | 237 | publish_npm: 238 | docker: 239 | - image: node:8 240 | user: node 241 | steps: 242 | - checkout 243 | - run: 244 | name: Set NPM authentication. 245 | command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc 246 | - run: 247 | name: Publish the module to npm. 248 | command: npm publish 249 | 250 | -------------------------------------------------------------------------------- /.circleci/key.json.enc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/snyk-bot/nodejs-pubsub/ace59b086c9f72fb1e582398f7cf232b1428b6bc/.circleci/key.json.enc -------------------------------------------------------------------------------- /.cloud-repo-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "requiresKeyFile": true, 3 | "requiresProjectId": true, 4 | "product": "pubsub", 5 | "client_reference_url": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub", 6 | "release_quality": "beta", 7 | "samples": [ 8 | { 9 | "id": "subscriptions", 10 | "name": "Subscriptions", 11 | "file": "subscriptions.js", 12 | "docs_link": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/subscription", 13 | "usage": "node subscriptions.js --help" 14 | }, 15 | { 16 | "id": "topics", 17 | "name": "Topics", 18 | "file": "topics.js", 19 | "docs_link": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/topic", 20 | "usage": "node topics.js --help" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | samples/node_modules/* 3 | src/**/doc/* 4 | -------------------------------------------------------------------------------- /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | extends: 3 | - 'eslint:recommended' 4 | - 'plugin:node/recommended' 5 | - prettier 6 | plugins: 7 | - node 8 | - prettier 9 | rules: 10 | prettier/prettier: error 11 | block-scoped-var: error 12 | eqeqeq: error 13 | no-warning-comments: warn 14 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | **Table of contents** 4 | 5 | * [Contributor License Agreements](#contributor-license-agreements) 6 | * [Contributing a patch](#contributing-a-patch) 7 | * [Running the tests](#running-the-tests) 8 | * [Releasing the library](#releasing-the-library) 9 | 10 | ## Contributor License Agreements 11 | 12 | We'd love to accept your sample apps and patches! Before we can take them, we 13 | have to jump a couple of legal hurdles. 14 | 15 | Please fill out either the individual or corporate Contributor License Agreement 16 | (CLA). 17 | 18 | * If you are an individual writing original source code and you're sure you 19 | own the intellectual property, then you'll need to sign an [individual CLA] 20 | (https://developers.google.com/open-source/cla/individual). 21 | * If you work for a company that wants to allow you to contribute your work, 22 | then you'll need to sign a [corporate CLA] 23 | (https://developers.google.com/open-source/cla/corporate). 24 | 25 | Follow either of the two links above to access the appropriate CLA and 26 | instructions for how to sign and return it. Once we receive it, we'll be able to 27 | accept your pull requests. 28 | 29 | ## Contributing A Patch 30 | 31 | 1. Submit an issue describing your proposed change to the repo in question. 32 | 1. The repo owner will respond to your issue promptly. 33 | 1. If your proposed change is accepted, and you haven't already done so, sign a 34 | Contributor License Agreement (see details above). 35 | 1. Fork the desired repo, develop and test your code changes. 36 | 1. Ensure that your code adheres to the existing style in the code to which 37 | you are contributing. 38 | 1. Ensure that your code has an appropriate set of tests which all pass. 39 | 1. Submit a pull request. 40 | 41 | ## Running the tests 42 | 43 | 1. [Prepare your environment for Node.js setup][setup]. 44 | 45 | 1. Install dependencies: 46 | 47 | npm install 48 | 49 | 1. Run the tests: 50 | 51 | npm test 52 | 53 | [setup]: https://cloud.google.com/nodejs/docs/setup 54 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thanks for stopping by to let us know something could be better! 2 | 3 | Please run down the following list and make sure you've tried the usual "quick 4 | fixes": 5 | 6 | - Search the issues already opened: https://github.com/googleapis/nodejs-pubsub/issues 7 | - Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js 8 | - Check our Troubleshooting guide: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/troubleshooting 9 | - Check our FAQ: https://googlecloudplatform.github.io/google-cloud-node/#/docs/guides/faq 10 | 11 | If you are still having issues, please be sure to include as much information as 12 | possible: 13 | 14 | #### Environment details 15 | 16 | - OS: 17 | - Node.js version: 18 | - npm version: 19 | - @google-cloud/pubsub version: 20 | 21 | #### Steps to reproduce 22 | 23 | 1. ??? 24 | 2. ??? 25 | 26 | Following these steps will guarantee the quickest resolution possible. 27 | 28 | Thanks! 29 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes # (it's a good idea to open an issue first for discussion) 2 | 3 | - [ ] Tests and linter pass 4 | - [ ] Code coverage does not decrease (if any source code was changed) 5 | - [ ] Appropriate docs were updated (if necessary) 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.log 2 | **/node_modules 3 | .coverage 4 | .nyc_output 5 | docs/ 6 | out/ 7 | system-test/secrets.js 8 | system-test/*key.json 9 | *.lock 10 | *-lock.js* 11 | -------------------------------------------------------------------------------- /.jsdoc.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | module.exports = { 20 | opts: { 21 | readme: './README.md', 22 | package: './package.json', 23 | template: './node_modules/ink-docstrap/template', 24 | recurse: true, 25 | verbose: true, 26 | destination: './docs/' 27 | }, 28 | plugins: [ 29 | 'plugins/markdown' 30 | ], 31 | source: { 32 | excludePattern: '(^|\\/|\\\\)[._]', 33 | include: [ 34 | 'src' 35 | ], 36 | includePattern: '\\.js$' 37 | }, 38 | templates: { 39 | copyright: 'Copyright 2017 Google, Inc.', 40 | includeDate: false, 41 | sourceFiles: false, 42 | systemName: '@google-cloud/pubsub', 43 | theme: 'lumen' 44 | } 45 | }; 46 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Jason Dobry Jason Dobry 2 | Jason Dobry Jason Dobry 3 | Luke Sneeringer Luke Sneeringer 4 | Stephen Sawchuk Stephen Sawchuk 5 | Stephen Sawchuk Stephen Sawchuk 6 | Stephen Sawchuk Stephen 7 | Alexander Fenster Alexander Fenster 8 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "report-dir": "./.coverage", 3 | "exclude": [ 4 | "src/*{/*,/**/*}.js", 5 | "src/*/v*/*.js", 6 | "test/**/*.js" 7 | ], 8 | "watermarks": { 9 | "branches": [ 10 | 95, 11 | 100 12 | ], 13 | "functions": [ 14 | 95, 15 | 100 16 | ], 17 | "lines": [ 18 | 95, 19 | 100 20 | ], 21 | "statements": [ 22 | 95, 23 | 100 24 | ] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | samples/node_modules/* 3 | src/**/doc/* 4 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | --- 2 | bracketSpacing: false 3 | printWidth: 80 4 | semi: true 5 | singleQuote: true 6 | tabWidth: 2 7 | trailingComma: es5 8 | useTabs: false 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, 4 | and in the interest of fostering an open and welcoming community, 5 | we pledge to respect all people who contribute through reporting issues, 6 | posting feature requests, updating documentation, 7 | submitting pull requests or patches, and other activities. 8 | 9 | We are committed to making participation in this project 10 | a harassment-free experience for everyone, 11 | regardless of level of experience, gender, gender identity and expression, 12 | sexual orientation, disability, personal appearance, 13 | body size, race, ethnicity, age, religion, or nationality. 14 | 15 | Examples of unacceptable behavior by participants include: 16 | 17 | * The use of sexualized language or imagery 18 | * Personal attacks 19 | * Trolling or insulting/derogatory comments 20 | * Public or private harassment 21 | * Publishing other's private information, 22 | such as physical or electronic 23 | addresses, without explicit permission 24 | * Other unethical or unprofessional conduct. 25 | 26 | Project maintainers have the right and responsibility to remove, edit, or reject 27 | comments, commits, code, wiki edits, issues, and other contributions 28 | that are not aligned to this Code of Conduct. 29 | By adopting this Code of Conduct, 30 | project maintainers commit themselves to fairly and consistently 31 | applying these principles to every aspect of managing this project. 32 | Project maintainers who do not follow or enforce the Code of Conduct 33 | may be permanently removed from the project team. 34 | 35 | This code of conduct applies both within project spaces and in public spaces 36 | when an individual is representing the project or its community. 37 | 38 | Instances of abusive, harassing, or otherwise unacceptable behavior 39 | may be reported by opening an issue 40 | or contacting one or more of the project maintainers. 41 | 42 | This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, 43 | available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) 44 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # The names of individuals who have contributed to this project. 2 | # 3 | # Names are formatted as: 4 | # name 5 | # 6 | Ace Nassri 7 | Alexander Fenster 8 | Ali Ijaz Sheikh 9 | Dave Gramlich 10 | David Fox 11 | Dennis 12 | Eric Uldall 13 | Jan Pretzel 14 | Jason Dobry 15 | Jun Mukai 16 | Justin King 17 | Matthew Arbesfeld 18 | Song Wang 19 | Stephen Sawchuk 20 | Tim Swast 21 | greenkeeper[bot] 22 | mkamioner 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Google Cloud Platform logo 2 | 3 | # [Google Cloud Pub/Sub: Node.js Client](https://github.com/googleapis/nodejs-pubsub) 4 | 5 | [![release level](https://img.shields.io/badge/release%20level-beta-yellow.svg?style=flat)](https://cloud.google.com/terms/launch-stages) 6 | [![CircleCI](https://img.shields.io/circleci/project/github/googleapis/nodejs-pubsub.svg?style=flat)](https://circleci.com/gh/googleapis/nodejs-pubsub) 7 | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/googleapis/nodejs-pubsub?branch=master&svg=true)](https://ci.appveyor.com/project/googleapis/nodejs-pubsub) 8 | [![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-pubsub/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-pubsub) 9 | 10 | > Node.js idiomatic client for [Cloud Pub/Sub][product-docs]. 11 | 12 | [Cloud Pub/Sub](https://cloud.google.com/pubsub/docs) is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. 13 | 14 | 15 | * [Cloud Pub/Sub Node.js Client API Reference][client-docs] 16 | * [github.com/googleapis/nodejs-pubsub](https://github.com/googleapis/nodejs-pubsub) 17 | * [Cloud Pub/Sub Documentation][product-docs] 18 | 19 | Read more about the client libraries for Cloud APIs, including the older 20 | Google APIs Client Libraries, in [Client Libraries Explained][explained]. 21 | 22 | [explained]: https://cloud.google.com/apis/docs/client-libraries-explained 23 | 24 | **Table of contents:** 25 | 26 | * [Quickstart](#quickstart) 27 | * [Before you begin](#before-you-begin) 28 | * [Installing the client library](#installing-the-client-library) 29 | * [Using the client library](#using-the-client-library) 30 | * [Samples](#samples) 31 | * [Versioning](#versioning) 32 | * [Contributing](#contributing) 33 | * [License](#license) 34 | 35 | ## Quickstart 36 | 37 | ### Before you begin 38 | 39 | 1. Select or create a Cloud Platform project. 40 | 41 | [Go to the projects page][projects] 42 | 43 | 1. Enable billing for your project. 44 | 45 | [Enable billing][billing] 46 | 47 | 1. Enable the Google Cloud Pub/Sub API. 48 | 49 | [Enable the API][enable_api] 50 | 51 | 1. [Set up authentication with a service account][auth] so you can access the 52 | API from your local workstation. 53 | 54 | [projects]: https://console.cloud.google.com/project 55 | [billing]: https://support.google.com/cloud/answer/6293499#enable-billing 56 | [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=pubsub.googleapis.com 57 | [auth]: https://cloud.google.com/docs/authentication/getting-started 58 | 59 | ### Installing the client library 60 | 61 | npm install --save @google-cloud/pubsub 62 | 63 | ### Using the client library 64 | 65 | ```javascript 66 | // Imports the Google Cloud client library 67 | const PubSub = require('@google-cloud/pubsub'); 68 | 69 | // Your Google Cloud Platform project ID 70 | const projectId = 'YOUR_PROJECT_ID'; 71 | 72 | // Instantiates a client 73 | const pubsubClient = new PubSub({ 74 | projectId: projectId, 75 | }); 76 | 77 | // The name for the new topic 78 | const topicName = 'my-new-topic'; 79 | 80 | // Creates the new topic 81 | pubsubClient 82 | .createTopic(topicName) 83 | .then(results => { 84 | const topic = results[0]; 85 | console.log(`Topic ${topic.name} created.`); 86 | }) 87 | .catch(err => { 88 | console.error('ERROR:', err); 89 | }); 90 | ``` 91 | 92 | ## Samples 93 | 94 | Samples are in the [`samples/`](https://github.com/googleapis/nodejs-pubsub/tree/master/samples) directory. The samples' `README.md` 95 | has instructions for running the samples. 96 | 97 | | Sample | Source Code | Try it | 98 | | --------------------------- | --------------------------------- | ------ | 99 | | Subscriptions | [source code](https://github.com/googleapis/nodejs-pubsub/blob/master/samples/subscriptions.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/subscriptions.js,samples/README.md) | 100 | | Topics | [source code](https://github.com/googleapis/nodejs-pubsub/blob/master/samples/topics.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/topics.js,samples/README.md) | 101 | 102 | The [Cloud Pub/Sub Node.js Client API Reference][client-docs] documentation 103 | also contains samples. 104 | 105 | ## Versioning 106 | 107 | This library follows [Semantic Versioning](http://semver.org/). 108 | 109 | This library is considered to be in **beta**. This means it is expected to be 110 | mostly stable while we work toward a general availability release; however, 111 | complete stability is not guaranteed. We will address issues and requests 112 | against beta libraries with a high priority. 113 | 114 | More Information: [Google Cloud Platform Launch Stages][launch_stages] 115 | 116 | [launch_stages]: https://cloud.google.com/terms/launch-stages 117 | 118 | ## Contributing 119 | 120 | Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-pubsub/blob/master/.github/CONTRIBUTING.md). 121 | 122 | ## License 123 | 124 | Apache Version 2.0 125 | 126 | See [LICENSE](https://github.com/googleapis/nodejs-pubsub/blob/master/LICENSE) 127 | 128 | [client-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub 129 | [product-docs]: https://cloud.google.com/pubsub/docs 130 | [shell_img]: http://gstatic.com/cloudssh/images/open-btn.png 131 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@google-cloud/pubsub", 3 | "description": "Cloud Pub/Sub Client Library for Node.js", 4 | "version": "0.16.2", 5 | "license": "Apache-2.0", 6 | "author": "Google Inc.", 7 | "engines": { 8 | "node": ">=4.0.0" 9 | }, 10 | "repository": "googleapis/nodejs-pubsub", 11 | "main": "./src/index.js", 12 | "files": [ 13 | "protos", 14 | "src", 15 | "AUTHORS", 16 | "CONTRIBUTORS", 17 | "LICENSE" 18 | ], 19 | "keywords": [ 20 | "google apis client", 21 | "google api client", 22 | "google apis", 23 | "google api", 24 | "google", 25 | "google cloud platform", 26 | "google cloud", 27 | "cloud", 28 | "google pubsub", 29 | "pubsub" 30 | ], 31 | "contributors": [ 32 | "Ace Nassri ", 33 | "Alexander Fenster ", 34 | "Ali Ijaz Sheikh ", 35 | "Dave Gramlich ", 36 | "David Fox ", 37 | "Dennis ", 38 | "Eric Uldall ", 39 | "Jan Pretzel ", 40 | "Jason Dobry ", 41 | "Jun Mukai ", 42 | "Justin King ", 43 | "Matthew Arbesfeld ", 44 | "Song Wang ", 45 | "Stephen Sawchuk ", 46 | "Tim Swast ", 47 | "greenkeeper[bot] ", 48 | "mkamioner " 49 | ], 50 | "scripts": { 51 | "system-test": "repo-tools test run --cmd mocha -- system-test/*.js --no-timeouts", 52 | "cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report", 53 | "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", 54 | "test-no-cover": "repo-tools test run --cmd mocha -- test/*.js --no-timeouts", 55 | "test": "repo-tools test run --cmd npm -- run cover", 56 | "lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/", 57 | "prettier": "repo-tools exec -- prettier --write src/*.js src/*/*.js samples/*.js samples/*/*.js test/*.js test/*/*.js system-test/*.js system-test/*/*.js", 58 | "docs": "repo-tools exec -- jsdoc -c .jsdoc.js", 59 | "publish-module": "node ../../scripts/publish.js pubsub", 60 | "generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json" 61 | }, 62 | "dependencies": { 63 | "@google-cloud/common": "^0.16.0", 64 | "arrify": "^1.0.0", 65 | "async-each": "^1.0.1", 66 | "extend": "^3.0.1", 67 | "google-auto-auth": "^0.9.0", 68 | "google-gax": "^0.14.2", 69 | "google-proto-files": "^0.15.0", 70 | "grpc": "^1.8.4", 71 | "is": "^3.0.1", 72 | "lodash.merge": "^4.6.0", 73 | "lodash.snakecase": "^4.1.1", 74 | "protobufjs": "^6.8.1", 75 | "uuid": "^3.1.0" 76 | }, 77 | "devDependencies": { 78 | "@google-cloud/nodejs-repo-tools": "^2.1.3", 79 | "async": "^2.6.0", 80 | "codecov": "^3.0.0", 81 | "eslint": "^4.11.0", 82 | "eslint-config-prettier": "^2.8.0", 83 | "eslint-plugin-node": "^6.0.0", 84 | "eslint-plugin-prettier": "^2.3.1", 85 | "ink-docstrap": "^1.3.2", 86 | "intelli-espower-loader": "^1.0.1", 87 | "jsdoc": "^3.5.5", 88 | "mocha": "^5.0.0", 89 | "nyc": "^11.3.0", 90 | "power-assert": "^1.4.4", 91 | "prettier": "^1.9.1", 92 | "proxyquire": "^1.7.10" 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /protos/google/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/http.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "AnnotationsProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | extend google.protobuf.MethodOptions { 29 | // See `HttpRule`. 30 | HttpRule http = 72295728; 31 | } 32 | -------------------------------------------------------------------------------- /protos/google/api/backend.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "BackendProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // `Backend` defines the backend configuration for a service. 27 | message Backend { 28 | // A list of API backend rules that apply to individual API methods. 29 | // 30 | // **NOTE:** All service configuration rules follow "last one wins" order. 31 | repeated BackendRule rules = 1; 32 | } 33 | 34 | // A backend rule provides configuration for an individual API element. 35 | message BackendRule { 36 | // Selects the methods to which this rule applies. 37 | // 38 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 39 | string selector = 1; 40 | 41 | // The address of the API backend. 42 | string address = 2; 43 | 44 | // The number of seconds to wait for a response from a request. The 45 | // default depends on the deployment context. 46 | double deadline = 3; 47 | } 48 | -------------------------------------------------------------------------------- /protos/google/api/billing.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/metric.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "BillingProto"; 25 | option java_package = "com.google.api"; 26 | 27 | 28 | // Billing related configuration of the service. 29 | // 30 | // The following example shows how to configure metrics for billing: 31 | // 32 | // metrics: 33 | // - name: library.googleapis.com/read_calls 34 | // metric_kind: DELTA 35 | // value_type: INT64 36 | // - name: library.googleapis.com/write_calls 37 | // metric_kind: DELTA 38 | // value_type: INT64 39 | // billing: 40 | // metrics: 41 | // - library.googleapis.com/read_calls 42 | // - library.googleapis.com/write_calls 43 | // 44 | // The next example shows how to enable billing status check and customize the 45 | // check behavior. It makes sure billing status check is included in the `Check` 46 | // method of [Service Control API](https://cloud.google.com/service-control/). 47 | // In the example, "google.storage.Get" method can be served when the billing 48 | // status is either `current` or `delinquent`, while "google.storage.Write" 49 | // method can only be served when the billing status is `current`: 50 | // 51 | // billing: 52 | // rules: 53 | // - selector: google.storage.Get 54 | // allowed_statuses: 55 | // - current 56 | // - delinquent 57 | // - selector: google.storage.Write 58 | // allowed_statuses: current 59 | // 60 | // Mostly services should only allow `current` status when serving requests. 61 | // In addition, services can choose to allow both `current` and `delinquent` 62 | // statuses when serving read-only requests to resources. If there's no 63 | // matching selector for operation, no billing status check will be performed. 64 | // 65 | message Billing { 66 | // Names of the metrics to report to billing. Each name must 67 | // be defined in [Service.metrics][google.api.Service.metrics] section. 68 | repeated string metrics = 1; 69 | 70 | // A list of billing status rules for configuring billing status check. 71 | repeated BillingStatusRule rules = 5; 72 | } 73 | 74 | // Defines the billing status requirements for operations. 75 | // 76 | // When used with 77 | // [Service Control API](https://cloud.google.com/service-control/), the 78 | // following statuses are supported: 79 | // 80 | // - **current**: the associated billing account is up to date and capable of 81 | // paying for resource usages. 82 | // - **delinquent**: the associated billing account has a correctable problem, 83 | // such as late payment. 84 | // 85 | // Mostly services should only allow `current` status when serving requests. 86 | // In addition, services can choose to allow both `current` and `delinquent` 87 | // statuses when serving read-only requests to resources. If the list of 88 | // allowed_statuses is empty, it means no billing requirement. 89 | // 90 | message BillingStatusRule { 91 | // Selects the operation names to which this rule applies. 92 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 93 | string selector = 1; 94 | 95 | // Allowed billing statuses. The billing status check passes if the actual 96 | // billing status matches any of the provided values here. 97 | repeated string allowed_statuses = 2; 98 | } 99 | -------------------------------------------------------------------------------- /protos/google/api/config_change.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/configchange;configchange"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "ConfigChangeProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // Output generated from semantically comparing two versions of a service 27 | // configuration. 28 | // 29 | // Includes detailed information about a field that have changed with 30 | // applicable advice about potential consequences for the change, such as 31 | // backwards-incompatibility. 32 | message ConfigChange { 33 | // Object hierarchy path to the change, with levels separated by a '.' 34 | // character. For repeated fields, an applicable unique identifier field is 35 | // used for the index (usually selector, name, or id). For maps, the term 36 | // 'key' is used. If the field has no unique identifier, the numeric index 37 | // is used. 38 | // Examples: 39 | // - visibility.rules[selector=="google.LibraryService.CreateBook"].restriction 40 | // - quota.metric_rules[selector=="google"].metric_costs[key=="reads"].value 41 | // - logging.producer_destinations[0] 42 | string element = 1; 43 | 44 | // Value of the changed object in the old Service configuration, 45 | // in JSON format. This field will not be populated if ChangeType == ADDED. 46 | string old_value = 2; 47 | 48 | // Value of the changed object in the new Service configuration, 49 | // in JSON format. This field will not be populated if ChangeType == REMOVED. 50 | string new_value = 3; 51 | 52 | // The type for this change, either ADDED, REMOVED, or MODIFIED. 53 | ChangeType change_type = 4; 54 | 55 | // Collection of advice provided for this change, useful for determining the 56 | // possible impact of this change. 57 | repeated Advice advices = 5; 58 | } 59 | 60 | // Generated advice about this change, used for providing more 61 | // information about how a change will affect the existing service. 62 | message Advice { 63 | // Useful description for why this advice was applied and what actions should 64 | // be taken to mitigate any implied risks. 65 | string description = 2; 66 | } 67 | 68 | // Classifies set of possible modifications to an object in the service 69 | // configuration. 70 | enum ChangeType { 71 | // No value was provided. 72 | CHANGE_TYPE_UNSPECIFIED = 0; 73 | 74 | // The changed object exists in the 'new' service configuration, but not 75 | // in the 'old' service configuration. 76 | ADDED = 1; 77 | 78 | // The changed object exists in the 'old' service configuration, but not 79 | // in the 'new' service configuration. 80 | REMOVED = 2; 81 | 82 | // The changed object exists in both service configurations, but its value 83 | // is different. 84 | MODIFIED = 3; 85 | } 86 | -------------------------------------------------------------------------------- /protos/google/api/consumer.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "ConsumerProto"; 22 | option java_package = "com.google.api"; 23 | 24 | 25 | // A descriptor for defining project properties for a service. One service may 26 | // have many consumer projects, and the service may want to behave differently 27 | // depending on some properties on the project. For example, a project may be 28 | // associated with a school, or a business, or a government agency, a business 29 | // type property on the project may affect how a service responds to the client. 30 | // This descriptor defines which properties are allowed to be set on a project. 31 | // 32 | // Example: 33 | // 34 | // project_properties: 35 | // properties: 36 | // - name: NO_WATERMARK 37 | // type: BOOL 38 | // description: Allows usage of the API without watermarks. 39 | // - name: EXTENDED_TILE_CACHE_PERIOD 40 | // type: INT64 41 | message ProjectProperties { 42 | // List of per consumer project-specific properties. 43 | repeated Property properties = 1; 44 | } 45 | 46 | // Defines project properties. 47 | // 48 | // API services can define properties that can be assigned to consumer projects 49 | // so that backends can perform response customization without having to make 50 | // additional calls or maintain additional storage. For example, Maps API 51 | // defines properties that controls map tile cache period, or whether to embed a 52 | // watermark in a result. 53 | // 54 | // These values can be set via API producer console. Only API providers can 55 | // define and set these properties. 56 | message Property { 57 | // Supported data type of the property values 58 | enum PropertyType { 59 | // The type is unspecified, and will result in an error. 60 | UNSPECIFIED = 0; 61 | 62 | // The type is `int64`. 63 | INT64 = 1; 64 | 65 | // The type is `bool`. 66 | BOOL = 2; 67 | 68 | // The type is `string`. 69 | STRING = 3; 70 | 71 | // The type is 'double'. 72 | DOUBLE = 4; 73 | } 74 | 75 | // The name of the property (a.k.a key). 76 | string name = 1; 77 | 78 | // The type of this property. 79 | PropertyType type = 2; 80 | 81 | // The description of the property 82 | string description = 3; 83 | } 84 | -------------------------------------------------------------------------------- /protos/google/api/context.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "ContextProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // `Context` defines which contexts an API requests. 27 | // 28 | // Example: 29 | // 30 | // context: 31 | // rules: 32 | // - selector: "*" 33 | // requested: 34 | // - google.rpc.context.ProjectContext 35 | // - google.rpc.context.OriginContext 36 | // 37 | // The above specifies that all methods in the API request 38 | // `google.rpc.context.ProjectContext` and 39 | // `google.rpc.context.OriginContext`. 40 | // 41 | // Available context types are defined in package 42 | // `google.rpc.context`. 43 | message Context { 44 | // A list of RPC context rules that apply to individual API methods. 45 | // 46 | // **NOTE:** All service configuration rules follow "last one wins" order. 47 | repeated ContextRule rules = 1; 48 | } 49 | 50 | // A context rule provides information about the context for an individual API 51 | // element. 52 | message ContextRule { 53 | // Selects the methods to which this rule applies. 54 | // 55 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 56 | string selector = 1; 57 | 58 | // A list of full type names of requested contexts. 59 | repeated string requested = 2; 60 | 61 | // A list of full type names of provided contexts. 62 | repeated string provided = 3; 63 | } 64 | -------------------------------------------------------------------------------- /protos/google/api/control.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "ControlProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // Selects and configures the service controller used by the service. The 27 | // service controller handles features like abuse, quota, billing, logging, 28 | // monitoring, etc. 29 | message Control { 30 | // The service control environment to use. If empty, no control plane 31 | // feature (like quota and billing) will be enabled. 32 | string environment = 1; 33 | } 34 | -------------------------------------------------------------------------------- /protos/google/api/documentation.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "DocumentationProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // `Documentation` provides the information for describing a service. 27 | // 28 | // Example: 29 | //
documentation:
 30 | //   summary: >
 31 | //     The Google Calendar API gives access
 32 | //     to most calendar features.
 33 | //   pages:
 34 | //   - name: Overview
 35 | //     content: (== include google/foo/overview.md ==)
 36 | //   - name: Tutorial
 37 | //     content: (== include google/foo/tutorial.md ==)
 38 | //     subpages;
 39 | //     - name: Java
 40 | //       content: (== include google/foo/tutorial_java.md ==)
 41 | //   rules:
 42 | //   - selector: google.calendar.Calendar.Get
 43 | //     description: >
 44 | //       ...
 45 | //   - selector: google.calendar.Calendar.Put
 46 | //     description: >
 47 | //       ...
 48 | // 
49 | // Documentation is provided in markdown syntax. In addition to 50 | // standard markdown features, definition lists, tables and fenced 51 | // code blocks are supported. Section headers can be provided and are 52 | // interpreted relative to the section nesting of the context where 53 | // a documentation fragment is embedded. 54 | // 55 | // Documentation from the IDL is merged with documentation defined 56 | // via the config at normalization time, where documentation provided 57 | // by config rules overrides IDL provided. 58 | // 59 | // A number of constructs specific to the API platform are supported 60 | // in documentation text. 61 | // 62 | // In order to reference a proto element, the following 63 | // notation can be used: 64 | //
[fully.qualified.proto.name][]
65 | // To override the display text used for the link, this can be used: 66 | //
[display text][fully.qualified.proto.name]
67 | // Text can be excluded from doc using the following notation: 68 | //
(-- internal comment --)
69 | // Comments can be made conditional using a visibility label. The below 70 | // text will be only rendered if the `BETA` label is available: 71 | //
(--BETA: comment for BETA users --)
72 | // A few directives are available in documentation. Note that 73 | // directives must appear on a single line to be properly 74 | // identified. The `include` directive includes a markdown file from 75 | // an external source: 76 | //
(== include path/to/file ==)
77 | // The `resource_for` directive marks a message to be the resource of 78 | // a collection in REST view. If it is not specified, tools attempt 79 | // to infer the resource from the operations in a collection: 80 | //
(== resource_for v1.shelves.books ==)
81 | // The directive `suppress_warning` does not directly affect documentation 82 | // and is documented together with service config validation. 83 | message Documentation { 84 | // A short summary of what the service does. Can only be provided by 85 | // plain text. 86 | string summary = 1; 87 | 88 | // The top level pages for the documentation set. 89 | repeated Page pages = 5; 90 | 91 | // A list of documentation rules that apply to individual API elements. 92 | // 93 | // **NOTE:** All service configuration rules follow "last one wins" order. 94 | repeated DocumentationRule rules = 3; 95 | 96 | // The URL to the root of documentation. 97 | string documentation_root_url = 4; 98 | 99 | // Declares a single overview page. For example: 100 | //
documentation:
101 |   //   summary: ...
102 |   //   overview: (== include overview.md ==)
103 |   // 
104 | // This is a shortcut for the following declaration (using pages style): 105 | //
documentation:
106 |   //   summary: ...
107 |   //   pages:
108 |   //   - name: Overview
109 |   //     content: (== include overview.md ==)
110 |   // 
111 | // Note: you cannot specify both `overview` field and `pages` field. 112 | string overview = 2; 113 | } 114 | 115 | // A documentation rule provides information about individual API elements. 116 | message DocumentationRule { 117 | // The selector is a comma-separated list of patterns. Each pattern is a 118 | // qualified name of the element which may end in "*", indicating a wildcard. 119 | // Wildcards are only allowed at the end and for a whole component of the 120 | // qualified name, i.e. "foo.*" is ok, but not "foo.b*" or "foo.*.bar". To 121 | // specify a default for all applicable elements, the whole pattern "*" 122 | // is used. 123 | string selector = 1; 124 | 125 | // Description of the selected API(s). 126 | string description = 2; 127 | 128 | // Deprecation description of the selected element(s). It can be provided if an 129 | // element is marked as `deprecated`. 130 | string deprecation_description = 3; 131 | } 132 | 133 | // Represents a documentation page. A page can contain subpages to represent 134 | // nested documentation set structure. 135 | message Page { 136 | // The name of the page. It will be used as an identity of the page to 137 | // generate URI of the page, text of the link to this page in navigation, 138 | // etc. The full page name (start from the root page name to this page 139 | // concatenated with `.`) can be used as reference to the page in your 140 | // documentation. For example: 141 | //
pages:
142 |   // - name: Tutorial
143 |   //   content: (== include tutorial.md ==)
144 |   //   subpages:
145 |   //   - name: Java
146 |   //     content: (== include tutorial_java.md ==)
147 |   // 
148 | // You can reference `Java` page using Markdown reference link syntax: 149 | // `[Java][Tutorial.Java]`. 150 | string name = 1; 151 | 152 | // The Markdown content of the page. You can use (== include {path} ==) 153 | // to include content from a Markdown file. 154 | string content = 2; 155 | 156 | // Subpages of this page. The order of subpages specified here will be 157 | // honored in the generated docset. 158 | repeated Page subpages = 3; 159 | } 160 | -------------------------------------------------------------------------------- /protos/google/api/endpoint.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "EndpointProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // `Endpoint` describes a network endpoint that serves a set of APIs. 29 | // A service may expose any number of endpoints, and all endpoints share the 30 | // same service configuration, such as quota configuration and monitoring 31 | // configuration. 32 | // 33 | // Example service configuration: 34 | // 35 | // name: library-example.googleapis.com 36 | // endpoints: 37 | // # Below entry makes 'google.example.library.v1.Library' 38 | // # API be served from endpoint address library-example.googleapis.com. 39 | // # It also allows HTTP OPTIONS calls to be passed to the backend, for 40 | // # it to decide whether the subsequent cross-origin request is 41 | // # allowed to proceed. 42 | // - name: library-example.googleapis.com 43 | // allow_cors: true 44 | message Endpoint { 45 | // The canonical name of this endpoint. 46 | string name = 1; 47 | 48 | // DEPRECATED: This field is no longer supported. Instead of using aliases, 49 | // please specify multiple [google.api.Endpoint][google.api.Endpoint] for each of the intented 50 | // alias. 51 | // 52 | // Additional names that this endpoint will be hosted on. 53 | repeated string aliases = 2; 54 | 55 | // The list of APIs served by this endpoint. 56 | repeated string apis = 3; 57 | 58 | // The list of features enabled on this endpoint. 59 | repeated string features = 4; 60 | 61 | // The specification of an Internet routable address of API frontend that will 62 | // handle requests to this [API Endpoint](https://cloud.google.com/apis/design/glossary). 63 | // It should be either a valid IPv4 address or a fully-qualified domain name. 64 | // For example, "8.8.8.8" or "myservice.appspot.com". 65 | string target = 101; 66 | 67 | // Allowing 68 | // [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), aka 69 | // cross-domain traffic, would allow the backends served from this endpoint to 70 | // receive and respond to HTTP OPTIONS requests. The response will be used by 71 | // the browser to determine whether the subsequent cross-origin request is 72 | // allowed to proceed. 73 | bool allow_cors = 5; 74 | } 75 | -------------------------------------------------------------------------------- /protos/google/api/experimental/authorization_config.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api;api"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "AuthorizationConfigProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // Configuration of authorization. 27 | // 28 | // This section determines the authorization provider, if unspecified, then no 29 | // authorization check will be done. 30 | // 31 | // Example: 32 | // 33 | // experimental: 34 | // authorization: 35 | // provider: firebaserules.googleapis.com 36 | message AuthorizationConfig { 37 | // The name of the authorization provider, such as 38 | // firebaserules.googleapis.com. 39 | string provider = 1; 40 | } 41 | -------------------------------------------------------------------------------- /protos/google/api/experimental/experimental.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/experimental/authorization_config.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api;api"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "ExperimentalProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | 29 | // Experimental service configuration. These configuration options can 30 | // only be used by whitelisted users. 31 | message Experimental { 32 | // Authorization configuration. 33 | AuthorizationConfig authorization = 8; 34 | } 35 | -------------------------------------------------------------------------------- /protos/google/api/httpbody.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "HttpBodyProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // Message that represents an arbitrary HTTP body. It should only be used for 27 | // payload formats that can't be represented as JSON, such as raw binary or 28 | // an HTML page. 29 | // 30 | // 31 | // This message can be used both in streaming and non-streaming API methods in 32 | // the request as well as the response. 33 | // 34 | // It can be used as a top-level request field, which is convenient if one 35 | // wants to extract parameters from either the URL or HTTP template into the 36 | // request fields and also want access to the raw HTTP body. 37 | // 38 | // Example: 39 | // 40 | // message GetResourceRequest { 41 | // // A unique request id. 42 | // string request_id = 1; 43 | // 44 | // // The raw HTTP body is bound to this field. 45 | // google.api.HttpBody http_body = 2; 46 | // } 47 | // 48 | // service ResourceService { 49 | // rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); 50 | // rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); 51 | // } 52 | // 53 | // Example with streaming methods: 54 | // 55 | // service CaldavService { 56 | // rpc GetCalendar(stream google.api.HttpBody) 57 | // returns (stream google.api.HttpBody); 58 | // rpc UpdateCalendar(stream google.api.HttpBody) 59 | // returns (stream google.api.HttpBody); 60 | // } 61 | // 62 | // Use of this type only changes how the request and response bodies are 63 | // handled, all other features will continue to work unchanged. 64 | message HttpBody { 65 | // The HTTP Content-Type string representing the content type of the body. 66 | string content_type = 1; 67 | 68 | // HTTP body binary data. 69 | bytes data = 2; 70 | } 71 | -------------------------------------------------------------------------------- /protos/google/api/label.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/api/label;label"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "LabelProto"; 23 | option java_package = "com.google.api"; 24 | option objc_class_prefix = "GAPI"; 25 | 26 | 27 | // A description of a label. 28 | message LabelDescriptor { 29 | // Value types that can be used as label values. 30 | enum ValueType { 31 | // A variable-length string. This is the default. 32 | STRING = 0; 33 | 34 | // Boolean; true or false. 35 | BOOL = 1; 36 | 37 | // A 64-bit signed integer. 38 | INT64 = 2; 39 | } 40 | 41 | // The label key. 42 | string key = 1; 43 | 44 | // The type of data that can be assigned to the label. 45 | ValueType value_type = 2; 46 | 47 | // A human-readable description for the label. 48 | string description = 3; 49 | } 50 | -------------------------------------------------------------------------------- /protos/google/api/log.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/label.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "LogProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // A description of a log type. Example in YAML format: 29 | // 30 | // - name: library.googleapis.com/activity_history 31 | // description: The history of borrowing and returning library items. 32 | // display_name: Activity 33 | // labels: 34 | // - key: /customer_id 35 | // description: Identifier of a library customer 36 | message LogDescriptor { 37 | // The name of the log. It must be less than 512 characters long and can 38 | // include the following characters: upper- and lower-case alphanumeric 39 | // characters [A-Za-z0-9], and punctuation characters including 40 | // slash, underscore, hyphen, period [/_-.]. 41 | string name = 1; 42 | 43 | // The set of labels that are available to describe a specific log entry. 44 | // Runtime requests that contain labels not specified here are 45 | // considered invalid. 46 | repeated LabelDescriptor labels = 2; 47 | 48 | // A human-readable description of this log. This information appears in 49 | // the documentation and can contain details. 50 | string description = 3; 51 | 52 | // The human-readable name for this log. This information appears on 53 | // the user interface and should be concise. 54 | string display_name = 4; 55 | } 56 | -------------------------------------------------------------------------------- /protos/google/api/logging.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "LoggingProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // Logging configuration of the service. 29 | // 30 | // The following example shows how to configure logs to be sent to the 31 | // producer and consumer projects. In the example, the `activity_history` 32 | // log is sent to both the producer and consumer projects, whereas the 33 | // `purchase_history` log is only sent to the producer project. 34 | // 35 | // monitored_resources: 36 | // - type: library.googleapis.com/branch 37 | // labels: 38 | // - key: /city 39 | // description: The city where the library branch is located in. 40 | // - key: /name 41 | // description: The name of the branch. 42 | // logs: 43 | // - name: activity_history 44 | // labels: 45 | // - key: /customer_id 46 | // - name: purchase_history 47 | // logging: 48 | // producer_destinations: 49 | // - monitored_resource: library.googleapis.com/branch 50 | // logs: 51 | // - activity_history 52 | // - purchase_history 53 | // consumer_destinations: 54 | // - monitored_resource: library.googleapis.com/branch 55 | // logs: 56 | // - activity_history 57 | message Logging { 58 | // Configuration of a specific logging destination (the producer project 59 | // or the consumer project). 60 | message LoggingDestination { 61 | // The monitored resource type. The type must be defined in the 62 | // [Service.monitored_resources][google.api.Service.monitored_resources] section. 63 | string monitored_resource = 3; 64 | 65 | // Names of the logs to be sent to this destination. Each name must 66 | // be defined in the [Service.logs][google.api.Service.logs] section. If the log name is 67 | // not a domain scoped name, it will be automatically prefixed with 68 | // the service name followed by "/". 69 | repeated string logs = 1; 70 | } 71 | 72 | // Logging configurations for sending logs to the producer project. 73 | // There can be multiple producer destinations, each one must have a 74 | // different monitored resource type. A log can be used in at most 75 | // one producer destination. 76 | repeated LoggingDestination producer_destinations = 1; 77 | 78 | // Logging configurations for sending logs to the consumer project. 79 | // There can be multiple consumer destinations, each one must have a 80 | // different monitored resource type. A log can be used in at most 81 | // one consumer destination. 82 | repeated LoggingDestination consumer_destinations = 2; 83 | } 84 | -------------------------------------------------------------------------------- /protos/google/api/monitored_resource.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/label.proto"; 20 | 21 | option cc_enable_arenas = true; 22 | option go_package = "google.golang.org/genproto/googleapis/api/monitoredres;monitoredres"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "MonitoredResourceProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | 29 | // An object that describes the schema of a [MonitoredResource][google.api.MonitoredResource] object using a 30 | // type name and a set of labels. For example, the monitored resource 31 | // descriptor for Google Compute Engine VM instances has a type of 32 | // `"gce_instance"` and specifies the use of the labels `"instance_id"` and 33 | // `"zone"` to identify particular VM instances. 34 | // 35 | // Different APIs can support different monitored resource types. APIs generally 36 | // provide a `list` method that returns the monitored resource descriptors used 37 | // by the API. 38 | message MonitoredResourceDescriptor { 39 | // Optional. The resource name of the monitored resource descriptor: 40 | // `"projects/{project_id}/monitoredResourceDescriptors/{type}"` where 41 | // {type} is the value of the `type` field in this object and 42 | // {project_id} is a project ID that provides API-specific context for 43 | // accessing the type. APIs that do not use project information can use the 44 | // resource name format `"monitoredResourceDescriptors/{type}"`. 45 | string name = 5; 46 | 47 | // Required. The monitored resource type. For example, the type 48 | // `"cloudsql_database"` represents databases in Google Cloud SQL. 49 | // The maximum length of this value is 256 characters. 50 | string type = 1; 51 | 52 | // Optional. A concise name for the monitored resource type that might be 53 | // displayed in user interfaces. It should be a Title Cased Noun Phrase, 54 | // without any article or other determiners. For example, 55 | // `"Google Cloud SQL Database"`. 56 | string display_name = 2; 57 | 58 | // Optional. A detailed description of the monitored resource type that might 59 | // be used in documentation. 60 | string description = 3; 61 | 62 | // Required. A set of labels used to describe instances of this monitored 63 | // resource type. For example, an individual Google Cloud SQL database is 64 | // identified by values for the labels `"database_id"` and `"zone"`. 65 | repeated LabelDescriptor labels = 4; 66 | } 67 | 68 | // An object representing a resource that can be used for monitoring, logging, 69 | // billing, or other purposes. Examples include virtual machine instances, 70 | // databases, and storage devices such as disks. The `type` field identifies a 71 | // [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object that describes the resource's 72 | // schema. Information in the `labels` field identifies the actual resource and 73 | // its attributes according to the schema. For example, a particular Compute 74 | // Engine VM instance could be represented by the following object, because the 75 | // [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] for `"gce_instance"` has labels 76 | // `"instance_id"` and `"zone"`: 77 | // 78 | // { "type": "gce_instance", 79 | // "labels": { "instance_id": "12345678901234", 80 | // "zone": "us-central1-a" }} 81 | message MonitoredResource { 82 | // Required. The monitored resource type. This field must match 83 | // the `type` field of a [MonitoredResourceDescriptor][google.api.MonitoredResourceDescriptor] object. For 84 | // example, the type of a Cloud SQL database is `"cloudsql_database"`. 85 | string type = 1; 86 | 87 | // Required. Values for all of the labels listed in the associated monitored 88 | // resource descriptor. For example, Cloud SQL databases use the labels 89 | // `"database_id"` and `"zone"`. 90 | map labels = 2; 91 | } 92 | -------------------------------------------------------------------------------- /protos/google/api/monitoring.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "MonitoringProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // Monitoring configuration of the service. 29 | // 30 | // The example below shows how to configure monitored resources and metrics 31 | // for monitoring. In the example, a monitored resource and two metrics are 32 | // defined. The `library.googleapis.com/book/returned_count` metric is sent 33 | // to both producer and consumer projects, whereas the 34 | // `library.googleapis.com/book/overdue_count` metric is only sent to the 35 | // consumer project. 36 | // 37 | // monitored_resources: 38 | // - type: library.googleapis.com/branch 39 | // labels: 40 | // - key: /city 41 | // description: The city where the library branch is located in. 42 | // - key: /name 43 | // description: The name of the branch. 44 | // metrics: 45 | // - name: library.googleapis.com/book/returned_count 46 | // metric_kind: DELTA 47 | // value_type: INT64 48 | // labels: 49 | // - key: /customer_id 50 | // - name: library.googleapis.com/book/overdue_count 51 | // metric_kind: GAUGE 52 | // value_type: INT64 53 | // labels: 54 | // - key: /customer_id 55 | // monitoring: 56 | // producer_destinations: 57 | // - monitored_resource: library.googleapis.com/branch 58 | // metrics: 59 | // - library.googleapis.com/book/returned_count 60 | // consumer_destinations: 61 | // - monitored_resource: library.googleapis.com/branch 62 | // metrics: 63 | // - library.googleapis.com/book/returned_count 64 | // - library.googleapis.com/book/overdue_count 65 | message Monitoring { 66 | // Configuration of a specific monitoring destination (the producer project 67 | // or the consumer project). 68 | message MonitoringDestination { 69 | // The monitored resource type. The type must be defined in 70 | // [Service.monitored_resources][google.api.Service.monitored_resources] section. 71 | string monitored_resource = 1; 72 | 73 | // Names of the metrics to report to this monitoring destination. 74 | // Each name must be defined in [Service.metrics][google.api.Service.metrics] section. 75 | repeated string metrics = 2; 76 | } 77 | 78 | // Monitoring configurations for sending metrics to the producer project. 79 | // There can be multiple producer destinations, each one must have a 80 | // different monitored resource type. A metric can be used in at most 81 | // one producer destination. 82 | repeated MonitoringDestination producer_destinations = 1; 83 | 84 | // Monitoring configurations for sending metrics to the consumer project. 85 | // There can be multiple consumer destinations, each one must have a 86 | // different monitored resource type. A metric can be used in at most 87 | // one consumer destination. 88 | repeated MonitoringDestination consumer_destinations = 2; 89 | } 90 | -------------------------------------------------------------------------------- /protos/google/api/service.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/auth.proto"; 21 | import "google/api/backend.proto"; 22 | import "google/api/context.proto"; 23 | import "google/api/control.proto"; 24 | import "google/api/documentation.proto"; 25 | import "google/api/endpoint.proto"; 26 | import "google/api/experimental/experimental.proto"; 27 | import "google/api/http.proto"; 28 | import "google/api/label.proto"; 29 | import "google/api/log.proto"; 30 | import "google/api/logging.proto"; 31 | import "google/api/metric.proto"; 32 | import "google/api/monitored_resource.proto"; 33 | import "google/api/monitoring.proto"; 34 | import "google/api/quota.proto"; 35 | import "google/api/source_info.proto"; 36 | import "google/api/system_parameter.proto"; 37 | import "google/api/usage.proto"; 38 | import "google/protobuf/any.proto"; 39 | import "google/protobuf/api.proto"; 40 | import "google/protobuf/type.proto"; 41 | import "google/protobuf/wrappers.proto"; 42 | 43 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 44 | option java_multiple_files = true; 45 | option java_outer_classname = "ServiceProto"; 46 | option java_package = "com.google.api"; 47 | option objc_class_prefix = "GAPI"; 48 | 49 | 50 | // `Service` is the root object of Google service configuration schema. It 51 | // describes basic information about a service, such as the name and the 52 | // title, and delegates other aspects to sub-sections. Each sub-section is 53 | // either a proto message or a repeated proto message that configures a 54 | // specific aspect, such as auth. See each proto message definition for details. 55 | // 56 | // Example: 57 | // 58 | // type: google.api.Service 59 | // config_version: 3 60 | // name: calendar.googleapis.com 61 | // title: Google Calendar API 62 | // apis: 63 | // - name: google.calendar.v3.Calendar 64 | // authentication: 65 | // providers: 66 | // - id: google_calendar_auth 67 | // jwks_uri: https://www.googleapis.com/oauth2/v1/certs 68 | // issuer: https://securetoken.google.com 69 | // rules: 70 | // - selector: "*" 71 | // requirements: 72 | // provider_id: google_calendar_auth 73 | message Service { 74 | // The version of the service configuration. The config version may 75 | // influence interpretation of the configuration, for example, to 76 | // determine defaults. This is documented together with applicable 77 | // options. The current default for the config version itself is `3`. 78 | google.protobuf.UInt32Value config_version = 20; 79 | 80 | // The DNS address at which this service is available, 81 | // e.g. `calendar.googleapis.com`. 82 | string name = 1; 83 | 84 | // A unique ID for a specific instance of this message, typically assigned 85 | // by the client for tracking purpose. If empty, the server may choose to 86 | // generate one instead. 87 | string id = 33; 88 | 89 | // The product title associated with this service. 90 | string title = 2; 91 | 92 | // The id of the Google developer project that owns the service. 93 | // Members of this project can manage the service configuration, 94 | // manage consumption of the service, etc. 95 | string producer_project_id = 22; 96 | 97 | // A list of API interfaces exported by this service. Only the `name` field 98 | // of the [google.protobuf.Api][google.protobuf.Api] needs to be provided by the configuration 99 | // author, as the remaining fields will be derived from the IDL during the 100 | // normalization process. It is an error to specify an API interface here 101 | // which cannot be resolved against the associated IDL files. 102 | repeated google.protobuf.Api apis = 3; 103 | 104 | // A list of all proto message types included in this API service. 105 | // Types referenced directly or indirectly by the `apis` are 106 | // automatically included. Messages which are not referenced but 107 | // shall be included, such as types used by the `google.protobuf.Any` type, 108 | // should be listed here by name. Example: 109 | // 110 | // types: 111 | // - name: google.protobuf.Int32 112 | repeated google.protobuf.Type types = 4; 113 | 114 | // A list of all enum types included in this API service. Enums 115 | // referenced directly or indirectly by the `apis` are automatically 116 | // included. Enums which are not referenced but shall be included 117 | // should be listed here by name. Example: 118 | // 119 | // enums: 120 | // - name: google.someapi.v1.SomeEnum 121 | repeated google.protobuf.Enum enums = 5; 122 | 123 | // Additional API documentation. 124 | Documentation documentation = 6; 125 | 126 | // API backend configuration. 127 | Backend backend = 8; 128 | 129 | // HTTP configuration. 130 | Http http = 9; 131 | 132 | // Quota configuration. 133 | Quota quota = 10; 134 | 135 | // Auth configuration. 136 | Authentication authentication = 11; 137 | 138 | // Context configuration. 139 | Context context = 12; 140 | 141 | // Configuration controlling usage of this service. 142 | Usage usage = 15; 143 | 144 | // Configuration for network endpoints. If this is empty, then an endpoint 145 | // with the same name as the service is automatically generated to service all 146 | // defined APIs. 147 | repeated Endpoint endpoints = 18; 148 | 149 | // Configuration for the service control plane. 150 | Control control = 21; 151 | 152 | // Defines the logs used by this service. 153 | repeated LogDescriptor logs = 23; 154 | 155 | // Defines the metrics used by this service. 156 | repeated MetricDescriptor metrics = 24; 157 | 158 | // Defines the monitored resources used by this service. This is required 159 | // by the [Service.monitoring][google.api.Service.monitoring] and [Service.logging][google.api.Service.logging] configurations. 160 | repeated MonitoredResourceDescriptor monitored_resources = 25; 161 | 162 | // Logging configuration. 163 | Logging logging = 27; 164 | 165 | // Monitoring configuration. 166 | Monitoring monitoring = 28; 167 | 168 | // System parameter configuration. 169 | SystemParameters system_parameters = 29; 170 | 171 | // Output only. The source information for this configuration if available. 172 | SourceInfo source_info = 37; 173 | 174 | // Experimental configuration. 175 | Experimental experimental = 101; 176 | } 177 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/check_error.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option cc_enable_arenas = true; 22 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "CheckErrorProto"; 25 | option java_package = "com.google.api.servicecontrol.v1"; 26 | 27 | 28 | // Defines the errors to be returned in 29 | // [google.api.servicecontrol.v1.CheckResponse.check_errors][google.api.servicecontrol.v1.CheckResponse.check_errors]. 30 | message CheckError { 31 | // Error codes for Check responses. 32 | enum Code { 33 | // This is never used in `CheckResponse`. 34 | ERROR_CODE_UNSPECIFIED = 0; 35 | 36 | // The consumer's project id was not found. 37 | // Same as [google.rpc.Code.NOT_FOUND][]. 38 | NOT_FOUND = 5; 39 | 40 | // The consumer doesn't have access to the specified resource. 41 | // Same as [google.rpc.Code.PERMISSION_DENIED][]. 42 | PERMISSION_DENIED = 7; 43 | 44 | // Quota check failed. Same as [google.rpc.Code.RESOURCE_EXHAUSTED][]. 45 | RESOURCE_EXHAUSTED = 8; 46 | 47 | // The consumer hasn't activated the service. 48 | SERVICE_NOT_ACTIVATED = 104; 49 | 50 | // The consumer cannot access the service because billing is disabled. 51 | BILLING_DISABLED = 107; 52 | 53 | // The consumer's project has been marked as deleted (soft deletion). 54 | PROJECT_DELETED = 108; 55 | 56 | // The consumer's project number or id does not represent a valid project. 57 | PROJECT_INVALID = 114; 58 | 59 | // The IP address of the consumer is invalid for the specific consumer 60 | // project. 61 | IP_ADDRESS_BLOCKED = 109; 62 | 63 | // The referer address of the consumer request is invalid for the specific 64 | // consumer project. 65 | REFERER_BLOCKED = 110; 66 | 67 | // The client application of the consumer request is invalid for the 68 | // specific consumer project. 69 | CLIENT_APP_BLOCKED = 111; 70 | 71 | // The consumer's API key is invalid. 72 | API_KEY_INVALID = 105; 73 | 74 | // The consumer's API Key has expired. 75 | API_KEY_EXPIRED = 112; 76 | 77 | // The consumer's API Key was not found in config record. 78 | API_KEY_NOT_FOUND = 113; 79 | 80 | // The backend server for looking up project id/number is unavailable. 81 | NAMESPACE_LOOKUP_UNAVAILABLE = 300; 82 | 83 | // The backend server for checking service status is unavailable. 84 | SERVICE_STATUS_UNAVAILABLE = 301; 85 | 86 | // The backend server for checking billing status is unavailable. 87 | BILLING_STATUS_UNAVAILABLE = 302; 88 | } 89 | 90 | // The error code. 91 | Code code = 1; 92 | 93 | // Free-form text providing details on the error cause of the error. 94 | string detail = 2; 95 | } 96 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/distribution.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "DistributionProto"; 23 | option java_package = "com.google.api.servicecontrol.v1"; 24 | 25 | 26 | // Distribution represents a frequency distribution of double-valued sample 27 | // points. It contains the size of the population of sample points plus 28 | // additional optional information: 29 | // 30 | // - the arithmetic mean of the samples 31 | // - the minimum and maximum of the samples 32 | // - the sum-squared-deviation of the samples, used to compute variance 33 | // - a histogram of the values of the sample points 34 | message Distribution { 35 | // Describing buckets with constant width. 36 | message LinearBuckets { 37 | // The number of finite buckets. With the underflow and overflow buckets, 38 | // the total number of buckets is `num_finite_buckets` + 2. 39 | // See comments on `bucket_options` for details. 40 | int32 num_finite_buckets = 1; 41 | 42 | // The i'th linear bucket covers the interval 43 | // [offset + (i-1) * width, offset + i * width) 44 | // where i ranges from 1 to num_finite_buckets, inclusive. 45 | // Must be strictly positive. 46 | double width = 2; 47 | 48 | // The i'th linear bucket covers the interval 49 | // [offset + (i-1) * width, offset + i * width) 50 | // where i ranges from 1 to num_finite_buckets, inclusive. 51 | double offset = 3; 52 | } 53 | 54 | // Describing buckets with exponentially growing width. 55 | message ExponentialBuckets { 56 | // The number of finite buckets. With the underflow and overflow buckets, 57 | // the total number of buckets is `num_finite_buckets` + 2. 58 | // See comments on `bucket_options` for details. 59 | int32 num_finite_buckets = 1; 60 | 61 | // The i'th exponential bucket covers the interval 62 | // [scale * growth_factor^(i-1), scale * growth_factor^i) 63 | // where i ranges from 1 to num_finite_buckets inclusive. 64 | // Must be larger than 1.0. 65 | double growth_factor = 2; 66 | 67 | // The i'th exponential bucket covers the interval 68 | // [scale * growth_factor^(i-1), scale * growth_factor^i) 69 | // where i ranges from 1 to num_finite_buckets inclusive. 70 | // Must be > 0. 71 | double scale = 3; 72 | } 73 | 74 | // Describing buckets with arbitrary user-provided width. 75 | message ExplicitBuckets { 76 | // 'bound' is a list of strictly increasing boundaries between 77 | // buckets. Note that a list of length N-1 defines N buckets because 78 | // of fenceposting. See comments on `bucket_options` for details. 79 | // 80 | // The i'th finite bucket covers the interval 81 | // [bound[i-1], bound[i]) 82 | // where i ranges from 1 to bound_size() - 1. Note that there are no 83 | // finite buckets at all if 'bound' only contains a single element; in 84 | // that special case the single bound defines the boundary between the 85 | // underflow and overflow buckets. 86 | // 87 | // bucket number lower bound upper bound 88 | // i == 0 (underflow) -inf bound[i] 89 | // 0 < i < bound_size() bound[i-1] bound[i] 90 | // i == bound_size() (overflow) bound[i-1] +inf 91 | repeated double bounds = 1; 92 | } 93 | 94 | // The total number of samples in the distribution. Must be >= 0. 95 | int64 count = 1; 96 | 97 | // The arithmetic mean of the samples in the distribution. If `count` is 98 | // zero then this field must be zero. 99 | double mean = 2; 100 | 101 | // The minimum of the population of values. Ignored if `count` is zero. 102 | double minimum = 3; 103 | 104 | // The maximum of the population of values. Ignored if `count` is zero. 105 | double maximum = 4; 106 | 107 | // The sum of squared deviations from the mean: 108 | // Sum[i=1..count]((x_i - mean)^2) 109 | // where each x_i is a sample values. If `count` is zero then this field 110 | // must be zero, otherwise validation of the request fails. 111 | double sum_of_squared_deviation = 5; 112 | 113 | // The number of samples in each histogram bucket. `bucket_counts` are 114 | // optional. If present, they must sum to the `count` value. 115 | // 116 | // The buckets are defined below in `bucket_option`. There are N buckets. 117 | // `bucket_counts[0]` is the number of samples in the underflow bucket. 118 | // `bucket_counts[1]` to `bucket_counts[N-1]` are the numbers of samples 119 | // in each of the finite buckets. And `bucket_counts[N] is the number 120 | // of samples in the overflow bucket. See the comments of `bucket_option` 121 | // below for more details. 122 | // 123 | // Any suffix of trailing zeros may be omitted. 124 | repeated int64 bucket_counts = 6; 125 | 126 | // Defines the buckets in the histogram. `bucket_option` and `bucket_counts` 127 | // must be both set, or both unset. 128 | // 129 | // Buckets are numbered the the range of [0, N], with a total of N+1 buckets. 130 | // There must be at least two buckets (a single-bucket histogram gives 131 | // no information that isn't already provided by `count`). 132 | // 133 | // The first bucket is the underflow bucket which has a lower bound 134 | // of -inf. The last bucket is the overflow bucket which has an 135 | // upper bound of +inf. All other buckets (if any) are called "finite" 136 | // buckets because they have finite lower and upper bounds. As described 137 | // below, there are three ways to define the finite buckets. 138 | // 139 | // (1) Buckets with constant width. 140 | // (2) Buckets with exponentially growing widths. 141 | // (3) Buckets with arbitrary user-provided widths. 142 | // 143 | // In all cases, the buckets cover the entire real number line (-inf, 144 | // +inf). Bucket upper bounds are exclusive and lower bounds are 145 | // inclusive. The upper bound of the underflow bucket is equal to the 146 | // lower bound of the smallest finite bucket; the lower bound of the 147 | // overflow bucket is equal to the upper bound of the largest finite 148 | // bucket. 149 | oneof bucket_option { 150 | // Buckets with constant width. 151 | LinearBuckets linear_buckets = 7; 152 | 153 | // Buckets with exponentially growing width. 154 | ExponentialBuckets exponential_buckets = 8; 155 | 156 | // Buckets with arbitrary user-provided width. 157 | ExplicitBuckets explicit_buckets = 9; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/log_entry.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/logging/type/log_severity.proto"; 21 | import "google/protobuf/any.proto"; 22 | import "google/protobuf/struct.proto"; 23 | import "google/protobuf/timestamp.proto"; 24 | 25 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 26 | option java_multiple_files = true; 27 | option java_outer_classname = "LogEntryProto"; 28 | option java_package = "com.google.api.servicecontrol.v1"; 29 | 30 | 31 | // An individual log entry. 32 | message LogEntry { 33 | // Required. The log to which this log entry belongs. Examples: `"syslog"`, 34 | // `"book_log"`. 35 | string name = 10; 36 | 37 | // The time the event described by the log entry occurred. If 38 | // omitted, defaults to operation start time. 39 | google.protobuf.Timestamp timestamp = 11; 40 | 41 | // The severity of the log entry. The default value is 42 | // `LogSeverity.DEFAULT`. 43 | google.logging.type.LogSeverity severity = 12; 44 | 45 | // A unique ID for the log entry used for deduplication. If omitted, 46 | // the implementation will generate one based on operation_id. 47 | string insert_id = 4; 48 | 49 | // A set of user-defined (key, value) data that provides additional 50 | // information about the log entry. 51 | map labels = 13; 52 | 53 | // The log entry payload, which can be one of multiple types. 54 | oneof payload { 55 | // The log entry payload, represented as a protocol buffer that is 56 | // expressed as a JSON object. You can only pass `protoPayload` 57 | // values that belong to a set of approved types. 58 | google.protobuf.Any proto_payload = 2; 59 | 60 | // The log entry payload, represented as a Unicode string (UTF-8). 61 | string text_payload = 3; 62 | 63 | // The log entry payload, represented as a structure that 64 | // is expressed as a JSON object. 65 | google.protobuf.Struct struct_payload = 6; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/metric_value.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/servicecontrol/v1/distribution.proto"; 21 | import "google/protobuf/timestamp.proto"; 22 | import "google/type/money.proto"; 23 | 24 | option cc_enable_arenas = true; 25 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 26 | option java_multiple_files = true; 27 | option java_outer_classname = "MetricValueSetProto"; 28 | option java_package = "com.google.api.servicecontrol.v1"; 29 | 30 | 31 | // Represents a single metric value. 32 | message MetricValue { 33 | // The labels describing the metric value. 34 | // See comments on [google.api.servicecontrol.v1.Operation.labels][google.api.servicecontrol.v1.Operation.labels] for 35 | // the overriding relationship. 36 | map labels = 1; 37 | 38 | // The start of the time period over which this metric value's measurement 39 | // applies. The time period has different semantics for different metric 40 | // types (cumulative, delta, and gauge). See the metric definition 41 | // documentation in the service configuration for details. 42 | google.protobuf.Timestamp start_time = 2; 43 | 44 | // The end of the time period over which this metric value's measurement 45 | // applies. 46 | google.protobuf.Timestamp end_time = 3; 47 | 48 | // The value. The type of value used in the request must 49 | // agree with the metric definition in the service configuration, otherwise 50 | // the MetricValue is rejected. 51 | oneof value { 52 | // A boolean value. 53 | bool bool_value = 4; 54 | 55 | // A signed 64-bit integer value. 56 | int64 int64_value = 5; 57 | 58 | // A double precision floating point value. 59 | double double_value = 6; 60 | 61 | // A text string value. 62 | string string_value = 7; 63 | 64 | // A distribution value. 65 | Distribution distribution_value = 8; 66 | } 67 | } 68 | 69 | // Represents a set of metric values in the same metric. 70 | // Each metric value in the set should have a unique combination of start time, 71 | // end time, and label values. 72 | message MetricValueSet { 73 | // The metric name defined in the service configuration. 74 | string metric_name = 1; 75 | 76 | // The values in this metric. 77 | repeated MetricValue metric_values = 2; 78 | } 79 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/operation.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/servicecontrol/v1/log_entry.proto"; 21 | import "google/api/servicecontrol/v1/metric_value.proto"; 22 | import "google/protobuf/timestamp.proto"; 23 | 24 | option cc_enable_arenas = true; 25 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 26 | option java_multiple_files = true; 27 | option java_outer_classname = "OperationProto"; 28 | option java_package = "com.google.api.servicecontrol.v1"; 29 | 30 | 31 | // Represents information regarding an operation. 32 | message Operation { 33 | // Defines the importance of the data contained in the operation. 34 | enum Importance { 35 | // The API implementation may cache and aggregate the data. 36 | // The data may be lost when rare and unexpected system failures occur. 37 | LOW = 0; 38 | 39 | // The API implementation doesn't cache and aggregate the data. 40 | // If the method returns successfully, it's guaranteed that the data has 41 | // been persisted in durable storage. 42 | HIGH = 1; 43 | } 44 | 45 | // Identity of the operation. This must be unique within the scope of the 46 | // service that generated the operation. If the service calls 47 | // Check() and Report() on the same operation, the two calls should carry 48 | // the same id. 49 | // 50 | // UUID version 4 is recommended, though not required. 51 | // In scenarios where an operation is computed from existing information 52 | // and an idempotent id is desirable for deduplication purpose, UUID version 5 53 | // is recommended. See RFC 4122 for details. 54 | string operation_id = 1; 55 | 56 | // Fully qualified name of the operation. Reserved for future use. 57 | string operation_name = 2; 58 | 59 | // Identity of the consumer who is using the service. 60 | // This field should be filled in for the operations initiated by a 61 | // consumer, but not for service-initiated operations that are 62 | // not related to a specific consumer. 63 | // 64 | // This can be in one of the following formats: 65 | // project:, 66 | // project_number:, 67 | // api_key:. 68 | string consumer_id = 3; 69 | 70 | // Required. Start time of the operation. 71 | google.protobuf.Timestamp start_time = 4; 72 | 73 | // End time of the operation. 74 | // Required when the operation is used in [ServiceController.Report][google.api.servicecontrol.v1.ServiceController.Report], 75 | // but optional when the operation is used in [ServiceController.Check][google.api.servicecontrol.v1.ServiceController.Check]. 76 | google.protobuf.Timestamp end_time = 5; 77 | 78 | // Labels describing the operation. Only the following labels are allowed: 79 | // 80 | // - Labels describing monitored resources as defined in 81 | // the service configuration. 82 | // - Default labels of metric values. When specified, labels defined in the 83 | // metric value override these default. 84 | // - The following labels defined by Google Cloud Platform: 85 | // - `cloud.googleapis.com/location` describing the location where the 86 | // operation happened, 87 | // - `servicecontrol.googleapis.com/user_agent` describing the user agent 88 | // of the API request, 89 | // - `servicecontrol.googleapis.com/service_agent` describing the service 90 | // used to handle the API request (e.g. ESP), 91 | // - `servicecontrol.googleapis.com/platform` describing the platform 92 | // where the API is served (e.g. GAE, GCE, GKE). 93 | map labels = 6; 94 | 95 | // Represents information about this operation. Each MetricValueSet 96 | // corresponds to a metric defined in the service configuration. 97 | // The data type used in the MetricValueSet must agree with 98 | // the data type specified in the metric definition. 99 | // 100 | // Within a single operation, it is not allowed to have more than one 101 | // MetricValue instances that have the same metric names and identical 102 | // label value combinations. If a request has such duplicated MetricValue 103 | // instances, the entire request is rejected with 104 | // an invalid argument error. 105 | repeated MetricValueSet metric_value_sets = 7; 106 | 107 | // Represents information to be logged. 108 | repeated LogEntry log_entries = 8; 109 | 110 | // DO NOT USE. This is an experimental field. 111 | Importance importance = 11; 112 | } 113 | -------------------------------------------------------------------------------- /protos/google/api/servicecontrol/v1/service_controller.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api.servicecontrol.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/api/servicecontrol/v1/check_error.proto"; 21 | import "google/api/servicecontrol/v1/operation.proto"; 22 | import "google/rpc/status.proto"; 23 | 24 | option cc_enable_arenas = true; 25 | option go_package = "google.golang.org/genproto/googleapis/api/servicecontrol/v1;servicecontrol"; 26 | option java_multiple_files = true; 27 | option java_outer_classname = "ServiceControllerProto"; 28 | option java_package = "com.google.api.servicecontrol.v1"; 29 | option objc_class_prefix = "GASC"; 30 | 31 | 32 | // [Google Service Control API](/service-control/overview) 33 | // 34 | // Lets clients check and report operations against 35 | // a [managed service][google.api.servicemanagement.v1.ManagedService]. 36 | service ServiceController { 37 | // Checks an operation with Google Service Control to decide whether 38 | // the given operation should proceed. It should be called before the 39 | // operation is executed. 40 | // 41 | // If feasible, the client should cache the check results and reuse them for 42 | // up to 60s. In case of server errors, the client may rely on the cached 43 | // results for longer time. 44 | // 45 | // This method requires the `servicemanagement.services.check` permission 46 | // on the specified service. For more information, see 47 | // [Google Cloud IAM](https://cloud.google.com/iam). 48 | rpc Check(CheckRequest) returns (CheckResponse) { 49 | option (google.api.http) = { post: "/v1/services/{service_name}:check" body: "*" }; 50 | } 51 | 52 | // Reports operations to Google Service Control. It should be called 53 | // after the operation is completed. 54 | // 55 | // If feasible, the client should aggregate reporting data for up to 5s to 56 | // reduce API traffic. Limiting aggregation to 5s is to reduce data loss 57 | // during client crashes. Clients should carefully choose the aggregation 58 | // window to avoid data loss risk more than 0.01% for business and 59 | // compliance reasons. 60 | // 61 | // This method requires the `servicemanagement.services.report` permission 62 | // on the specified service. For more information, see 63 | // [Google Cloud IAM](https://cloud.google.com/iam). 64 | rpc Report(ReportRequest) returns (ReportResponse) { 65 | option (google.api.http) = { post: "/v1/services/{service_name}:report" body: "*" }; 66 | } 67 | } 68 | 69 | // Request message for the Check method. 70 | message CheckRequest { 71 | // The service name as specified in its service configuration. For example, 72 | // `"pubsub.googleapis.com"`. 73 | // 74 | // See [google.api.Service][google.api.Service] for the definition of a service name. 75 | string service_name = 1; 76 | 77 | // The operation to be checked. 78 | Operation operation = 2; 79 | 80 | // Specifies which version of service configuration should be used to process 81 | // the request. 82 | // 83 | // If unspecified or no matching version can be found, the 84 | // latest one will be used. 85 | string service_config_id = 4; 86 | } 87 | 88 | // Response message for the Check method. 89 | message CheckResponse { 90 | // The same operation_id value used in the CheckRequest. 91 | // Used for logging and diagnostics purposes. 92 | string operation_id = 1; 93 | 94 | // Indicate the decision of the check. 95 | // 96 | // If no check errors are present, the service should process the operation. 97 | // Otherwise the service should use the list of errors to determine the 98 | // appropriate action. 99 | repeated CheckError check_errors = 2; 100 | 101 | // The actual config id used to process the request. 102 | string service_config_id = 5; 103 | } 104 | 105 | // Request message for the Report method. 106 | message ReportRequest { 107 | // The service name as specified in its service configuration. For example, 108 | // `"pubsub.googleapis.com"`. 109 | // 110 | // See [google.api.Service][google.api.Service] for the definition of a service name. 111 | string service_name = 1; 112 | 113 | // Operations to be reported. 114 | // 115 | // Typically the service should report one operation per request. 116 | // Putting multiple operations into a single request is allowed, but should 117 | // be used only when multiple operations are natually available at the time 118 | // of the report. 119 | // 120 | // If multiple operations are in a single request, the total request size 121 | // should be no larger than 1MB. See [ReportResponse.report_errors][google.api.servicecontrol.v1.ReportResponse.report_errors] for 122 | // partial failure behavior. 123 | repeated Operation operations = 2; 124 | 125 | // Specifies which version of service config should be used to process the 126 | // request. 127 | // 128 | // If unspecified or no matching version can be found, the 129 | // latest one will be used. 130 | string service_config_id = 3; 131 | } 132 | 133 | // Response message for the Report method. 134 | message ReportResponse { 135 | // Represents the processing error of one `Operation` in the request. 136 | message ReportError { 137 | // The [Operation.operation_id][google.api.servicecontrol.v1.Operation.operation_id] value from the request. 138 | string operation_id = 1; 139 | 140 | // Details of the error when processing the `Operation`. 141 | google.rpc.Status status = 2; 142 | } 143 | 144 | // Partial failures, one for each `Operation` in the request that failed 145 | // processing. There are three possible combinations of the RPC status: 146 | // 147 | // 1. The combination of a successful RPC status and an empty `report_errors` 148 | // list indicates a complete success where all `Operations` in the 149 | // request are processed successfully. 150 | // 2. The combination of a successful RPC status and a non-empty 151 | // `report_errors` list indicates a partial success where some 152 | // `Operations` in the request succeeded. Each 153 | // `Operation` that failed processing has a corresponding item 154 | // in this list. 155 | // 3. A failed RPC status indicates a complete failure where none of the 156 | // `Operations` in the request succeeded. 157 | repeated ReportError report_errors = 1; 158 | 159 | // The actual config id used to process the request. 160 | string service_config_id = 2; 161 | } 162 | -------------------------------------------------------------------------------- /protos/google/api/source_info.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/protobuf/any.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "SourceInfoProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // Source information used to create a Service Config 29 | message SourceInfo { 30 | // All files used during config generation. 31 | repeated google.protobuf.Any source_files = 1; 32 | } 33 | -------------------------------------------------------------------------------- /protos/google/api/system_parameter.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 20 | option java_multiple_files = true; 21 | option java_outer_classname = "SystemParameterProto"; 22 | option java_package = "com.google.api"; 23 | option objc_class_prefix = "GAPI"; 24 | 25 | 26 | // ### System parameter configuration 27 | // 28 | // A system parameter is a special kind of parameter defined by the API 29 | // system, not by an individual API. It is typically mapped to an HTTP header 30 | // and/or a URL query parameter. This configuration specifies which methods 31 | // change the names of the system parameters. 32 | message SystemParameters { 33 | // Define system parameters. 34 | // 35 | // The parameters defined here will override the default parameters 36 | // implemented by the system. If this field is missing from the service 37 | // config, default system parameters will be used. Default system parameters 38 | // and names is implementation-dependent. 39 | // 40 | // Example: define api key for all methods 41 | // 42 | // system_parameters 43 | // rules: 44 | // - selector: "*" 45 | // parameters: 46 | // - name: api_key 47 | // url_query_parameter: api_key 48 | // 49 | // 50 | // Example: define 2 api key names for a specific method. 51 | // 52 | // system_parameters 53 | // rules: 54 | // - selector: "/ListShelves" 55 | // parameters: 56 | // - name: api_key 57 | // http_header: Api-Key1 58 | // - name: api_key 59 | // http_header: Api-Key2 60 | // 61 | // **NOTE:** All service configuration rules follow "last one wins" order. 62 | repeated SystemParameterRule rules = 1; 63 | } 64 | 65 | // Define a system parameter rule mapping system parameter definitions to 66 | // methods. 67 | message SystemParameterRule { 68 | // Selects the methods to which this rule applies. Use '*' to indicate all 69 | // methods in all APIs. 70 | // 71 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 72 | string selector = 1; 73 | 74 | // Define parameters. Multiple names may be defined for a parameter. 75 | // For a given method call, only one of them should be used. If multiple 76 | // names are used the behavior is implementation-dependent. 77 | // If none of the specified names are present the behavior is 78 | // parameter-dependent. 79 | repeated SystemParameter parameters = 2; 80 | } 81 | 82 | // Define a parameter's name and location. The parameter may be passed as either 83 | // an HTTP header or a URL query parameter, and if both are passed the behavior 84 | // is implementation-dependent. 85 | message SystemParameter { 86 | // Define the name of the parameter, such as "api_key" . It is case sensitive. 87 | string name = 1; 88 | 89 | // Define the HTTP header name to use for the parameter. It is case 90 | // insensitive. 91 | string http_header = 2; 92 | 93 | // Define the URL query parameter name to use for the parameter. It is case 94 | // sensitive. 95 | string url_query_parameter = 3; 96 | } 97 | -------------------------------------------------------------------------------- /protos/google/api/usage.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; 22 | option java_multiple_files = true; 23 | option java_outer_classname = "UsageProto"; 24 | option java_package = "com.google.api"; 25 | option objc_class_prefix = "GAPI"; 26 | 27 | 28 | // Configuration controlling usage of a service. 29 | message Usage { 30 | // Requirements that must be satisfied before a consumer project can use the 31 | // service. Each requirement is of the form /; 32 | // for example 'serviceusage.googleapis.com/billing-enabled'. 33 | repeated string requirements = 1; 34 | 35 | // A list of usage rules that apply to individual API methods. 36 | // 37 | // **NOTE:** All service configuration rules follow "last one wins" order. 38 | repeated UsageRule rules = 6; 39 | 40 | // The full resource name of a channel used for sending notifications to the 41 | // service producer. 42 | // 43 | // Google Service Management currently only supports 44 | // [Google Cloud Pub/Sub](https://cloud.google.com/pubsub) as a notification 45 | // channel. To use Google Cloud Pub/Sub as the channel, this must be the name 46 | // of a Cloud Pub/Sub topic that uses the Cloud Pub/Sub topic name format 47 | // documented in https://cloud.google.com/pubsub/docs/overview. 48 | string producer_notification_channel = 7; 49 | } 50 | 51 | // Usage configuration rules for the service. 52 | // 53 | // NOTE: Under development. 54 | // 55 | // 56 | // Use this rule to configure unregistered calls for the service. Unregistered 57 | // calls are calls that do not contain consumer project identity. 58 | // (Example: calls that do not contain an API key). 59 | // By default, API methods do not allow unregistered calls, and each method call 60 | // must be identified by a consumer project identity. Use this rule to 61 | // allow/disallow unregistered calls. 62 | // 63 | // Example of an API that wants to allow unregistered calls for entire service. 64 | // 65 | // usage: 66 | // rules: 67 | // - selector: "*" 68 | // allow_unregistered_calls: true 69 | // 70 | // Example of a method that wants to allow unregistered calls. 71 | // 72 | // usage: 73 | // rules: 74 | // - selector: "google.example.library.v1.LibraryService.CreateBook" 75 | // allow_unregistered_calls: true 76 | message UsageRule { 77 | // Selects the methods to which this rule applies. Use '*' to indicate all 78 | // methods in all APIs. 79 | // 80 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 81 | string selector = 1; 82 | 83 | // True, if the method allows unregistered calls; false otherwise. 84 | bool allow_unregistered_calls = 2; 85 | } 86 | -------------------------------------------------------------------------------- /protos/google/iam/v1/iam_policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.iam.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | import "google/iam/v1/policy.proto"; 21 | 22 | option cc_enable_arenas = true; 23 | option csharp_namespace = "Google.Cloud.Iam.V1"; 24 | option go_package = "google.golang.org/genproto/googleapis/iam/v1;iam"; 25 | option java_multiple_files = true; 26 | option java_outer_classname = "IamPolicyProto"; 27 | option java_package = "com.google.iam.v1"; 28 | 29 | 30 | // ## API Overview 31 | // 32 | // Manages Identity and Access Management (IAM) policies. 33 | // 34 | // Any implementation of an API that offers access control features 35 | // implements the google.iam.v1.IAMPolicy interface. 36 | // 37 | // ## Data model 38 | // 39 | // Access control is applied when a principal (user or service account), takes 40 | // some action on a resource exposed by a service. Resources, identified by 41 | // URI-like names, are the unit of access control specification. Service 42 | // implementations can choose the granularity of access control and the 43 | // supported permissions for their resources. 44 | // For example one database service may allow access control to be 45 | // specified only at the Table level, whereas another might allow access control 46 | // to also be specified at the Column level. 47 | // 48 | // ## Policy Structure 49 | // 50 | // See google.iam.v1.Policy 51 | // 52 | // This is intentionally not a CRUD style API because access control policies 53 | // are created and deleted implicitly with the resources to which they are 54 | // attached. 55 | service IAMPolicy { 56 | // Sets the access control policy on the specified resource. Replaces any 57 | // existing policy. 58 | rpc SetIamPolicy(SetIamPolicyRequest) returns (Policy) { 59 | option (google.api.http) = { post: "/v1/{resource=**}:setIamPolicy" body: "*" }; 60 | } 61 | 62 | // Gets the access control policy for a resource. 63 | // Returns an empty policy if the resource exists and does not have a policy 64 | // set. 65 | rpc GetIamPolicy(GetIamPolicyRequest) returns (Policy) { 66 | option (google.api.http) = { post: "/v1/{resource=**}:getIamPolicy" body: "*" }; 67 | } 68 | 69 | // Returns permissions that a caller has on the specified resource. 70 | // If the resource does not exist, this will return an empty set of 71 | // permissions, not a NOT_FOUND error. 72 | rpc TestIamPermissions(TestIamPermissionsRequest) returns (TestIamPermissionsResponse) { 73 | option (google.api.http) = { post: "/v1/{resource=**}:testIamPermissions" body: "*" }; 74 | } 75 | } 76 | 77 | // Request message for `SetIamPolicy` method. 78 | message SetIamPolicyRequest { 79 | // REQUIRED: The resource for which the policy is being specified. 80 | // `resource` is usually specified as a path. For example, a Project 81 | // resource is specified as `projects/{project}`. 82 | string resource = 1; 83 | 84 | // REQUIRED: The complete policy to be applied to the `resource`. The size of 85 | // the policy is limited to a few 10s of KB. An empty policy is a 86 | // valid policy but certain Cloud Platform services (such as Projects) 87 | // might reject them. 88 | Policy policy = 2; 89 | } 90 | 91 | // Request message for `GetIamPolicy` method. 92 | message GetIamPolicyRequest { 93 | // REQUIRED: The resource for which the policy is being requested. 94 | // `resource` is usually specified as a path. For example, a Project 95 | // resource is specified as `projects/{project}`. 96 | string resource = 1; 97 | } 98 | 99 | // Request message for `TestIamPermissions` method. 100 | message TestIamPermissionsRequest { 101 | // REQUIRED: The resource for which the policy detail is being requested. 102 | // `resource` is usually specified as a path. For example, a Project 103 | // resource is specified as `projects/{project}`. 104 | string resource = 1; 105 | 106 | // The set of permissions to check for the `resource`. Permissions with 107 | // wildcards (such as '*' or 'storage.*') are not allowed. For more 108 | // information see 109 | // [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). 110 | repeated string permissions = 2; 111 | } 112 | 113 | // Response message for `TestIamPermissions` method. 114 | message TestIamPermissionsResponse { 115 | // A subset of `TestPermissionsRequest.permissions` that the caller is 116 | // allowed. 117 | repeated string permissions = 1; 118 | } 119 | -------------------------------------------------------------------------------- /protos/google/iam/v1/policy.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.iam.v1; 18 | 19 | import "google/api/annotations.proto"; 20 | 21 | option cc_enable_arenas = true; 22 | option csharp_namespace = "Google.Cloud.Iam.V1"; 23 | option go_package = "google.golang.org/genproto/googleapis/iam/v1;iam"; 24 | option java_multiple_files = true; 25 | option java_outer_classname = "PolicyProto"; 26 | option java_package = "com.google.iam.v1"; 27 | 28 | 29 | // Defines an Identity and Access Management (IAM) policy. It is used to 30 | // specify access control policies for Cloud Platform resources. 31 | // 32 | // 33 | // A `Policy` consists of a list of `bindings`. A `Binding` binds a list of 34 | // `members` to a `role`, where the members can be user accounts, Google groups, 35 | // Google domains, and service accounts. A `role` is a named list of permissions 36 | // defined by IAM. 37 | // 38 | // **Example** 39 | // 40 | // { 41 | // "bindings": [ 42 | // { 43 | // "role": "roles/owner", 44 | // "members": [ 45 | // "user:mike@example.com", 46 | // "group:admins@example.com", 47 | // "domain:google.com", 48 | // "serviceAccount:my-other-app@appspot.gserviceaccount.com", 49 | // ] 50 | // }, 51 | // { 52 | // "role": "roles/viewer", 53 | // "members": ["user:sean@example.com"] 54 | // } 55 | // ] 56 | // } 57 | // 58 | // For a description of IAM and its features, see the 59 | // [IAM developer's guide](https://cloud.google.com/iam). 60 | message Policy { 61 | // Version of the `Policy`. The default version is 0. 62 | int32 version = 1; 63 | 64 | // Associates a list of `members` to a `role`. 65 | // Multiple `bindings` must not be specified for the same `role`. 66 | // `bindings` with no members will result in an error. 67 | repeated Binding bindings = 4; 68 | 69 | // `etag` is used for optimistic concurrency control as a way to help 70 | // prevent simultaneous updates of a policy from overwriting each other. 71 | // It is strongly suggested that systems make use of the `etag` in the 72 | // read-modify-write cycle to perform policy updates in order to avoid race 73 | // conditions: An `etag` is returned in the response to `getIamPolicy`, and 74 | // systems are expected to put that etag in the request to `setIamPolicy` to 75 | // ensure that their change will be applied to the same version of the policy. 76 | // 77 | // If no `etag` is provided in the call to `setIamPolicy`, then the existing 78 | // policy is overwritten blindly. 79 | bytes etag = 3; 80 | } 81 | 82 | // Associates `members` with a `role`. 83 | message Binding { 84 | // Role that is assigned to `members`. 85 | // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. 86 | // Required 87 | string role = 1; 88 | 89 | // Specifies the identities requesting access for a Cloud Platform resource. 90 | // `members` can have the following values: 91 | // 92 | // * `allUsers`: A special identifier that represents anyone who is 93 | // on the internet; with or without a Google account. 94 | // 95 | // * `allAuthenticatedUsers`: A special identifier that represents anyone 96 | // who is authenticated with a Google account or a service account. 97 | // 98 | // * `user:{emailid}`: An email address that represents a specific Google 99 | // account. For example, `alice@gmail.com` or `joe@example.com`. 100 | // 101 | // 102 | // * `serviceAccount:{emailid}`: An email address that represents a service 103 | // account. For example, `my-other-app@appspot.gserviceaccount.com`. 104 | // 105 | // * `group:{emailid}`: An email address that represents a Google group. 106 | // For example, `admins@example.com`. 107 | // 108 | // * `domain:{domain}`: A Google Apps domain name that represents all the 109 | // users of that domain. For example, `google.com` or `example.com`. 110 | // 111 | // 112 | repeated string members = 2; 113 | } 114 | 115 | // The difference delta between two policies. 116 | message PolicyDelta { 117 | // The delta for Bindings between two policies. 118 | repeated BindingDelta binding_deltas = 1; 119 | } 120 | 121 | // One delta entry for Binding. Each individual change (only one member in each 122 | // entry) to a binding will be a separate entry. 123 | message BindingDelta { 124 | // The type of action performed on a Binding in a policy. 125 | enum Action { 126 | // Unspecified. 127 | ACTION_UNSPECIFIED = 0; 128 | 129 | // Addition of a Binding. 130 | ADD = 1; 131 | 132 | // Removal of a Binding. 133 | REMOVE = 2; 134 | } 135 | 136 | // The action that was performed on a Binding. 137 | // Required 138 | Action action = 1; 139 | 140 | // Role that is assigned to `members`. 141 | // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. 142 | // Required 143 | string role = 2; 144 | 145 | // A single identity requesting access for a Cloud Platform resource. 146 | // Follows the same format of Binding.members. 147 | // Required 148 | string member = 3; 149 | } 150 | -------------------------------------------------------------------------------- /protos/google/protobuf/any.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/any"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "AnyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | 42 | // `Any` contains an arbitrary serialized protocol buffer message along with a 43 | // URL that describes the type of the serialized message. 44 | // 45 | // Protobuf library provides support to pack/unpack Any values in the form 46 | // of utility functions or additional generated methods of the Any type. 47 | // 48 | // Example 1: Pack and unpack a message in C++. 49 | // 50 | // Foo foo = ...; 51 | // Any any; 52 | // any.PackFrom(foo); 53 | // ... 54 | // if (any.UnpackTo(&foo)) { 55 | // ... 56 | // } 57 | // 58 | // Example 2: Pack and unpack a message in Java. 59 | // 60 | // Foo foo = ...; 61 | // Any any = Any.pack(foo); 62 | // ... 63 | // if (any.is(Foo.class)) { 64 | // foo = any.unpack(Foo.class); 65 | // } 66 | // 67 | // Example 3: Pack and unpack a message in Python. 68 | // 69 | // foo = Foo(...) 70 | // any = Any() 71 | // any.Pack(foo) 72 | // ... 73 | // if any.Is(Foo.DESCRIPTOR): 74 | // any.Unpack(foo) 75 | // ... 76 | // 77 | // The pack methods provided by protobuf library will by default use 78 | // 'type.googleapis.com/full.type.name' as the type URL and the unpack 79 | // methods only use the fully qualified type name after the last '/' 80 | // in the type URL, for example "foo.bar.com/x/y.z" will yield type 81 | // name "y.z". 82 | // 83 | // 84 | // JSON 85 | // ==== 86 | // The JSON representation of an `Any` value uses the regular 87 | // representation of the deserialized, embedded message, with an 88 | // additional field `@type` which contains the type URL. Example: 89 | // 90 | // package google.profile; 91 | // message Person { 92 | // string first_name = 1; 93 | // string last_name = 2; 94 | // } 95 | // 96 | // { 97 | // "@type": "type.googleapis.com/google.profile.Person", 98 | // "firstName": , 99 | // "lastName": 100 | // } 101 | // 102 | // If the embedded message type is well-known and has a custom JSON 103 | // representation, that representation will be embedded adding a field 104 | // `value` which holds the custom JSON in addition to the `@type` 105 | // field. Example (for message [google.protobuf.Duration][]): 106 | // 107 | // { 108 | // "@type": "type.googleapis.com/google.protobuf.Duration", 109 | // "value": "1.212s" 110 | // } 111 | // 112 | message Any { 113 | // A URL/resource name whose content describes the type of the 114 | // serialized protocol buffer message. 115 | // 116 | // For URLs which use the scheme `http`, `https`, or no scheme, the 117 | // following restrictions and interpretations apply: 118 | // 119 | // * If no scheme is provided, `https` is assumed. 120 | // * The last segment of the URL's path must represent the fully 121 | // qualified name of the type (as in `path/google.protobuf.Duration`). 122 | // The name should be in a canonical form (e.g., leading "." is 123 | // not accepted). 124 | // * An HTTP GET on the URL must yield a [google.protobuf.Type][] 125 | // value in binary format, or produce an error. 126 | // * Applications are allowed to cache lookup results based on the 127 | // URL, or have them precompiled into a binary to avoid any 128 | // lookup. Therefore, binary compatibility needs to be preserved 129 | // on changes to types. (Use versioned type names to manage 130 | // breaking changes.) 131 | // 132 | // Schemes other than `http`, `https` (or the empty scheme) might be 133 | // used with implementation specific semantics. 134 | // 135 | string type_url = 1; 136 | 137 | // Must be a valid serialized protocol buffer of the above specified type. 138 | bytes value = 2; 139 | } 140 | -------------------------------------------------------------------------------- /protos/google/protobuf/duration.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/duration"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "DurationProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Duration represents a signed, fixed-length span of time represented 44 | // as a count of seconds and fractions of seconds at nanosecond 45 | // resolution. It is independent of any calendar and concepts like "day" 46 | // or "month". It is related to Timestamp in that the difference between 47 | // two Timestamp values is a Duration and it can be added or subtracted 48 | // from a Timestamp. Range is approximately +-10,000 years. 49 | // 50 | // # Examples 51 | // 52 | // Example 1: Compute Duration from two Timestamps in pseudo code. 53 | // 54 | // Timestamp start = ...; 55 | // Timestamp end = ...; 56 | // Duration duration = ...; 57 | // 58 | // duration.seconds = end.seconds - start.seconds; 59 | // duration.nanos = end.nanos - start.nanos; 60 | // 61 | // if (duration.seconds < 0 && duration.nanos > 0) { 62 | // duration.seconds += 1; 63 | // duration.nanos -= 1000000000; 64 | // } else if (durations.seconds > 0 && duration.nanos < 0) { 65 | // duration.seconds -= 1; 66 | // duration.nanos += 1000000000; 67 | // } 68 | // 69 | // Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. 70 | // 71 | // Timestamp start = ...; 72 | // Duration duration = ...; 73 | // Timestamp end = ...; 74 | // 75 | // end.seconds = start.seconds + duration.seconds; 76 | // end.nanos = start.nanos + duration.nanos; 77 | // 78 | // if (end.nanos < 0) { 79 | // end.seconds -= 1; 80 | // end.nanos += 1000000000; 81 | // } else if (end.nanos >= 1000000000) { 82 | // end.seconds += 1; 83 | // end.nanos -= 1000000000; 84 | // } 85 | // 86 | // Example 3: Compute Duration from datetime.timedelta in Python. 87 | // 88 | // td = datetime.timedelta(days=3, minutes=10) 89 | // duration = Duration() 90 | // duration.FromTimedelta(td) 91 | // 92 | // # JSON Mapping 93 | // 94 | // In JSON format, the Duration type is encoded as a string rather than an 95 | // object, where the string ends in the suffix "s" (indicating seconds) and 96 | // is preceded by the number of seconds, with nanoseconds expressed as 97 | // fractional seconds. For example, 3 seconds with 0 nanoseconds should be 98 | // encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should 99 | // be expressed in JSON format as "3.000000001s", and 3 seconds and 1 100 | // microsecond should be expressed in JSON format as "3.000001s". 101 | // 102 | // 103 | message Duration { 104 | 105 | // Signed seconds of the span of time. Must be from -315,576,000,000 106 | // to +315,576,000,000 inclusive. Note: these bounds are computed from: 107 | // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years 108 | int64 seconds = 1; 109 | 110 | // Signed fractions of a second at nanosecond resolution of the span 111 | // of time. Durations less than one second are represented with a 0 112 | // `seconds` field and a positive or negative `nanos` field. For durations 113 | // of one second or more, a non-zero value for the `nanos` field must be 114 | // of the same sign as the `seconds` field. Must be from -999,999,999 115 | // to +999,999,999 inclusive. 116 | int32 nanos = 2; 117 | } 118 | -------------------------------------------------------------------------------- /protos/google/protobuf/empty.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option go_package = "github.com/golang/protobuf/ptypes/empty"; 37 | option java_package = "com.google.protobuf"; 38 | option java_outer_classname = "EmptyProto"; 39 | option java_multiple_files = true; 40 | option objc_class_prefix = "GPB"; 41 | option cc_enable_arenas = true; 42 | 43 | // A generic empty message that you can re-use to avoid defining duplicated 44 | // empty messages in your APIs. A typical example is to use it as the request 45 | // or the response type of an API method. For instance: 46 | // 47 | // service Foo { 48 | // rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); 49 | // } 50 | // 51 | // The JSON representation for `Empty` is empty JSON object `{}`. 52 | message Empty {} 53 | -------------------------------------------------------------------------------- /protos/google/protobuf/source_context.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option java_package = "com.google.protobuf"; 37 | option java_outer_classname = "SourceContextProto"; 38 | option java_multiple_files = true; 39 | option objc_class_prefix = "GPB"; 40 | option go_package = "google.golang.org/genproto/protobuf/source_context;source_context"; 41 | 42 | // `SourceContext` represents information about the source of a 43 | // protobuf element, like the file in which it is defined. 44 | message SourceContext { 45 | // The path-qualified name of the .proto file that contained the associated 46 | // protobuf element. For example: `"google/protobuf/source_context.proto"`. 47 | string file_name = 1; 48 | } 49 | -------------------------------------------------------------------------------- /protos/google/protobuf/struct.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/struct;structpb"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "StructProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | 44 | // `Struct` represents a structured data value, consisting of fields 45 | // which map to dynamically typed values. In some languages, `Struct` 46 | // might be supported by a native representation. For example, in 47 | // scripting languages like JS a struct is represented as an 48 | // object. The details of that representation are described together 49 | // with the proto support for the language. 50 | // 51 | // The JSON representation for `Struct` is JSON object. 52 | message Struct { 53 | // Unordered map of dynamically typed values. 54 | map fields = 1; 55 | } 56 | 57 | // `Value` represents a dynamically typed value which can be either 58 | // null, a number, a string, a boolean, a recursive struct value, or a 59 | // list of values. A producer of value is expected to set one of that 60 | // variants, absence of any variant indicates an error. 61 | // 62 | // The JSON representation for `Value` is JSON value. 63 | message Value { 64 | // The kind of value. 65 | oneof kind { 66 | // Represents a null value. 67 | NullValue null_value = 1; 68 | // Represents a double value. 69 | double number_value = 2; 70 | // Represents a string value. 71 | string string_value = 3; 72 | // Represents a boolean value. 73 | bool bool_value = 4; 74 | // Represents a structured value. 75 | Struct struct_value = 5; 76 | // Represents a repeated `Value`. 77 | ListValue list_value = 6; 78 | } 79 | } 80 | 81 | // `NullValue` is a singleton enumeration to represent the null value for the 82 | // `Value` type union. 83 | // 84 | // The JSON representation for `NullValue` is JSON `null`. 85 | enum NullValue { 86 | // Null value. 87 | NULL_VALUE = 0; 88 | } 89 | 90 | // `ListValue` is a wrapper around a repeated field of values. 91 | // 92 | // The JSON representation for `ListValue` is JSON array. 93 | message ListValue { 94 | // Repeated field of dynamically typed values. 95 | repeated Value values = 1; 96 | } 97 | -------------------------------------------------------------------------------- /protos/google/protobuf/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone 44 | // or calendar, represented as seconds and fractions of seconds at 45 | // nanosecond resolution in UTC Epoch time. It is encoded using the 46 | // Proleptic Gregorian Calendar which extends the Gregorian calendar 47 | // backwards to year one. It is encoded assuming all minutes are 60 48 | // seconds long, i.e. leap seconds are "smeared" so that no leap second 49 | // table is needed for interpretation. Range is from 50 | // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. 51 | // By restricting to that range, we ensure that we can convert to 52 | // and from RFC 3339 date strings. 53 | // See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt). 54 | // 55 | // # Examples 56 | // 57 | // Example 1: Compute Timestamp from POSIX `time()`. 58 | // 59 | // Timestamp timestamp; 60 | // timestamp.set_seconds(time(NULL)); 61 | // timestamp.set_nanos(0); 62 | // 63 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 64 | // 65 | // struct timeval tv; 66 | // gettimeofday(&tv, NULL); 67 | // 68 | // Timestamp timestamp; 69 | // timestamp.set_seconds(tv.tv_sec); 70 | // timestamp.set_nanos(tv.tv_usec * 1000); 71 | // 72 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 73 | // 74 | // FILETIME ft; 75 | // GetSystemTimeAsFileTime(&ft); 76 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 77 | // 78 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 79 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 80 | // Timestamp timestamp; 81 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 82 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 83 | // 84 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 85 | // 86 | // long millis = System.currentTimeMillis(); 87 | // 88 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 89 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 90 | // 91 | // 92 | // Example 5: Compute Timestamp from current time in Python. 93 | // 94 | // timestamp = Timestamp() 95 | // timestamp.GetCurrentTime() 96 | // 97 | // # JSON Mapping 98 | // 99 | // In JSON format, the Timestamp type is encoded as a string in the 100 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 101 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 102 | // where {year} is always expressed using four digits while {month}, {day}, 103 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 104 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 105 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 106 | // is required, though only UTC (as indicated by "Z") is presently supported. 107 | // 108 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 109 | // 01:30 UTC on January 15, 2017. 110 | // 111 | // In JavaScript, one can convert a Date object to this format using the 112 | // standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString] 113 | // method. In Python, a standard `datetime.datetime` object can be converted 114 | // to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) 115 | // with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one 116 | // can use the Joda Time's [`ISODateTimeFormat.dateTime()`]( 117 | // http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()) 118 | // to obtain a formatter capable of generating timestamps in this format. 119 | // 120 | // 121 | message Timestamp { 122 | 123 | // Represents seconds of UTC time since Unix epoch 124 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 125 | // 9999-12-31T23:59:59Z inclusive. 126 | int64 seconds = 1; 127 | 128 | // Non-negative fractions of a second at nanosecond resolution. Negative 129 | // second values with fractions must still have non-negative nanos values 130 | // that count forward in time. Must be from 0 to 999,999,999 131 | // inclusive. 132 | int32 nanos = 2; 133 | } 134 | -------------------------------------------------------------------------------- /protos/google/protobuf/type.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | import "google/protobuf/any.proto"; 36 | import "google/protobuf/source_context.proto"; 37 | 38 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 39 | option cc_enable_arenas = true; 40 | option java_package = "com.google.protobuf"; 41 | option java_outer_classname = "TypeProto"; 42 | option java_multiple_files = true; 43 | option objc_class_prefix = "GPB"; 44 | option go_package = "google.golang.org/genproto/protobuf/ptype;ptype"; 45 | 46 | // A protocol buffer message type. 47 | message Type { 48 | // The fully qualified message name. 49 | string name = 1; 50 | // The list of fields. 51 | repeated Field fields = 2; 52 | // The list of types appearing in `oneof` definitions in this type. 53 | repeated string oneofs = 3; 54 | // The protocol buffer options. 55 | repeated Option options = 4; 56 | // The source context. 57 | SourceContext source_context = 5; 58 | // The source syntax. 59 | Syntax syntax = 6; 60 | } 61 | 62 | // A single field of a message type. 63 | message Field { 64 | // Basic field types. 65 | enum Kind { 66 | // Field type unknown. 67 | TYPE_UNKNOWN = 0; 68 | // Field type double. 69 | TYPE_DOUBLE = 1; 70 | // Field type float. 71 | TYPE_FLOAT = 2; 72 | // Field type int64. 73 | TYPE_INT64 = 3; 74 | // Field type uint64. 75 | TYPE_UINT64 = 4; 76 | // Field type int32. 77 | TYPE_INT32 = 5; 78 | // Field type fixed64. 79 | TYPE_FIXED64 = 6; 80 | // Field type fixed32. 81 | TYPE_FIXED32 = 7; 82 | // Field type bool. 83 | TYPE_BOOL = 8; 84 | // Field type string. 85 | TYPE_STRING = 9; 86 | // Field type group. Proto2 syntax only, and deprecated. 87 | TYPE_GROUP = 10; 88 | // Field type message. 89 | TYPE_MESSAGE = 11; 90 | // Field type bytes. 91 | TYPE_BYTES = 12; 92 | // Field type uint32. 93 | TYPE_UINT32 = 13; 94 | // Field type enum. 95 | TYPE_ENUM = 14; 96 | // Field type sfixed32. 97 | TYPE_SFIXED32 = 15; 98 | // Field type sfixed64. 99 | TYPE_SFIXED64 = 16; 100 | // Field type sint32. 101 | TYPE_SINT32 = 17; 102 | // Field type sint64. 103 | TYPE_SINT64 = 18; 104 | }; 105 | 106 | // Whether a field is optional, required, or repeated. 107 | enum Cardinality { 108 | // For fields with unknown cardinality. 109 | CARDINALITY_UNKNOWN = 0; 110 | // For optional fields. 111 | CARDINALITY_OPTIONAL = 1; 112 | // For required fields. Proto2 syntax only. 113 | CARDINALITY_REQUIRED = 2; 114 | // For repeated fields. 115 | CARDINALITY_REPEATED = 3; 116 | }; 117 | 118 | // The field type. 119 | Kind kind = 1; 120 | // The field cardinality. 121 | Cardinality cardinality = 2; 122 | // The field number. 123 | int32 number = 3; 124 | // The field name. 125 | string name = 4; 126 | // The field type URL, without the scheme, for message or enumeration 127 | // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. 128 | string type_url = 6; 129 | // The index of the field type in `Type.oneofs`, for message or enumeration 130 | // types. The first type has index 1; zero means the type is not in the list. 131 | int32 oneof_index = 7; 132 | // Whether to use alternative packed wire representation. 133 | bool packed = 8; 134 | // The protocol buffer options. 135 | repeated Option options = 9; 136 | // The field JSON name. 137 | string json_name = 10; 138 | // The string value of the default value of this field. Proto2 syntax only. 139 | string default_value = 11; 140 | } 141 | 142 | // Enum type definition. 143 | message Enum { 144 | // Enum type name. 145 | string name = 1; 146 | // Enum value definitions. 147 | repeated EnumValue enumvalue = 2; 148 | // Protocol buffer options. 149 | repeated Option options = 3; 150 | // The source context. 151 | SourceContext source_context = 4; 152 | // The source syntax. 153 | Syntax syntax = 5; 154 | } 155 | 156 | // Enum value definition. 157 | message EnumValue { 158 | // Enum value name. 159 | string name = 1; 160 | // Enum value number. 161 | int32 number = 2; 162 | // Protocol buffer options. 163 | repeated Option options = 3; 164 | } 165 | 166 | // A protocol buffer option, which can be attached to a message, field, 167 | // enumeration, etc. 168 | message Option { 169 | // The option's name. For protobuf built-in options (options defined in 170 | // descriptor.proto), this is the short name. For example, `"map_entry"`. 171 | // For custom options, it should be the fully-qualified name. For example, 172 | // `"google.api.http"`. 173 | string name = 1; 174 | // The option's value packed in an Any message. If the value is a primitive, 175 | // the corresponding wrapper type defined in google/protobuf/wrappers.proto 176 | // should be used. If the value is an enum, it should be stored as an int32 177 | // value using the google.protobuf.Int32Value type. 178 | Any value = 2; 179 | } 180 | 181 | // The syntax in which a protocol buffer element is defined. 182 | enum Syntax { 183 | // Syntax `proto2`. 184 | SYNTAX_PROTO2 = 0; 185 | // Syntax `proto3`. 186 | SYNTAX_PROTO3 = 1; 187 | } 188 | -------------------------------------------------------------------------------- /protos/google/protobuf/util/json_format_proto3.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package proto3; 34 | 35 | option java_package = "com.google.protobuf.util"; 36 | option java_outer_classname = "JsonFormatProto3"; 37 | 38 | import "google/protobuf/duration.proto"; 39 | import "google/protobuf/timestamp.proto"; 40 | import "google/protobuf/wrappers.proto"; 41 | import "google/protobuf/struct.proto"; 42 | import "google/protobuf/any.proto"; 43 | import "google/protobuf/field_mask.proto"; 44 | import "google/protobuf/unittest.proto"; 45 | 46 | enum EnumType { 47 | FOO = 0; 48 | BAR = 1; 49 | } 50 | 51 | message MessageType { 52 | int32 value = 1; 53 | } 54 | 55 | message TestMessage { 56 | bool bool_value = 1; 57 | int32 int32_value = 2; 58 | int64 int64_value = 3; 59 | uint32 uint32_value = 4; 60 | uint64 uint64_value = 5; 61 | float float_value = 6; 62 | double double_value = 7; 63 | string string_value = 8; 64 | bytes bytes_value = 9; 65 | EnumType enum_value = 10; 66 | MessageType message_value = 11; 67 | 68 | repeated bool repeated_bool_value = 21; 69 | repeated int32 repeated_int32_value = 22; 70 | repeated int64 repeated_int64_value = 23; 71 | repeated uint32 repeated_uint32_value = 24; 72 | repeated uint64 repeated_uint64_value = 25; 73 | repeated float repeated_float_value = 26; 74 | repeated double repeated_double_value = 27; 75 | repeated string repeated_string_value = 28; 76 | repeated bytes repeated_bytes_value = 29; 77 | repeated EnumType repeated_enum_value = 30; 78 | repeated MessageType repeated_message_value = 31; 79 | } 80 | 81 | message TestOneof { 82 | // In JSON format oneof fields behave mostly the same as optional 83 | // fields except that: 84 | // 1. Oneof fields have field presence information and will be 85 | // printed if it's set no matter whether it's the default value. 86 | // 2. Multiple oneof fields in the same oneof cannot appear at the 87 | // same time in the input. 88 | oneof oneof_value { 89 | int32 oneof_int32_value = 1; 90 | string oneof_string_value = 2; 91 | bytes oneof_bytes_value = 3; 92 | EnumType oneof_enum_value = 4; 93 | MessageType oneof_message_value = 5; 94 | } 95 | } 96 | 97 | message TestMap { 98 | map bool_map = 1; 99 | map int32_map = 2; 100 | map int64_map = 3; 101 | map uint32_map = 4; 102 | map uint64_map = 5; 103 | map string_map = 6; 104 | } 105 | 106 | message TestNestedMap { 107 | map bool_map = 1; 108 | map int32_map = 2; 109 | map int64_map = 3; 110 | map uint32_map = 4; 111 | map uint64_map = 5; 112 | map string_map = 6; 113 | map map_map = 7; 114 | } 115 | 116 | message TestWrapper { 117 | google.protobuf.BoolValue bool_value = 1; 118 | google.protobuf.Int32Value int32_value = 2; 119 | google.protobuf.Int64Value int64_value = 3; 120 | google.protobuf.UInt32Value uint32_value = 4; 121 | google.protobuf.UInt64Value uint64_value = 5; 122 | google.protobuf.FloatValue float_value = 6; 123 | google.protobuf.DoubleValue double_value = 7; 124 | google.protobuf.StringValue string_value = 8; 125 | google.protobuf.BytesValue bytes_value = 9; 126 | 127 | repeated google.protobuf.BoolValue repeated_bool_value = 11; 128 | repeated google.protobuf.Int32Value repeated_int32_value = 12; 129 | repeated google.protobuf.Int64Value repeated_int64_value = 13; 130 | repeated google.protobuf.UInt32Value repeated_uint32_value = 14; 131 | repeated google.protobuf.UInt64Value repeated_uint64_value = 15; 132 | repeated google.protobuf.FloatValue repeated_float_value = 16; 133 | repeated google.protobuf.DoubleValue repeated_double_value = 17; 134 | repeated google.protobuf.StringValue repeated_string_value = 18; 135 | repeated google.protobuf.BytesValue repeated_bytes_value = 19; 136 | } 137 | 138 | message TestTimestamp { 139 | google.protobuf.Timestamp value = 1; 140 | repeated google.protobuf.Timestamp repeated_value = 2; 141 | } 142 | 143 | message TestDuration { 144 | google.protobuf.Duration value = 1; 145 | repeated google.protobuf.Duration repeated_value = 2; 146 | } 147 | 148 | message TestFieldMask { 149 | google.protobuf.FieldMask value = 1; 150 | } 151 | 152 | message TestStruct { 153 | google.protobuf.Struct value = 1; 154 | repeated google.protobuf.Struct repeated_value = 2; 155 | } 156 | 157 | message TestAny { 158 | google.protobuf.Any value = 1; 159 | repeated google.protobuf.Any repeated_value = 2; 160 | } 161 | 162 | message TestValue { 163 | google.protobuf.Value value = 1; 164 | repeated google.protobuf.Value repeated_value = 2; 165 | } 166 | 167 | message TestListValue { 168 | google.protobuf.ListValue value = 1; 169 | repeated google.protobuf.ListValue repeated_value = 2; 170 | } 171 | 172 | message TestBoolValue { 173 | bool bool_value = 1; 174 | map bool_map = 2; 175 | } 176 | 177 | message TestCustomJsonName { 178 | int32 value = 1 [json_name = "@value"]; 179 | } 180 | 181 | message TestExtensions { 182 | .protobuf_unittest.TestAllExtensions extensions = 1; 183 | } 184 | -------------------------------------------------------------------------------- /protos/google/protobuf/wrappers.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | // Wrappers for primitive (non-message) types. These types are useful 32 | // for embedding primitives in the `google.protobuf.Any` type and for places 33 | // where we need to distinguish between the absence of a primitive 34 | // typed field and its default value. 35 | 36 | syntax = "proto3"; 37 | 38 | package google.protobuf; 39 | 40 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 41 | option cc_enable_arenas = true; 42 | option go_package = "github.com/golang/protobuf/ptypes/wrappers"; 43 | option java_package = "com.google.protobuf"; 44 | option java_outer_classname = "WrappersProto"; 45 | option java_multiple_files = true; 46 | option objc_class_prefix = "GPB"; 47 | 48 | // Wrapper message for `double`. 49 | // 50 | // The JSON representation for `DoubleValue` is JSON number. 51 | message DoubleValue { 52 | // The double value. 53 | double value = 1; 54 | } 55 | 56 | // Wrapper message for `float`. 57 | // 58 | // The JSON representation for `FloatValue` is JSON number. 59 | message FloatValue { 60 | // The float value. 61 | float value = 1; 62 | } 63 | 64 | // Wrapper message for `int64`. 65 | // 66 | // The JSON representation for `Int64Value` is JSON string. 67 | message Int64Value { 68 | // The int64 value. 69 | int64 value = 1; 70 | } 71 | 72 | // Wrapper message for `uint64`. 73 | // 74 | // The JSON representation for `UInt64Value` is JSON string. 75 | message UInt64Value { 76 | // The uint64 value. 77 | uint64 value = 1; 78 | } 79 | 80 | // Wrapper message for `int32`. 81 | // 82 | // The JSON representation for `Int32Value` is JSON number. 83 | message Int32Value { 84 | // The int32 value. 85 | int32 value = 1; 86 | } 87 | 88 | // Wrapper message for `uint32`. 89 | // 90 | // The JSON representation for `UInt32Value` is JSON number. 91 | message UInt32Value { 92 | // The uint32 value. 93 | uint32 value = 1; 94 | } 95 | 96 | // Wrapper message for `bool`. 97 | // 98 | // The JSON representation for `BoolValue` is JSON `true` and `false`. 99 | message BoolValue { 100 | // The bool value. 101 | bool value = 1; 102 | } 103 | 104 | // Wrapper message for `string`. 105 | // 106 | // The JSON representation for `StringValue` is JSON string. 107 | message StringValue { 108 | // The string value. 109 | string value = 1; 110 | } 111 | 112 | // Wrapper message for `bytes`. 113 | // 114 | // The JSON representation for `BytesValue` is JSON string. 115 | message BytesValue { 116 | // The bytes value. 117 | bytes value = 1; 118 | } 119 | -------------------------------------------------------------------------------- /samples/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | rules: 3 | no-console: off 4 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | Google Cloud Platform logo 2 | 3 | # Google Cloud Pub/Sub: Node.js Samples 4 | 5 | [![Open in Cloud Shell][shell_img]][shell_link] 6 | 7 | [Cloud Pub/Sub](https://cloud.google.com/pubsub/docs) is a fully-managed real-time messaging service that allows you to send and receive messages between independent applications. 8 | 9 | ## Table of Contents 10 | 11 | * [Before you begin](#before-you-begin) 12 | * [Samples](#samples) 13 | * [Subscriptions](#subscriptions) 14 | * [Topics](#topics) 15 | 16 | ## Before you begin 17 | 18 | Before running the samples, make sure you've followed the steps in the 19 | [Before you begin section](../README.md#before-you-begin) of the client 20 | library's README. 21 | 22 | ## Samples 23 | 24 | ### Subscriptions 25 | 26 | View the [source code][subscriptions_0_code]. 27 | 28 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/subscriptions.js,samples/README.md) 29 | 30 | __Usage:__ `node subscriptions.js --help` 31 | 32 | ``` 33 | subscriptions.js 34 | 35 | Commands: 36 | subscriptions.js list [topicName] Lists all subscriptions in the current project, 37 | optionally filtering by a topic. 38 | subscriptions.js create Creates a new subscription. 39 | subscriptions.js create-flow Creates a new subscription with flow-control limits, 40 | which don't persist between subscriptions. 41 | subscriptions.js create-push Creates a new push subscription. 42 | subscriptions.js modify-config Modifies the configuration of an existing push 43 | subscription. 44 | subscriptions.js delete Deletes a subscription. 45 | subscriptions.js get Gets the metadata for a subscription. 46 | subscriptions.js listen-messages Listens to messages for a subscription. 47 | subscriptions.js listen-errors Listens to messages and errors for a subscription. 48 | subscriptions.js get-policy Gets the IAM policy for a subscription. 49 | subscriptions.js set-policy Sets the IAM policy for a subscription. 50 | subscriptions.js test-permissions Tests the permissions for a subscription. 51 | 52 | Options: 53 | --version Show version number [boolean] 54 | --help Show help [boolean] 55 | 56 | Examples: 57 | node subscriptions.js list 58 | node subscriptions.js list my-topic 59 | node subscriptions.js create my-topic worker-1 60 | node subscriptions.js create-flow my-topic worker-1 -m 5 61 | node subscriptions.js create-push my-topic worker-1 62 | node subscriptions.js modify-config my-topic worker-1 63 | node subscriptions.js get worker-1 64 | node subscriptions.js listen-messages my-subscription 65 | node subscriptions.js listen-errors my-subscription 66 | node subscriptions.js delete worker-1 67 | node subscriptions.js pull worker-1 68 | node subscriptions.js get-policy worker-1 69 | node subscriptions.js set-policy worker-1 70 | node subscriptions.js test-permissions worker-1 71 | 72 | For more information, see https://cloud.google.com/pubsub/docs 73 | ``` 74 | 75 | [subscriptions_0_docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/subscription 76 | [subscriptions_0_code]: subscriptions.js 77 | 78 | ### Topics 79 | 80 | View the [source code][topics_1_code]. 81 | 82 | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/topics.js,samples/README.md) 83 | 84 | __Usage:__ `node topics.js --help` 85 | 86 | ``` 87 | topics.js 88 | 89 | Commands: 90 | topics.js list Lists all topics in the current project. 91 | topics.js create Creates a new topic. 92 | topics.js delete Deletes a topic. 93 | topics.js publish Publishes a message to a topic. 94 | topics.js publish-batch Publishes messages to a topic using custom batching settings. 95 | topics.js publish-ordered Publishes an ordered message to a topic. 96 | topics.js get-policy Gets the IAM policy for a topic. 97 | topics.js set-policy Sets the IAM policy for a topic. 98 | topics.js test-permissions Tests the permissions for a topic. 99 | 100 | Options: 101 | --version Show version number [boolean] 102 | --help Show help [boolean] 103 | 104 | Examples: 105 | node topics.js list 106 | node topics.js create my-topic 107 | node topics.js delete my-topic 108 | node topics.js publish my-topic "Hello, world!" 109 | node topics.js publish my-topic '{"data":"Hello, world!"}' 110 | node topics.js publish-ordered my-topic "Hello, world!" 111 | node topics.js publish-batch my-topic "Hello, world!" -w 1000 112 | node topics.js get-policy greetings 113 | node topics.js set-policy greetings 114 | node topics.js test-permissions greetings 115 | 116 | For more information, see https://cloud.google.com/pubsub/docs 117 | ``` 118 | 119 | [topics_1_docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/topic 120 | [topics_1_code]: topics.js 121 | 122 | [shell_img]: http://gstatic.com/cloudssh/images/open-btn.png 123 | [shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-pubsub&page=editor&open_in_editor=samples/README.md 124 | -------------------------------------------------------------------------------- /samples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-docs-samples-pubsub", 3 | "version": "0.0.1", 4 | "private": true, 5 | "license": "Apache-2.0", 6 | "author": "Google Inc.", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/googleapis/nodejs-pubsub.git" 10 | }, 11 | "engines": { 12 | "node": ">=4.3.2" 13 | }, 14 | "scripts": { 15 | "ava": "ava -T 20s --verbose system-test/*.test.js", 16 | "cover": "nyc --reporter=lcov --cache ava -T 20s --verbose test/*.test.js system-test/*.test.js && nyc report", 17 | "test": "repo-tools test run --cmd npm -- run cover" 18 | }, 19 | "dependencies": { 20 | "@google-cloud/pubsub": "0.16.2", 21 | "yargs": "10.0.3" 22 | }, 23 | "devDependencies": { 24 | "@google-cloud/nodejs-repo-tools": "2.0.11", 25 | "ava": "^0.22.0", 26 | "nyc": "^11.3.0", 27 | "proxyquire": "1.8.0", 28 | "sinon": "4.0.1", 29 | "uuid": "^3.1.0" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /samples/quickstart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017, Google, Inc. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 'use strict'; 17 | 18 | // [START pubsub_quickstart] 19 | // Imports the Google Cloud client library 20 | const PubSub = require('@google-cloud/pubsub'); 21 | 22 | // Your Google Cloud Platform project ID 23 | const projectId = 'YOUR_PROJECT_ID'; 24 | 25 | // Instantiates a client 26 | const pubsubClient = new PubSub({ 27 | projectId: projectId, 28 | }); 29 | 30 | // The name for the new topic 31 | const topicName = 'my-new-topic'; 32 | 33 | // Creates the new topic 34 | pubsubClient 35 | .createTopic(topicName) 36 | .then(results => { 37 | const topic = results[0]; 38 | console.log(`Topic ${topic.name} created.`); 39 | }) 40 | .catch(err => { 41 | console.error('ERROR:', err); 42 | }); 43 | // [END pubsub_quickstart] 44 | -------------------------------------------------------------------------------- /samples/system-test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | rules: 3 | node/no-unpublished-require: off 4 | node/no-unsupported-features: off 5 | no-empty: off 6 | -------------------------------------------------------------------------------- /samples/system-test/quickstart.test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017, Google, Inc. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | 'use strict'; 17 | 18 | const proxyquire = require(`proxyquire`).noPreserveCache(); 19 | const pubsub = proxyquire(`@google-cloud/pubsub`, {})(); 20 | const sinon = require(`sinon`); 21 | const test = require(`ava`); 22 | const tools = require(`@google-cloud/nodejs-repo-tools`); 23 | const uuid = require(`uuid`); 24 | 25 | const topicName = `nodejs-docs-samples-test-${uuid.v4()}`; 26 | const projectId = process.env.GCLOUD_PROJECT; 27 | const fullTopicName = `projects/${projectId}/topics/${topicName}`; 28 | 29 | test.before(tools.stubConsole); 30 | test.after.always(() => { 31 | tools.restoreConsole(); 32 | return pubsub 33 | .topic(topicName) 34 | .delete() 35 | .catch(() => {}); 36 | }); 37 | 38 | test.cb(`should create a topic`, t => { 39 | const expectedTopicName = `my-new-topic`; 40 | const pubsubMock = { 41 | createTopic: _topicName => { 42 | t.is(_topicName, expectedTopicName); 43 | 44 | return pubsub.createTopic(topicName).then(([topic]) => { 45 | t.is(topic.name, fullTopicName); 46 | 47 | setTimeout(() => { 48 | try { 49 | t.is(console.log.callCount, 1); 50 | t.deepEqual(console.log.getCall(0).args, [ 51 | `Topic ${topic.name} created.`, 52 | ]); 53 | t.end(); 54 | } catch (err) { 55 | t.end(err); 56 | } 57 | }, 200); 58 | 59 | return [topic]; 60 | }); 61 | }, 62 | }; 63 | 64 | proxyquire(`../quickstart`, { 65 | '@google-cloud/pubsub': sinon.stub().returns(pubsubMock), 66 | }); 67 | }); 68 | -------------------------------------------------------------------------------- /src/histogram.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | var MIN_VALUE = 10000; 20 | var MAX_VALUE = 600000; 21 | 22 | /*! 23 | * The Histogram class is used to capture the lifespan of messages within the 24 | * the client. These durations are then used to calculate the 99th percentile 25 | * of ack deadlines for future messages. 26 | * 27 | * @private 28 | * @class 29 | */ 30 | function Histogram() { 31 | this.data = new Map(); 32 | this.length = 0; 33 | } 34 | 35 | /*! 36 | * Adds a value to the histogram. 37 | * 38 | * @private 39 | * @param {numnber} value - The value in milliseconds. 40 | */ 41 | Histogram.prototype.add = function(value) { 42 | value = Math.max(value, MIN_VALUE); 43 | value = Math.min(value, MAX_VALUE); 44 | value = Math.ceil(value / 1000) * 1000; 45 | 46 | if (!this.data.has(value)) { 47 | this.data.set(value, 0); 48 | } 49 | 50 | var count = this.data.get(value); 51 | this.data.set(value, count + 1); 52 | this.length += 1; 53 | }; 54 | 55 | /*! 56 | * Retrieves the nth percentile of recorded values. 57 | * 58 | * @private 59 | * @param {number} percent The requested percentage. 60 | * @return {number} 61 | */ 62 | Histogram.prototype.percentile = function(percent) { 63 | percent = Math.min(percent, 100); 64 | 65 | var target = this.length - this.length * (percent / 100); 66 | var keys = Array.from(this.data.keys()); 67 | var key; 68 | 69 | for (var i = keys.length - 1; i > -1; i--) { 70 | key = keys[i]; 71 | target -= this.data.get(key); 72 | 73 | if (target <= 0) { 74 | return key; 75 | } 76 | } 77 | 78 | return MIN_VALUE; 79 | }; 80 | 81 | module.exports = Histogram; 82 | -------------------------------------------------------------------------------- /src/snapshot.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | var common = require('@google-cloud/common'); 20 | var is = require('is'); 21 | 22 | /** 23 | * A Snapshot object will give you access to your Cloud Pub/Sub snapshot. 24 | * 25 | * Snapshots are sometimes retrieved when using various methods: 26 | * 27 | * - {@link PubSub#getSnapshots} 28 | * - {@link PubSub#getSnapshotsStream} 29 | * - {@link PubSub#snapshot} 30 | * 31 | * Snapshots may be created with: 32 | * 33 | * - {@link Subscription#createSnapshot} 34 | * 35 | * You can use snapshots to seek a subscription to a specific point in time. 36 | * 37 | * - {@link Subscription#seek} 38 | * 39 | * @class 40 | * 41 | * @example 42 | * //- 43 | * // From {@link PubSub#getSnapshots}: 44 | * //- 45 | * pubsub.getSnapshots(function(err, snapshots) { 46 | * // `snapshots` is an array of Snapshot objects. 47 | * }); 48 | * 49 | * //- 50 | * // From {@link PubSub#getSnapshotsStream}: 51 | * //- 52 | * pubsub.getSnapshotsStream() 53 | * .on('error', console.error) 54 | * .on('data', function(snapshot) { 55 | * // `snapshot` is a Snapshot object. 56 | * }); 57 | * 58 | * //- 59 | * // From {@link PubSub#snapshot}: 60 | * //- 61 | * var snapshot = pubsub.snapshot('my-snapshot'); 62 | * // snapshot is a Snapshot object. 63 | * 64 | * //- 65 | * // Create a snapshot with {module:pubsub/subscription#createSnapshot}: 66 | * //- 67 | * var subscription = pubsub.subscription('my-subscription'); 68 | * 69 | * subscription.createSnapshot('my-snapshot', function(err, snapshot) { 70 | * if (!err) { 71 | * // `snapshot` is a Snapshot object. 72 | * } 73 | * }); 74 | * 75 | * //- 76 | * // Seek to your snapshot: 77 | * //- 78 | * var subscription = pubsub.subscription('my-subscription'); 79 | * 80 | * subscription.seek('my-snapshot', function(err) { 81 | * if (err) { 82 | * // Error handling omitted. 83 | * } 84 | * }); 85 | */ 86 | function Snapshot(parent, name) { 87 | if (parent.Promise) { 88 | this.Promise = parent.Promise; 89 | } 90 | 91 | this.parent = parent; 92 | this.name = Snapshot.formatName_(parent.projectId, name); 93 | 94 | if (is.fn(parent.createSnapshot)) { 95 | /** 96 | * Create a snapshot with the given name. 97 | * 98 | * **This is only available if you accessed this object through 99 | * {@link Subscription#snapshot}.** 100 | * 101 | * @method Snapshot#create 102 | * @param {string} name Name of the snapshot. 103 | * @param {function} [callback] The callback function. 104 | * @param {?error} callback.err An error from the API call, may be null. 105 | * @param {Snapshot} callback.snapshot The newly created 106 | * snapshot. 107 | * @param {object} callback.apiResponse The full API response from the 108 | * service. 109 | * 110 | * @example 111 | * var subscription = pubsub.subscription('my-subscription'); 112 | * var snapshot = subscription.snapshot('my-snapshot'); 113 | * 114 | * var callback = function(err, snapshot, apiResponse) { 115 | * if (!err) { 116 | * // The snapshot was created successfully. 117 | * } 118 | * }; 119 | * 120 | * snapshot.create('my-snapshot', callback); 121 | * 122 | * //- 123 | * // If the callback is omitted, we'll return a Promise. 124 | * //- 125 | * snapshot.create('my-snapshot').then(function(data) { 126 | * var snapshot = data[0]; 127 | * var apiResponse = data[1]; 128 | * }); 129 | */ 130 | this.create = parent.createSnapshot.bind(parent, name); 131 | } 132 | 133 | if (is.fn(parent.seek)) { 134 | /** 135 | * Seeks an existing subscription to the snapshot. 136 | * 137 | * **This is only available if you accessed this object through 138 | * {@link Subscription#snapshot}.** 139 | * 140 | * @method Snapshot#seek 141 | * @param {function} callback The callback function. 142 | * @param {?error} callback.err An error from the API call, may be null. 143 | * @param {object} callback.apiResponse The full API response from the 144 | * service. 145 | * 146 | * @example 147 | * var subscription = pubsub.subscription('my-subscription'); 148 | * var snapshot = subscription.snapshot('my-snapshot'); 149 | * 150 | * snapshot.seek(function(err, apiResponse) {}); 151 | * 152 | * //- 153 | * // If the callback is omitted, we'll return a Promise. 154 | * //- 155 | * snapshot.seek().then(function(data) { 156 | * var apiResponse = data[0]; 157 | * }); 158 | */ 159 | this.seek = parent.seek.bind(parent, name); 160 | } 161 | } 162 | 163 | /*@ 164 | * Format the name of a snapshot. A snapshot's full name is in the format of 165 | * projects/{projectId}/snapshots/{snapshotName} 166 | * 167 | * @private 168 | */ 169 | Snapshot.formatName_ = function(projectId, name) { 170 | return 'projects/' + projectId + '/snapshots/' + name.split('/').pop(); 171 | }; 172 | 173 | /** 174 | * Delete the snapshot. 175 | * 176 | * @param {function} [callback] The callback function. 177 | * @param {?error} callback.err An error returned while making this 178 | * request. 179 | * @param {object} callback.apiResponse The full API response from the 180 | * service. 181 | * 182 | * @example 183 | * snapshot.delete(function(err, apiResponse) {}); 184 | * 185 | * //- 186 | * // If the callback is omitted, we'll return a Promise. 187 | * //- 188 | * snapshot.delete().then(function(data) { 189 | * var apiResponse = data[0]; 190 | * }); 191 | */ 192 | Snapshot.prototype.delete = function(callback) { 193 | var reqOpts = { 194 | snapshot: this.name, 195 | }; 196 | 197 | callback = callback || common.util.noop; 198 | 199 | this.parent.request( 200 | { 201 | client: 'SubscriberClient', 202 | method: 'deleteSnapshot', 203 | reqOpts: reqOpts, 204 | }, 205 | callback 206 | ); 207 | }; 208 | 209 | /*! Developer Documentation 210 | * 211 | * All async methods (except for streams) will return a Promise in the event 212 | * that a callback is omitted. 213 | */ 214 | common.util.promisifyAll(Snapshot); 215 | 216 | module.exports = Snapshot; 217 | -------------------------------------------------------------------------------- /src/v1/index.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const PublisherClient = require('./publisher_client'); 18 | const SubscriberClient = require('./subscriber_client'); 19 | 20 | module.exports.PublisherClient = PublisherClient; 21 | module.exports.SubscriberClient = SubscriberClient; 22 | -------------------------------------------------------------------------------- /src/v1/publisher_client_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "interfaces": { 3 | "google.pubsub.v1.Publisher": { 4 | "retry_codes": { 5 | "idempotent": [ 6 | "DEADLINE_EXCEEDED", 7 | "UNAVAILABLE" 8 | ], 9 | "one_plus_delivery": [ 10 | "ABORTED", 11 | "CANCELLED", 12 | "DEADLINE_EXCEEDED", 13 | "INTERNAL", 14 | "RESOURCE_EXHAUSTED", 15 | "UNAVAILABLE", 16 | "UNKNOWN" 17 | ], 18 | "non_idempotent": [] 19 | }, 20 | "retry_params": { 21 | "default": { 22 | "initial_retry_delay_millis": 100, 23 | "retry_delay_multiplier": 1.3, 24 | "max_retry_delay_millis": 60000, 25 | "initial_rpc_timeout_millis": 60000, 26 | "rpc_timeout_multiplier": 1.0, 27 | "max_rpc_timeout_millis": 60000, 28 | "total_timeout_millis": 600000 29 | }, 30 | "messaging": { 31 | "initial_retry_delay_millis": 100, 32 | "retry_delay_multiplier": 1.3, 33 | "max_retry_delay_millis": 60000, 34 | "initial_rpc_timeout_millis": 12000, 35 | "rpc_timeout_multiplier": 1.0, 36 | "max_rpc_timeout_millis": 30000, 37 | "total_timeout_millis": 600000 38 | } 39 | }, 40 | "methods": { 41 | "CreateTopic": { 42 | "timeout_millis": 60000, 43 | "retry_codes_name": "idempotent", 44 | "retry_params_name": "default" 45 | }, 46 | "UpdateTopic": { 47 | "timeout_millis": 60000, 48 | "retry_codes_name": "idempotent", 49 | "retry_params_name": "default" 50 | }, 51 | "Publish": { 52 | "timeout_millis": 60000, 53 | "retry_codes_name": "one_plus_delivery", 54 | "retry_params_name": "messaging", 55 | "bundling": { 56 | "element_count_threshold": 10, 57 | "element_count_limit": 1000, 58 | "request_byte_threshold": 1024, 59 | "request_byte_limit": 10485760, 60 | "delay_threshold_millis": 10 61 | } 62 | }, 63 | "GetTopic": { 64 | "timeout_millis": 60000, 65 | "retry_codes_name": "idempotent", 66 | "retry_params_name": "default" 67 | }, 68 | "ListTopics": { 69 | "timeout_millis": 60000, 70 | "retry_codes_name": "idempotent", 71 | "retry_params_name": "default" 72 | }, 73 | "ListTopicSubscriptions": { 74 | "timeout_millis": 60000, 75 | "retry_codes_name": "idempotent", 76 | "retry_params_name": "default" 77 | }, 78 | "DeleteTopic": { 79 | "timeout_millis": 60000, 80 | "retry_codes_name": "idempotent", 81 | "retry_params_name": "default" 82 | }, 83 | "SetIamPolicy": { 84 | "timeout_millis": 60000, 85 | "retry_codes_name": "non_idempotent", 86 | "retry_params_name": "default" 87 | }, 88 | "GetIamPolicy": { 89 | "timeout_millis": 60000, 90 | "retry_codes_name": "idempotent", 91 | "retry_params_name": "default" 92 | }, 93 | "TestIamPermissions": { 94 | "timeout_millis": 60000, 95 | "retry_codes_name": "non_idempotent", 96 | "retry_params_name": "default" 97 | } 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/v1/subscriber_client_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "interfaces": { 3 | "google.pubsub.v1.Subscriber": { 4 | "retry_codes": { 5 | "idempotent": [ 6 | "DEADLINE_EXCEEDED", 7 | "UNAVAILABLE" 8 | ], 9 | "non_idempotent": [], 10 | "pull": [ 11 | "CANCELLED", 12 | "DEADLINE_EXCEEDED", 13 | "INTERNAL", 14 | "RESOURCE_EXHAUSTED", 15 | "UNAVAILABLE" 16 | ] 17 | }, 18 | "retry_params": { 19 | "default": { 20 | "initial_retry_delay_millis": 100, 21 | "retry_delay_multiplier": 1.3, 22 | "max_retry_delay_millis": 60000, 23 | "initial_rpc_timeout_millis": 60000, 24 | "rpc_timeout_multiplier": 1.0, 25 | "max_rpc_timeout_millis": 60000, 26 | "total_timeout_millis": 600000 27 | }, 28 | "messaging": { 29 | "initial_retry_delay_millis": 100, 30 | "retry_delay_multiplier": 1.3, 31 | "max_retry_delay_millis": 60000, 32 | "initial_rpc_timeout_millis": 12000, 33 | "rpc_timeout_multiplier": 1.0, 34 | "max_rpc_timeout_millis": 12000, 35 | "total_timeout_millis": 600000 36 | }, 37 | "streaming_messaging": { 38 | "initial_retry_delay_millis": 100, 39 | "retry_delay_multiplier": 1.3, 40 | "max_retry_delay_millis": 60000, 41 | "initial_rpc_timeout_millis": 600000, 42 | "rpc_timeout_multiplier": 1.0, 43 | "max_rpc_timeout_millis": 600000, 44 | "total_timeout_millis": 600000 45 | } 46 | }, 47 | "methods": { 48 | "CreateSubscription": { 49 | "timeout_millis": 60000, 50 | "retry_codes_name": "idempotent", 51 | "retry_params_name": "default" 52 | }, 53 | "GetSubscription": { 54 | "timeout_millis": 60000, 55 | "retry_codes_name": "idempotent", 56 | "retry_params_name": "default" 57 | }, 58 | "UpdateSubscription": { 59 | "timeout_millis": 60000, 60 | "retry_codes_name": "idempotent", 61 | "retry_params_name": "default" 62 | }, 63 | "ListSubscriptions": { 64 | "timeout_millis": 60000, 65 | "retry_codes_name": "idempotent", 66 | "retry_params_name": "default" 67 | }, 68 | "DeleteSubscription": { 69 | "timeout_millis": 60000, 70 | "retry_codes_name": "idempotent", 71 | "retry_params_name": "default" 72 | }, 73 | "ModifyAckDeadline": { 74 | "timeout_millis": 60000, 75 | "retry_codes_name": "non_idempotent", 76 | "retry_params_name": "default" 77 | }, 78 | "Acknowledge": { 79 | "timeout_millis": 60000, 80 | "retry_codes_name": "non_idempotent", 81 | "retry_params_name": "messaging" 82 | }, 83 | "Pull": { 84 | "timeout_millis": 60000, 85 | "retry_codes_name": "pull", 86 | "retry_params_name": "messaging" 87 | }, 88 | "StreamingPull": { 89 | "timeout_millis": 60000, 90 | "retry_codes_name": "pull", 91 | "retry_params_name": "streaming_messaging" 92 | }, 93 | "ModifyPushConfig": { 94 | "timeout_millis": 60000, 95 | "retry_codes_name": "non_idempotent", 96 | "retry_params_name": "default" 97 | }, 98 | "ListSnapshots": { 99 | "timeout_millis": 60000, 100 | "retry_codes_name": "idempotent", 101 | "retry_params_name": "default" 102 | }, 103 | "CreateSnapshot": { 104 | "timeout_millis": 60000, 105 | "retry_codes_name": "idempotent", 106 | "retry_params_name": "default" 107 | }, 108 | "UpdateSnapshot": { 109 | "timeout_millis": 60000, 110 | "retry_codes_name": "idempotent", 111 | "retry_params_name": "default" 112 | }, 113 | "DeleteSnapshot": { 114 | "timeout_millis": 60000, 115 | "retry_codes_name": "idempotent", 116 | "retry_params_name": "default" 117 | }, 118 | "Seek": { 119 | "timeout_millis": 60000, 120 | "retry_codes_name": "non_idempotent", 121 | "retry_params_name": "default" 122 | }, 123 | "SetIamPolicy": { 124 | "timeout_millis": 60000, 125 | "retry_codes_name": "non_idempotent", 126 | "retry_params_name": "default" 127 | }, 128 | "GetIamPolicy": { 129 | "timeout_millis": 60000, 130 | "retry_codes_name": "idempotent", 131 | "retry_params_name": "default" 132 | }, 133 | "TestIamPermissions": { 134 | "timeout_millis": 60000, 135 | "retry_codes_name": "non_idempotent", 136 | "retry_params_name": "default" 137 | } 138 | } 139 | } 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /system-test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | mocha: true 4 | rules: 5 | node/no-unpublished-require: off 6 | no-console: off 7 | -------------------------------------------------------------------------------- /test/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | env: 3 | mocha: true 4 | rules: 5 | node/no-unpublished-require: off 6 | -------------------------------------------------------------------------------- /test/histogram.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | var assert = require('assert'); 20 | 21 | var Histogram = require('../src/histogram.js'); 22 | 23 | describe('Histogram', function() { 24 | var histogram; 25 | 26 | var MIN_VALUE = 10000; 27 | var MAX_VALUE = 600000; 28 | 29 | beforeEach(function() { 30 | histogram = new Histogram(); 31 | }); 32 | 33 | describe('initialization', function() { 34 | it('should create a data map', function() { 35 | assert(histogram.data instanceof Map); 36 | }); 37 | 38 | it('should set the initial length to 0', function() { 39 | assert.strictEqual(histogram.length, 0); 40 | }); 41 | }); 42 | 43 | describe('add', function() { 44 | it('should increment a value', function() { 45 | histogram.data.set(MIN_VALUE, 1); 46 | histogram.add(MIN_VALUE); 47 | 48 | assert.strictEqual(histogram.data.get(MIN_VALUE), 2); 49 | }); 50 | 51 | it('should initialize a value if absent', function() { 52 | histogram.add(MIN_VALUE); 53 | 54 | assert.strictEqual(histogram.data.get(MIN_VALUE), 1); 55 | }); 56 | 57 | it('should adjust the length for each item added', function() { 58 | histogram.add(MIN_VALUE); 59 | histogram.add(MIN_VALUE); 60 | histogram.add(MIN_VALUE * 2); 61 | 62 | assert.strictEqual(histogram.length, 3); 63 | }); 64 | 65 | it('should cap the value', function() { 66 | var outOfBounds = MAX_VALUE + MIN_VALUE; 67 | 68 | histogram.add(outOfBounds); 69 | 70 | assert.strictEqual(histogram.data.get(outOfBounds), undefined); 71 | assert.strictEqual(histogram.data.get(MAX_VALUE), 1); 72 | }); 73 | 74 | it('should apply a minimum', function() { 75 | var outOfBounds = MIN_VALUE - 1000; 76 | 77 | histogram.add(outOfBounds); 78 | 79 | assert.strictEqual(histogram.data.get(outOfBounds), undefined); 80 | assert.strictEqual(histogram.data.get(MIN_VALUE), 1); 81 | }); 82 | 83 | it('should use seconds level precision', function() { 84 | var ms = 303823; 85 | var expected = 304000; 86 | 87 | histogram.add(ms); 88 | 89 | assert.strictEqual(histogram.data.get(ms), undefined); 90 | assert.strictEqual(histogram.data.get(expected), 1); 91 | }); 92 | }); 93 | 94 | describe('percentile', function() { 95 | function range(a, b) { 96 | var result = []; 97 | 98 | for (; a < b; a++) { 99 | result.push(a); 100 | } 101 | 102 | return result; 103 | } 104 | 105 | it('should return the nth percentile', function() { 106 | range(100, 201).forEach(function(value) { 107 | histogram.add(value * 1000); 108 | }); 109 | 110 | assert.strictEqual(histogram.percentile(100), 200000); 111 | assert.strictEqual(histogram.percentile(101), 200000); 112 | assert.strictEqual(histogram.percentile(99), 199000); 113 | assert.strictEqual(histogram.percentile(1), 101000); 114 | }); 115 | 116 | it('should return the min value if unable to determine', function() { 117 | assert.strictEqual(histogram.percentile(99), MIN_VALUE); 118 | }); 119 | }); 120 | }); 121 | -------------------------------------------------------------------------------- /test/iam.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | var assert = require('assert'); 20 | var extend = require('extend'); 21 | var proxyquire = require('proxyquire'); 22 | var util = require('@google-cloud/common').util; 23 | 24 | var promisified = false; 25 | var fakeUtil = extend({}, util, { 26 | promisifyAll: function(Class) { 27 | if (Class.name === 'IAM') { 28 | promisified = true; 29 | } 30 | }, 31 | }); 32 | 33 | describe('IAM', function() { 34 | var IAM; 35 | var iam; 36 | 37 | var PUBSUB = { 38 | options: {}, 39 | Promise: {}, 40 | request: util.noop, 41 | }; 42 | var ID = 'id'; 43 | 44 | before(function() { 45 | IAM = proxyquire('../src/iam.js', { 46 | '@google-cloud/common': { 47 | util: fakeUtil, 48 | }, 49 | }); 50 | }); 51 | 52 | beforeEach(function() { 53 | iam = new IAM(PUBSUB, ID); 54 | }); 55 | 56 | describe('initialization', function() { 57 | it('should localize pubsub.Promise', function() { 58 | assert.strictEqual(iam.Promise, PUBSUB.Promise); 59 | }); 60 | 61 | it('should localize pubsub', function() { 62 | assert.strictEqual(iam.pubsub, PUBSUB); 63 | }); 64 | 65 | it('should localize pubsub#request', function() { 66 | var fakeRequest = function() {}; 67 | var fakePubsub = { 68 | request: { 69 | bind: function(context) { 70 | assert.strictEqual(context, fakePubsub); 71 | return fakeRequest; 72 | }, 73 | }, 74 | }; 75 | var iam = new IAM(fakePubsub, ID); 76 | 77 | assert.strictEqual(iam.request, fakeRequest); 78 | }); 79 | 80 | it('should localize the ID', function() { 81 | assert.strictEqual(iam.id, ID); 82 | }); 83 | 84 | it('should promisify all the things', function() { 85 | assert(promisified); 86 | }); 87 | }); 88 | 89 | describe('getPolicy', function() { 90 | it('should make the correct API request', function(done) { 91 | iam.request = function(config, callback) { 92 | assert.strictEqual(config.client, 'SubscriberClient'); 93 | assert.strictEqual(config.method, 'getIamPolicy'); 94 | assert.strictEqual(config.reqOpts.resource, iam.id); 95 | 96 | callback(); // done() 97 | }; 98 | 99 | iam.getPolicy(done); 100 | }); 101 | 102 | it('should accept gax options', function(done) { 103 | var gaxOpts = {}; 104 | 105 | iam.request = function(config) { 106 | assert.strictEqual(config.gaxOpts, gaxOpts); 107 | done(); 108 | }; 109 | 110 | iam.getPolicy(gaxOpts, assert.ifError); 111 | }); 112 | }); 113 | 114 | describe('setPolicy', function() { 115 | var policy = {etag: 'ACAB'}; 116 | 117 | it('should throw an error if a policy is not supplied', function() { 118 | assert.throws(function() { 119 | iam.setPolicy(util.noop); 120 | }, /A policy object is required\./); 121 | }); 122 | 123 | it('should make the correct API request', function(done) { 124 | iam.request = function(config, callback) { 125 | assert.strictEqual(config.client, 'SubscriberClient'); 126 | assert.strictEqual(config.method, 'setIamPolicy'); 127 | assert.strictEqual(config.reqOpts.resource, iam.id); 128 | assert.strictEqual(config.reqOpts.policy, policy); 129 | 130 | callback(); // done() 131 | }; 132 | 133 | iam.setPolicy(policy, done); 134 | }); 135 | 136 | it('should accept gax options', function(done) { 137 | var gaxOpts = {}; 138 | 139 | iam.request = function(config) { 140 | assert.strictEqual(config.gaxOpts, gaxOpts); 141 | done(); 142 | }; 143 | 144 | iam.setPolicy(policy, gaxOpts, assert.ifError); 145 | }); 146 | }); 147 | 148 | describe('testPermissions', function() { 149 | it('should throw an error if permissions are missing', function() { 150 | assert.throws(function() { 151 | iam.testPermissions(util.noop); 152 | }, /Permissions are required\./); 153 | }); 154 | 155 | it('should make the correct API request', function(done) { 156 | var permissions = 'storage.bucket.list'; 157 | 158 | iam.request = function(config) { 159 | assert.strictEqual(config.client, 'SubscriberClient'); 160 | assert.strictEqual(config.method, 'testIamPermissions'); 161 | assert.strictEqual(config.reqOpts.resource, iam.id); 162 | assert.deepEqual(config.reqOpts.permissions, [permissions]); 163 | 164 | done(); 165 | }; 166 | 167 | iam.testPermissions(permissions, assert.ifError); 168 | }); 169 | 170 | it('should accept gax options', function(done) { 171 | var permissions = 'storage.bucket.list'; 172 | var gaxOpts = {}; 173 | 174 | iam.request = function(config) { 175 | assert.strictEqual(config.gaxOpts, gaxOpts); 176 | done(); 177 | }; 178 | 179 | iam.testPermissions(permissions, gaxOpts, assert.ifError); 180 | }); 181 | 182 | it('should send an error back if the request fails', function(done) { 183 | var permissions = ['storage.bucket.list']; 184 | var error = new Error('Error.'); 185 | var apiResponse = {}; 186 | 187 | iam.request = function(config, callback) { 188 | callback(error, apiResponse); 189 | }; 190 | 191 | iam.testPermissions(permissions, function(err, permissions, apiResp) { 192 | assert.strictEqual(err, error); 193 | assert.strictEqual(permissions, null); 194 | assert.strictEqual(apiResp, apiResponse); 195 | done(); 196 | }); 197 | }); 198 | 199 | it('should pass back a hash of permissions the user has', function(done) { 200 | var permissions = ['storage.bucket.list', 'storage.bucket.consume']; 201 | var apiResponse = { 202 | permissions: ['storage.bucket.consume'], 203 | }; 204 | 205 | iam.request = function(config, callback) { 206 | callback(null, apiResponse); 207 | }; 208 | 209 | iam.testPermissions(permissions, function(err, permissions, apiResp) { 210 | assert.ifError(err); 211 | assert.deepEqual(permissions, { 212 | 'storage.bucket.list': false, 213 | 'storage.bucket.consume': true, 214 | }); 215 | assert.strictEqual(apiResp, apiResponse); 216 | 217 | done(); 218 | }); 219 | }); 220 | }); 221 | }); 222 | -------------------------------------------------------------------------------- /test/snapshot.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2014 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 'use strict'; 18 | 19 | var assert = require('assert'); 20 | var common = require('@google-cloud/common'); 21 | var extend = require('extend'); 22 | var proxyquire = require('proxyquire'); 23 | 24 | var promisified = false; 25 | var fakeUtil = extend({}, common.util, { 26 | promisifyAll: function(Class) { 27 | if (Class.name === 'Snapshot') { 28 | promisified = true; 29 | } 30 | }, 31 | }); 32 | 33 | describe('Snapshot', function() { 34 | var Snapshot; 35 | var snapshot; 36 | 37 | var SNAPSHOT_NAME = 'a'; 38 | var PROJECT_ID = 'grape-spaceship-123'; 39 | 40 | var PUBSUB = { 41 | projectId: PROJECT_ID, 42 | }; 43 | 44 | var SUBSCRIPTION = { 45 | Promise: {}, 46 | projectId: PROJECT_ID, 47 | pubsub: PUBSUB, 48 | api: {}, 49 | createSnapshot: function() {}, 50 | seek: function() {}, 51 | }; 52 | 53 | before(function() { 54 | Snapshot = proxyquire('../src/snapshot.js', { 55 | '@google-cloud/common': { 56 | util: fakeUtil, 57 | }, 58 | }); 59 | }); 60 | 61 | beforeEach(function() { 62 | fakeUtil.noop = function() {}; 63 | snapshot = new Snapshot(SUBSCRIPTION, SNAPSHOT_NAME); 64 | }); 65 | 66 | describe('initialization', function() { 67 | var FULL_SNAPSHOT_NAME = 'a/b/c/d'; 68 | var formatName_; 69 | 70 | before(function() { 71 | formatName_ = Snapshot.formatName_; 72 | Snapshot.formatName_ = function() { 73 | return FULL_SNAPSHOT_NAME; 74 | }; 75 | }); 76 | 77 | after(function() { 78 | Snapshot.formatName_ = formatName_; 79 | }); 80 | 81 | it('should promisify all the things', function() { 82 | assert(promisified); 83 | }); 84 | 85 | it('should localize parent.Promise', function() { 86 | assert.strictEqual(snapshot.Promise, SUBSCRIPTION.Promise); 87 | }); 88 | 89 | it('should localize the parent', function() { 90 | assert.strictEqual(snapshot.parent, SUBSCRIPTION); 91 | }); 92 | 93 | describe('name', function() { 94 | it('should create and cache the full name', function() { 95 | Snapshot.formatName_ = function(projectId, name) { 96 | assert.strictEqual(projectId, PROJECT_ID); 97 | assert.strictEqual(name, SNAPSHOT_NAME); 98 | return FULL_SNAPSHOT_NAME; 99 | }; 100 | 101 | var snapshot = new Snapshot(SUBSCRIPTION, SNAPSHOT_NAME); 102 | assert.strictEqual(snapshot.name, FULL_SNAPSHOT_NAME); 103 | }); 104 | 105 | it('should pull the projectId from parent object', function() { 106 | Snapshot.formatName_ = function(projectId, name) { 107 | assert.strictEqual(projectId, PROJECT_ID); 108 | assert.strictEqual(name, SNAPSHOT_NAME); 109 | return FULL_SNAPSHOT_NAME; 110 | }; 111 | 112 | var snapshot = new Snapshot(SUBSCRIPTION, SNAPSHOT_NAME); 113 | assert.strictEqual(snapshot.name, FULL_SNAPSHOT_NAME); 114 | }); 115 | }); 116 | 117 | describe('with Subscription parent', function() { 118 | it('should include the create method', function(done) { 119 | SUBSCRIPTION.createSnapshot = function(name, callback) { 120 | assert.strictEqual(name, SNAPSHOT_NAME); 121 | callback(); // The done function 122 | }; 123 | 124 | var snapshot = new Snapshot(SUBSCRIPTION, SNAPSHOT_NAME); 125 | snapshot.create(done); 126 | }); 127 | 128 | it('should create a seek method', function(done) { 129 | SUBSCRIPTION.seek = function(name, callback) { 130 | assert.strictEqual(name, SNAPSHOT_NAME); 131 | callback(); // The done function 132 | }; 133 | 134 | var snapshot = new Snapshot(SUBSCRIPTION, SNAPSHOT_NAME); 135 | snapshot.seek(done); 136 | }); 137 | }); 138 | 139 | describe('with PubSub parent', function() { 140 | var snapshot; 141 | 142 | beforeEach(function() { 143 | snapshot = new Snapshot(PUBSUB, SNAPSHOT_NAME); 144 | }); 145 | 146 | it('should not include the create method', function() { 147 | assert.strictEqual(snapshot.create, undefined); 148 | }); 149 | 150 | it('should not include a seek method', function() { 151 | assert.strictEqual(snapshot.seek, undefined); 152 | }); 153 | }); 154 | }); 155 | 156 | describe('formatName_', function() { 157 | var EXPECTED = 'projects/' + PROJECT_ID + '/snapshots/' + SNAPSHOT_NAME; 158 | 159 | it('should format the name', function() { 160 | var name = Snapshot.formatName_(PROJECT_ID, SNAPSHOT_NAME); 161 | 162 | assert.strictEqual(name, EXPECTED); 163 | }); 164 | 165 | it('should not re-format the name', function() { 166 | var name = Snapshot.formatName_(PROJECT_ID, EXPECTED); 167 | 168 | assert.strictEqual(name, EXPECTED); 169 | }); 170 | }); 171 | 172 | describe('delete', function() { 173 | it('should make the correct request', function(done) { 174 | snapshot.parent.request = function(config, callback) { 175 | assert.strictEqual(config.client, 'SubscriberClient'); 176 | assert.strictEqual(config.method, 'deleteSnapshot'); 177 | assert.deepEqual(config.reqOpts, {snapshot: snapshot.name}); 178 | callback(); // the done fn 179 | }; 180 | 181 | snapshot.delete(done); 182 | }); 183 | 184 | it('should optionally accept a callback', function(done) { 185 | fakeUtil.noop = done; 186 | 187 | snapshot.parent.request = function(config, callback) { 188 | callback(); // the done fn 189 | }; 190 | 191 | snapshot.delete(); 192 | }); 193 | }); 194 | }); 195 | --------------------------------------------------------------------------------