├── .jshintrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── lib ├── apphosting │ ├── api │ │ ├── api_base.pb.js │ │ ├── app_identity │ │ │ └── app_identity_service.pb.js │ │ ├── blobstore │ │ │ ├── blobstore_service.pb.js │ │ │ └── blobstore_upload.pb.js │ │ ├── capabilities │ │ │ └── capability_service.pb.js │ │ ├── channel │ │ │ └── channel_service.pb.js │ │ ├── dos │ │ │ └── dos_service.pb.js │ │ ├── files │ │ │ └── file_service.pb.js │ │ ├── images │ │ │ └── images_service.pb.js │ │ ├── logservice │ │ │ └── log_service.pb.js │ │ ├── mail_service.pb.js │ │ ├── memcache │ │ │ └── memcache_service.pb.js │ │ ├── modules │ │ │ └── modules_service.pb.js │ │ ├── system │ │ │ └── system_service.pb.js │ │ ├── taskqueue │ │ │ └── taskqueue_service.pb.js │ │ ├── urlfetch_service.pb.js │ │ └── user_service.pb.js │ ├── base │ │ └── capabilities.pb.js │ └── ext │ │ └── remote_api │ │ └── remote_api.pb.js ├── closure │ └── goog │ │ ├── array │ │ └── array.js │ │ ├── asserts │ │ └── asserts.js │ │ ├── base.js │ │ ├── bootstrap │ │ └── nodejs.js │ │ ├── debug │ │ └── error.js │ │ ├── deps.js │ │ ├── dom │ │ └── nodetype.js │ │ ├── math │ │ └── long.js │ │ ├── object │ │ └── object.js │ │ ├── proto2 │ │ ├── descriptor.js │ │ ├── fielddescriptor.js │ │ ├── message.js │ │ └── serializer.js │ │ └── string │ │ └── string.js ├── deps.js ├── index.js ├── net │ └── proto2 │ │ └── contrib │ │ └── WireSerializer.js └── utils.js ├── package.json └── test ├── index.js └── utils.js /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "bitwise": true, 3 | "curly": true, 4 | "eqeqeq": true, 5 | "freeze": true, 6 | "immed": true, 7 | "indent": 2, 8 | "latedef": "nofunc", 9 | "newcap": true, 10 | "noarg": true, 11 | "node": true, 12 | "quotmark": "single", 13 | "strict": true, 14 | "undef": true, 15 | "unused": true 16 | } 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles. 6 | 7 | Please fill out either the individual or corporate Contributor License Agreement (CLA). 8 | 9 | * If you are an individual writing original source code and you're sure you own the intellectual property, then you'll need to sign an [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 10 | * If you work for a company that wants to allow you to contribute your work, then you'll need to sign a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 11 | 12 | Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once we receive it, we'll be able to accept your pull requests. 13 | 14 | ## Contributing A Patch 15 | 16 | 1. Submit an issue describing your proposed change to the repo in question. 17 | 1. The repo owner will respond to your issue promptly. 18 | 1. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see details above). 19 | 1. Fork the desired repo, develop and test your code changes. 20 | 1. Submit a pull request. 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![status: inactive](https://img.shields.io/badge/status-inactive-red.svg) 2 | 3 | This project is no longer actively developed or maintained. 4 | 5 | To use Google Cloud APIs from Google App Engine in Node.js, use [gcloud-node](https://github.com/GoogleCloudPlatform/gcloud-node). 6 | 7 | --- 8 | 9 | # appengine-nodejs 10 | 11 | An experimental set of node.js libraries for interacting with App Engine specific services from within [Google App Engine Managed VMs](https://developers.google.com/appengine/docs/managed-vms/) using Custom Runtimes. 12 | 13 | To get started, clone the [quickstart][3] project and follow the instructions there. 14 | 15 | ## Usage 16 | 17 | This library will only work inside App Engine Managed VMs, or with the Managed VM SDK. 18 | 19 | Declare this library as a dependency in `package.json`: 20 | 21 | ~~~~ 22 | "dependencies": { 23 | "appengine": "git://github.com/GoogleCloudPlatform/appengine-nodejs.git", 24 | } 25 | ~~~~ 26 | 27 | Add a `Dockerfile` to the application with the following contents: 28 | 29 | ~~~~ 30 | FROM google/nodejs-runtime 31 | ~~~~ 32 | 33 | Then, before calling functions in this library, http handlers need to make sure to call the `appengine.middleware.base` function with three arguments: the node.js request, the node.js response and a callback. 34 | 35 | Frameworks such as `express.js` do this automatically if you register that function as a middleware. Here's an example: 36 | 37 | ~~~~ 38 | var appengine = require('appengine'); 39 | var express = require('express'); 40 | 41 | var app = express(); 42 | app.use(appengine.middleware.base); 43 | // ... register any handlers... 44 | app.listen(8080, '0.0.0.0'); 45 | ~~~~ 46 | 47 | ## APIs 48 | 49 | This library currently supports a subset of the App Engine APIs available to the official runtimes such as Java or Python. 50 | 51 | An application may use any other Google APIs, such as Google Cloud Storage or Google Calendar, e.g. via the [googleapis][1] or [gcloud-node][2] libraries: 52 | 53 | ~~~~ 54 | "dependencies": { 55 | "googleapis" : "latest" 56 | "gcloud" : "latest" 57 | } 58 | ~~~~ 59 | 60 | All API functions provided by this library take as their last argument a callback, i.e. a function of the form `function(err, arg1, arg2, ...)`. The first argument is always an optional `Error` object (or `null` if there is no error). The subsequent arguments depend on the API function itself and are described below. 61 | 62 | ### Logging 63 | 64 | ##### appengine.logOneLine 65 | 66 | ~~~~ 67 | appengine.logOneLine(request, message, level, function(err) { ... }); 68 | ~~~~ 69 | 70 | Logs a message (a string) at the specified log level. 71 | 72 | Log records are buffered by default. They are flushed when `request.end()` is called or when the buffer grows too big or after a certain amount of time (currently, after 60 seconds). 73 | 74 | Two caveats: 75 | 76 | - log flushes are never asynchronous, so for a flush to happen after 60 seconds your application must regularly call `appengine.logOneLine` 77 | - the `request.end()` method is never called on background requests 78 | 79 | The `appengine.flushLogs` method can be used to flush the buffered logs at any time. 80 | 81 | Valid log levels are: 82 | ~~~~ 83 | appengine.LogLevel.DEBUG 84 | appengine.LogLevel.INFO 85 | appengine.LogLevel.WARNING 86 | appengine.LogLevel.ERROR 87 | appengine.LogLevel.CRITICAL 88 | ~~~~ 89 | 90 | The callback is optional. Note that while most calls to `logOneLine` will return immediately, some may result in the buffer being flushed. 91 | 92 | The following code snippet logs at the `INFO` level and ignores any logging errors: 93 | ~~~~ 94 | appengine.logOneLine(request, 'this is a test', appengine.LogLevel.INFO); 95 | ~~~~ 96 | 97 | For backward compatibility, the same function can be invoked without a log level, with or without a callback: 98 | 99 | ~~~~ 100 | appengine.logOneLine(request, message, function(err) { ... }); 101 | 102 | appengine.logOneLine(request, message); 103 | ~~~~ 104 | 105 | In this case, it logs the given message at the DEBUG log level. 106 | 107 | ##### appengine.flushLogs 108 | 109 | ~~~~ 110 | appengine.flushLogs(request, function(err) { ... }); 111 | ~~~~ 112 | 113 | Flushes any buffered log records. 114 | 115 | ### Memcache 116 | 117 | ##### appengine.memcache.get 118 | 119 | ~~~~ 120 | appengine.memcache.get(request, key, function(err, value) { ... }); 121 | ~~~~ 122 | 123 | Reads from memcache the value (a string) for a given key (also a string). 124 | 125 | ##### appengine.memcache.set 126 | 127 | ~~~~ 128 | appengine.memcache.set(request, key, value, function(err) { ... }); 129 | ~~~~ 130 | 131 | Writes to memcache a value (a string) for a given key (also a string). 132 | 133 | ### Task Queues 134 | 135 | ##### appengine.taskqueue.add 136 | 137 | ~~~~ 138 | appengine.taskqueue.add(request, taskOptions, function(err) { ... }); 139 | ~~~~ 140 | 141 | Add a task to a queue. `taskOptions` must be an object with the following properties: 142 | 143 | * `url`: a string, url to dispatch to, required 144 | * `queueName`: a string, queue name, optional 145 | * `taskName`: a string, task name, optional 146 | * `etaUsec`: a string, ETA in microseconds, e.g. `"1000"`, optional 147 | * `method`: http method to use, one of `"get"`, `"post"`, `"put"`, or `"delete"`, optional, defaults to `"post"` 148 | * `body`: a string, the body of the request, optional, for put and post methods only 149 | * `headers`: optional, an object containing http headers as property/value pairs 150 | 151 | ### Modules 152 | 153 | ##### appengine.modules.getHostname 154 | 155 | ~~~~ 156 | appengine.modules.getHostname(request, module, version, instance, function(err, hostname) { ... }); 157 | ~~~~ 158 | 159 | Returns the hostname (a string) to use to talk to the given module/version/instance (all strings, all required). 160 | 161 | ### System 162 | 163 | ##### appengine.system.getBackgroundRequest 164 | 165 | ~~~~ 166 | appengine.system.getBackgroundRequest(request, function(err, backgroundRequest) { ... }); 167 | ~~~~ 168 | 169 | Returns a new request-like object that can be used to make App Engine API calls in the background, i.e. outside a request handler. 170 | 171 | A common pattern is to call this API during a start request and store the returned request object for later use. 172 | 173 | Application code should not assume any specific properties to be defined on the returned background request object. 174 | 175 | ### Auth 176 | 177 | ##### appengine.auth.getServiceAccountToken 178 | 179 | ~~~~ 180 | appengine.auth.getServiceAccountToken(request, function(err, token) { ... }); 181 | ~~~~ 182 | 183 | Returns an OAuth token for the service account for the VM as provided by the metadata server. `token` is an object with three properties: 184 | 185 | * `accessToken`: a string, the access token itself 186 | * `tokenType`: a string, the type of token returned, e.g. `"Bearer"` 187 | * `expiresIn`: a number, the time to expiration in seconds 188 | 189 | ### Metadata 190 | 191 | ##### appengine.metadata.getAttribute 192 | 193 | ~~~~ 194 | appengine.metadata.getAttribute(request, name, function(err, value) { ... }); 195 | ~~~~ 196 | 197 | Returns the value (a string) of the metadata attribute with the specified name (a string). 198 | For example, to retrieve the `foo` instance attribute, the name to use is `"instance/attributes/foo"`. 199 | 200 | 201 | ### Middleware 202 | 203 | ##### appengine.middleware.base 204 | 205 | ~~~~ 206 | appengine.middleware.base(request, response, function() { ... }); 207 | ~~~~ 208 | 209 | A middleware function that extracts App Engine-specific information from request headers and environment properties and sets them into the request under `request.appengine`. 210 | This function must be called by all http handlers that intend to make any App Engine API calls. 211 | 212 | [1]: https://www.npmjs.org/package/googleapis 213 | [2]: https://github.com/GoogleCloudPlatform/gcloud-node 214 | [3]: https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart 215 | -------------------------------------------------------------------------------- /lib/apphosting/api/api_base.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.base.StringProto'); 20 | goog.provide('apphosting.base.Integer32Proto'); 21 | goog.provide('apphosting.base.Integer64Proto'); 22 | goog.provide('apphosting.base.BoolProto'); 23 | goog.provide('apphosting.base.DoubleProto'); 24 | goog.provide('apphosting.base.BytesProto'); 25 | goog.provide('apphosting.base.VoidProto'); 26 | 27 | goog.require('goog.proto2.Message'); 28 | 29 | 30 | 31 | /** 32 | * Message StringProto. 33 | * @constructor 34 | * @extends {goog.proto2.Message} 35 | */ 36 | apphosting.base.StringProto = function() { 37 | goog.proto2.Message.apply(this); 38 | }; 39 | goog.inherits(apphosting.base.StringProto, goog.proto2.Message); 40 | 41 | 42 | /** 43 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 44 | * @return {!apphosting.base.StringProto} The cloned message. 45 | * @override 46 | */ 47 | apphosting.base.StringProto.prototype.clone; 48 | 49 | 50 | /** 51 | * Gets the value of the value field. 52 | * @return {?string} The value. 53 | */ 54 | apphosting.base.StringProto.prototype.getValue = function() { 55 | return /** @type {?string} */ (this.get$Value(1)); 56 | }; 57 | 58 | 59 | /** 60 | * Gets the value of the value field or the default value if not set. 61 | * @return {string} The value. 62 | */ 63 | apphosting.base.StringProto.prototype.getValueOrDefault = function() { 64 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 65 | }; 66 | 67 | 68 | /** 69 | * Sets the value of the value field. 70 | * @param {string} value The value. 71 | */ 72 | apphosting.base.StringProto.prototype.setValue = function(value) { 73 | this.set$Value(1, value); 74 | }; 75 | 76 | 77 | /** 78 | * @return {boolean} Whether the value field has a value. 79 | */ 80 | apphosting.base.StringProto.prototype.hasValue = function() { 81 | return this.has$Value(1); 82 | }; 83 | 84 | 85 | /** 86 | * @return {number} The number of values in the value field. 87 | */ 88 | apphosting.base.StringProto.prototype.valueCount = function() { 89 | return this.count$Values(1); 90 | }; 91 | 92 | 93 | /** 94 | * Clears the values in the value field. 95 | */ 96 | apphosting.base.StringProto.prototype.clearValue = function() { 97 | this.clear$Field(1); 98 | }; 99 | 100 | 101 | 102 | /** 103 | * Message Integer32Proto. 104 | * @constructor 105 | * @extends {goog.proto2.Message} 106 | */ 107 | apphosting.base.Integer32Proto = function() { 108 | goog.proto2.Message.apply(this); 109 | }; 110 | goog.inherits(apphosting.base.Integer32Proto, goog.proto2.Message); 111 | 112 | 113 | /** 114 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 115 | * @return {!apphosting.base.Integer32Proto} The cloned message. 116 | * @override 117 | */ 118 | apphosting.base.Integer32Proto.prototype.clone; 119 | 120 | 121 | /** 122 | * Gets the value of the value field. 123 | * @return {?number} The value. 124 | */ 125 | apphosting.base.Integer32Proto.prototype.getValue = function() { 126 | return /** @type {?number} */ (this.get$Value(1)); 127 | }; 128 | 129 | 130 | /** 131 | * Gets the value of the value field or the default value if not set. 132 | * @return {number} The value. 133 | */ 134 | apphosting.base.Integer32Proto.prototype.getValueOrDefault = function() { 135 | return /** @type {number} */ (this.get$ValueOrDefault(1)); 136 | }; 137 | 138 | 139 | /** 140 | * Sets the value of the value field. 141 | * @param {number} value The value. 142 | */ 143 | apphosting.base.Integer32Proto.prototype.setValue = function(value) { 144 | this.set$Value(1, value); 145 | }; 146 | 147 | 148 | /** 149 | * @return {boolean} Whether the value field has a value. 150 | */ 151 | apphosting.base.Integer32Proto.prototype.hasValue = function() { 152 | return this.has$Value(1); 153 | }; 154 | 155 | 156 | /** 157 | * @return {number} The number of values in the value field. 158 | */ 159 | apphosting.base.Integer32Proto.prototype.valueCount = function() { 160 | return this.count$Values(1); 161 | }; 162 | 163 | 164 | /** 165 | * Clears the values in the value field. 166 | */ 167 | apphosting.base.Integer32Proto.prototype.clearValue = function() { 168 | this.clear$Field(1); 169 | }; 170 | 171 | 172 | 173 | /** 174 | * Message Integer64Proto. 175 | * @constructor 176 | * @extends {goog.proto2.Message} 177 | */ 178 | apphosting.base.Integer64Proto = function() { 179 | goog.proto2.Message.apply(this); 180 | }; 181 | goog.inherits(apphosting.base.Integer64Proto, goog.proto2.Message); 182 | 183 | 184 | /** 185 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 186 | * @return {!apphosting.base.Integer64Proto} The cloned message. 187 | * @override 188 | */ 189 | apphosting.base.Integer64Proto.prototype.clone; 190 | 191 | 192 | /** 193 | * Gets the value of the value field. 194 | * @return {?string} The value. 195 | */ 196 | apphosting.base.Integer64Proto.prototype.getValue = function() { 197 | return /** @type {?string} */ (this.get$Value(1)); 198 | }; 199 | 200 | 201 | /** 202 | * Gets the value of the value field or the default value if not set. 203 | * @return {string} The value. 204 | */ 205 | apphosting.base.Integer64Proto.prototype.getValueOrDefault = function() { 206 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 207 | }; 208 | 209 | 210 | /** 211 | * Sets the value of the value field. 212 | * @param {string} value The value. 213 | */ 214 | apphosting.base.Integer64Proto.prototype.setValue = function(value) { 215 | this.set$Value(1, value); 216 | }; 217 | 218 | 219 | /** 220 | * @return {boolean} Whether the value field has a value. 221 | */ 222 | apphosting.base.Integer64Proto.prototype.hasValue = function() { 223 | return this.has$Value(1); 224 | }; 225 | 226 | 227 | /** 228 | * @return {number} The number of values in the value field. 229 | */ 230 | apphosting.base.Integer64Proto.prototype.valueCount = function() { 231 | return this.count$Values(1); 232 | }; 233 | 234 | 235 | /** 236 | * Clears the values in the value field. 237 | */ 238 | apphosting.base.Integer64Proto.prototype.clearValue = function() { 239 | this.clear$Field(1); 240 | }; 241 | 242 | 243 | 244 | /** 245 | * Message BoolProto. 246 | * @constructor 247 | * @extends {goog.proto2.Message} 248 | */ 249 | apphosting.base.BoolProto = function() { 250 | goog.proto2.Message.apply(this); 251 | }; 252 | goog.inherits(apphosting.base.BoolProto, goog.proto2.Message); 253 | 254 | 255 | /** 256 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 257 | * @return {!apphosting.base.BoolProto} The cloned message. 258 | * @override 259 | */ 260 | apphosting.base.BoolProto.prototype.clone; 261 | 262 | 263 | /** 264 | * Gets the value of the value field. 265 | * @return {?boolean} The value. 266 | */ 267 | apphosting.base.BoolProto.prototype.getValue = function() { 268 | return /** @type {?boolean} */ (this.get$Value(1)); 269 | }; 270 | 271 | 272 | /** 273 | * Gets the value of the value field or the default value if not set. 274 | * @return {boolean} The value. 275 | */ 276 | apphosting.base.BoolProto.prototype.getValueOrDefault = function() { 277 | return /** @type {boolean} */ (this.get$ValueOrDefault(1)); 278 | }; 279 | 280 | 281 | /** 282 | * Sets the value of the value field. 283 | * @param {boolean} value The value. 284 | */ 285 | apphosting.base.BoolProto.prototype.setValue = function(value) { 286 | this.set$Value(1, value); 287 | }; 288 | 289 | 290 | /** 291 | * @return {boolean} Whether the value field has a value. 292 | */ 293 | apphosting.base.BoolProto.prototype.hasValue = function() { 294 | return this.has$Value(1); 295 | }; 296 | 297 | 298 | /** 299 | * @return {number} The number of values in the value field. 300 | */ 301 | apphosting.base.BoolProto.prototype.valueCount = function() { 302 | return this.count$Values(1); 303 | }; 304 | 305 | 306 | /** 307 | * Clears the values in the value field. 308 | */ 309 | apphosting.base.BoolProto.prototype.clearValue = function() { 310 | this.clear$Field(1); 311 | }; 312 | 313 | 314 | 315 | /** 316 | * Message DoubleProto. 317 | * @constructor 318 | * @extends {goog.proto2.Message} 319 | */ 320 | apphosting.base.DoubleProto = function() { 321 | goog.proto2.Message.apply(this); 322 | }; 323 | goog.inherits(apphosting.base.DoubleProto, goog.proto2.Message); 324 | 325 | 326 | /** 327 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 328 | * @return {!apphosting.base.DoubleProto} The cloned message. 329 | * @override 330 | */ 331 | apphosting.base.DoubleProto.prototype.clone; 332 | 333 | 334 | /** 335 | * Gets the value of the value field. 336 | * @return {?number} The value. 337 | */ 338 | apphosting.base.DoubleProto.prototype.getValue = function() { 339 | return /** @type {?number} */ (this.get$Value(1)); 340 | }; 341 | 342 | 343 | /** 344 | * Gets the value of the value field or the default value if not set. 345 | * @return {number} The value. 346 | */ 347 | apphosting.base.DoubleProto.prototype.getValueOrDefault = function() { 348 | return /** @type {number} */ (this.get$ValueOrDefault(1)); 349 | }; 350 | 351 | 352 | /** 353 | * Sets the value of the value field. 354 | * @param {number} value The value. 355 | */ 356 | apphosting.base.DoubleProto.prototype.setValue = function(value) { 357 | this.set$Value(1, value); 358 | }; 359 | 360 | 361 | /** 362 | * @return {boolean} Whether the value field has a value. 363 | */ 364 | apphosting.base.DoubleProto.prototype.hasValue = function() { 365 | return this.has$Value(1); 366 | }; 367 | 368 | 369 | /** 370 | * @return {number} The number of values in the value field. 371 | */ 372 | apphosting.base.DoubleProto.prototype.valueCount = function() { 373 | return this.count$Values(1); 374 | }; 375 | 376 | 377 | /** 378 | * Clears the values in the value field. 379 | */ 380 | apphosting.base.DoubleProto.prototype.clearValue = function() { 381 | this.clear$Field(1); 382 | }; 383 | 384 | 385 | 386 | /** 387 | * Message BytesProto. 388 | * @constructor 389 | * @extends {goog.proto2.Message} 390 | */ 391 | apphosting.base.BytesProto = function() { 392 | goog.proto2.Message.apply(this); 393 | }; 394 | goog.inherits(apphosting.base.BytesProto, goog.proto2.Message); 395 | 396 | 397 | /** 398 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 399 | * @return {!apphosting.base.BytesProto} The cloned message. 400 | * @override 401 | */ 402 | apphosting.base.BytesProto.prototype.clone; 403 | 404 | 405 | /** 406 | * Gets the value of the value field. 407 | * @return {?string} The value. 408 | */ 409 | apphosting.base.BytesProto.prototype.getValue = function() { 410 | return /** @type {?string} */ (this.get$Value(1)); 411 | }; 412 | 413 | 414 | /** 415 | * Gets the value of the value field or the default value if not set. 416 | * @return {string} The value. 417 | */ 418 | apphosting.base.BytesProto.prototype.getValueOrDefault = function() { 419 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 420 | }; 421 | 422 | 423 | /** 424 | * Sets the value of the value field. 425 | * @param {string} value The value. 426 | */ 427 | apphosting.base.BytesProto.prototype.setValue = function(value) { 428 | this.set$Value(1, value); 429 | }; 430 | 431 | 432 | /** 433 | * @return {boolean} Whether the value field has a value. 434 | */ 435 | apphosting.base.BytesProto.prototype.hasValue = function() { 436 | return this.has$Value(1); 437 | }; 438 | 439 | 440 | /** 441 | * @return {number} The number of values in the value field. 442 | */ 443 | apphosting.base.BytesProto.prototype.valueCount = function() { 444 | return this.count$Values(1); 445 | }; 446 | 447 | 448 | /** 449 | * Clears the values in the value field. 450 | */ 451 | apphosting.base.BytesProto.prototype.clearValue = function() { 452 | this.clear$Field(1); 453 | }; 454 | 455 | 456 | 457 | /** 458 | * Message VoidProto. 459 | * @constructor 460 | * @extends {goog.proto2.Message} 461 | */ 462 | apphosting.base.VoidProto = function() { 463 | goog.proto2.Message.apply(this); 464 | }; 465 | goog.inherits(apphosting.base.VoidProto, goog.proto2.Message); 466 | 467 | 468 | /** 469 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 470 | * @return {!apphosting.base.VoidProto} The cloned message. 471 | * @override 472 | */ 473 | apphosting.base.VoidProto.prototype.clone; 474 | 475 | 476 | goog.proto2.Message.set$Metadata(apphosting.base.StringProto, { 477 | 0: { 478 | name: 'StringProto', 479 | fullName: 'apphosting.base.StringProto' 480 | }, 481 | 1: { 482 | name: 'value', 483 | required: true, 484 | fieldType: goog.proto2.Message.FieldType.STRING, 485 | type: String 486 | } 487 | }); 488 | 489 | 490 | goog.proto2.Message.set$Metadata(apphosting.base.Integer32Proto, { 491 | 0: { 492 | name: 'Integer32Proto', 493 | fullName: 'apphosting.base.Integer32Proto' 494 | }, 495 | 1: { 496 | name: 'value', 497 | required: true, 498 | fieldType: goog.proto2.Message.FieldType.INT32, 499 | type: Number 500 | } 501 | }); 502 | 503 | 504 | goog.proto2.Message.set$Metadata(apphosting.base.Integer64Proto, { 505 | 0: { 506 | name: 'Integer64Proto', 507 | fullName: 'apphosting.base.Integer64Proto' 508 | }, 509 | 1: { 510 | name: 'value', 511 | required: true, 512 | fieldType: goog.proto2.Message.FieldType.INT64, 513 | type: String 514 | } 515 | }); 516 | 517 | 518 | goog.proto2.Message.set$Metadata(apphosting.base.BoolProto, { 519 | 0: { 520 | name: 'BoolProto', 521 | fullName: 'apphosting.base.BoolProto' 522 | }, 523 | 1: { 524 | name: 'value', 525 | required: true, 526 | fieldType: goog.proto2.Message.FieldType.BOOL, 527 | type: Boolean 528 | } 529 | }); 530 | 531 | 532 | goog.proto2.Message.set$Metadata(apphosting.base.DoubleProto, { 533 | 0: { 534 | name: 'DoubleProto', 535 | fullName: 'apphosting.base.DoubleProto' 536 | }, 537 | 1: { 538 | name: 'value', 539 | required: true, 540 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 541 | type: Number 542 | } 543 | }); 544 | 545 | 546 | goog.proto2.Message.set$Metadata(apphosting.base.BytesProto, { 547 | 0: { 548 | name: 'BytesProto', 549 | fullName: 'apphosting.base.BytesProto' 550 | }, 551 | 1: { 552 | name: 'value', 553 | required: true, 554 | fieldType: goog.proto2.Message.FieldType.BYTES, 555 | type: String 556 | } 557 | }); 558 | 559 | 560 | goog.proto2.Message.set$Metadata(apphosting.base.VoidProto, { 561 | 0: { 562 | name: 'VoidProto', 563 | fullName: 'apphosting.base.VoidProto' 564 | } 565 | }); 566 | -------------------------------------------------------------------------------- /lib/apphosting/api/capabilities/capability_service.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.IsEnabledRequest'); 20 | goog.provide('apphosting.IsEnabledResponse'); 21 | goog.provide('apphosting.IsEnabledResponse.SummaryStatus'); 22 | 23 | goog.require('apphosting.CapabilityConfig'); 24 | goog.require('goog.proto2.Message'); 25 | 26 | 27 | 28 | /** 29 | * Message IsEnabledRequest. 30 | * @constructor 31 | * @extends {goog.proto2.Message} 32 | */ 33 | apphosting.IsEnabledRequest = function() { 34 | goog.proto2.Message.apply(this); 35 | }; 36 | goog.inherits(apphosting.IsEnabledRequest, goog.proto2.Message); 37 | 38 | 39 | /** 40 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 41 | * @return {!apphosting.IsEnabledRequest} The cloned message. 42 | * @override 43 | */ 44 | apphosting.IsEnabledRequest.prototype.clone; 45 | 46 | 47 | /** 48 | * Gets the value of the package field. 49 | * @return {?string} The value. 50 | */ 51 | apphosting.IsEnabledRequest.prototype.getPackage = function() { 52 | return /** @type {?string} */ (this.get$Value(1)); 53 | }; 54 | 55 | 56 | /** 57 | * Gets the value of the package field or the default value if not set. 58 | * @return {string} The value. 59 | */ 60 | apphosting.IsEnabledRequest.prototype.getPackageOrDefault = function() { 61 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 62 | }; 63 | 64 | 65 | /** 66 | * Sets the value of the package field. 67 | * @param {string} value The value. 68 | */ 69 | apphosting.IsEnabledRequest.prototype.setPackage = function(value) { 70 | this.set$Value(1, value); 71 | }; 72 | 73 | 74 | /** 75 | * @return {boolean} Whether the package field has a value. 76 | */ 77 | apphosting.IsEnabledRequest.prototype.hasPackage = function() { 78 | return this.has$Value(1); 79 | }; 80 | 81 | 82 | /** 83 | * @return {number} The number of values in the package field. 84 | */ 85 | apphosting.IsEnabledRequest.prototype.packageCount = function() { 86 | return this.count$Values(1); 87 | }; 88 | 89 | 90 | /** 91 | * Clears the values in the package field. 92 | */ 93 | apphosting.IsEnabledRequest.prototype.clearPackage = function() { 94 | this.clear$Field(1); 95 | }; 96 | 97 | 98 | /** 99 | * Gets the value of the capability field at the index given. 100 | * @param {number} index The index to lookup. 101 | * @return {?string} The value. 102 | */ 103 | apphosting.IsEnabledRequest.prototype.getCapability = function(index) { 104 | return /** @type {?string} */ (this.get$Value(2, index)); 105 | }; 106 | 107 | 108 | /** 109 | * Gets the value of the capability field at the index given or the default value if not set. 110 | * @param {number} index The index to lookup. 111 | * @return {string} The value. 112 | */ 113 | apphosting.IsEnabledRequest.prototype.getCapabilityOrDefault = function(index) { 114 | return /** @type {string} */ (this.get$ValueOrDefault(2, index)); 115 | }; 116 | 117 | 118 | /** 119 | * Adds a value to the capability field. 120 | * @param {string} value The value to add. 121 | */ 122 | apphosting.IsEnabledRequest.prototype.addCapability = function(value) { 123 | this.add$Value(2, value); 124 | }; 125 | 126 | 127 | /** 128 | * Returns the array of values in the capability field. 129 | * @return {!Array.} The values in the field. 130 | */ 131 | apphosting.IsEnabledRequest.prototype.capabilityArray = function() { 132 | return /** @type {!Array.} */ (this.array$Values(2)); 133 | }; 134 | 135 | 136 | /** 137 | * @return {boolean} Whether the capability field has a value. 138 | */ 139 | apphosting.IsEnabledRequest.prototype.hasCapability = function() { 140 | return this.has$Value(2); 141 | }; 142 | 143 | 144 | /** 145 | * @return {number} The number of values in the capability field. 146 | */ 147 | apphosting.IsEnabledRequest.prototype.capabilityCount = function() { 148 | return this.count$Values(2); 149 | }; 150 | 151 | 152 | /** 153 | * Clears the values in the capability field. 154 | */ 155 | apphosting.IsEnabledRequest.prototype.clearCapability = function() { 156 | this.clear$Field(2); 157 | }; 158 | 159 | 160 | /** 161 | * Gets the value of the call field at the index given. 162 | * @param {number} index The index to lookup. 163 | * @return {?string} The value. 164 | */ 165 | apphosting.IsEnabledRequest.prototype.getCall = function(index) { 166 | return /** @type {?string} */ (this.get$Value(3, index)); 167 | }; 168 | 169 | 170 | /** 171 | * Gets the value of the call field at the index given or the default value if not set. 172 | * @param {number} index The index to lookup. 173 | * @return {string} The value. 174 | */ 175 | apphosting.IsEnabledRequest.prototype.getCallOrDefault = function(index) { 176 | return /** @type {string} */ (this.get$ValueOrDefault(3, index)); 177 | }; 178 | 179 | 180 | /** 181 | * Adds a value to the call field. 182 | * @param {string} value The value to add. 183 | */ 184 | apphosting.IsEnabledRequest.prototype.addCall = function(value) { 185 | this.add$Value(3, value); 186 | }; 187 | 188 | 189 | /** 190 | * Returns the array of values in the call field. 191 | * @return {!Array.} The values in the field. 192 | */ 193 | apphosting.IsEnabledRequest.prototype.callArray = function() { 194 | return /** @type {!Array.} */ (this.array$Values(3)); 195 | }; 196 | 197 | 198 | /** 199 | * @return {boolean} Whether the call field has a value. 200 | */ 201 | apphosting.IsEnabledRequest.prototype.hasCall = function() { 202 | return this.has$Value(3); 203 | }; 204 | 205 | 206 | /** 207 | * @return {number} The number of values in the call field. 208 | */ 209 | apphosting.IsEnabledRequest.prototype.callCount = function() { 210 | return this.count$Values(3); 211 | }; 212 | 213 | 214 | /** 215 | * Clears the values in the call field. 216 | */ 217 | apphosting.IsEnabledRequest.prototype.clearCall = function() { 218 | this.clear$Field(3); 219 | }; 220 | 221 | 222 | 223 | /** 224 | * Message IsEnabledResponse. 225 | * @constructor 226 | * @extends {goog.proto2.Message} 227 | */ 228 | apphosting.IsEnabledResponse = function() { 229 | goog.proto2.Message.apply(this); 230 | }; 231 | goog.inherits(apphosting.IsEnabledResponse, goog.proto2.Message); 232 | 233 | 234 | /** 235 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 236 | * @return {!apphosting.IsEnabledResponse} The cloned message. 237 | * @override 238 | */ 239 | apphosting.IsEnabledResponse.prototype.clone; 240 | 241 | 242 | /** 243 | * Gets the value of the summary_status field. 244 | * @return {?apphosting.IsEnabledResponse.SummaryStatus} The value. 245 | */ 246 | apphosting.IsEnabledResponse.prototype.getSummaryStatus = function() { 247 | return /** @type {?apphosting.IsEnabledResponse.SummaryStatus} */ (this.get$Value(1)); 248 | }; 249 | 250 | 251 | /** 252 | * Gets the value of the summary_status field or the default value if not set. 253 | * @return {apphosting.IsEnabledResponse.SummaryStatus} The value. 254 | */ 255 | apphosting.IsEnabledResponse.prototype.getSummaryStatusOrDefault = function() { 256 | return /** @type {apphosting.IsEnabledResponse.SummaryStatus} */ (this.get$ValueOrDefault(1)); 257 | }; 258 | 259 | 260 | /** 261 | * Sets the value of the summary_status field. 262 | * @param {apphosting.IsEnabledResponse.SummaryStatus} value The value. 263 | */ 264 | apphosting.IsEnabledResponse.prototype.setSummaryStatus = function(value) { 265 | this.set$Value(1, value); 266 | }; 267 | 268 | 269 | /** 270 | * @return {boolean} Whether the summary_status field has a value. 271 | */ 272 | apphosting.IsEnabledResponse.prototype.hasSummaryStatus = function() { 273 | return this.has$Value(1); 274 | }; 275 | 276 | 277 | /** 278 | * @return {number} The number of values in the summary_status field. 279 | */ 280 | apphosting.IsEnabledResponse.prototype.summaryStatusCount = function() { 281 | return this.count$Values(1); 282 | }; 283 | 284 | 285 | /** 286 | * Clears the values in the summary_status field. 287 | */ 288 | apphosting.IsEnabledResponse.prototype.clearSummaryStatus = function() { 289 | this.clear$Field(1); 290 | }; 291 | 292 | 293 | /** 294 | * Gets the value of the time_until_scheduled field. 295 | * @return {?string} The value. 296 | */ 297 | apphosting.IsEnabledResponse.prototype.getTimeUntilScheduled = function() { 298 | return /** @type {?string} */ (this.get$Value(2)); 299 | }; 300 | 301 | 302 | /** 303 | * Gets the value of the time_until_scheduled field or the default value if not set. 304 | * @return {string} The value. 305 | */ 306 | apphosting.IsEnabledResponse.prototype.getTimeUntilScheduledOrDefault = function() { 307 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 308 | }; 309 | 310 | 311 | /** 312 | * Sets the value of the time_until_scheduled field. 313 | * @param {string} value The value. 314 | */ 315 | apphosting.IsEnabledResponse.prototype.setTimeUntilScheduled = function(value) { 316 | this.set$Value(2, value); 317 | }; 318 | 319 | 320 | /** 321 | * @return {boolean} Whether the time_until_scheduled field has a value. 322 | */ 323 | apphosting.IsEnabledResponse.prototype.hasTimeUntilScheduled = function() { 324 | return this.has$Value(2); 325 | }; 326 | 327 | 328 | /** 329 | * @return {number} The number of values in the time_until_scheduled field. 330 | */ 331 | apphosting.IsEnabledResponse.prototype.timeUntilScheduledCount = function() { 332 | return this.count$Values(2); 333 | }; 334 | 335 | 336 | /** 337 | * Clears the values in the time_until_scheduled field. 338 | */ 339 | apphosting.IsEnabledResponse.prototype.clearTimeUntilScheduled = function() { 340 | this.clear$Field(2); 341 | }; 342 | 343 | 344 | /** 345 | * Gets the value of the config field at the index given. 346 | * @param {number} index The index to lookup. 347 | * @return {apphosting.CapabilityConfig} The value. 348 | */ 349 | apphosting.IsEnabledResponse.prototype.getConfig = function(index) { 350 | return /** @type {apphosting.CapabilityConfig} */ (this.get$Value(3, index)); 351 | }; 352 | 353 | 354 | /** 355 | * Gets the value of the config field at the index given or the default value if not set. 356 | * @param {number} index The index to lookup. 357 | * @return {!apphosting.CapabilityConfig} The value. 358 | */ 359 | apphosting.IsEnabledResponse.prototype.getConfigOrDefault = function(index) { 360 | return /** @type {!apphosting.CapabilityConfig} */ (this.get$ValueOrDefault(3, index)); 361 | }; 362 | 363 | 364 | /** 365 | * Adds a value to the config field. 366 | * @param {!apphosting.CapabilityConfig} value The value to add. 367 | */ 368 | apphosting.IsEnabledResponse.prototype.addConfig = function(value) { 369 | this.add$Value(3, value); 370 | }; 371 | 372 | 373 | /** 374 | * Returns the array of values in the config field. 375 | * @return {!Array.} The values in the field. 376 | */ 377 | apphosting.IsEnabledResponse.prototype.configArray = function() { 378 | return /** @type {!Array.} */ (this.array$Values(3)); 379 | }; 380 | 381 | 382 | /** 383 | * @return {boolean} Whether the config field has a value. 384 | */ 385 | apphosting.IsEnabledResponse.prototype.hasConfig = function() { 386 | return this.has$Value(3); 387 | }; 388 | 389 | 390 | /** 391 | * @return {number} The number of values in the config field. 392 | */ 393 | apphosting.IsEnabledResponse.prototype.configCount = function() { 394 | return this.count$Values(3); 395 | }; 396 | 397 | 398 | /** 399 | * Clears the values in the config field. 400 | */ 401 | apphosting.IsEnabledResponse.prototype.clearConfig = function() { 402 | this.clear$Field(3); 403 | }; 404 | 405 | 406 | /** 407 | * Enumeration SummaryStatus. 408 | * @enum {number} 409 | */ 410 | apphosting.IsEnabledResponse.SummaryStatus = { 411 | ENABLED: 1, 412 | SCHEDULED_FUTURE: 2, 413 | SCHEDULED_NOW: 3, 414 | DISABLED: 4, 415 | UNKNOWN: 5 416 | }; 417 | 418 | 419 | goog.proto2.Message.set$Metadata(apphosting.IsEnabledRequest, { 420 | 0: { 421 | name: 'IsEnabledRequest', 422 | fullName: 'apphosting.IsEnabledRequest' 423 | }, 424 | 1: { 425 | name: 'package', 426 | required: true, 427 | fieldType: goog.proto2.Message.FieldType.STRING, 428 | type: String 429 | }, 430 | 2: { 431 | name: 'capability', 432 | repeated: true, 433 | fieldType: goog.proto2.Message.FieldType.STRING, 434 | type: String 435 | }, 436 | 3: { 437 | name: 'call', 438 | repeated: true, 439 | fieldType: goog.proto2.Message.FieldType.STRING, 440 | type: String 441 | } 442 | }); 443 | 444 | 445 | goog.proto2.Message.set$Metadata(apphosting.IsEnabledResponse, { 446 | 0: { 447 | name: 'IsEnabledResponse', 448 | fullName: 'apphosting.IsEnabledResponse' 449 | }, 450 | 1: { 451 | name: 'summary_status', 452 | required: true, 453 | fieldType: goog.proto2.Message.FieldType.ENUM, 454 | defaultValue: apphosting.IsEnabledResponse.SummaryStatus.ENABLED, 455 | type: apphosting.IsEnabledResponse.SummaryStatus 456 | }, 457 | 2: { 458 | name: 'time_until_scheduled', 459 | fieldType: goog.proto2.Message.FieldType.INT64, 460 | type: String 461 | }, 462 | 3: { 463 | name: 'config', 464 | repeated: true, 465 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 466 | type: apphosting.CapabilityConfig 467 | } 468 | }); 469 | -------------------------------------------------------------------------------- /lib/apphosting/api/channel/channel_service.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.ChannelServiceError'); 20 | goog.provide('apphosting.ChannelServiceError.ErrorCode'); 21 | goog.provide('apphosting.CreateChannelRequest'); 22 | goog.provide('apphosting.CreateChannelResponse'); 23 | goog.provide('apphosting.SendMessageRequest'); 24 | 25 | goog.require('goog.proto2.Message'); 26 | 27 | 28 | 29 | /** 30 | * Message ChannelServiceError. 31 | * @constructor 32 | * @extends {goog.proto2.Message} 33 | */ 34 | apphosting.ChannelServiceError = function() { 35 | goog.proto2.Message.apply(this); 36 | }; 37 | goog.inherits(apphosting.ChannelServiceError, goog.proto2.Message); 38 | 39 | 40 | /** 41 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 42 | * @return {!apphosting.ChannelServiceError} The cloned message. 43 | * @override 44 | */ 45 | apphosting.ChannelServiceError.prototype.clone; 46 | 47 | 48 | /** 49 | * Enumeration ErrorCode. 50 | * @enum {number} 51 | */ 52 | apphosting.ChannelServiceError.ErrorCode = { 53 | OK: 0, 54 | INTERNAL_ERROR: 1, 55 | INVALID_CHANNEL_KEY: 2, 56 | BAD_MESSAGE: 3, 57 | INVALID_CHANNEL_TOKEN_DURATION: 4, 58 | APPID_ALIAS_REQUIRED: 5 59 | }; 60 | 61 | 62 | 63 | /** 64 | * Message CreateChannelRequest. 65 | * @constructor 66 | * @extends {goog.proto2.Message} 67 | */ 68 | apphosting.CreateChannelRequest = function() { 69 | goog.proto2.Message.apply(this); 70 | }; 71 | goog.inherits(apphosting.CreateChannelRequest, goog.proto2.Message); 72 | 73 | 74 | /** 75 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 76 | * @return {!apphosting.CreateChannelRequest} The cloned message. 77 | * @override 78 | */ 79 | apphosting.CreateChannelRequest.prototype.clone; 80 | 81 | 82 | /** 83 | * Gets the value of the application_key field. 84 | * @return {?string} The value. 85 | */ 86 | apphosting.CreateChannelRequest.prototype.getApplicationKey = function() { 87 | return /** @type {?string} */ (this.get$Value(1)); 88 | }; 89 | 90 | 91 | /** 92 | * Gets the value of the application_key field or the default value if not set. 93 | * @return {string} The value. 94 | */ 95 | apphosting.CreateChannelRequest.prototype.getApplicationKeyOrDefault = function() { 96 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 97 | }; 98 | 99 | 100 | /** 101 | * Sets the value of the application_key field. 102 | * @param {string} value The value. 103 | */ 104 | apphosting.CreateChannelRequest.prototype.setApplicationKey = function(value) { 105 | this.set$Value(1, value); 106 | }; 107 | 108 | 109 | /** 110 | * @return {boolean} Whether the application_key field has a value. 111 | */ 112 | apphosting.CreateChannelRequest.prototype.hasApplicationKey = function() { 113 | return this.has$Value(1); 114 | }; 115 | 116 | 117 | /** 118 | * @return {number} The number of values in the application_key field. 119 | */ 120 | apphosting.CreateChannelRequest.prototype.applicationKeyCount = function() { 121 | return this.count$Values(1); 122 | }; 123 | 124 | 125 | /** 126 | * Clears the values in the application_key field. 127 | */ 128 | apphosting.CreateChannelRequest.prototype.clearApplicationKey = function() { 129 | this.clear$Field(1); 130 | }; 131 | 132 | 133 | /** 134 | * Gets the value of the duration_minutes field. 135 | * @return {?number} The value. 136 | */ 137 | apphosting.CreateChannelRequest.prototype.getDurationMinutes = function() { 138 | return /** @type {?number} */ (this.get$Value(2)); 139 | }; 140 | 141 | 142 | /** 143 | * Gets the value of the duration_minutes field or the default value if not set. 144 | * @return {number} The value. 145 | */ 146 | apphosting.CreateChannelRequest.prototype.getDurationMinutesOrDefault = function() { 147 | return /** @type {number} */ (this.get$ValueOrDefault(2)); 148 | }; 149 | 150 | 151 | /** 152 | * Sets the value of the duration_minutes field. 153 | * @param {number} value The value. 154 | */ 155 | apphosting.CreateChannelRequest.prototype.setDurationMinutes = function(value) { 156 | this.set$Value(2, value); 157 | }; 158 | 159 | 160 | /** 161 | * @return {boolean} Whether the duration_minutes field has a value. 162 | */ 163 | apphosting.CreateChannelRequest.prototype.hasDurationMinutes = function() { 164 | return this.has$Value(2); 165 | }; 166 | 167 | 168 | /** 169 | * @return {number} The number of values in the duration_minutes field. 170 | */ 171 | apphosting.CreateChannelRequest.prototype.durationMinutesCount = function() { 172 | return this.count$Values(2); 173 | }; 174 | 175 | 176 | /** 177 | * Clears the values in the duration_minutes field. 178 | */ 179 | apphosting.CreateChannelRequest.prototype.clearDurationMinutes = function() { 180 | this.clear$Field(2); 181 | }; 182 | 183 | 184 | 185 | /** 186 | * Message CreateChannelResponse. 187 | * @constructor 188 | * @extends {goog.proto2.Message} 189 | */ 190 | apphosting.CreateChannelResponse = function() { 191 | goog.proto2.Message.apply(this); 192 | }; 193 | goog.inherits(apphosting.CreateChannelResponse, goog.proto2.Message); 194 | 195 | 196 | /** 197 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 198 | * @return {!apphosting.CreateChannelResponse} The cloned message. 199 | * @override 200 | */ 201 | apphosting.CreateChannelResponse.prototype.clone; 202 | 203 | 204 | /** 205 | * Gets the value of the token field. 206 | * @return {?string} The value. 207 | */ 208 | apphosting.CreateChannelResponse.prototype.getToken = function() { 209 | return /** @type {?string} */ (this.get$Value(2)); 210 | }; 211 | 212 | 213 | /** 214 | * Gets the value of the token field or the default value if not set. 215 | * @return {string} The value. 216 | */ 217 | apphosting.CreateChannelResponse.prototype.getTokenOrDefault = function() { 218 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 219 | }; 220 | 221 | 222 | /** 223 | * Sets the value of the token field. 224 | * @param {string} value The value. 225 | */ 226 | apphosting.CreateChannelResponse.prototype.setToken = function(value) { 227 | this.set$Value(2, value); 228 | }; 229 | 230 | 231 | /** 232 | * @return {boolean} Whether the token field has a value. 233 | */ 234 | apphosting.CreateChannelResponse.prototype.hasToken = function() { 235 | return this.has$Value(2); 236 | }; 237 | 238 | 239 | /** 240 | * @return {number} The number of values in the token field. 241 | */ 242 | apphosting.CreateChannelResponse.prototype.tokenCount = function() { 243 | return this.count$Values(2); 244 | }; 245 | 246 | 247 | /** 248 | * Clears the values in the token field. 249 | */ 250 | apphosting.CreateChannelResponse.prototype.clearToken = function() { 251 | this.clear$Field(2); 252 | }; 253 | 254 | 255 | /** 256 | * Gets the value of the duration_minutes field. 257 | * @return {?number} The value. 258 | */ 259 | apphosting.CreateChannelResponse.prototype.getDurationMinutes = function() { 260 | return /** @type {?number} */ (this.get$Value(3)); 261 | }; 262 | 263 | 264 | /** 265 | * Gets the value of the duration_minutes field or the default value if not set. 266 | * @return {number} The value. 267 | */ 268 | apphosting.CreateChannelResponse.prototype.getDurationMinutesOrDefault = function() { 269 | return /** @type {number} */ (this.get$ValueOrDefault(3)); 270 | }; 271 | 272 | 273 | /** 274 | * Sets the value of the duration_minutes field. 275 | * @param {number} value The value. 276 | */ 277 | apphosting.CreateChannelResponse.prototype.setDurationMinutes = function(value) { 278 | this.set$Value(3, value); 279 | }; 280 | 281 | 282 | /** 283 | * @return {boolean} Whether the duration_minutes field has a value. 284 | */ 285 | apphosting.CreateChannelResponse.prototype.hasDurationMinutes = function() { 286 | return this.has$Value(3); 287 | }; 288 | 289 | 290 | /** 291 | * @return {number} The number of values in the duration_minutes field. 292 | */ 293 | apphosting.CreateChannelResponse.prototype.durationMinutesCount = function() { 294 | return this.count$Values(3); 295 | }; 296 | 297 | 298 | /** 299 | * Clears the values in the duration_minutes field. 300 | */ 301 | apphosting.CreateChannelResponse.prototype.clearDurationMinutes = function() { 302 | this.clear$Field(3); 303 | }; 304 | 305 | 306 | 307 | /** 308 | * Message SendMessageRequest. 309 | * @constructor 310 | * @extends {goog.proto2.Message} 311 | */ 312 | apphosting.SendMessageRequest = function() { 313 | goog.proto2.Message.apply(this); 314 | }; 315 | goog.inherits(apphosting.SendMessageRequest, goog.proto2.Message); 316 | 317 | 318 | /** 319 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 320 | * @return {!apphosting.SendMessageRequest} The cloned message. 321 | * @override 322 | */ 323 | apphosting.SendMessageRequest.prototype.clone; 324 | 325 | 326 | /** 327 | * Gets the value of the application_key field. 328 | * @return {?string} The value. 329 | */ 330 | apphosting.SendMessageRequest.prototype.getApplicationKey = function() { 331 | return /** @type {?string} */ (this.get$Value(1)); 332 | }; 333 | 334 | 335 | /** 336 | * Gets the value of the application_key field or the default value if not set. 337 | * @return {string} The value. 338 | */ 339 | apphosting.SendMessageRequest.prototype.getApplicationKeyOrDefault = function() { 340 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 341 | }; 342 | 343 | 344 | /** 345 | * Sets the value of the application_key field. 346 | * @param {string} value The value. 347 | */ 348 | apphosting.SendMessageRequest.prototype.setApplicationKey = function(value) { 349 | this.set$Value(1, value); 350 | }; 351 | 352 | 353 | /** 354 | * @return {boolean} Whether the application_key field has a value. 355 | */ 356 | apphosting.SendMessageRequest.prototype.hasApplicationKey = function() { 357 | return this.has$Value(1); 358 | }; 359 | 360 | 361 | /** 362 | * @return {number} The number of values in the application_key field. 363 | */ 364 | apphosting.SendMessageRequest.prototype.applicationKeyCount = function() { 365 | return this.count$Values(1); 366 | }; 367 | 368 | 369 | /** 370 | * Clears the values in the application_key field. 371 | */ 372 | apphosting.SendMessageRequest.prototype.clearApplicationKey = function() { 373 | this.clear$Field(1); 374 | }; 375 | 376 | 377 | /** 378 | * Gets the value of the message field. 379 | * @return {?string} The value. 380 | */ 381 | apphosting.SendMessageRequest.prototype.getMessage = function() { 382 | return /** @type {?string} */ (this.get$Value(2)); 383 | }; 384 | 385 | 386 | /** 387 | * Gets the value of the message field or the default value if not set. 388 | * @return {string} The value. 389 | */ 390 | apphosting.SendMessageRequest.prototype.getMessageOrDefault = function() { 391 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 392 | }; 393 | 394 | 395 | /** 396 | * Sets the value of the message field. 397 | * @param {string} value The value. 398 | */ 399 | apphosting.SendMessageRequest.prototype.setMessage = function(value) { 400 | this.set$Value(2, value); 401 | }; 402 | 403 | 404 | /** 405 | * @return {boolean} Whether the message field has a value. 406 | */ 407 | apphosting.SendMessageRequest.prototype.hasMessage = function() { 408 | return this.has$Value(2); 409 | }; 410 | 411 | 412 | /** 413 | * @return {number} The number of values in the message field. 414 | */ 415 | apphosting.SendMessageRequest.prototype.messageCount = function() { 416 | return this.count$Values(2); 417 | }; 418 | 419 | 420 | /** 421 | * Clears the values in the message field. 422 | */ 423 | apphosting.SendMessageRequest.prototype.clearMessage = function() { 424 | this.clear$Field(2); 425 | }; 426 | 427 | 428 | goog.proto2.Message.set$Metadata(apphosting.ChannelServiceError, { 429 | 0: { 430 | name: 'ChannelServiceError', 431 | fullName: 'apphosting.ChannelServiceError' 432 | } 433 | }); 434 | 435 | 436 | goog.proto2.Message.set$Metadata(apphosting.CreateChannelRequest, { 437 | 0: { 438 | name: 'CreateChannelRequest', 439 | fullName: 'apphosting.CreateChannelRequest' 440 | }, 441 | 1: { 442 | name: 'application_key', 443 | required: true, 444 | fieldType: goog.proto2.Message.FieldType.STRING, 445 | type: String 446 | }, 447 | 2: { 448 | name: 'duration_minutes', 449 | fieldType: goog.proto2.Message.FieldType.INT32, 450 | type: Number 451 | } 452 | }); 453 | 454 | 455 | goog.proto2.Message.set$Metadata(apphosting.CreateChannelResponse, { 456 | 0: { 457 | name: 'CreateChannelResponse', 458 | fullName: 'apphosting.CreateChannelResponse' 459 | }, 460 | 2: { 461 | name: 'token', 462 | fieldType: goog.proto2.Message.FieldType.STRING, 463 | type: String 464 | }, 465 | 3: { 466 | name: 'duration_minutes', 467 | fieldType: goog.proto2.Message.FieldType.INT32, 468 | type: Number 469 | } 470 | }); 471 | 472 | 473 | goog.proto2.Message.set$Metadata(apphosting.SendMessageRequest, { 474 | 0: { 475 | name: 'SendMessageRequest', 476 | fullName: 'apphosting.SendMessageRequest' 477 | }, 478 | 1: { 479 | name: 'application_key', 480 | required: true, 481 | fieldType: goog.proto2.Message.FieldType.STRING, 482 | type: String 483 | }, 484 | 2: { 485 | name: 'message', 486 | required: true, 487 | fieldType: goog.proto2.Message.FieldType.STRING, 488 | type: String 489 | } 490 | }); 491 | -------------------------------------------------------------------------------- /lib/apphosting/api/system/system_service.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.SystemServiceError'); 20 | goog.provide('apphosting.SystemServiceError.ErrorCode'); 21 | goog.provide('apphosting.SystemStat'); 22 | goog.provide('apphosting.GetSystemStatsRequest'); 23 | goog.provide('apphosting.GetSystemStatsResponse'); 24 | goog.provide('apphosting.StartBackgroundRequestRequest'); 25 | goog.provide('apphosting.StartBackgroundRequestResponse'); 26 | 27 | goog.require('goog.proto2.Message'); 28 | 29 | 30 | 31 | /** 32 | * Message SystemServiceError. 33 | * @constructor 34 | * @extends {goog.proto2.Message} 35 | */ 36 | apphosting.SystemServiceError = function() { 37 | goog.proto2.Message.apply(this); 38 | }; 39 | goog.inherits(apphosting.SystemServiceError, goog.proto2.Message); 40 | 41 | 42 | /** 43 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 44 | * @return {!apphosting.SystemServiceError} The cloned message. 45 | * @override 46 | */ 47 | apphosting.SystemServiceError.prototype.clone; 48 | 49 | 50 | /** 51 | * Enumeration ErrorCode. 52 | * @enum {number} 53 | */ 54 | apphosting.SystemServiceError.ErrorCode = { 55 | OK: 0, 56 | INTERNAL_ERROR: 1, 57 | BACKEND_REQUIRED: 2, 58 | LIMIT_REACHED: 3 59 | }; 60 | 61 | 62 | 63 | /** 64 | * Message SystemStat. 65 | * @constructor 66 | * @extends {goog.proto2.Message} 67 | */ 68 | apphosting.SystemStat = function() { 69 | goog.proto2.Message.apply(this); 70 | }; 71 | goog.inherits(apphosting.SystemStat, goog.proto2.Message); 72 | 73 | 74 | /** 75 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 76 | * @return {!apphosting.SystemStat} The cloned message. 77 | * @override 78 | */ 79 | apphosting.SystemStat.prototype.clone; 80 | 81 | 82 | /** 83 | * Gets the value of the current field. 84 | * @return {?number} The value. 85 | */ 86 | apphosting.SystemStat.prototype.getCurrent = function() { 87 | return /** @type {?number} */ (this.get$Value(1)); 88 | }; 89 | 90 | 91 | /** 92 | * Gets the value of the current field or the default value if not set. 93 | * @return {number} The value. 94 | */ 95 | apphosting.SystemStat.prototype.getCurrentOrDefault = function() { 96 | return /** @type {number} */ (this.get$ValueOrDefault(1)); 97 | }; 98 | 99 | 100 | /** 101 | * Sets the value of the current field. 102 | * @param {number} value The value. 103 | */ 104 | apphosting.SystemStat.prototype.setCurrent = function(value) { 105 | this.set$Value(1, value); 106 | }; 107 | 108 | 109 | /** 110 | * @return {boolean} Whether the current field has a value. 111 | */ 112 | apphosting.SystemStat.prototype.hasCurrent = function() { 113 | return this.has$Value(1); 114 | }; 115 | 116 | 117 | /** 118 | * @return {number} The number of values in the current field. 119 | */ 120 | apphosting.SystemStat.prototype.currentCount = function() { 121 | return this.count$Values(1); 122 | }; 123 | 124 | 125 | /** 126 | * Clears the values in the current field. 127 | */ 128 | apphosting.SystemStat.prototype.clearCurrent = function() { 129 | this.clear$Field(1); 130 | }; 131 | 132 | 133 | /** 134 | * Gets the value of the average1m field. 135 | * @return {?number} The value. 136 | */ 137 | apphosting.SystemStat.prototype.getAverage1m = function() { 138 | return /** @type {?number} */ (this.get$Value(3)); 139 | }; 140 | 141 | 142 | /** 143 | * Gets the value of the average1m field or the default value if not set. 144 | * @return {number} The value. 145 | */ 146 | apphosting.SystemStat.prototype.getAverage1mOrDefault = function() { 147 | return /** @type {number} */ (this.get$ValueOrDefault(3)); 148 | }; 149 | 150 | 151 | /** 152 | * Sets the value of the average1m field. 153 | * @param {number} value The value. 154 | */ 155 | apphosting.SystemStat.prototype.setAverage1m = function(value) { 156 | this.set$Value(3, value); 157 | }; 158 | 159 | 160 | /** 161 | * @return {boolean} Whether the average1m field has a value. 162 | */ 163 | apphosting.SystemStat.prototype.hasAverage1m = function() { 164 | return this.has$Value(3); 165 | }; 166 | 167 | 168 | /** 169 | * @return {number} The number of values in the average1m field. 170 | */ 171 | apphosting.SystemStat.prototype.average1mCount = function() { 172 | return this.count$Values(3); 173 | }; 174 | 175 | 176 | /** 177 | * Clears the values in the average1m field. 178 | */ 179 | apphosting.SystemStat.prototype.clearAverage1m = function() { 180 | this.clear$Field(3); 181 | }; 182 | 183 | 184 | /** 185 | * Gets the value of the average10m field. 186 | * @return {?number} The value. 187 | */ 188 | apphosting.SystemStat.prototype.getAverage10m = function() { 189 | return /** @type {?number} */ (this.get$Value(4)); 190 | }; 191 | 192 | 193 | /** 194 | * Gets the value of the average10m field or the default value if not set. 195 | * @return {number} The value. 196 | */ 197 | apphosting.SystemStat.prototype.getAverage10mOrDefault = function() { 198 | return /** @type {number} */ (this.get$ValueOrDefault(4)); 199 | }; 200 | 201 | 202 | /** 203 | * Sets the value of the average10m field. 204 | * @param {number} value The value. 205 | */ 206 | apphosting.SystemStat.prototype.setAverage10m = function(value) { 207 | this.set$Value(4, value); 208 | }; 209 | 210 | 211 | /** 212 | * @return {boolean} Whether the average10m field has a value. 213 | */ 214 | apphosting.SystemStat.prototype.hasAverage10m = function() { 215 | return this.has$Value(4); 216 | }; 217 | 218 | 219 | /** 220 | * @return {number} The number of values in the average10m field. 221 | */ 222 | apphosting.SystemStat.prototype.average10mCount = function() { 223 | return this.count$Values(4); 224 | }; 225 | 226 | 227 | /** 228 | * Clears the values in the average10m field. 229 | */ 230 | apphosting.SystemStat.prototype.clearAverage10m = function() { 231 | this.clear$Field(4); 232 | }; 233 | 234 | 235 | /** 236 | * Gets the value of the total field. 237 | * @return {?number} The value. 238 | */ 239 | apphosting.SystemStat.prototype.getTotal = function() { 240 | return /** @type {?number} */ (this.get$Value(2)); 241 | }; 242 | 243 | 244 | /** 245 | * Gets the value of the total field or the default value if not set. 246 | * @return {number} The value. 247 | */ 248 | apphosting.SystemStat.prototype.getTotalOrDefault = function() { 249 | return /** @type {number} */ (this.get$ValueOrDefault(2)); 250 | }; 251 | 252 | 253 | /** 254 | * Sets the value of the total field. 255 | * @param {number} value The value. 256 | */ 257 | apphosting.SystemStat.prototype.setTotal = function(value) { 258 | this.set$Value(2, value); 259 | }; 260 | 261 | 262 | /** 263 | * @return {boolean} Whether the total field has a value. 264 | */ 265 | apphosting.SystemStat.prototype.hasTotal = function() { 266 | return this.has$Value(2); 267 | }; 268 | 269 | 270 | /** 271 | * @return {number} The number of values in the total field. 272 | */ 273 | apphosting.SystemStat.prototype.totalCount = function() { 274 | return this.count$Values(2); 275 | }; 276 | 277 | 278 | /** 279 | * Clears the values in the total field. 280 | */ 281 | apphosting.SystemStat.prototype.clearTotal = function() { 282 | this.clear$Field(2); 283 | }; 284 | 285 | 286 | /** 287 | * Gets the value of the rate1m field. 288 | * @return {?number} The value. 289 | */ 290 | apphosting.SystemStat.prototype.getRate1m = function() { 291 | return /** @type {?number} */ (this.get$Value(5)); 292 | }; 293 | 294 | 295 | /** 296 | * Gets the value of the rate1m field or the default value if not set. 297 | * @return {number} The value. 298 | */ 299 | apphosting.SystemStat.prototype.getRate1mOrDefault = function() { 300 | return /** @type {number} */ (this.get$ValueOrDefault(5)); 301 | }; 302 | 303 | 304 | /** 305 | * Sets the value of the rate1m field. 306 | * @param {number} value The value. 307 | */ 308 | apphosting.SystemStat.prototype.setRate1m = function(value) { 309 | this.set$Value(5, value); 310 | }; 311 | 312 | 313 | /** 314 | * @return {boolean} Whether the rate1m field has a value. 315 | */ 316 | apphosting.SystemStat.prototype.hasRate1m = function() { 317 | return this.has$Value(5); 318 | }; 319 | 320 | 321 | /** 322 | * @return {number} The number of values in the rate1m field. 323 | */ 324 | apphosting.SystemStat.prototype.rate1mCount = function() { 325 | return this.count$Values(5); 326 | }; 327 | 328 | 329 | /** 330 | * Clears the values in the rate1m field. 331 | */ 332 | apphosting.SystemStat.prototype.clearRate1m = function() { 333 | this.clear$Field(5); 334 | }; 335 | 336 | 337 | /** 338 | * Gets the value of the rate10m field. 339 | * @return {?number} The value. 340 | */ 341 | apphosting.SystemStat.prototype.getRate10m = function() { 342 | return /** @type {?number} */ (this.get$Value(6)); 343 | }; 344 | 345 | 346 | /** 347 | * Gets the value of the rate10m field or the default value if not set. 348 | * @return {number} The value. 349 | */ 350 | apphosting.SystemStat.prototype.getRate10mOrDefault = function() { 351 | return /** @type {number} */ (this.get$ValueOrDefault(6)); 352 | }; 353 | 354 | 355 | /** 356 | * Sets the value of the rate10m field. 357 | * @param {number} value The value. 358 | */ 359 | apphosting.SystemStat.prototype.setRate10m = function(value) { 360 | this.set$Value(6, value); 361 | }; 362 | 363 | 364 | /** 365 | * @return {boolean} Whether the rate10m field has a value. 366 | */ 367 | apphosting.SystemStat.prototype.hasRate10m = function() { 368 | return this.has$Value(6); 369 | }; 370 | 371 | 372 | /** 373 | * @return {number} The number of values in the rate10m field. 374 | */ 375 | apphosting.SystemStat.prototype.rate10mCount = function() { 376 | return this.count$Values(6); 377 | }; 378 | 379 | 380 | /** 381 | * Clears the values in the rate10m field. 382 | */ 383 | apphosting.SystemStat.prototype.clearRate10m = function() { 384 | this.clear$Field(6); 385 | }; 386 | 387 | 388 | 389 | /** 390 | * Message GetSystemStatsRequest. 391 | * @constructor 392 | * @extends {goog.proto2.Message} 393 | */ 394 | apphosting.GetSystemStatsRequest = function() { 395 | goog.proto2.Message.apply(this); 396 | }; 397 | goog.inherits(apphosting.GetSystemStatsRequest, goog.proto2.Message); 398 | 399 | 400 | /** 401 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 402 | * @return {!apphosting.GetSystemStatsRequest} The cloned message. 403 | * @override 404 | */ 405 | apphosting.GetSystemStatsRequest.prototype.clone; 406 | 407 | 408 | 409 | /** 410 | * Message GetSystemStatsResponse. 411 | * @constructor 412 | * @extends {goog.proto2.Message} 413 | */ 414 | apphosting.GetSystemStatsResponse = function() { 415 | goog.proto2.Message.apply(this); 416 | }; 417 | goog.inherits(apphosting.GetSystemStatsResponse, goog.proto2.Message); 418 | 419 | 420 | /** 421 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 422 | * @return {!apphosting.GetSystemStatsResponse} The cloned message. 423 | * @override 424 | */ 425 | apphosting.GetSystemStatsResponse.prototype.clone; 426 | 427 | 428 | /** 429 | * Gets the value of the cpu field. 430 | * @return {apphosting.SystemStat} The value. 431 | */ 432 | apphosting.GetSystemStatsResponse.prototype.getCpu = function() { 433 | return /** @type {apphosting.SystemStat} */ (this.get$Value(1)); 434 | }; 435 | 436 | 437 | /** 438 | * Gets the value of the cpu field or the default value if not set. 439 | * @return {!apphosting.SystemStat} The value. 440 | */ 441 | apphosting.GetSystemStatsResponse.prototype.getCpuOrDefault = function() { 442 | return /** @type {!apphosting.SystemStat} */ (this.get$ValueOrDefault(1)); 443 | }; 444 | 445 | 446 | /** 447 | * Sets the value of the cpu field. 448 | * @param {!apphosting.SystemStat} value The value. 449 | */ 450 | apphosting.GetSystemStatsResponse.prototype.setCpu = function(value) { 451 | this.set$Value(1, value); 452 | }; 453 | 454 | 455 | /** 456 | * @return {boolean} Whether the cpu field has a value. 457 | */ 458 | apphosting.GetSystemStatsResponse.prototype.hasCpu = function() { 459 | return this.has$Value(1); 460 | }; 461 | 462 | 463 | /** 464 | * @return {number} The number of values in the cpu field. 465 | */ 466 | apphosting.GetSystemStatsResponse.prototype.cpuCount = function() { 467 | return this.count$Values(1); 468 | }; 469 | 470 | 471 | /** 472 | * Clears the values in the cpu field. 473 | */ 474 | apphosting.GetSystemStatsResponse.prototype.clearCpu = function() { 475 | this.clear$Field(1); 476 | }; 477 | 478 | 479 | /** 480 | * Gets the value of the memory field. 481 | * @return {apphosting.SystemStat} The value. 482 | */ 483 | apphosting.GetSystemStatsResponse.prototype.getMemory = function() { 484 | return /** @type {apphosting.SystemStat} */ (this.get$Value(2)); 485 | }; 486 | 487 | 488 | /** 489 | * Gets the value of the memory field or the default value if not set. 490 | * @return {!apphosting.SystemStat} The value. 491 | */ 492 | apphosting.GetSystemStatsResponse.prototype.getMemoryOrDefault = function() { 493 | return /** @type {!apphosting.SystemStat} */ (this.get$ValueOrDefault(2)); 494 | }; 495 | 496 | 497 | /** 498 | * Sets the value of the memory field. 499 | * @param {!apphosting.SystemStat} value The value. 500 | */ 501 | apphosting.GetSystemStatsResponse.prototype.setMemory = function(value) { 502 | this.set$Value(2, value); 503 | }; 504 | 505 | 506 | /** 507 | * @return {boolean} Whether the memory field has a value. 508 | */ 509 | apphosting.GetSystemStatsResponse.prototype.hasMemory = function() { 510 | return this.has$Value(2); 511 | }; 512 | 513 | 514 | /** 515 | * @return {number} The number of values in the memory field. 516 | */ 517 | apphosting.GetSystemStatsResponse.prototype.memoryCount = function() { 518 | return this.count$Values(2); 519 | }; 520 | 521 | 522 | /** 523 | * Clears the values in the memory field. 524 | */ 525 | apphosting.GetSystemStatsResponse.prototype.clearMemory = function() { 526 | this.clear$Field(2); 527 | }; 528 | 529 | 530 | 531 | /** 532 | * Message StartBackgroundRequestRequest. 533 | * @constructor 534 | * @extends {goog.proto2.Message} 535 | */ 536 | apphosting.StartBackgroundRequestRequest = function() { 537 | goog.proto2.Message.apply(this); 538 | }; 539 | goog.inherits(apphosting.StartBackgroundRequestRequest, goog.proto2.Message); 540 | 541 | 542 | /** 543 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 544 | * @return {!apphosting.StartBackgroundRequestRequest} The cloned message. 545 | * @override 546 | */ 547 | apphosting.StartBackgroundRequestRequest.prototype.clone; 548 | 549 | 550 | 551 | /** 552 | * Message StartBackgroundRequestResponse. 553 | * @constructor 554 | * @extends {goog.proto2.Message} 555 | */ 556 | apphosting.StartBackgroundRequestResponse = function() { 557 | goog.proto2.Message.apply(this); 558 | }; 559 | goog.inherits(apphosting.StartBackgroundRequestResponse, goog.proto2.Message); 560 | 561 | 562 | /** 563 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 564 | * @return {!apphosting.StartBackgroundRequestResponse} The cloned message. 565 | * @override 566 | */ 567 | apphosting.StartBackgroundRequestResponse.prototype.clone; 568 | 569 | 570 | /** 571 | * Gets the value of the request_id field. 572 | * @return {?string} The value. 573 | */ 574 | apphosting.StartBackgroundRequestResponse.prototype.getRequestId = function() { 575 | return /** @type {?string} */ (this.get$Value(1)); 576 | }; 577 | 578 | 579 | /** 580 | * Gets the value of the request_id field or the default value if not set. 581 | * @return {string} The value. 582 | */ 583 | apphosting.StartBackgroundRequestResponse.prototype.getRequestIdOrDefault = function() { 584 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 585 | }; 586 | 587 | 588 | /** 589 | * Sets the value of the request_id field. 590 | * @param {string} value The value. 591 | */ 592 | apphosting.StartBackgroundRequestResponse.prototype.setRequestId = function(value) { 593 | this.set$Value(1, value); 594 | }; 595 | 596 | 597 | /** 598 | * @return {boolean} Whether the request_id field has a value. 599 | */ 600 | apphosting.StartBackgroundRequestResponse.prototype.hasRequestId = function() { 601 | return this.has$Value(1); 602 | }; 603 | 604 | 605 | /** 606 | * @return {number} The number of values in the request_id field. 607 | */ 608 | apphosting.StartBackgroundRequestResponse.prototype.requestIdCount = function() { 609 | return this.count$Values(1); 610 | }; 611 | 612 | 613 | /** 614 | * Clears the values in the request_id field. 615 | */ 616 | apphosting.StartBackgroundRequestResponse.prototype.clearRequestId = function() { 617 | this.clear$Field(1); 618 | }; 619 | 620 | 621 | goog.proto2.Message.set$Metadata(apphosting.SystemServiceError, { 622 | 0: { 623 | name: 'SystemServiceError', 624 | fullName: 'apphosting.SystemServiceError' 625 | } 626 | }); 627 | 628 | 629 | goog.proto2.Message.set$Metadata(apphosting.SystemStat, { 630 | 0: { 631 | name: 'SystemStat', 632 | fullName: 'apphosting.SystemStat' 633 | }, 634 | 1: { 635 | name: 'current', 636 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 637 | type: Number 638 | }, 639 | 3: { 640 | name: 'average1m', 641 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 642 | type: Number 643 | }, 644 | 4: { 645 | name: 'average10m', 646 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 647 | type: Number 648 | }, 649 | 2: { 650 | name: 'total', 651 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 652 | type: Number 653 | }, 654 | 5: { 655 | name: 'rate1m', 656 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 657 | type: Number 658 | }, 659 | 6: { 660 | name: 'rate10m', 661 | fieldType: goog.proto2.Message.FieldType.DOUBLE, 662 | type: Number 663 | } 664 | }); 665 | 666 | 667 | goog.proto2.Message.set$Metadata(apphosting.GetSystemStatsRequest, { 668 | 0: { 669 | name: 'GetSystemStatsRequest', 670 | fullName: 'apphosting.GetSystemStatsRequest' 671 | } 672 | }); 673 | 674 | 675 | goog.proto2.Message.set$Metadata(apphosting.GetSystemStatsResponse, { 676 | 0: { 677 | name: 'GetSystemStatsResponse', 678 | fullName: 'apphosting.GetSystemStatsResponse' 679 | }, 680 | 1: { 681 | name: 'cpu', 682 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 683 | type: apphosting.SystemStat 684 | }, 685 | 2: { 686 | name: 'memory', 687 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 688 | type: apphosting.SystemStat 689 | } 690 | }); 691 | 692 | 693 | goog.proto2.Message.set$Metadata(apphosting.StartBackgroundRequestRequest, { 694 | 0: { 695 | name: 'StartBackgroundRequestRequest', 696 | fullName: 'apphosting.StartBackgroundRequestRequest' 697 | } 698 | }); 699 | 700 | 701 | goog.proto2.Message.set$Metadata(apphosting.StartBackgroundRequestResponse, { 702 | 0: { 703 | name: 'StartBackgroundRequestResponse', 704 | fullName: 'apphosting.StartBackgroundRequestResponse' 705 | }, 706 | 1: { 707 | name: 'request_id', 708 | fieldType: goog.proto2.Message.FieldType.STRING, 709 | type: String 710 | } 711 | }); 712 | -------------------------------------------------------------------------------- /lib/apphosting/base/capabilities.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.CapabilityConfigList'); 20 | goog.provide('apphosting.CapabilityConfig'); 21 | goog.provide('apphosting.CapabilityConfig.Status'); 22 | 23 | goog.require('goog.proto2.Message'); 24 | 25 | 26 | 27 | /** 28 | * Message CapabilityConfigList. 29 | * @constructor 30 | * @extends {goog.proto2.Message} 31 | */ 32 | apphosting.CapabilityConfigList = function() { 33 | goog.proto2.Message.apply(this); 34 | }; 35 | goog.inherits(apphosting.CapabilityConfigList, goog.proto2.Message); 36 | 37 | 38 | /** 39 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 40 | * @return {!apphosting.CapabilityConfigList} The cloned message. 41 | * @override 42 | */ 43 | apphosting.CapabilityConfigList.prototype.clone; 44 | 45 | 46 | /** 47 | * Gets the value of the config field at the index given. 48 | * @param {number} index The index to lookup. 49 | * @return {apphosting.CapabilityConfig} The value. 50 | */ 51 | apphosting.CapabilityConfigList.prototype.getConfig = function(index) { 52 | return /** @type {apphosting.CapabilityConfig} */ (this.get$Value(1, index)); 53 | }; 54 | 55 | 56 | /** 57 | * Gets the value of the config field at the index given or the default value if not set. 58 | * @param {number} index The index to lookup. 59 | * @return {!apphosting.CapabilityConfig} The value. 60 | */ 61 | apphosting.CapabilityConfigList.prototype.getConfigOrDefault = function(index) { 62 | return /** @type {!apphosting.CapabilityConfig} */ (this.get$ValueOrDefault(1, index)); 63 | }; 64 | 65 | 66 | /** 67 | * Adds a value to the config field. 68 | * @param {!apphosting.CapabilityConfig} value The value to add. 69 | */ 70 | apphosting.CapabilityConfigList.prototype.addConfig = function(value) { 71 | this.add$Value(1, value); 72 | }; 73 | 74 | 75 | /** 76 | * Returns the array of values in the config field. 77 | * @return {!Array.} The values in the field. 78 | */ 79 | apphosting.CapabilityConfigList.prototype.configArray = function() { 80 | return /** @type {!Array.} */ (this.array$Values(1)); 81 | }; 82 | 83 | 84 | /** 85 | * @return {boolean} Whether the config field has a value. 86 | */ 87 | apphosting.CapabilityConfigList.prototype.hasConfig = function() { 88 | return this.has$Value(1); 89 | }; 90 | 91 | 92 | /** 93 | * @return {number} The number of values in the config field. 94 | */ 95 | apphosting.CapabilityConfigList.prototype.configCount = function() { 96 | return this.count$Values(1); 97 | }; 98 | 99 | 100 | /** 101 | * Clears the values in the config field. 102 | */ 103 | apphosting.CapabilityConfigList.prototype.clearConfig = function() { 104 | this.clear$Field(1); 105 | }; 106 | 107 | 108 | /** 109 | * Gets the value of the default_config field. 110 | * @return {apphosting.CapabilityConfig} The value. 111 | */ 112 | apphosting.CapabilityConfigList.prototype.getDefaultConfig = function() { 113 | return /** @type {apphosting.CapabilityConfig} */ (this.get$Value(2)); 114 | }; 115 | 116 | 117 | /** 118 | * Gets the value of the default_config field or the default value if not set. 119 | * @return {!apphosting.CapabilityConfig} The value. 120 | */ 121 | apphosting.CapabilityConfigList.prototype.getDefaultConfigOrDefault = function() { 122 | return /** @type {!apphosting.CapabilityConfig} */ (this.get$ValueOrDefault(2)); 123 | }; 124 | 125 | 126 | /** 127 | * Sets the value of the default_config field. 128 | * @param {!apphosting.CapabilityConfig} value The value. 129 | */ 130 | apphosting.CapabilityConfigList.prototype.setDefaultConfig = function(value) { 131 | this.set$Value(2, value); 132 | }; 133 | 134 | 135 | /** 136 | * @return {boolean} Whether the default_config field has a value. 137 | */ 138 | apphosting.CapabilityConfigList.prototype.hasDefaultConfig = function() { 139 | return this.has$Value(2); 140 | }; 141 | 142 | 143 | /** 144 | * @return {number} The number of values in the default_config field. 145 | */ 146 | apphosting.CapabilityConfigList.prototype.defaultConfigCount = function() { 147 | return this.count$Values(2); 148 | }; 149 | 150 | 151 | /** 152 | * Clears the values in the default_config field. 153 | */ 154 | apphosting.CapabilityConfigList.prototype.clearDefaultConfig = function() { 155 | this.clear$Field(2); 156 | }; 157 | 158 | 159 | 160 | /** 161 | * Message CapabilityConfig. 162 | * @constructor 163 | * @extends {goog.proto2.Message} 164 | */ 165 | apphosting.CapabilityConfig = function() { 166 | goog.proto2.Message.apply(this); 167 | }; 168 | goog.inherits(apphosting.CapabilityConfig, goog.proto2.Message); 169 | 170 | 171 | /** 172 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 173 | * @return {!apphosting.CapabilityConfig} The cloned message. 174 | * @override 175 | */ 176 | apphosting.CapabilityConfig.prototype.clone; 177 | 178 | 179 | /** 180 | * Gets the value of the package field. 181 | * @return {?string} The value. 182 | */ 183 | apphosting.CapabilityConfig.prototype.getPackage = function() { 184 | return /** @type {?string} */ (this.get$Value(1)); 185 | }; 186 | 187 | 188 | /** 189 | * Gets the value of the package field or the default value if not set. 190 | * @return {string} The value. 191 | */ 192 | apphosting.CapabilityConfig.prototype.getPackageOrDefault = function() { 193 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 194 | }; 195 | 196 | 197 | /** 198 | * Sets the value of the package field. 199 | * @param {string} value The value. 200 | */ 201 | apphosting.CapabilityConfig.prototype.setPackage = function(value) { 202 | this.set$Value(1, value); 203 | }; 204 | 205 | 206 | /** 207 | * @return {boolean} Whether the package field has a value. 208 | */ 209 | apphosting.CapabilityConfig.prototype.hasPackage = function() { 210 | return this.has$Value(1); 211 | }; 212 | 213 | 214 | /** 215 | * @return {number} The number of values in the package field. 216 | */ 217 | apphosting.CapabilityConfig.prototype.packageCount = function() { 218 | return this.count$Values(1); 219 | }; 220 | 221 | 222 | /** 223 | * Clears the values in the package field. 224 | */ 225 | apphosting.CapabilityConfig.prototype.clearPackage = function() { 226 | this.clear$Field(1); 227 | }; 228 | 229 | 230 | /** 231 | * Gets the value of the capability field. 232 | * @return {?string} The value. 233 | */ 234 | apphosting.CapabilityConfig.prototype.getCapability = function() { 235 | return /** @type {?string} */ (this.get$Value(2)); 236 | }; 237 | 238 | 239 | /** 240 | * Gets the value of the capability field or the default value if not set. 241 | * @return {string} The value. 242 | */ 243 | apphosting.CapabilityConfig.prototype.getCapabilityOrDefault = function() { 244 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 245 | }; 246 | 247 | 248 | /** 249 | * Sets the value of the capability field. 250 | * @param {string} value The value. 251 | */ 252 | apphosting.CapabilityConfig.prototype.setCapability = function(value) { 253 | this.set$Value(2, value); 254 | }; 255 | 256 | 257 | /** 258 | * @return {boolean} Whether the capability field has a value. 259 | */ 260 | apphosting.CapabilityConfig.prototype.hasCapability = function() { 261 | return this.has$Value(2); 262 | }; 263 | 264 | 265 | /** 266 | * @return {number} The number of values in the capability field. 267 | */ 268 | apphosting.CapabilityConfig.prototype.capabilityCount = function() { 269 | return this.count$Values(2); 270 | }; 271 | 272 | 273 | /** 274 | * Clears the values in the capability field. 275 | */ 276 | apphosting.CapabilityConfig.prototype.clearCapability = function() { 277 | this.clear$Field(2); 278 | }; 279 | 280 | 281 | /** 282 | * Gets the value of the status field. 283 | * @return {?apphosting.CapabilityConfig.Status} The value. 284 | */ 285 | apphosting.CapabilityConfig.prototype.getStatus = function() { 286 | return /** @type {?apphosting.CapabilityConfig.Status} */ (this.get$Value(3)); 287 | }; 288 | 289 | 290 | /** 291 | * Gets the value of the status field or the default value if not set. 292 | * @return {apphosting.CapabilityConfig.Status} The value. 293 | */ 294 | apphosting.CapabilityConfig.prototype.getStatusOrDefault = function() { 295 | return /** @type {apphosting.CapabilityConfig.Status} */ (this.get$ValueOrDefault(3)); 296 | }; 297 | 298 | 299 | /** 300 | * Sets the value of the status field. 301 | * @param {apphosting.CapabilityConfig.Status} value The value. 302 | */ 303 | apphosting.CapabilityConfig.prototype.setStatus = function(value) { 304 | this.set$Value(3, value); 305 | }; 306 | 307 | 308 | /** 309 | * @return {boolean} Whether the status field has a value. 310 | */ 311 | apphosting.CapabilityConfig.prototype.hasStatus = function() { 312 | return this.has$Value(3); 313 | }; 314 | 315 | 316 | /** 317 | * @return {number} The number of values in the status field. 318 | */ 319 | apphosting.CapabilityConfig.prototype.statusCount = function() { 320 | return this.count$Values(3); 321 | }; 322 | 323 | 324 | /** 325 | * Clears the values in the status field. 326 | */ 327 | apphosting.CapabilityConfig.prototype.clearStatus = function() { 328 | this.clear$Field(3); 329 | }; 330 | 331 | 332 | /** 333 | * Gets the value of the scheduled_time field. 334 | * @return {?string} The value. 335 | */ 336 | apphosting.CapabilityConfig.prototype.getScheduledTime = function() { 337 | return /** @type {?string} */ (this.get$Value(7)); 338 | }; 339 | 340 | 341 | /** 342 | * Gets the value of the scheduled_time field or the default value if not set. 343 | * @return {string} The value. 344 | */ 345 | apphosting.CapabilityConfig.prototype.getScheduledTimeOrDefault = function() { 346 | return /** @type {string} */ (this.get$ValueOrDefault(7)); 347 | }; 348 | 349 | 350 | /** 351 | * Sets the value of the scheduled_time field. 352 | * @param {string} value The value. 353 | */ 354 | apphosting.CapabilityConfig.prototype.setScheduledTime = function(value) { 355 | this.set$Value(7, value); 356 | }; 357 | 358 | 359 | /** 360 | * @return {boolean} Whether the scheduled_time field has a value. 361 | */ 362 | apphosting.CapabilityConfig.prototype.hasScheduledTime = function() { 363 | return this.has$Value(7); 364 | }; 365 | 366 | 367 | /** 368 | * @return {number} The number of values in the scheduled_time field. 369 | */ 370 | apphosting.CapabilityConfig.prototype.scheduledTimeCount = function() { 371 | return this.count$Values(7); 372 | }; 373 | 374 | 375 | /** 376 | * Clears the values in the scheduled_time field. 377 | */ 378 | apphosting.CapabilityConfig.prototype.clearScheduledTime = function() { 379 | this.clear$Field(7); 380 | }; 381 | 382 | 383 | /** 384 | * Gets the value of the internal_message field. 385 | * @return {?string} The value. 386 | */ 387 | apphosting.CapabilityConfig.prototype.getInternalMessage = function() { 388 | return /** @type {?string} */ (this.get$Value(4)); 389 | }; 390 | 391 | 392 | /** 393 | * Gets the value of the internal_message field or the default value if not set. 394 | * @return {string} The value. 395 | */ 396 | apphosting.CapabilityConfig.prototype.getInternalMessageOrDefault = function() { 397 | return /** @type {string} */ (this.get$ValueOrDefault(4)); 398 | }; 399 | 400 | 401 | /** 402 | * Sets the value of the internal_message field. 403 | * @param {string} value The value. 404 | */ 405 | apphosting.CapabilityConfig.prototype.setInternalMessage = function(value) { 406 | this.set$Value(4, value); 407 | }; 408 | 409 | 410 | /** 411 | * @return {boolean} Whether the internal_message field has a value. 412 | */ 413 | apphosting.CapabilityConfig.prototype.hasInternalMessage = function() { 414 | return this.has$Value(4); 415 | }; 416 | 417 | 418 | /** 419 | * @return {number} The number of values in the internal_message field. 420 | */ 421 | apphosting.CapabilityConfig.prototype.internalMessageCount = function() { 422 | return this.count$Values(4); 423 | }; 424 | 425 | 426 | /** 427 | * Clears the values in the internal_message field. 428 | */ 429 | apphosting.CapabilityConfig.prototype.clearInternalMessage = function() { 430 | this.clear$Field(4); 431 | }; 432 | 433 | 434 | /** 435 | * Gets the value of the admin_message field. 436 | * @return {?string} The value. 437 | */ 438 | apphosting.CapabilityConfig.prototype.getAdminMessage = function() { 439 | return /** @type {?string} */ (this.get$Value(5)); 440 | }; 441 | 442 | 443 | /** 444 | * Gets the value of the admin_message field or the default value if not set. 445 | * @return {string} The value. 446 | */ 447 | apphosting.CapabilityConfig.prototype.getAdminMessageOrDefault = function() { 448 | return /** @type {string} */ (this.get$ValueOrDefault(5)); 449 | }; 450 | 451 | 452 | /** 453 | * Sets the value of the admin_message field. 454 | * @param {string} value The value. 455 | */ 456 | apphosting.CapabilityConfig.prototype.setAdminMessage = function(value) { 457 | this.set$Value(5, value); 458 | }; 459 | 460 | 461 | /** 462 | * @return {boolean} Whether the admin_message field has a value. 463 | */ 464 | apphosting.CapabilityConfig.prototype.hasAdminMessage = function() { 465 | return this.has$Value(5); 466 | }; 467 | 468 | 469 | /** 470 | * @return {number} The number of values in the admin_message field. 471 | */ 472 | apphosting.CapabilityConfig.prototype.adminMessageCount = function() { 473 | return this.count$Values(5); 474 | }; 475 | 476 | 477 | /** 478 | * Clears the values in the admin_message field. 479 | */ 480 | apphosting.CapabilityConfig.prototype.clearAdminMessage = function() { 481 | this.clear$Field(5); 482 | }; 483 | 484 | 485 | /** 486 | * Gets the value of the error_message field. 487 | * @return {?string} The value. 488 | */ 489 | apphosting.CapabilityConfig.prototype.getErrorMessage = function() { 490 | return /** @type {?string} */ (this.get$Value(6)); 491 | }; 492 | 493 | 494 | /** 495 | * Gets the value of the error_message field or the default value if not set. 496 | * @return {string} The value. 497 | */ 498 | apphosting.CapabilityConfig.prototype.getErrorMessageOrDefault = function() { 499 | return /** @type {string} */ (this.get$ValueOrDefault(6)); 500 | }; 501 | 502 | 503 | /** 504 | * Sets the value of the error_message field. 505 | * @param {string} value The value. 506 | */ 507 | apphosting.CapabilityConfig.prototype.setErrorMessage = function(value) { 508 | this.set$Value(6, value); 509 | }; 510 | 511 | 512 | /** 513 | * @return {boolean} Whether the error_message field has a value. 514 | */ 515 | apphosting.CapabilityConfig.prototype.hasErrorMessage = function() { 516 | return this.has$Value(6); 517 | }; 518 | 519 | 520 | /** 521 | * @return {number} The number of values in the error_message field. 522 | */ 523 | apphosting.CapabilityConfig.prototype.errorMessageCount = function() { 524 | return this.count$Values(6); 525 | }; 526 | 527 | 528 | /** 529 | * Clears the values in the error_message field. 530 | */ 531 | apphosting.CapabilityConfig.prototype.clearErrorMessage = function() { 532 | this.clear$Field(6); 533 | }; 534 | 535 | 536 | /** 537 | * Enumeration Status. 538 | * @enum {number} 539 | */ 540 | apphosting.CapabilityConfig.Status = { 541 | ENABLED: 1, 542 | SCHEDULED: 2, 543 | DISABLED: 3, 544 | UNKNOWN: 4 545 | }; 546 | 547 | 548 | goog.proto2.Message.set$Metadata(apphosting.CapabilityConfigList, { 549 | 0: { 550 | name: 'CapabilityConfigList', 551 | fullName: 'apphosting.CapabilityConfigList' 552 | }, 553 | 1: { 554 | name: 'config', 555 | repeated: true, 556 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 557 | type: apphosting.CapabilityConfig 558 | }, 559 | 2: { 560 | name: 'default_config', 561 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 562 | type: apphosting.CapabilityConfig 563 | } 564 | }); 565 | 566 | 567 | goog.proto2.Message.set$Metadata(apphosting.CapabilityConfig, { 568 | 0: { 569 | name: 'CapabilityConfig', 570 | fullName: 'apphosting.CapabilityConfig' 571 | }, 572 | 1: { 573 | name: 'package', 574 | required: true, 575 | fieldType: goog.proto2.Message.FieldType.STRING, 576 | type: String 577 | }, 578 | 2: { 579 | name: 'capability', 580 | required: true, 581 | fieldType: goog.proto2.Message.FieldType.STRING, 582 | type: String 583 | }, 584 | 3: { 585 | name: 'status', 586 | fieldType: goog.proto2.Message.FieldType.ENUM, 587 | defaultValue: apphosting.CapabilityConfig.Status.UNKNOWN, 588 | type: apphosting.CapabilityConfig.Status 589 | }, 590 | 7: { 591 | name: 'scheduled_time', 592 | fieldType: goog.proto2.Message.FieldType.STRING, 593 | type: String 594 | }, 595 | 4: { 596 | name: 'internal_message', 597 | fieldType: goog.proto2.Message.FieldType.STRING, 598 | type: String 599 | }, 600 | 5: { 601 | name: 'admin_message', 602 | fieldType: goog.proto2.Message.FieldType.STRING, 603 | type: String 604 | }, 605 | 6: { 606 | name: 'error_message', 607 | fieldType: goog.proto2.Message.FieldType.STRING, 608 | type: String 609 | } 610 | }); 611 | -------------------------------------------------------------------------------- /lib/apphosting/ext/remote_api/remote_api.pb.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Generated Protocol Buffer code. 17 | */ 18 | 19 | goog.provide('apphosting.ext.remote_api.Request'); 20 | goog.provide('apphosting.ext.remote_api.ApplicationError'); 21 | goog.provide('apphosting.ext.remote_api.RpcError'); 22 | goog.provide('apphosting.ext.remote_api.RpcError.ErrorCode'); 23 | goog.provide('apphosting.ext.remote_api.Response'); 24 | 25 | goog.require('goog.proto2.Message'); 26 | 27 | 28 | 29 | /** 30 | * Message Request. 31 | * @constructor 32 | * @extends {goog.proto2.Message} 33 | */ 34 | apphosting.ext.remote_api.Request = function() { 35 | goog.proto2.Message.apply(this); 36 | }; 37 | goog.inherits(apphosting.ext.remote_api.Request, goog.proto2.Message); 38 | 39 | 40 | /** 41 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 42 | * @return {!apphosting.ext.remote_api.Request} The cloned message. 43 | * @override 44 | */ 45 | apphosting.ext.remote_api.Request.prototype.clone; 46 | 47 | 48 | /** 49 | * Gets the value of the service_name field. 50 | * @return {?string} The value. 51 | */ 52 | apphosting.ext.remote_api.Request.prototype.getServiceName = function() { 53 | return /** @type {?string} */ (this.get$Value(2)); 54 | }; 55 | 56 | 57 | /** 58 | * Gets the value of the service_name field or the default value if not set. 59 | * @return {string} The value. 60 | */ 61 | apphosting.ext.remote_api.Request.prototype.getServiceNameOrDefault = function() { 62 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 63 | }; 64 | 65 | 66 | /** 67 | * Sets the value of the service_name field. 68 | * @param {string} value The value. 69 | */ 70 | apphosting.ext.remote_api.Request.prototype.setServiceName = function(value) { 71 | this.set$Value(2, value); 72 | }; 73 | 74 | 75 | /** 76 | * @return {boolean} Whether the service_name field has a value. 77 | */ 78 | apphosting.ext.remote_api.Request.prototype.hasServiceName = function() { 79 | return this.has$Value(2); 80 | }; 81 | 82 | 83 | /** 84 | * @return {number} The number of values in the service_name field. 85 | */ 86 | apphosting.ext.remote_api.Request.prototype.serviceNameCount = function() { 87 | return this.count$Values(2); 88 | }; 89 | 90 | 91 | /** 92 | * Clears the values in the service_name field. 93 | */ 94 | apphosting.ext.remote_api.Request.prototype.clearServiceName = function() { 95 | this.clear$Field(2); 96 | }; 97 | 98 | 99 | /** 100 | * Gets the value of the method field. 101 | * @return {?string} The value. 102 | */ 103 | apphosting.ext.remote_api.Request.prototype.getMethod = function() { 104 | return /** @type {?string} */ (this.get$Value(3)); 105 | }; 106 | 107 | 108 | /** 109 | * Gets the value of the method field or the default value if not set. 110 | * @return {string} The value. 111 | */ 112 | apphosting.ext.remote_api.Request.prototype.getMethodOrDefault = function() { 113 | return /** @type {string} */ (this.get$ValueOrDefault(3)); 114 | }; 115 | 116 | 117 | /** 118 | * Sets the value of the method field. 119 | * @param {string} value The value. 120 | */ 121 | apphosting.ext.remote_api.Request.prototype.setMethod = function(value) { 122 | this.set$Value(3, value); 123 | }; 124 | 125 | 126 | /** 127 | * @return {boolean} Whether the method field has a value. 128 | */ 129 | apphosting.ext.remote_api.Request.prototype.hasMethod = function() { 130 | return this.has$Value(3); 131 | }; 132 | 133 | 134 | /** 135 | * @return {number} The number of values in the method field. 136 | */ 137 | apphosting.ext.remote_api.Request.prototype.methodCount = function() { 138 | return this.count$Values(3); 139 | }; 140 | 141 | 142 | /** 143 | * Clears the values in the method field. 144 | */ 145 | apphosting.ext.remote_api.Request.prototype.clearMethod = function() { 146 | this.clear$Field(3); 147 | }; 148 | 149 | 150 | /** 151 | * Gets the value of the request field. 152 | * @return {?string} The value. 153 | */ 154 | apphosting.ext.remote_api.Request.prototype.getRequest = function() { 155 | return /** @type {?string} */ (this.get$Value(4)); 156 | }; 157 | 158 | 159 | /** 160 | * Gets the value of the request field or the default value if not set. 161 | * @return {string} The value. 162 | */ 163 | apphosting.ext.remote_api.Request.prototype.getRequestOrDefault = function() { 164 | return /** @type {string} */ (this.get$ValueOrDefault(4)); 165 | }; 166 | 167 | 168 | /** 169 | * Sets the value of the request field. 170 | * @param {string} value The value. 171 | */ 172 | apphosting.ext.remote_api.Request.prototype.setRequest = function(value) { 173 | this.set$Value(4, value); 174 | }; 175 | 176 | 177 | /** 178 | * @return {boolean} Whether the request field has a value. 179 | */ 180 | apphosting.ext.remote_api.Request.prototype.hasRequest = function() { 181 | return this.has$Value(4); 182 | }; 183 | 184 | 185 | /** 186 | * @return {number} The number of values in the request field. 187 | */ 188 | apphosting.ext.remote_api.Request.prototype.requestCount = function() { 189 | return this.count$Values(4); 190 | }; 191 | 192 | 193 | /** 194 | * Clears the values in the request field. 195 | */ 196 | apphosting.ext.remote_api.Request.prototype.clearRequest = function() { 197 | this.clear$Field(4); 198 | }; 199 | 200 | 201 | /** 202 | * Gets the value of the request_id field. 203 | * @return {?string} The value. 204 | */ 205 | apphosting.ext.remote_api.Request.prototype.getRequestId = function() { 206 | return /** @type {?string} */ (this.get$Value(5)); 207 | }; 208 | 209 | 210 | /** 211 | * Gets the value of the request_id field or the default value if not set. 212 | * @return {string} The value. 213 | */ 214 | apphosting.ext.remote_api.Request.prototype.getRequestIdOrDefault = function() { 215 | return /** @type {string} */ (this.get$ValueOrDefault(5)); 216 | }; 217 | 218 | 219 | /** 220 | * Sets the value of the request_id field. 221 | * @param {string} value The value. 222 | */ 223 | apphosting.ext.remote_api.Request.prototype.setRequestId = function(value) { 224 | this.set$Value(5, value); 225 | }; 226 | 227 | 228 | /** 229 | * @return {boolean} Whether the request_id field has a value. 230 | */ 231 | apphosting.ext.remote_api.Request.prototype.hasRequestId = function() { 232 | return this.has$Value(5); 233 | }; 234 | 235 | 236 | /** 237 | * @return {number} The number of values in the request_id field. 238 | */ 239 | apphosting.ext.remote_api.Request.prototype.requestIdCount = function() { 240 | return this.count$Values(5); 241 | }; 242 | 243 | 244 | /** 245 | * Clears the values in the request_id field. 246 | */ 247 | apphosting.ext.remote_api.Request.prototype.clearRequestId = function() { 248 | this.clear$Field(5); 249 | }; 250 | 251 | 252 | 253 | /** 254 | * Message ApplicationError. 255 | * @constructor 256 | * @extends {goog.proto2.Message} 257 | */ 258 | apphosting.ext.remote_api.ApplicationError = function() { 259 | goog.proto2.Message.apply(this); 260 | }; 261 | goog.inherits(apphosting.ext.remote_api.ApplicationError, goog.proto2.Message); 262 | 263 | 264 | /** 265 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 266 | * @return {!apphosting.ext.remote_api.ApplicationError} The cloned message. 267 | * @override 268 | */ 269 | apphosting.ext.remote_api.ApplicationError.prototype.clone; 270 | 271 | 272 | /** 273 | * Gets the value of the code field. 274 | * @return {?number} The value. 275 | */ 276 | apphosting.ext.remote_api.ApplicationError.prototype.getCode = function() { 277 | return /** @type {?number} */ (this.get$Value(1)); 278 | }; 279 | 280 | 281 | /** 282 | * Gets the value of the code field or the default value if not set. 283 | * @return {number} The value. 284 | */ 285 | apphosting.ext.remote_api.ApplicationError.prototype.getCodeOrDefault = function() { 286 | return /** @type {number} */ (this.get$ValueOrDefault(1)); 287 | }; 288 | 289 | 290 | /** 291 | * Sets the value of the code field. 292 | * @param {number} value The value. 293 | */ 294 | apphosting.ext.remote_api.ApplicationError.prototype.setCode = function(value) { 295 | this.set$Value(1, value); 296 | }; 297 | 298 | 299 | /** 300 | * @return {boolean} Whether the code field has a value. 301 | */ 302 | apphosting.ext.remote_api.ApplicationError.prototype.hasCode = function() { 303 | return this.has$Value(1); 304 | }; 305 | 306 | 307 | /** 308 | * @return {number} The number of values in the code field. 309 | */ 310 | apphosting.ext.remote_api.ApplicationError.prototype.codeCount = function() { 311 | return this.count$Values(1); 312 | }; 313 | 314 | 315 | /** 316 | * Clears the values in the code field. 317 | */ 318 | apphosting.ext.remote_api.ApplicationError.prototype.clearCode = function() { 319 | this.clear$Field(1); 320 | }; 321 | 322 | 323 | /** 324 | * Gets the value of the detail field. 325 | * @return {?string} The value. 326 | */ 327 | apphosting.ext.remote_api.ApplicationError.prototype.getDetail = function() { 328 | return /** @type {?string} */ (this.get$Value(2)); 329 | }; 330 | 331 | 332 | /** 333 | * Gets the value of the detail field or the default value if not set. 334 | * @return {string} The value. 335 | */ 336 | apphosting.ext.remote_api.ApplicationError.prototype.getDetailOrDefault = function() { 337 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 338 | }; 339 | 340 | 341 | /** 342 | * Sets the value of the detail field. 343 | * @param {string} value The value. 344 | */ 345 | apphosting.ext.remote_api.ApplicationError.prototype.setDetail = function(value) { 346 | this.set$Value(2, value); 347 | }; 348 | 349 | 350 | /** 351 | * @return {boolean} Whether the detail field has a value. 352 | */ 353 | apphosting.ext.remote_api.ApplicationError.prototype.hasDetail = function() { 354 | return this.has$Value(2); 355 | }; 356 | 357 | 358 | /** 359 | * @return {number} The number of values in the detail field. 360 | */ 361 | apphosting.ext.remote_api.ApplicationError.prototype.detailCount = function() { 362 | return this.count$Values(2); 363 | }; 364 | 365 | 366 | /** 367 | * Clears the values in the detail field. 368 | */ 369 | apphosting.ext.remote_api.ApplicationError.prototype.clearDetail = function() { 370 | this.clear$Field(2); 371 | }; 372 | 373 | 374 | 375 | /** 376 | * Message RpcError. 377 | * @constructor 378 | * @extends {goog.proto2.Message} 379 | */ 380 | apphosting.ext.remote_api.RpcError = function() { 381 | goog.proto2.Message.apply(this); 382 | }; 383 | goog.inherits(apphosting.ext.remote_api.RpcError, goog.proto2.Message); 384 | 385 | 386 | /** 387 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 388 | * @return {!apphosting.ext.remote_api.RpcError} The cloned message. 389 | * @override 390 | */ 391 | apphosting.ext.remote_api.RpcError.prototype.clone; 392 | 393 | 394 | /** 395 | * Gets the value of the code field. 396 | * @return {?number} The value. 397 | */ 398 | apphosting.ext.remote_api.RpcError.prototype.getCode = function() { 399 | return /** @type {?number} */ (this.get$Value(1)); 400 | }; 401 | 402 | 403 | /** 404 | * Gets the value of the code field or the default value if not set. 405 | * @return {number} The value. 406 | */ 407 | apphosting.ext.remote_api.RpcError.prototype.getCodeOrDefault = function() { 408 | return /** @type {number} */ (this.get$ValueOrDefault(1)); 409 | }; 410 | 411 | 412 | /** 413 | * Sets the value of the code field. 414 | * @param {number} value The value. 415 | */ 416 | apphosting.ext.remote_api.RpcError.prototype.setCode = function(value) { 417 | this.set$Value(1, value); 418 | }; 419 | 420 | 421 | /** 422 | * @return {boolean} Whether the code field has a value. 423 | */ 424 | apphosting.ext.remote_api.RpcError.prototype.hasCode = function() { 425 | return this.has$Value(1); 426 | }; 427 | 428 | 429 | /** 430 | * @return {number} The number of values in the code field. 431 | */ 432 | apphosting.ext.remote_api.RpcError.prototype.codeCount = function() { 433 | return this.count$Values(1); 434 | }; 435 | 436 | 437 | /** 438 | * Clears the values in the code field. 439 | */ 440 | apphosting.ext.remote_api.RpcError.prototype.clearCode = function() { 441 | this.clear$Field(1); 442 | }; 443 | 444 | 445 | /** 446 | * Gets the value of the detail field. 447 | * @return {?string} The value. 448 | */ 449 | apphosting.ext.remote_api.RpcError.prototype.getDetail = function() { 450 | return /** @type {?string} */ (this.get$Value(2)); 451 | }; 452 | 453 | 454 | /** 455 | * Gets the value of the detail field or the default value if not set. 456 | * @return {string} The value. 457 | */ 458 | apphosting.ext.remote_api.RpcError.prototype.getDetailOrDefault = function() { 459 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 460 | }; 461 | 462 | 463 | /** 464 | * Sets the value of the detail field. 465 | * @param {string} value The value. 466 | */ 467 | apphosting.ext.remote_api.RpcError.prototype.setDetail = function(value) { 468 | this.set$Value(2, value); 469 | }; 470 | 471 | 472 | /** 473 | * @return {boolean} Whether the detail field has a value. 474 | */ 475 | apphosting.ext.remote_api.RpcError.prototype.hasDetail = function() { 476 | return this.has$Value(2); 477 | }; 478 | 479 | 480 | /** 481 | * @return {number} The number of values in the detail field. 482 | */ 483 | apphosting.ext.remote_api.RpcError.prototype.detailCount = function() { 484 | return this.count$Values(2); 485 | }; 486 | 487 | 488 | /** 489 | * Clears the values in the detail field. 490 | */ 491 | apphosting.ext.remote_api.RpcError.prototype.clearDetail = function() { 492 | this.clear$Field(2); 493 | }; 494 | 495 | 496 | /** 497 | * Enumeration ErrorCode. 498 | * @enum {number} 499 | */ 500 | apphosting.ext.remote_api.RpcError.ErrorCode = { 501 | UNKNOWN: 0, 502 | CALL_NOT_FOUND: 1, 503 | PARSE_ERROR: 2, 504 | SECURITY_VIOLATION: 3, 505 | OVER_QUOTA: 4, 506 | REQUEST_TOO_LARGE: 5, 507 | CAPABILITY_DISABLED: 6, 508 | FEATURE_DISABLED: 7, 509 | BAD_REQUEST: 8, 510 | RESPONSE_TOO_LARGE: 9, 511 | CANCELLED: 10, 512 | REPLAY_ERROR: 11, 513 | DEADLINE_EXCEEDED: 12 514 | }; 515 | 516 | 517 | 518 | /** 519 | * Message Response. 520 | * @constructor 521 | * @extends {goog.proto2.Message} 522 | */ 523 | apphosting.ext.remote_api.Response = function() { 524 | goog.proto2.Message.apply(this); 525 | }; 526 | goog.inherits(apphosting.ext.remote_api.Response, goog.proto2.Message); 527 | 528 | 529 | /** 530 | * Overrides {@link goog.proto2.Message#clone} to specify its exact return type. 531 | * @return {!apphosting.ext.remote_api.Response} The cloned message. 532 | * @override 533 | */ 534 | apphosting.ext.remote_api.Response.prototype.clone; 535 | 536 | 537 | /** 538 | * Gets the value of the response field. 539 | * @return {?string} The value. 540 | */ 541 | apphosting.ext.remote_api.Response.prototype.getResponse = function() { 542 | return /** @type {?string} */ (this.get$Value(1)); 543 | }; 544 | 545 | 546 | /** 547 | * Gets the value of the response field or the default value if not set. 548 | * @return {string} The value. 549 | */ 550 | apphosting.ext.remote_api.Response.prototype.getResponseOrDefault = function() { 551 | return /** @type {string} */ (this.get$ValueOrDefault(1)); 552 | }; 553 | 554 | 555 | /** 556 | * Sets the value of the response field. 557 | * @param {string} value The value. 558 | */ 559 | apphosting.ext.remote_api.Response.prototype.setResponse = function(value) { 560 | this.set$Value(1, value); 561 | }; 562 | 563 | 564 | /** 565 | * @return {boolean} Whether the response field has a value. 566 | */ 567 | apphosting.ext.remote_api.Response.prototype.hasResponse = function() { 568 | return this.has$Value(1); 569 | }; 570 | 571 | 572 | /** 573 | * @return {number} The number of values in the response field. 574 | */ 575 | apphosting.ext.remote_api.Response.prototype.responseCount = function() { 576 | return this.count$Values(1); 577 | }; 578 | 579 | 580 | /** 581 | * Clears the values in the response field. 582 | */ 583 | apphosting.ext.remote_api.Response.prototype.clearResponse = function() { 584 | this.clear$Field(1); 585 | }; 586 | 587 | 588 | /** 589 | * Gets the value of the exception field. 590 | * @return {?string} The value. 591 | */ 592 | apphosting.ext.remote_api.Response.prototype.getException = function() { 593 | return /** @type {?string} */ (this.get$Value(2)); 594 | }; 595 | 596 | 597 | /** 598 | * Gets the value of the exception field or the default value if not set. 599 | * @return {string} The value. 600 | */ 601 | apphosting.ext.remote_api.Response.prototype.getExceptionOrDefault = function() { 602 | return /** @type {string} */ (this.get$ValueOrDefault(2)); 603 | }; 604 | 605 | 606 | /** 607 | * Sets the value of the exception field. 608 | * @param {string} value The value. 609 | */ 610 | apphosting.ext.remote_api.Response.prototype.setException = function(value) { 611 | this.set$Value(2, value); 612 | }; 613 | 614 | 615 | /** 616 | * @return {boolean} Whether the exception field has a value. 617 | */ 618 | apphosting.ext.remote_api.Response.prototype.hasException = function() { 619 | return this.has$Value(2); 620 | }; 621 | 622 | 623 | /** 624 | * @return {number} The number of values in the exception field. 625 | */ 626 | apphosting.ext.remote_api.Response.prototype.exceptionCount = function() { 627 | return this.count$Values(2); 628 | }; 629 | 630 | 631 | /** 632 | * Clears the values in the exception field. 633 | */ 634 | apphosting.ext.remote_api.Response.prototype.clearException = function() { 635 | this.clear$Field(2); 636 | }; 637 | 638 | 639 | /** 640 | * Gets the value of the application_error field. 641 | * @return {apphosting.ext.remote_api.ApplicationError} The value. 642 | */ 643 | apphosting.ext.remote_api.Response.prototype.getApplicationError = function() { 644 | return /** @type {apphosting.ext.remote_api.ApplicationError} */ (this.get$Value(3)); 645 | }; 646 | 647 | 648 | /** 649 | * Gets the value of the application_error field or the default value if not set. 650 | * @return {!apphosting.ext.remote_api.ApplicationError} The value. 651 | */ 652 | apphosting.ext.remote_api.Response.prototype.getApplicationErrorOrDefault = function() { 653 | return /** @type {!apphosting.ext.remote_api.ApplicationError} */ (this.get$ValueOrDefault(3)); 654 | }; 655 | 656 | 657 | /** 658 | * Sets the value of the application_error field. 659 | * @param {!apphosting.ext.remote_api.ApplicationError} value The value. 660 | */ 661 | apphosting.ext.remote_api.Response.prototype.setApplicationError = function(value) { 662 | this.set$Value(3, value); 663 | }; 664 | 665 | 666 | /** 667 | * @return {boolean} Whether the application_error field has a value. 668 | */ 669 | apphosting.ext.remote_api.Response.prototype.hasApplicationError = function() { 670 | return this.has$Value(3); 671 | }; 672 | 673 | 674 | /** 675 | * @return {number} The number of values in the application_error field. 676 | */ 677 | apphosting.ext.remote_api.Response.prototype.applicationErrorCount = function() { 678 | return this.count$Values(3); 679 | }; 680 | 681 | 682 | /** 683 | * Clears the values in the application_error field. 684 | */ 685 | apphosting.ext.remote_api.Response.prototype.clearApplicationError = function() { 686 | this.clear$Field(3); 687 | }; 688 | 689 | 690 | /** 691 | * Gets the value of the java_exception field. 692 | * @return {?string} The value. 693 | */ 694 | apphosting.ext.remote_api.Response.prototype.getJavaException = function() { 695 | return /** @type {?string} */ (this.get$Value(4)); 696 | }; 697 | 698 | 699 | /** 700 | * Gets the value of the java_exception field or the default value if not set. 701 | * @return {string} The value. 702 | */ 703 | apphosting.ext.remote_api.Response.prototype.getJavaExceptionOrDefault = function() { 704 | return /** @type {string} */ (this.get$ValueOrDefault(4)); 705 | }; 706 | 707 | 708 | /** 709 | * Sets the value of the java_exception field. 710 | * @param {string} value The value. 711 | */ 712 | apphosting.ext.remote_api.Response.prototype.setJavaException = function(value) { 713 | this.set$Value(4, value); 714 | }; 715 | 716 | 717 | /** 718 | * @return {boolean} Whether the java_exception field has a value. 719 | */ 720 | apphosting.ext.remote_api.Response.prototype.hasJavaException = function() { 721 | return this.has$Value(4); 722 | }; 723 | 724 | 725 | /** 726 | * @return {number} The number of values in the java_exception field. 727 | */ 728 | apphosting.ext.remote_api.Response.prototype.javaExceptionCount = function() { 729 | return this.count$Values(4); 730 | }; 731 | 732 | 733 | /** 734 | * Clears the values in the java_exception field. 735 | */ 736 | apphosting.ext.remote_api.Response.prototype.clearJavaException = function() { 737 | this.clear$Field(4); 738 | }; 739 | 740 | 741 | /** 742 | * Gets the value of the rpc_error field. 743 | * @return {apphosting.ext.remote_api.RpcError} The value. 744 | */ 745 | apphosting.ext.remote_api.Response.prototype.getRpcError = function() { 746 | return /** @type {apphosting.ext.remote_api.RpcError} */ (this.get$Value(5)); 747 | }; 748 | 749 | 750 | /** 751 | * Gets the value of the rpc_error field or the default value if not set. 752 | * @return {!apphosting.ext.remote_api.RpcError} The value. 753 | */ 754 | apphosting.ext.remote_api.Response.prototype.getRpcErrorOrDefault = function() { 755 | return /** @type {!apphosting.ext.remote_api.RpcError} */ (this.get$ValueOrDefault(5)); 756 | }; 757 | 758 | 759 | /** 760 | * Sets the value of the rpc_error field. 761 | * @param {!apphosting.ext.remote_api.RpcError} value The value. 762 | */ 763 | apphosting.ext.remote_api.Response.prototype.setRpcError = function(value) { 764 | this.set$Value(5, value); 765 | }; 766 | 767 | 768 | /** 769 | * @return {boolean} Whether the rpc_error field has a value. 770 | */ 771 | apphosting.ext.remote_api.Response.prototype.hasRpcError = function() { 772 | return this.has$Value(5); 773 | }; 774 | 775 | 776 | /** 777 | * @return {number} The number of values in the rpc_error field. 778 | */ 779 | apphosting.ext.remote_api.Response.prototype.rpcErrorCount = function() { 780 | return this.count$Values(5); 781 | }; 782 | 783 | 784 | /** 785 | * Clears the values in the rpc_error field. 786 | */ 787 | apphosting.ext.remote_api.Response.prototype.clearRpcError = function() { 788 | this.clear$Field(5); 789 | }; 790 | 791 | 792 | goog.proto2.Message.set$Metadata(apphosting.ext.remote_api.Request, { 793 | 0: { 794 | name: 'Request', 795 | fullName: 'apphosting.ext.remote_api.Request' 796 | }, 797 | 2: { 798 | name: 'service_name', 799 | required: true, 800 | fieldType: goog.proto2.Message.FieldType.STRING, 801 | type: String 802 | }, 803 | 3: { 804 | name: 'method', 805 | required: true, 806 | fieldType: goog.proto2.Message.FieldType.STRING, 807 | type: String 808 | }, 809 | 4: { 810 | name: 'request', 811 | required: true, 812 | fieldType: goog.proto2.Message.FieldType.BYTES, 813 | type: String 814 | }, 815 | 5: { 816 | name: 'request_id', 817 | fieldType: goog.proto2.Message.FieldType.STRING, 818 | type: String 819 | } 820 | }); 821 | 822 | 823 | goog.proto2.Message.set$Metadata(apphosting.ext.remote_api.ApplicationError, { 824 | 0: { 825 | name: 'ApplicationError', 826 | fullName: 'apphosting.ext.remote_api.ApplicationError' 827 | }, 828 | 1: { 829 | name: 'code', 830 | required: true, 831 | fieldType: goog.proto2.Message.FieldType.INT32, 832 | type: Number 833 | }, 834 | 2: { 835 | name: 'detail', 836 | required: true, 837 | fieldType: goog.proto2.Message.FieldType.STRING, 838 | type: String 839 | } 840 | }); 841 | 842 | 843 | goog.proto2.Message.set$Metadata(apphosting.ext.remote_api.RpcError, { 844 | 0: { 845 | name: 'RpcError', 846 | fullName: 'apphosting.ext.remote_api.RpcError' 847 | }, 848 | 1: { 849 | name: 'code', 850 | required: true, 851 | fieldType: goog.proto2.Message.FieldType.INT32, 852 | type: Number 853 | }, 854 | 2: { 855 | name: 'detail', 856 | fieldType: goog.proto2.Message.FieldType.STRING, 857 | type: String 858 | } 859 | }); 860 | 861 | 862 | goog.proto2.Message.set$Metadata(apphosting.ext.remote_api.Response, { 863 | 0: { 864 | name: 'Response', 865 | fullName: 'apphosting.ext.remote_api.Response' 866 | }, 867 | 1: { 868 | name: 'response', 869 | fieldType: goog.proto2.Message.FieldType.BYTES, 870 | type: String 871 | }, 872 | 2: { 873 | name: 'exception', 874 | fieldType: goog.proto2.Message.FieldType.BYTES, 875 | type: String 876 | }, 877 | 3: { 878 | name: 'application_error', 879 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 880 | type: apphosting.ext.remote_api.ApplicationError 881 | }, 882 | 4: { 883 | name: 'java_exception', 884 | fieldType: goog.proto2.Message.FieldType.BYTES, 885 | type: String 886 | }, 887 | 5: { 888 | name: 'rpc_error', 889 | fieldType: goog.proto2.Message.FieldType.MESSAGE, 890 | type: apphosting.ext.remote_api.RpcError 891 | } 892 | }); 893 | -------------------------------------------------------------------------------- /lib/closure/goog/asserts/asserts.js: -------------------------------------------------------------------------------- 1 | // Copyright 2008 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Utilities to check the preconditions, postconditions and 17 | * invariants runtime. 18 | * 19 | * Methods in this package should be given special treatment by the compiler 20 | * for type-inference. For example, goog.asserts.assert(foo) 21 | * will restrict foo to a truthy value. 22 | * 23 | * The compiler has an option to disable asserts. So code like: 24 | * 25 | * var x = goog.asserts.assert(foo()); goog.asserts.assert(bar()); 26 | * 27 | * will be transformed into: 28 | * 29 | * var x = foo(); 30 | * 31 | * The compiler will leave in foo() (because its return value is used), 32 | * but it will remove bar() because it assumes it does not have side-effects. 33 | * 34 | */ 35 | 36 | goog.provide('goog.asserts'); 37 | goog.provide('goog.asserts.AssertionError'); 38 | 39 | goog.require('goog.debug.Error'); 40 | goog.require('goog.dom.NodeType'); 41 | goog.require('goog.string'); 42 | 43 | 44 | /** 45 | * @define {boolean} Whether to strip out asserts or to leave them in. 46 | */ 47 | goog.define('goog.asserts.ENABLE_ASSERTS', goog.DEBUG); 48 | 49 | 50 | 51 | /** 52 | * Error object for failed assertions. 53 | * @param {string} messagePattern The pattern that was used to form message. 54 | * @param {!Array.<*>} messageArgs The items to substitute into the pattern. 55 | * @constructor 56 | * @extends {goog.debug.Error} 57 | * @final 58 | */ 59 | goog.asserts.AssertionError = function(messagePattern, messageArgs) { 60 | messageArgs.unshift(messagePattern); 61 | goog.debug.Error.call(this, goog.string.subs.apply(null, messageArgs)); 62 | // Remove the messagePattern afterwards to avoid permenantly modifying the 63 | // passed in array. 64 | messageArgs.shift(); 65 | 66 | /** 67 | * The message pattern used to format the error message. Error handlers can 68 | * use this to uniquely identify the assertion. 69 | * @type {string} 70 | */ 71 | this.messagePattern = messagePattern; 72 | }; 73 | goog.inherits(goog.asserts.AssertionError, goog.debug.Error); 74 | 75 | 76 | /** @override */ 77 | goog.asserts.AssertionError.prototype.name = 'AssertionError'; 78 | 79 | 80 | /** 81 | * Throws an exception with the given message and "Assertion failed" prefixed 82 | * onto it. 83 | * @param {string} defaultMessage The message to use if givenMessage is empty. 84 | * @param {Array.<*>} defaultArgs The substitution arguments for defaultMessage. 85 | * @param {string|undefined} givenMessage Message supplied by the caller. 86 | * @param {Array.<*>} givenArgs The substitution arguments for givenMessage. 87 | * @throws {goog.asserts.AssertionError} When the value is not a number. 88 | * @private 89 | */ 90 | goog.asserts.doAssertFailure_ = 91 | function(defaultMessage, defaultArgs, givenMessage, givenArgs) { 92 | var message = 'Assertion failed'; 93 | if (givenMessage) { 94 | message += ': ' + givenMessage; 95 | var args = givenArgs; 96 | } else if (defaultMessage) { 97 | message += ': ' + defaultMessage; 98 | args = defaultArgs; 99 | } 100 | // The '' + works around an Opera 10 bug in the unit tests. Without it, 101 | // a stack trace is added to var message above. With this, a stack trace is 102 | // not added until this line (it causes the extra garbage to be added after 103 | // the assertion message instead of in the middle of it). 104 | throw new goog.asserts.AssertionError('' + message, args || []); 105 | }; 106 | 107 | 108 | /** 109 | * Checks if the condition evaluates to true if goog.asserts.ENABLE_ASSERTS is 110 | * true. 111 | * @param {*} condition The condition to check. 112 | * @param {string=} opt_message Error message in case of failure. 113 | * @param {...*} var_args The items to substitute into the failure message. 114 | * @return {*} The value of the condition. 115 | * @throws {goog.asserts.AssertionError} When the condition evaluates to false. 116 | */ 117 | goog.asserts.assert = function(condition, opt_message, var_args) { 118 | if (goog.asserts.ENABLE_ASSERTS && !condition) { 119 | goog.asserts.doAssertFailure_('', null, opt_message, 120 | Array.prototype.slice.call(arguments, 2)); 121 | } 122 | return condition; 123 | }; 124 | 125 | 126 | /** 127 | * Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case 128 | * when we want to add a check in the unreachable area like switch-case 129 | * statement: 130 | * 131 | *
132 |  *  switch(type) {
133 |  *    case FOO: doSomething(); break;
134 |  *    case BAR: doSomethingElse(); break;
135 |  *    default: goog.assert.fail('Unrecognized type: ' + type);
136 |  *      // We have only 2 types - "default:" section is unreachable code.
137 |  *  }
138 |  * 
139 | * 140 | * @param {string=} opt_message Error message in case of failure. 141 | * @param {...*} var_args The items to substitute into the failure message. 142 | * @throws {goog.asserts.AssertionError} Failure. 143 | */ 144 | goog.asserts.fail = function(opt_message, var_args) { 145 | if (goog.asserts.ENABLE_ASSERTS) { 146 | throw new goog.asserts.AssertionError( 147 | 'Failure' + (opt_message ? ': ' + opt_message : ''), 148 | Array.prototype.slice.call(arguments, 1)); 149 | } 150 | }; 151 | 152 | 153 | /** 154 | * Checks if the value is a number if goog.asserts.ENABLE_ASSERTS is true. 155 | * @param {*} value The value to check. 156 | * @param {string=} opt_message Error message in case of failure. 157 | * @param {...*} var_args The items to substitute into the failure message. 158 | * @return {number} The value, guaranteed to be a number when asserts enabled. 159 | * @throws {goog.asserts.AssertionError} When the value is not a number. 160 | */ 161 | goog.asserts.assertNumber = function(value, opt_message, var_args) { 162 | if (goog.asserts.ENABLE_ASSERTS && !goog.isNumber(value)) { 163 | goog.asserts.doAssertFailure_('Expected number but got %s: %s.', 164 | [goog.typeOf(value), value], opt_message, 165 | Array.prototype.slice.call(arguments, 2)); 166 | } 167 | return /** @type {number} */ (value); 168 | }; 169 | 170 | 171 | /** 172 | * Checks if the value is a string if goog.asserts.ENABLE_ASSERTS is true. 173 | * @param {*} value The value to check. 174 | * @param {string=} opt_message Error message in case of failure. 175 | * @param {...*} var_args The items to substitute into the failure message. 176 | * @return {string} The value, guaranteed to be a string when asserts enabled. 177 | * @throws {goog.asserts.AssertionError} When the value is not a string. 178 | */ 179 | goog.asserts.assertString = function(value, opt_message, var_args) { 180 | if (goog.asserts.ENABLE_ASSERTS && !goog.isString(value)) { 181 | goog.asserts.doAssertFailure_('Expected string but got %s: %s.', 182 | [goog.typeOf(value), value], opt_message, 183 | Array.prototype.slice.call(arguments, 2)); 184 | } 185 | return /** @type {string} */ (value); 186 | }; 187 | 188 | 189 | /** 190 | * Checks if the value is a function if goog.asserts.ENABLE_ASSERTS is true. 191 | * @param {*} value The value to check. 192 | * @param {string=} opt_message Error message in case of failure. 193 | * @param {...*} var_args The items to substitute into the failure message. 194 | * @return {!Function} The value, guaranteed to be a function when asserts 195 | * enabled. 196 | * @throws {goog.asserts.AssertionError} When the value is not a function. 197 | */ 198 | goog.asserts.assertFunction = function(value, opt_message, var_args) { 199 | if (goog.asserts.ENABLE_ASSERTS && !goog.isFunction(value)) { 200 | goog.asserts.doAssertFailure_('Expected function but got %s: %s.', 201 | [goog.typeOf(value), value], opt_message, 202 | Array.prototype.slice.call(arguments, 2)); 203 | } 204 | return /** @type {!Function} */ (value); 205 | }; 206 | 207 | 208 | /** 209 | * Checks if the value is an Object if goog.asserts.ENABLE_ASSERTS is true. 210 | * @param {*} value The value to check. 211 | * @param {string=} opt_message Error message in case of failure. 212 | * @param {...*} var_args The items to substitute into the failure message. 213 | * @return {!Object} The value, guaranteed to be a non-null object. 214 | * @throws {goog.asserts.AssertionError} When the value is not an object. 215 | */ 216 | goog.asserts.assertObject = function(value, opt_message, var_args) { 217 | if (goog.asserts.ENABLE_ASSERTS && !goog.isObject(value)) { 218 | goog.asserts.doAssertFailure_('Expected object but got %s: %s.', 219 | [goog.typeOf(value), value], 220 | opt_message, Array.prototype.slice.call(arguments, 2)); 221 | } 222 | return /** @type {!Object} */ (value); 223 | }; 224 | 225 | 226 | /** 227 | * Checks if the value is an Array if goog.asserts.ENABLE_ASSERTS is true. 228 | * @param {*} value The value to check. 229 | * @param {string=} opt_message Error message in case of failure. 230 | * @param {...*} var_args The items to substitute into the failure message. 231 | * @return {!Array} The value, guaranteed to be a non-null array. 232 | * @throws {goog.asserts.AssertionError} When the value is not an array. 233 | */ 234 | goog.asserts.assertArray = function(value, opt_message, var_args) { 235 | if (goog.asserts.ENABLE_ASSERTS && !goog.isArray(value)) { 236 | goog.asserts.doAssertFailure_('Expected array but got %s: %s.', 237 | [goog.typeOf(value), value], opt_message, 238 | Array.prototype.slice.call(arguments, 2)); 239 | } 240 | return /** @type {!Array} */ (value); 241 | }; 242 | 243 | 244 | /** 245 | * Checks if the value is a boolean if goog.asserts.ENABLE_ASSERTS is true. 246 | * @param {*} value The value to check. 247 | * @param {string=} opt_message Error message in case of failure. 248 | * @param {...*} var_args The items to substitute into the failure message. 249 | * @return {boolean} The value, guaranteed to be a boolean when asserts are 250 | * enabled. 251 | * @throws {goog.asserts.AssertionError} When the value is not a boolean. 252 | */ 253 | goog.asserts.assertBoolean = function(value, opt_message, var_args) { 254 | if (goog.asserts.ENABLE_ASSERTS && !goog.isBoolean(value)) { 255 | goog.asserts.doAssertFailure_('Expected boolean but got %s: %s.', 256 | [goog.typeOf(value), value], opt_message, 257 | Array.prototype.slice.call(arguments, 2)); 258 | } 259 | return /** @type {boolean} */ (value); 260 | }; 261 | 262 | 263 | /** 264 | * Checks if the value is a DOM Element if goog.asserts.ENABLE_ASSERTS is true. 265 | * @param {*} value The value to check. 266 | * @param {string=} opt_message Error message in case of failure. 267 | * @param {...*} var_args The items to substitute into the failure message. 268 | * @return {!Element} The value, likely to be a DOM Element when asserts are 269 | * enabled. 270 | * @throws {goog.asserts.AssertionError} When the value is not a boolean. 271 | */ 272 | goog.asserts.assertElement = function(value, opt_message, var_args) { 273 | if (goog.asserts.ENABLE_ASSERTS && (!goog.isObject(value) || 274 | value.nodeType != goog.dom.NodeType.ELEMENT)) { 275 | goog.asserts.doAssertFailure_('Expected Element but got %s: %s.', 276 | [goog.typeOf(value), value], opt_message, 277 | Array.prototype.slice.call(arguments, 2)); 278 | } 279 | return /** @type {!Element} */ (value); 280 | }; 281 | 282 | 283 | /** 284 | * Checks if the value is an instance of the user-defined type if 285 | * goog.asserts.ENABLE_ASSERTS is true. 286 | * 287 | * The compiler may tighten the type returned by this function. 288 | * 289 | * @param {*} value The value to check. 290 | * @param {function(new: T, ...)} type A user-defined constructor. 291 | * @param {string=} opt_message Error message in case of failure. 292 | * @param {...*} var_args The items to substitute into the failure message. 293 | * @throws {goog.asserts.AssertionError} When the value is not an instance of 294 | * type. 295 | * @return {!T} 296 | * @template T 297 | */ 298 | goog.asserts.assertInstanceof = function(value, type, opt_message, var_args) { 299 | if (goog.asserts.ENABLE_ASSERTS && !(value instanceof type)) { 300 | goog.asserts.doAssertFailure_('instanceof check failed.', null, 301 | opt_message, Array.prototype.slice.call(arguments, 3)); 302 | } 303 | return value; 304 | }; 305 | 306 | 307 | /** 308 | * Checks that no enumerable keys are present in Object.prototype. Such keys 309 | * would break most code that use {@code for (var ... in ...)} loops. 310 | */ 311 | goog.asserts.assertObjectPrototypeIsIntact = function() { 312 | for (var key in Object.prototype) { 313 | goog.asserts.fail(key + ' should not be enumerable in Object.prototype.'); 314 | } 315 | }; 316 | -------------------------------------------------------------------------------- /lib/closure/goog/bootstrap/nodejs.js: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Closure Library Authors. 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 | /** 16 | * @fileoverview A nodejs script for dynamically requiring Closure within 17 | * nodejs. 18 | * 19 | * Example of usage: 20 | * 21 | * require('./bootstrap/nodejs') 22 | * goog.require('goog.ui.Component') 23 | * 24 | * 25 | * This loads goog.ui.Component in the global scope. 26 | * 27 | * If you want to load custom libraries, you can require the custom deps file 28 | * directly. If your custom libraries introduce new globals, you may 29 | * need to run goog.nodeGlobalRequire to get them to load correctly. 30 | * 31 | * 32 | * require('./path/to/my/deps.js') 33 | * goog.bootstrap.nodeJs.nodeGlobalRequire('./path/to/my/base.js') 34 | * goog.require('my.Class') 35 | * 36 | * 37 | * @author nick@medium.com (Nick Santos) 38 | * 39 | * @nocompile 40 | */ 41 | 42 | 43 | var fs = require('fs'); 44 | var path = require('path'); 45 | var vm = require('vm'); 46 | 47 | /** 48 | * The goog namespace in the global scope. 49 | */ 50 | global.goog = {}; 51 | 52 | 53 | /** 54 | * Imports a script using Node's require() API. 55 | * 56 | * @param {string} src The script source. 57 | * @return {boolean} True if the script was imported, false otherwise. 58 | */ 59 | global.CLOSURE_IMPORT_SCRIPT = function(src) { 60 | // Sources are always expressed relative to closure's base.js, but 61 | // require() is always relative to the current source. 62 | require('./../' + src); 63 | return true; 64 | }; 65 | 66 | 67 | // Declared here so it can be used to require base.js 68 | function nodeGlobalRequire(file) { 69 | vm.runInThisContext.call( 70 | global, fs.readFileSync(file), file); 71 | } 72 | 73 | 74 | // Load Closure's base.js into memory. It is assumed base.js is in the 75 | // directory above this directory given this script's location in 76 | // bootstrap/nodejs.js. 77 | nodeGlobalRequire(path.resolve(__dirname, '..', 'base.js')); 78 | 79 | 80 | /** 81 | * Bootstraps a file into the global scope. 82 | * 83 | * This is strictly for cases where normal require() won't work, 84 | * because the file declares global symbols with 'var' that need to 85 | * be added to the global scope. 86 | * @suppress {missingProvide} 87 | * 88 | * @param {string} file The path to the file. 89 | */ 90 | goog.nodeGlobalRequire = nodeGlobalRequire; 91 | 92 | -------------------------------------------------------------------------------- /lib/closure/goog/debug/error.js: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Provides a base class for custom Error objects such that the 17 | * stack is correctly maintained. 18 | * 19 | * You should never need to throw goog.debug.Error(msg) directly, Error(msg) is 20 | * sufficient. 21 | * 22 | */ 23 | 24 | goog.provide('goog.debug.Error'); 25 | 26 | 27 | 28 | /** 29 | * Base class for custom error objects. 30 | * @param {*=} opt_msg The message associated with the error. 31 | * @constructor 32 | * @extends {Error} 33 | */ 34 | goog.debug.Error = function(opt_msg) { 35 | 36 | // Ensure there is a stack trace. 37 | if (Error.captureStackTrace) { 38 | Error.captureStackTrace(this, goog.debug.Error); 39 | } else { 40 | this.stack = new Error().stack || ''; 41 | } 42 | 43 | if (opt_msg) { 44 | this.message = String(opt_msg); 45 | } 46 | }; 47 | goog.inherits(goog.debug.Error, Error); 48 | 49 | 50 | /** @override */ 51 | goog.debug.Error.prototype.name = 'CustomError'; 52 | -------------------------------------------------------------------------------- /lib/closure/goog/deps.js: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Closure Library Authors. All Rights Reserved. 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 | // This file has been auto-generated by GenJsDeps, please do not edit. 16 | goog.addDependency('base.js', ['goog'], []); 17 | goog.addDependency('debug/error.js', ['goog.debug.Error'], []); 18 | goog.addDependency('dom/nodetype.js', ['goog.dom.NodeType'], []); 19 | goog.addDependency('string/string.js', ['goog.string', 'goog.string.Unicode'], []); 20 | goog.addDependency('asserts/asserts.js', ['goog.asserts', 'goog.asserts.AssertionError'], ['goog.debug.Error', 'goog.dom.NodeType', 'goog.string']); 21 | goog.addDependency('array/array.js', ['goog.array', 'goog.array.ArrayLike'], ['goog.asserts']); 22 | goog.addDependency('object/object.js', ['goog.object'], []); 23 | goog.addDependency('proto2/descriptor.js', ['goog.proto2.Descriptor', 'goog.proto2.Metadata'], ['goog.array', 'goog.asserts', 'goog.object', 'goog.string']); 24 | goog.addDependency('proto2/fielddescriptor.js', ['goog.proto2.FieldDescriptor'], ['goog.asserts', 'goog.string']); 25 | goog.addDependency('proto2/message.js', ['goog.proto2.Message'], ['goog.asserts', 'goog.proto2.Descriptor', 'goog.proto2.FieldDescriptor']); 26 | goog.addDependency('math/long.js', ['goog.math.Long'], []); 27 | goog.addDependency('proto2/serializer.js', ['goog.proto2.Serializer'], ['goog.asserts', 'goog.proto2.FieldDescriptor', 'goog.proto2.Message']); 28 | -------------------------------------------------------------------------------- /lib/closure/goog/dom/nodetype.js: -------------------------------------------------------------------------------- 1 | // Copyright 2006 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Definition of goog.dom.NodeType. 17 | */ 18 | 19 | goog.provide('goog.dom.NodeType'); 20 | 21 | 22 | /** 23 | * Constants for the nodeType attribute in the Node interface. 24 | * 25 | * These constants match those specified in the Node interface. These are 26 | * usually present on the Node object in recent browsers, but not in older 27 | * browsers (specifically, early IEs) and thus are given here. 28 | * 29 | * In some browsers (early IEs), these are not defined on the Node object, 30 | * so they are provided here. 31 | * 32 | * See http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247 33 | * @enum {number} 34 | */ 35 | goog.dom.NodeType = { 36 | ELEMENT: 1, 37 | ATTRIBUTE: 2, 38 | TEXT: 3, 39 | CDATA_SECTION: 4, 40 | ENTITY_REFERENCE: 5, 41 | ENTITY: 6, 42 | PROCESSING_INSTRUCTION: 7, 43 | COMMENT: 8, 44 | DOCUMENT: 9, 45 | DOCUMENT_TYPE: 10, 46 | DOCUMENT_FRAGMENT: 11, 47 | NOTATION: 12 48 | }; 49 | -------------------------------------------------------------------------------- /lib/closure/goog/object/object.js: -------------------------------------------------------------------------------- 1 | // Copyright 2006 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Utilities for manipulating objects/maps/hashes. 17 | */ 18 | 19 | goog.provide('goog.object'); 20 | 21 | 22 | /** 23 | * Calls a function for each element in an object/map/hash. 24 | * 25 | * @param {Object.} obj The object over which to iterate. 26 | * @param {function(this:T,V,?,Object.):?} f The function to call 27 | * for every element. This function takes 3 arguments (the element, the 28 | * index and the object) and the return value is ignored. 29 | * @param {T=} opt_obj This is used as the 'this' object within f. 30 | * @template T,K,V 31 | */ 32 | goog.object.forEach = function(obj, f, opt_obj) { 33 | for (var key in obj) { 34 | f.call(opt_obj, obj[key], key, obj); 35 | } 36 | }; 37 | 38 | 39 | /** 40 | * Calls a function for each element in an object/map/hash. If that call returns 41 | * true, adds the element to a new object. 42 | * 43 | * @param {Object.} obj The object over which to iterate. 44 | * @param {function(this:T,V,?,Object.):boolean} f The function to call 45 | * for every element. This 46 | * function takes 3 arguments (the element, the index and the object) 47 | * and should return a boolean. If the return value is true the 48 | * element is added to the result object. If it is false the 49 | * element is not included. 50 | * @param {T=} opt_obj This is used as the 'this' object within f. 51 | * @return {!Object.} a new object in which only elements that passed the 52 | * test are present. 53 | * @template T,K,V 54 | */ 55 | goog.object.filter = function(obj, f, opt_obj) { 56 | var res = {}; 57 | for (var key in obj) { 58 | if (f.call(opt_obj, obj[key], key, obj)) { 59 | res[key] = obj[key]; 60 | } 61 | } 62 | return res; 63 | }; 64 | 65 | 66 | /** 67 | * For every element in an object/map/hash calls a function and inserts the 68 | * result into a new object. 69 | * 70 | * @param {Object.} obj The object over which to iterate. 71 | * @param {function(this:T,V,?,Object.):R} f The function to call 72 | * for every element. This function 73 | * takes 3 arguments (the element, the index and the object) 74 | * and should return something. The result will be inserted 75 | * into a new object. 76 | * @param {T=} opt_obj This is used as the 'this' object within f. 77 | * @return {!Object.} a new object with the results from f. 78 | * @template T,K,V,R 79 | */ 80 | goog.object.map = function(obj, f, opt_obj) { 81 | var res = {}; 82 | for (var key in obj) { 83 | res[key] = f.call(opt_obj, obj[key], key, obj); 84 | } 85 | return res; 86 | }; 87 | 88 | 89 | /** 90 | * Calls a function for each element in an object/map/hash. If any 91 | * call returns true, returns true (without checking the rest). If 92 | * all calls return false, returns false. 93 | * 94 | * @param {Object.} obj The object to check. 95 | * @param {function(this:T,V,?,Object.):boolean} f The function to 96 | * call for every element. This function 97 | * takes 3 arguments (the element, the index and the object) and should 98 | * return a boolean. 99 | * @param {T=} opt_obj This is used as the 'this' object within f. 100 | * @return {boolean} true if any element passes the test. 101 | * @template T,K,V 102 | */ 103 | goog.object.some = function(obj, f, opt_obj) { 104 | for (var key in obj) { 105 | if (f.call(opt_obj, obj[key], key, obj)) { 106 | return true; 107 | } 108 | } 109 | return false; 110 | }; 111 | 112 | 113 | /** 114 | * Calls a function for each element in an object/map/hash. If 115 | * all calls return true, returns true. If any call returns false, returns 116 | * false at this point and does not continue to check the remaining elements. 117 | * 118 | * @param {Object.} obj The object to check. 119 | * @param {?function(this:T,V,?,Object.):boolean} f The function to 120 | * call for every element. This function 121 | * takes 3 arguments (the element, the index and the object) and should 122 | * return a boolean. 123 | * @param {T=} opt_obj This is used as the 'this' object within f. 124 | * @return {boolean} false if any element fails the test. 125 | * @template T,K,V 126 | */ 127 | goog.object.every = function(obj, f, opt_obj) { 128 | for (var key in obj) { 129 | if (!f.call(opt_obj, obj[key], key, obj)) { 130 | return false; 131 | } 132 | } 133 | return true; 134 | }; 135 | 136 | 137 | /** 138 | * Returns the number of key-value pairs in the object map. 139 | * 140 | * @param {Object} obj The object for which to get the number of key-value 141 | * pairs. 142 | * @return {number} The number of key-value pairs in the object map. 143 | */ 144 | goog.object.getCount = function(obj) { 145 | // JS1.5 has __count__ but it has been deprecated so it raises a warning... 146 | // in other words do not use. Also __count__ only includes the fields on the 147 | // actual object and not in the prototype chain. 148 | var rv = 0; 149 | for (var key in obj) { 150 | rv++; 151 | } 152 | return rv; 153 | }; 154 | 155 | 156 | /** 157 | * Returns one key from the object map, if any exists. 158 | * For map literals the returned key will be the first one in most of the 159 | * browsers (a know exception is Konqueror). 160 | * 161 | * @param {Object} obj The object to pick a key from. 162 | * @return {string|undefined} The key or undefined if the object is empty. 163 | */ 164 | goog.object.getAnyKey = function(obj) { 165 | for (var key in obj) { 166 | return key; 167 | } 168 | }; 169 | 170 | 171 | /** 172 | * Returns one value from the object map, if any exists. 173 | * For map literals the returned value will be the first one in most of the 174 | * browsers (a know exception is Konqueror). 175 | * 176 | * @param {Object.} obj The object to pick a value from. 177 | * @return {V|undefined} The value or undefined if the object is empty. 178 | * @template K,V 179 | */ 180 | goog.object.getAnyValue = function(obj) { 181 | for (var key in obj) { 182 | return obj[key]; 183 | } 184 | }; 185 | 186 | 187 | /** 188 | * Whether the object/hash/map contains the given object as a value. 189 | * An alias for goog.object.containsValue(obj, val). 190 | * 191 | * @param {Object.} obj The object in which to look for val. 192 | * @param {V} val The object for which to check. 193 | * @return {boolean} true if val is present. 194 | * @template K,V 195 | */ 196 | goog.object.contains = function(obj, val) { 197 | return goog.object.containsValue(obj, val); 198 | }; 199 | 200 | 201 | /** 202 | * Returns the values of the object/map/hash. 203 | * 204 | * @param {Object.} obj The object from which to get the values. 205 | * @return {!Array.} The values in the object/map/hash. 206 | * @template K,V 207 | */ 208 | goog.object.getValues = function(obj) { 209 | var res = []; 210 | var i = 0; 211 | for (var key in obj) { 212 | res[i++] = obj[key]; 213 | } 214 | return res; 215 | }; 216 | 217 | 218 | /** 219 | * Returns the keys of the object/map/hash. 220 | * 221 | * @param {Object} obj The object from which to get the keys. 222 | * @return {!Array.} Array of property keys. 223 | */ 224 | goog.object.getKeys = function(obj) { 225 | var res = []; 226 | var i = 0; 227 | for (var key in obj) { 228 | res[i++] = key; 229 | } 230 | return res; 231 | }; 232 | 233 | 234 | /** 235 | * Get a value from an object multiple levels deep. This is useful for 236 | * pulling values from deeply nested objects, such as JSON responses. 237 | * Example usage: getValueByKeys(jsonObj, 'foo', 'entries', 3) 238 | * 239 | * @param {!Object} obj An object to get the value from. Can be array-like. 240 | * @param {...(string|number|!Array.)} var_args A number of keys 241 | * (as strings, or numbers, for array-like objects). Can also be 242 | * specified as a single array of keys. 243 | * @return {*} The resulting value. If, at any point, the value for a key 244 | * is undefined, returns undefined. 245 | */ 246 | goog.object.getValueByKeys = function(obj, var_args) { 247 | var isArrayLike = goog.isArrayLike(var_args); 248 | var keys = isArrayLike ? var_args : arguments; 249 | 250 | // Start with the 2nd parameter for the variable parameters syntax. 251 | for (var i = isArrayLike ? 0 : 1; i < keys.length; i++) { 252 | obj = obj[keys[i]]; 253 | if (!goog.isDef(obj)) { 254 | break; 255 | } 256 | } 257 | 258 | return obj; 259 | }; 260 | 261 | 262 | /** 263 | * Whether the object/map/hash contains the given key. 264 | * 265 | * @param {Object} obj The object in which to look for key. 266 | * @param {*} key The key for which to check. 267 | * @return {boolean} true If the map contains the key. 268 | */ 269 | goog.object.containsKey = function(obj, key) { 270 | return key in obj; 271 | }; 272 | 273 | 274 | /** 275 | * Whether the object/map/hash contains the given value. This is O(n). 276 | * 277 | * @param {Object.} obj The object in which to look for val. 278 | * @param {V} val The value for which to check. 279 | * @return {boolean} true If the map contains the value. 280 | * @template K,V 281 | */ 282 | goog.object.containsValue = function(obj, val) { 283 | for (var key in obj) { 284 | if (obj[key] == val) { 285 | return true; 286 | } 287 | } 288 | return false; 289 | }; 290 | 291 | 292 | /** 293 | * Searches an object for an element that satisfies the given condition and 294 | * returns its key. 295 | * @param {Object.} obj The object to search in. 296 | * @param {function(this:T,V,string,Object.):boolean} f The 297 | * function to call for every element. Takes 3 arguments (the value, 298 | * the key and the object) and should return a boolean. 299 | * @param {T=} opt_this An optional "this" context for the function. 300 | * @return {string|undefined} The key of an element for which the function 301 | * returns true or undefined if no such element is found. 302 | * @template T,K,V 303 | */ 304 | goog.object.findKey = function(obj, f, opt_this) { 305 | for (var key in obj) { 306 | if (f.call(opt_this, obj[key], key, obj)) { 307 | return key; 308 | } 309 | } 310 | return undefined; 311 | }; 312 | 313 | 314 | /** 315 | * Searches an object for an element that satisfies the given condition and 316 | * returns its value. 317 | * @param {Object.} obj The object to search in. 318 | * @param {function(this:T,V,string,Object.):boolean} f The function 319 | * to call for every element. Takes 3 arguments (the value, the key 320 | * and the object) and should return a boolean. 321 | * @param {T=} opt_this An optional "this" context for the function. 322 | * @return {V} The value of an element for which the function returns true or 323 | * undefined if no such element is found. 324 | * @template T,K,V 325 | */ 326 | goog.object.findValue = function(obj, f, opt_this) { 327 | var key = goog.object.findKey(obj, f, opt_this); 328 | return key && obj[key]; 329 | }; 330 | 331 | 332 | /** 333 | * Whether the object/map/hash is empty. 334 | * 335 | * @param {Object} obj The object to test. 336 | * @return {boolean} true if obj is empty. 337 | */ 338 | goog.object.isEmpty = function(obj) { 339 | for (var key in obj) { 340 | return false; 341 | } 342 | return true; 343 | }; 344 | 345 | 346 | /** 347 | * Removes all key value pairs from the object/map/hash. 348 | * 349 | * @param {Object} obj The object to clear. 350 | */ 351 | goog.object.clear = function(obj) { 352 | for (var i in obj) { 353 | delete obj[i]; 354 | } 355 | }; 356 | 357 | 358 | /** 359 | * Removes a key-value pair based on the key. 360 | * 361 | * @param {Object} obj The object from which to remove the key. 362 | * @param {*} key The key to remove. 363 | * @return {boolean} Whether an element was removed. 364 | */ 365 | goog.object.remove = function(obj, key) { 366 | var rv; 367 | if ((rv = key in obj)) { 368 | delete obj[key]; 369 | } 370 | return rv; 371 | }; 372 | 373 | 374 | /** 375 | * Adds a key-value pair to the object. Throws an exception if the key is 376 | * already in use. Use set if you want to change an existing pair. 377 | * 378 | * @param {Object.} obj The object to which to add the key-value pair. 379 | * @param {string} key The key to add. 380 | * @param {V} val The value to add. 381 | * @template K,V 382 | */ 383 | goog.object.add = function(obj, key, val) { 384 | if (key in obj) { 385 | throw Error('The object already contains the key "' + key + '"'); 386 | } 387 | goog.object.set(obj, key, val); 388 | }; 389 | 390 | 391 | /** 392 | * Returns the value for the given key. 393 | * 394 | * @param {Object.} obj The object from which to get the value. 395 | * @param {string} key The key for which to get the value. 396 | * @param {R=} opt_val The value to return if no item is found for the given 397 | * key (default is undefined). 398 | * @return {V|R|undefined} The value for the given key. 399 | * @template K,V,R 400 | */ 401 | goog.object.get = function(obj, key, opt_val) { 402 | if (key in obj) { 403 | return obj[key]; 404 | } 405 | return opt_val; 406 | }; 407 | 408 | 409 | /** 410 | * Adds a key-value pair to the object/map/hash. 411 | * 412 | * @param {Object.} obj The object to which to add the key-value pair. 413 | * @param {string} key The key to add. 414 | * @param {V} value The value to add. 415 | * @template K,V 416 | */ 417 | goog.object.set = function(obj, key, value) { 418 | obj[key] = value; 419 | }; 420 | 421 | 422 | /** 423 | * Adds a key-value pair to the object/map/hash if it doesn't exist yet. 424 | * 425 | * @param {Object.} obj The object to which to add the key-value pair. 426 | * @param {string} key The key to add. 427 | * @param {V} value The value to add if the key wasn't present. 428 | * @return {V} The value of the entry at the end of the function. 429 | * @template K,V 430 | */ 431 | goog.object.setIfUndefined = function(obj, key, value) { 432 | return key in obj ? obj[key] : (obj[key] = value); 433 | }; 434 | 435 | 436 | /** 437 | * Does a flat clone of the object. 438 | * 439 | * @param {Object.} obj Object to clone. 440 | * @return {!Object.} Clone of the input object. 441 | * @template K,V 442 | */ 443 | goog.object.clone = function(obj) { 444 | // We cannot use the prototype trick because a lot of methods depend on where 445 | // the actual key is set. 446 | 447 | var res = {}; 448 | for (var key in obj) { 449 | res[key] = obj[key]; 450 | } 451 | return res; 452 | // We could also use goog.mixin but I wanted this to be independent from that. 453 | }; 454 | 455 | 456 | /** 457 | * Clones a value. The input may be an Object, Array, or basic type. Objects and 458 | * arrays will be cloned recursively. 459 | * 460 | * WARNINGS: 461 | * goog.object.unsafeClone does not detect reference loops. Objects 462 | * that refer to themselves will cause infinite recursion. 463 | * 464 | * goog.object.unsafeClone is unaware of unique identifiers, and 465 | * copies UIDs created by getUid into cloned results. 466 | * 467 | * @param {*} obj The value to clone. 468 | * @return {*} A clone of the input value. 469 | */ 470 | goog.object.unsafeClone = function(obj) { 471 | var type = goog.typeOf(obj); 472 | if (type == 'object' || type == 'array') { 473 | if (obj.clone) { 474 | return obj.clone(); 475 | } 476 | var clone = type == 'array' ? [] : {}; 477 | for (var key in obj) { 478 | clone[key] = goog.object.unsafeClone(obj[key]); 479 | } 480 | return clone; 481 | } 482 | 483 | return obj; 484 | }; 485 | 486 | 487 | /** 488 | * Returns a new object in which all the keys and values are interchanged 489 | * (keys become values and values become keys). If multiple keys map to the 490 | * same value, the chosen transposed value is implementation-dependent. 491 | * 492 | * @param {Object} obj The object to transpose. 493 | * @return {!Object} The transposed object. 494 | */ 495 | goog.object.transpose = function(obj) { 496 | var transposed = {}; 497 | for (var key in obj) { 498 | transposed[obj[key]] = key; 499 | } 500 | return transposed; 501 | }; 502 | 503 | 504 | /** 505 | * The names of the fields that are defined on Object.prototype. 506 | * @type {Array.} 507 | * @private 508 | */ 509 | goog.object.PROTOTYPE_FIELDS_ = [ 510 | 'constructor', 511 | 'hasOwnProperty', 512 | 'isPrototypeOf', 513 | 'propertyIsEnumerable', 514 | 'toLocaleString', 515 | 'toString', 516 | 'valueOf' 517 | ]; 518 | 519 | 520 | /** 521 | * Extends an object with another object. 522 | * This operates 'in-place'; it does not create a new Object. 523 | * 524 | * Example: 525 | * var o = {}; 526 | * goog.object.extend(o, {a: 0, b: 1}); 527 | * o; // {a: 0, b: 1} 528 | * goog.object.extend(o, {c: 2}); 529 | * o; // {a: 0, b: 1, c: 2} 530 | * 531 | * @param {Object} target The object to modify. 532 | * @param {...Object} var_args The objects from which values will be copied. 533 | */ 534 | goog.object.extend = function(target, var_args) { 535 | var key, source; 536 | for (var i = 1; i < arguments.length; i++) { 537 | source = arguments[i]; 538 | for (key in source) { 539 | target[key] = source[key]; 540 | } 541 | 542 | // For IE the for-in-loop does not contain any properties that are not 543 | // enumerable on the prototype object (for example isPrototypeOf from 544 | // Object.prototype) and it will also not include 'replace' on objects that 545 | // extend String and change 'replace' (not that it is common for anyone to 546 | // extend anything except Object). 547 | 548 | for (var j = 0; j < goog.object.PROTOTYPE_FIELDS_.length; j++) { 549 | key = goog.object.PROTOTYPE_FIELDS_[j]; 550 | if (Object.prototype.hasOwnProperty.call(source, key)) { 551 | target[key] = source[key]; 552 | } 553 | } 554 | } 555 | }; 556 | 557 | 558 | /** 559 | * Creates a new object built from the key-value pairs provided as arguments. 560 | * @param {...*} var_args If only one argument is provided and it is an array 561 | * then this is used as the arguments, otherwise even arguments are used as 562 | * the property names and odd arguments are used as the property values. 563 | * @return {!Object} The new object. 564 | * @throws {Error} If there are uneven number of arguments or there is only one 565 | * non array argument. 566 | */ 567 | goog.object.create = function(var_args) { 568 | var argLength = arguments.length; 569 | if (argLength == 1 && goog.isArray(arguments[0])) { 570 | return goog.object.create.apply(null, arguments[0]); 571 | } 572 | 573 | if (argLength % 2) { 574 | throw Error('Uneven number of arguments'); 575 | } 576 | 577 | var rv = {}; 578 | for (var i = 0; i < argLength; i += 2) { 579 | rv[arguments[i]] = arguments[i + 1]; 580 | } 581 | return rv; 582 | }; 583 | 584 | 585 | /** 586 | * Creates a new object where the property names come from the arguments but 587 | * the value is always set to true 588 | * @param {...*} var_args If only one argument is provided and it is an array 589 | * then this is used as the arguments, otherwise the arguments are used 590 | * as the property names. 591 | * @return {!Object} The new object. 592 | */ 593 | goog.object.createSet = function(var_args) { 594 | var argLength = arguments.length; 595 | if (argLength == 1 && goog.isArray(arguments[0])) { 596 | return goog.object.createSet.apply(null, arguments[0]); 597 | } 598 | 599 | var rv = {}; 600 | for (var i = 0; i < argLength; i++) { 601 | rv[arguments[i]] = true; 602 | } 603 | return rv; 604 | }; 605 | 606 | 607 | /** 608 | * Creates an immutable view of the underlying object, if the browser 609 | * supports immutable objects. 610 | * 611 | * In default mode, writes to this view will fail silently. In strict mode, 612 | * they will throw an error. 613 | * 614 | * @param {!Object.} obj An object. 615 | * @return {!Object.} An immutable view of that object, or the 616 | * original object if this browser does not support immutables. 617 | * @template K,V 618 | */ 619 | goog.object.createImmutableView = function(obj) { 620 | var result = obj; 621 | if (Object.isFrozen && !Object.isFrozen(obj)) { 622 | result = Object.create(obj); 623 | Object.freeze(result); 624 | } 625 | return result; 626 | }; 627 | 628 | 629 | /** 630 | * @param {!Object} obj An object. 631 | * @return {boolean} Whether this is an immutable view of the object. 632 | */ 633 | goog.object.isImmutableView = function(obj) { 634 | return !!Object.isFrozen && Object.isFrozen(obj); 635 | }; 636 | -------------------------------------------------------------------------------- /lib/closure/goog/proto2/descriptor.js: -------------------------------------------------------------------------------- 1 | // Copyright 2008 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Protocol Buffer (Message) Descriptor class. 17 | */ 18 | 19 | goog.provide('goog.proto2.Descriptor'); 20 | goog.provide('goog.proto2.Metadata'); 21 | 22 | goog.require('goog.array'); 23 | goog.require('goog.asserts'); 24 | goog.require('goog.object'); 25 | goog.require('goog.string'); 26 | 27 | 28 | /** 29 | * @typedef {{name: (string|undefined), 30 | * fullName: (string|undefined), 31 | * containingType: (goog.proto2.Message|undefined)}} 32 | */ 33 | goog.proto2.Metadata; 34 | 35 | 36 | 37 | /** 38 | * A class which describes a Protocol Buffer 2 Message. 39 | * 40 | * @param {function(new:goog.proto2.Message)} messageType Constructor for 41 | * the message class that this descriptor describes. 42 | * @param {!goog.proto2.Metadata} metadata The metadata about the message that 43 | * will be used to construct this descriptor. 44 | * @param {Array.} fields The fields of the 45 | * message described by this descriptor. 46 | * 47 | * @constructor 48 | * @final 49 | */ 50 | goog.proto2.Descriptor = function(messageType, metadata, fields) { 51 | 52 | /** 53 | * @type {function(new:goog.proto2.Message)} 54 | * @private 55 | */ 56 | this.messageType_ = messageType; 57 | 58 | /** 59 | * @type {?string} 60 | * @private 61 | */ 62 | this.name_ = metadata.name || null; 63 | 64 | /** 65 | * @type {?string} 66 | * @private 67 | */ 68 | this.fullName_ = metadata.fullName || null; 69 | 70 | /** 71 | * @type {goog.proto2.Message|undefined} 72 | * @private 73 | */ 74 | this.containingType_ = metadata.containingType; 75 | 76 | /** 77 | * The fields of the message described by this descriptor. 78 | * @type {!Object.} 79 | * @private 80 | */ 81 | this.fields_ = {}; 82 | 83 | for (var i = 0; i < fields.length; i++) { 84 | var field = fields[i]; 85 | this.fields_[field.getTag()] = field; 86 | } 87 | }; 88 | 89 | 90 | /** 91 | * Returns the name of the message, if any. 92 | * 93 | * @return {?string} The name. 94 | */ 95 | goog.proto2.Descriptor.prototype.getName = function() { 96 | return this.name_; 97 | }; 98 | 99 | 100 | /** 101 | * Returns the full name of the message, if any. 102 | * 103 | * @return {?string} The name. 104 | */ 105 | goog.proto2.Descriptor.prototype.getFullName = function() { 106 | return this.fullName_; 107 | }; 108 | 109 | 110 | /** 111 | * Returns the descriptor of the containing message type or null if none. 112 | * 113 | * @return {goog.proto2.Descriptor} The descriptor. 114 | */ 115 | goog.proto2.Descriptor.prototype.getContainingType = function() { 116 | if (!this.containingType_) { 117 | return null; 118 | } 119 | 120 | return this.containingType_.getDescriptor(); 121 | }; 122 | 123 | 124 | /** 125 | * Returns the fields in the message described by this descriptor ordered by 126 | * tag. 127 | * 128 | * @return {!Array.} The array of field 129 | * descriptors. 130 | */ 131 | goog.proto2.Descriptor.prototype.getFields = function() { 132 | /** 133 | * @param {!goog.proto2.FieldDescriptor} fieldA First field. 134 | * @param {!goog.proto2.FieldDescriptor} fieldB Second field. 135 | * @return {number} Negative if fieldA's tag number is smaller, positive 136 | * if greater, zero if the same. 137 | */ 138 | function tagComparator(fieldA, fieldB) { 139 | return fieldA.getTag() - fieldB.getTag(); 140 | }; 141 | 142 | var fields = goog.object.getValues(this.fields_); 143 | goog.array.sort(fields, tagComparator); 144 | 145 | return fields; 146 | }; 147 | 148 | 149 | /** 150 | * Returns the fields in the message as a key/value map, where the key is 151 | * the tag number of the field. DO NOT MODIFY THE RETURNED OBJECT. We return 152 | * the actual, internal, fields map for performance reasons, and changing the 153 | * map can result in undefined behavior of this library. 154 | * 155 | * @return {!Object.} The field map. 156 | */ 157 | goog.proto2.Descriptor.prototype.getFieldsMap = function() { 158 | return this.fields_; 159 | }; 160 | 161 | 162 | /** 163 | * Returns the field matching the given name, if any. Note that 164 | * this method searches over the *original* name of the field, 165 | * not the camelCase version. 166 | * 167 | * @param {string} name The field name for which to search. 168 | * 169 | * @return {goog.proto2.FieldDescriptor} The field found, if any. 170 | */ 171 | goog.proto2.Descriptor.prototype.findFieldByName = function(name) { 172 | var valueFound = goog.object.findValue(this.fields_, 173 | function(field, key, obj) { 174 | return field.getName() == name; 175 | }); 176 | 177 | return /** @type {goog.proto2.FieldDescriptor} */ (valueFound) || null; 178 | }; 179 | 180 | 181 | /** 182 | * Returns the field matching the given tag number, if any. 183 | * 184 | * @param {number|string} tag The field tag number for which to search. 185 | * 186 | * @return {goog.proto2.FieldDescriptor} The field found, if any. 187 | */ 188 | goog.proto2.Descriptor.prototype.findFieldByTag = function(tag) { 189 | goog.asserts.assert(goog.string.isNumeric(tag)); 190 | return this.fields_[parseInt(tag, 10)] || null; 191 | }; 192 | 193 | 194 | /** 195 | * Creates an instance of the message type that this descriptor 196 | * describes. 197 | * 198 | * @return {!goog.proto2.Message} The instance of the message. 199 | */ 200 | goog.proto2.Descriptor.prototype.createMessageInstance = function() { 201 | return new this.messageType_; 202 | }; 203 | -------------------------------------------------------------------------------- /lib/closure/goog/proto2/fielddescriptor.js: -------------------------------------------------------------------------------- 1 | // Copyright 2008 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Protocol Buffer Field Descriptor class. 17 | */ 18 | 19 | goog.provide('goog.proto2.FieldDescriptor'); 20 | 21 | goog.require('goog.asserts'); 22 | goog.require('goog.string'); 23 | 24 | 25 | 26 | /** 27 | * A class which describes a field in a Protocol Buffer 2 Message. 28 | * 29 | * @param {Function} messageType Constructor for the message 30 | * class to which the field described by this class belongs. 31 | * @param {number|string} tag The field's tag index. 32 | * @param {Object} metadata The metadata about this field that will be used 33 | * to construct this descriptor. 34 | * 35 | * @constructor 36 | * @final 37 | */ 38 | goog.proto2.FieldDescriptor = function(messageType, tag, metadata) { 39 | /** 40 | * The message type that contains the field that this 41 | * descriptor describes. 42 | * @type {Function} 43 | * @private 44 | */ 45 | this.parent_ = messageType; 46 | 47 | // Ensure that the tag is numeric. 48 | goog.asserts.assert(goog.string.isNumeric(tag)); 49 | 50 | /** 51 | * The field's tag number. 52 | * @type {number} 53 | * @private 54 | */ 55 | this.tag_ = /** @type {number} */ (tag); 56 | 57 | /** 58 | * The field's name. 59 | * @type {string} 60 | * @private 61 | */ 62 | this.name_ = metadata.name; 63 | 64 | /** @type {goog.proto2.FieldDescriptor.FieldType} */ 65 | metadata.fieldType; 66 | 67 | /** @type {*} */ 68 | metadata.repeated; 69 | 70 | /** @type {*} */ 71 | metadata.required; 72 | 73 | /** 74 | * If true, this field is a repeating field. 75 | * @type {boolean} 76 | * @private 77 | */ 78 | this.isRepeated_ = !!metadata.repeated; 79 | 80 | /** 81 | * If true, this field is required. 82 | * @type {boolean} 83 | * @private 84 | */ 85 | this.isRequired_ = !!metadata.required; 86 | 87 | /** 88 | * The field type of this field. 89 | * @type {goog.proto2.FieldDescriptor.FieldType} 90 | * @private 91 | */ 92 | this.fieldType_ = metadata.fieldType; 93 | 94 | /** 95 | * If this field is a primitive: The native (ECMAScript) type of this field. 96 | * If an enumeration: The enumeration object. 97 | * If a message or group field: The Message function. 98 | * @type {Function} 99 | * @private 100 | */ 101 | this.nativeType_ = metadata.type; 102 | 103 | /** 104 | * Is it permissible on deserialization to convert between numbers and 105 | * well-formed strings? Is true for 64-bit integral field types, false for 106 | * all other field types. 107 | * @type {boolean} 108 | * @private 109 | */ 110 | this.deserializationConversionPermitted_ = false; 111 | 112 | switch (this.fieldType_) { 113 | case goog.proto2.FieldDescriptor.FieldType.INT64: 114 | case goog.proto2.FieldDescriptor.FieldType.UINT64: 115 | case goog.proto2.FieldDescriptor.FieldType.FIXED64: 116 | case goog.proto2.FieldDescriptor.FieldType.SFIXED64: 117 | case goog.proto2.FieldDescriptor.FieldType.SINT64: 118 | this.deserializationConversionPermitted_ = true; 119 | break; 120 | } 121 | 122 | /** 123 | * The default value of this field, if different from the default, default 124 | * value. 125 | * @type {*} 126 | * @private 127 | */ 128 | this.defaultValue_ = metadata.defaultValue; 129 | }; 130 | 131 | 132 | /** 133 | * An enumeration defining the possible field types. 134 | * Should be a mirror of that defined in descriptor.h. 135 | * 136 | * @enum {number} 137 | */ 138 | goog.proto2.FieldDescriptor.FieldType = { 139 | DOUBLE: 1, 140 | FLOAT: 2, 141 | INT64: 3, 142 | UINT64: 4, 143 | INT32: 5, 144 | FIXED64: 6, 145 | FIXED32: 7, 146 | BOOL: 8, 147 | STRING: 9, 148 | GROUP: 10, 149 | MESSAGE: 11, 150 | BYTES: 12, 151 | UINT32: 13, 152 | ENUM: 14, 153 | SFIXED32: 15, 154 | SFIXED64: 16, 155 | SINT32: 17, 156 | SINT64: 18 157 | }; 158 | 159 | 160 | /** 161 | * Returns the tag of the field that this descriptor represents. 162 | * 163 | * @return {number} The tag number. 164 | */ 165 | goog.proto2.FieldDescriptor.prototype.getTag = function() { 166 | return this.tag_; 167 | }; 168 | 169 | 170 | /** 171 | * Returns the descriptor describing the message that defined this field. 172 | * @return {goog.proto2.Descriptor} The descriptor. 173 | */ 174 | goog.proto2.FieldDescriptor.prototype.getContainingType = function() { 175 | return this.parent_.getDescriptor(); 176 | }; 177 | 178 | 179 | /** 180 | * Returns the name of the field that this descriptor represents. 181 | * @return {string} The name. 182 | */ 183 | goog.proto2.FieldDescriptor.prototype.getName = function() { 184 | return this.name_; 185 | }; 186 | 187 | 188 | /** 189 | * Returns the default value of this field. 190 | * @return {*} The default value. 191 | */ 192 | goog.proto2.FieldDescriptor.prototype.getDefaultValue = function() { 193 | if (this.defaultValue_ === undefined) { 194 | // Set the default value based on a new instance of the native type. 195 | // This will be (0, false, "") for (number, boolean, string) and will 196 | // be a new instance of a group/message if the field is a message type. 197 | var nativeType = this.nativeType_; 198 | if (nativeType === Boolean) { 199 | this.defaultValue_ = false; 200 | } else if (nativeType === Number) { 201 | this.defaultValue_ = 0; 202 | } else if (nativeType === String) { 203 | if (this.deserializationConversionPermitted_) { 204 | // This field is a 64 bit integer represented as a string. 205 | this.defaultValue_ = '0'; 206 | } else { 207 | this.defaultValue_ = ''; 208 | } 209 | } else { 210 | this.defaultValue_ = new nativeType; 211 | } 212 | } 213 | 214 | return this.defaultValue_; 215 | }; 216 | 217 | 218 | /** 219 | * Returns the field type of the field described by this descriptor. 220 | * @return {goog.proto2.FieldDescriptor.FieldType} The field type. 221 | */ 222 | goog.proto2.FieldDescriptor.prototype.getFieldType = function() { 223 | return this.fieldType_; 224 | }; 225 | 226 | 227 | /** 228 | * Returns the native (i.e. ECMAScript) type of the field described by this 229 | * descriptor. 230 | * 231 | * @return {Object} The native type. 232 | */ 233 | goog.proto2.FieldDescriptor.prototype.getNativeType = function() { 234 | return this.nativeType_; 235 | }; 236 | 237 | 238 | /** 239 | * Returns true if simple conversions between numbers and strings are permitted 240 | * during deserialization for this field. 241 | * 242 | * @return {boolean} Whether conversion is permitted. 243 | */ 244 | goog.proto2.FieldDescriptor.prototype.deserializationConversionPermitted = 245 | function() { 246 | return this.deserializationConversionPermitted_; 247 | }; 248 | 249 | 250 | /** 251 | * Returns the descriptor of the message type of this field. Only valid 252 | * for fields of type GROUP and MESSAGE. 253 | * 254 | * @return {goog.proto2.Descriptor} The message descriptor. 255 | */ 256 | goog.proto2.FieldDescriptor.prototype.getFieldMessageType = function() { 257 | goog.asserts.assert(this.isCompositeType(), 'Expected message or group'); 258 | 259 | return this.nativeType_.getDescriptor(); 260 | }; 261 | 262 | 263 | /** 264 | * @return {boolean} True if the field stores composite data or repeated 265 | * composite data (message or group). 266 | */ 267 | goog.proto2.FieldDescriptor.prototype.isCompositeType = function() { 268 | return this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.MESSAGE || 269 | this.fieldType_ == goog.proto2.FieldDescriptor.FieldType.GROUP; 270 | }; 271 | 272 | 273 | /** 274 | * Returns whether the field described by this descriptor is repeating. 275 | * @return {boolean} Whether the field is repeated. 276 | */ 277 | goog.proto2.FieldDescriptor.prototype.isRepeated = function() { 278 | return this.isRepeated_; 279 | }; 280 | 281 | 282 | /** 283 | * Returns whether the field described by this descriptor is required. 284 | * @return {boolean} Whether the field is required. 285 | */ 286 | goog.proto2.FieldDescriptor.prototype.isRequired = function() { 287 | return this.isRequired_; 288 | }; 289 | 290 | 291 | /** 292 | * Returns whether the field described by this descriptor is optional. 293 | * @return {boolean} Whether the field is optional. 294 | */ 295 | goog.proto2.FieldDescriptor.prototype.isOptional = function() { 296 | return !this.isRepeated_ && !this.isRequired_; 297 | }; 298 | -------------------------------------------------------------------------------- /lib/closure/goog/proto2/serializer.js: -------------------------------------------------------------------------------- 1 | // Copyright 2008 The Closure Library Authors. All Rights Reserved. 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 | /** 16 | * @fileoverview Base class for all Protocol Buffer 2 serializers. 17 | */ 18 | 19 | goog.provide('goog.proto2.Serializer'); 20 | 21 | goog.require('goog.asserts'); 22 | goog.require('goog.proto2.FieldDescriptor'); 23 | goog.require('goog.proto2.Message'); 24 | 25 | 26 | 27 | /** 28 | * Abstract base class for PB2 serializers. A serializer is a class which 29 | * implements the serialization and deserialization of a Protocol Buffer Message 30 | * to/from a specific format. 31 | * 32 | * @constructor 33 | */ 34 | goog.proto2.Serializer = function() {}; 35 | 36 | 37 | /** 38 | * @define {boolean} Whether to decode and convert symbolic enum values to 39 | * actual enum values or leave them as strings. 40 | */ 41 | goog.define('goog.proto2.Serializer.DECODE_SYMBOLIC_ENUMS', false); 42 | 43 | 44 | /** 45 | * Serializes a message to the expected format. 46 | * 47 | * @param {goog.proto2.Message} message The message to be serialized. 48 | * 49 | * @return {*} The serialized form of the message. 50 | */ 51 | goog.proto2.Serializer.prototype.serialize = goog.abstractMethod; 52 | 53 | 54 | /** 55 | * Returns the serialized form of the given value for the given field 56 | * if the field is a Message or Group and returns the value unchanged 57 | * otherwise. 58 | * 59 | * @param {goog.proto2.FieldDescriptor} field The field from which this 60 | * value came. 61 | * 62 | * @param {*} value The value of the field. 63 | * 64 | * @return {*} The value. 65 | * @protected 66 | */ 67 | goog.proto2.Serializer.prototype.getSerializedValue = function(field, value) { 68 | if (field.isCompositeType()) { 69 | return this.serialize(/** @type {goog.proto2.Message} */ (value)); 70 | } else { 71 | return value; 72 | } 73 | }; 74 | 75 | 76 | /** 77 | * Deserializes a message from the expected format. 78 | * 79 | * @param {goog.proto2.Descriptor} descriptor The descriptor of the message 80 | * to be created. 81 | * @param {*} data The data of the message. 82 | * 83 | * @return {goog.proto2.Message} The message created. 84 | */ 85 | goog.proto2.Serializer.prototype.deserialize = function(descriptor, data) { 86 | var message = descriptor.createMessageInstance(); 87 | this.deserializeTo(message, data); 88 | goog.asserts.assert(message instanceof goog.proto2.Message); 89 | return message; 90 | }; 91 | 92 | 93 | /** 94 | * Deserializes a message from the expected format and places the 95 | * data in the message. 96 | * 97 | * @param {goog.proto2.Message} message The message in which to 98 | * place the information. 99 | * @param {*} data The data of the message. 100 | */ 101 | goog.proto2.Serializer.prototype.deserializeTo = goog.abstractMethod; 102 | 103 | 104 | /** 105 | * Returns the deserialized form of the given value for the given field if the 106 | * field is a Message or Group and returns the value, converted or unchanged, 107 | * for primitive field types otherwise. 108 | * 109 | * @param {goog.proto2.FieldDescriptor} field The field from which this 110 | * value came. 111 | * 112 | * @param {*} value The value of the field. 113 | * 114 | * @return {*} The value. 115 | * @protected 116 | */ 117 | goog.proto2.Serializer.prototype.getDeserializedValue = function(field, value) { 118 | // Composite types are deserialized recursively. 119 | if (field.isCompositeType()) { 120 | if (value instanceof goog.proto2.Message) { 121 | return value; 122 | } 123 | 124 | return this.deserialize(field.getFieldMessageType(), value); 125 | } 126 | 127 | // Decode enum values. 128 | if (field.getFieldType() == goog.proto2.FieldDescriptor.FieldType.ENUM) { 129 | // If it's a string, get enum value by name. 130 | // NB: In order this feature to work, property renaming should be turned off 131 | // for the respective enums. 132 | if (goog.proto2.Serializer.DECODE_SYMBOLIC_ENUMS && goog.isString(value)) { 133 | // enumType is a regular Javascript enum as defined in field's metadata. 134 | var enumType = field.getNativeType(); 135 | if (enumType.hasOwnProperty(value)) { 136 | return enumType[value]; 137 | } 138 | } 139 | // Return unknown values as is for backward compatibility. 140 | return value; 141 | } 142 | 143 | // Return the raw value if the field does not allow the JSON input to be 144 | // converted. 145 | if (!field.deserializationConversionPermitted()) { 146 | return value; 147 | } 148 | 149 | // Convert to native type of field. Return the converted value or fall 150 | // through to return the raw value. The JSON encoding of int64 value 123 151 | // might be either the number 123 or the string "123". The field native type 152 | // could be either Number or String (depending on field options in the .proto 153 | // file). All four combinations should work correctly. 154 | var nativeType = field.getNativeType(); 155 | if (nativeType === String) { 156 | // JSON numbers can be converted to strings. 157 | if (goog.isNumber(value)) { 158 | return String(value); 159 | } 160 | } else if (nativeType === Number) { 161 | // JSON strings are sometimes used for large integer numeric values. 162 | if (goog.isString(value)) { 163 | // Validate the string. If the string is not an integral number, we would 164 | // rather have an assertion or error in the caller than a mysterious NaN 165 | // value. 166 | if (/^-?[0-9]+$/.test(value)) { 167 | return Number(value); 168 | } 169 | } 170 | } 171 | 172 | return value; 173 | }; 174 | -------------------------------------------------------------------------------- /lib/deps.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* global goog */ 16 | 17 | goog.addDependency('../../apphosting/api/urlfetch_service.pb.js', ['apphosting.URLFetchServiceError', 'apphosting.URLFetchServiceError.ErrorCode', 'apphosting.URLFetchRequest', 'apphosting.URLFetchRequest.Header', 'apphosting.URLFetchRequest.RequestMethod', 'apphosting.URLFetchResponse', 'apphosting.URLFetchResponse.Header'], ['goog.proto2.Message']); 18 | goog.addDependency('../../apphosting/api/dos/dos_service.pb.js', ['apphosting.DosServiceError', 'apphosting.DosServiceError.ErrorCode', 'apphosting.BlacklistEntry', 'apphosting.DosConfiguration', 'apphosting.SetDosConfigRequest', 'apphosting.SetDosConfigResponse', 'apphosting.GetDosConfigRequest', 'apphosting.GetDosConfigResponse', 'apphosting.ListRequest', 'apphosting.ListRequest.Category', 'apphosting.TopUsersRequest', 'apphosting.TopUser', 'apphosting.UsersList', 'apphosting.TopUsersResponse'], ['goog.proto2.Message']); 19 | goog.addDependency('../../apphosting/ext/remote_api/remote_api.pb.js', ['apphosting.ext.remote_api.Request', 'apphosting.ext.remote_api.ApplicationError', 'apphosting.ext.remote_api.RpcError', 'apphosting.ext.remote_api.RpcError.ErrorCode', 'apphosting.ext.remote_api.Response'], ['goog.proto2.Message']); 20 | goog.addDependency('../../apphosting/api/memcache/memcache_service.pb.js', ['apphosting.MemcacheServiceError', 'apphosting.MemcacheServiceError.ErrorCode', 'apphosting.AppOverride', 'apphosting.MemcacheGetRequest', 'apphosting.MemcacheGetResponse', 'apphosting.MemcacheGetResponse.Item', 'apphosting.MemcacheSetRequest', 'apphosting.MemcacheSetRequest.Item', 'apphosting.MemcacheSetRequest.SetPolicy', 'apphosting.MemcacheSetResponse', 'apphosting.MemcacheSetResponse.SetStatusCode', 'apphosting.MemcacheDeleteRequest', 'apphosting.MemcacheDeleteRequest.Item', 'apphosting.MemcacheDeleteResponse', 'apphosting.MemcacheDeleteResponse.DeleteStatusCode', 'apphosting.MemcacheIncrementRequest', 'apphosting.MemcacheIncrementRequest.Direction', 'apphosting.MemcacheIncrementResponse', 'apphosting.MemcacheIncrementResponse.IncrementStatusCode', 'apphosting.MemcacheBatchIncrementRequest', 'apphosting.MemcacheBatchIncrementResponse', 'apphosting.MemcacheFlushRequest', 'apphosting.MemcacheFlushResponse', 'apphosting.MemcacheStatsRequest', 'apphosting.MergedNamespaceStats', 'apphosting.MemcacheStatsResponse', 'apphosting.MemcacheGrabTailRequest', 'apphosting.MemcacheGrabTailResponse', 'apphosting.MemcacheGrabTailResponse.Item'], ['goog.proto2.Message']); 21 | goog.addDependency('../../apphosting/api/channel/channel_service.pb.js', ['apphosting.ChannelServiceError', 'apphosting.ChannelServiceError.ErrorCode', 'apphosting.CreateChannelRequest', 'apphosting.CreateChannelResponse', 'apphosting.SendMessageRequest'], ['goog.proto2.Message']); 22 | goog.addDependency('../../apphosting/api/blobstore/blobstore_upload.pb.js', ['apphosting.BlobstoreUploadInfo', 'apphosting.BlobInfo', 'apphosting.BlobRecord', 'apphosting.BlobUploadCheckpoint'], ['goog.proto2.Message']); 23 | goog.addDependency('../../apphosting/api/logservice/log_service.pb.js', ['apphosting.LogServiceError', 'apphosting.LogServiceError.ErrorCode', 'apphosting.UserAppLogLine', 'apphosting.UserAppLogGroup', 'apphosting.FlushRequest', 'apphosting.SetStatusRequest', 'apphosting.LogOffset', 'apphosting.LogLine', 'apphosting.RequestLog', 'apphosting.LogModuleVersion', 'apphosting.LogReadRequest', 'apphosting.LogReadResponse', 'apphosting.LogUsageRecord', 'apphosting.LogUsageRequest', 'apphosting.LogUsageResponse'], ['goog.proto2.Message']); 24 | goog.addDependency('../../apphosting/api/modules/modules_service.pb.js', ['apphosting.ModulesServiceError', 'apphosting.ModulesServiceError.ErrorCode', 'apphosting.GetModulesRequest', 'apphosting.GetModulesResponse', 'apphosting.GetVersionsRequest', 'apphosting.GetVersionsResponse', 'apphosting.GetDefaultVersionRequest', 'apphosting.GetDefaultVersionResponse', 'apphosting.GetNumInstancesRequest', 'apphosting.GetNumInstancesResponse', 'apphosting.SetNumInstancesRequest', 'apphosting.SetNumInstancesResponse', 'apphosting.StartModuleRequest', 'apphosting.StartModuleResponse', 'apphosting.StopModuleRequest', 'apphosting.StopModuleResponse', 'apphosting.GetHostnameRequest', 'apphosting.GetHostnameResponse'], ['goog.proto2.Message']); 25 | goog.addDependency('../../apphosting/api/app_identity/app_identity_service.pb.js', ['apphosting.AppIdentityServiceError', 'apphosting.AppIdentityServiceError.ErrorCode', 'apphosting.SignForAppRequest', 'apphosting.SignForAppResponse', 'apphosting.GetPublicCertificateForAppRequest', 'apphosting.PublicCertificate', 'apphosting.GetPublicCertificateForAppResponse', 'apphosting.GetServiceAccountNameRequest', 'apphosting.GetServiceAccountNameResponse', 'apphosting.GetAccessTokenRequest', 'apphosting.GetAccessTokenResponse', 'apphosting.GetDefaultGcsBucketNameRequest', 'apphosting.GetDefaultGcsBucketNameResponse'], ['goog.proto2.Message']); 26 | goog.addDependency('../../apphosting/api/files/file_service.pb.js', ['apphosting.files.FileServiceErrors', 'apphosting.files.FileServiceErrors.ErrorCode', 'apphosting.files.KeyValue', 'apphosting.files.KeyValues', 'apphosting.files.FileContentType', 'apphosting.files.FileContentType.ContentType', 'apphosting.files.CreateRequest', 'apphosting.files.CreateRequest.Parameter', 'apphosting.files.CreateResponse', 'apphosting.files.OpenRequest', 'apphosting.files.OpenRequest.OpenMode', 'apphosting.files.OpenResponse', 'apphosting.files.CloseRequest', 'apphosting.files.CloseResponse', 'apphosting.files.FileStat', 'apphosting.files.StatRequest', 'apphosting.files.StatResponse', 'apphosting.files.AppendRequest', 'apphosting.files.AppendResponse', 'apphosting.files.DeleteRequest', 'apphosting.files.DeleteResponse', 'apphosting.files.ReadRequest', 'apphosting.files.ReadResponse', 'apphosting.files.ReadKeyValueRequest', 'apphosting.files.ReadKeyValueResponse', 'apphosting.files.ReadKeyValueResponse.KeyValue', 'apphosting.files.ShuffleEnums', 'apphosting.files.ShuffleEnums.InputFormat', 'apphosting.files.ShuffleEnums.OutputFormat', 'apphosting.files.ShuffleEnums.Status', 'apphosting.files.ShuffleInputSpecification', 'apphosting.files.ShuffleOutputSpecification', 'apphosting.files.ShuffleRequest', 'apphosting.files.ShuffleRequest.Callback', 'apphosting.files.ShuffleResponse', 'apphosting.files.GetShuffleStatusRequest', 'apphosting.files.GetShuffleStatusResponse', 'apphosting.files.GetCapabilitiesRequest', 'apphosting.files.GetCapabilitiesResponse', 'apphosting.files.FinalizeRequest', 'apphosting.files.FinalizeResponse', 'apphosting.files.GetDefaultGsBucketNameRequest', 'apphosting.files.GetDefaultGsBucketNameResponse', 'apphosting.files.ListDirRequest', 'apphosting.files.ListDirResponse'], ['goog.proto2.Message']); 27 | goog.addDependency('../../apphosting/api/user_service.pb.js', ['apphosting.UserServiceError', 'apphosting.UserServiceError.ErrorCode', 'apphosting.CreateLoginURLRequest', 'apphosting.CreateLoginURLResponse', 'apphosting.CreateLogoutURLRequest', 'apphosting.CreateLogoutURLResponse', 'apphosting.GetOAuthUserRequest', 'apphosting.GetOAuthUserResponse', 'apphosting.CheckOAuthSignatureRequest', 'apphosting.CheckOAuthSignatureResponse'], ['goog.proto2.Message']); 28 | goog.addDependency('../../apphosting/api/taskqueue/taskqueue_service.pb.js', ['apphosting.TaskQueueServiceError', 'apphosting.TaskQueueServiceError.ErrorCode', 'apphosting.TaskPayload', 'apphosting.TaskQueueRetryParameters', 'apphosting.TaskQueueAcl', 'apphosting.TaskQueueHttpHeader', 'apphosting.TaskQueueMode', 'apphosting.TaskQueueMode.Mode', 'apphosting.TaskQueueAddRequest', 'apphosting.TaskQueueAddRequest.Header', 'apphosting.TaskQueueAddRequest.CronTimetable', 'apphosting.TaskQueueAddRequest.RequestMethod', 'apphosting.TaskQueueAddResponse', 'apphosting.TaskQueueBulkAddRequest', 'apphosting.TaskQueueBulkAddResponse', 'apphosting.TaskQueueBulkAddResponse.TaskResult', 'apphosting.TaskQueueDeleteRequest', 'apphosting.TaskQueueDeleteResponse', 'apphosting.TaskQueueForceRunRequest', 'apphosting.TaskQueueForceRunResponse', 'apphosting.TaskQueueUpdateQueueRequest', 'apphosting.TaskQueueUpdateQueueResponse', 'apphosting.TaskQueueFetchQueuesRequest', 'apphosting.TaskQueueFetchQueuesResponse', 'apphosting.TaskQueueFetchQueuesResponse.Queue', 'apphosting.TaskQueueFetchQueueStatsRequest', 'apphosting.TaskQueueScannerQueueInfo', 'apphosting.TaskQueueFetchQueueStatsResponse', 'apphosting.TaskQueueFetchQueueStatsResponse.QueueStats', 'apphosting.TaskQueuePauseQueueRequest', 'apphosting.TaskQueuePauseQueueResponse', 'apphosting.TaskQueuePurgeQueueRequest', 'apphosting.TaskQueuePurgeQueueResponse', 'apphosting.TaskQueueDeleteQueueRequest', 'apphosting.TaskQueueDeleteQueueResponse', 'apphosting.TaskQueueDeleteGroupRequest', 'apphosting.TaskQueueDeleteGroupResponse', 'apphosting.TaskQueueQueryTasksRequest', 'apphosting.TaskQueueQueryTasksResponse', 'apphosting.TaskQueueQueryTasksResponse.Task', 'apphosting.TaskQueueQueryTasksResponse.Task.Header', 'apphosting.TaskQueueQueryTasksResponse.Task.CronTimetable', 'apphosting.TaskQueueQueryTasksResponse.Task.RunLog', 'apphosting.TaskQueueQueryTasksResponse.Task.RequestMethod', 'apphosting.TaskQueueFetchTaskRequest', 'apphosting.TaskQueueFetchTaskResponse', 'apphosting.TaskQueueUpdateStorageLimitRequest', 'apphosting.TaskQueueUpdateStorageLimitResponse', 'apphosting.TaskQueueQueryAndOwnTasksRequest', 'apphosting.TaskQueueQueryAndOwnTasksResponse', 'apphosting.TaskQueueQueryAndOwnTasksResponse.Task', 'apphosting.TaskQueueModifyTaskLeaseRequest', 'apphosting.TaskQueueModifyTaskLeaseResponse'], ['goog.proto2.Message']); 29 | goog.addDependency('../../apphosting/api/mail_service.pb.js', ['apphosting.MailServiceError', 'apphosting.MailServiceError.ErrorCode', 'apphosting.MailAttachment', 'apphosting.MailHeader', 'apphosting.MailMessage'], ['goog.proto2.Message']); 30 | goog.addDependency('../../apphosting/api/capabilities/capability_service.pb.js', ['apphosting.IsEnabledRequest', 'apphosting.IsEnabledResponse', 'apphosting.IsEnabledResponse.SummaryStatus'], ['apphosting.CapabilityConfig', 'goog.proto2.Message']); 31 | goog.addDependency('../../apphosting/api/system/system_service.pb.js', ['apphosting.SystemServiceError', 'apphosting.SystemServiceError.ErrorCode', 'apphosting.SystemStat', 'apphosting.GetSystemStatsRequest', 'apphosting.GetSystemStatsResponse', 'apphosting.StartBackgroundRequestRequest', 'apphosting.StartBackgroundRequestResponse'], ['goog.proto2.Message']); 32 | goog.addDependency('../../apphosting/api/api_base.pb.js', ['apphosting.base.StringProto', 'apphosting.base.Integer32Proto', 'apphosting.base.Integer64Proto', 'apphosting.base.BoolProto', 'apphosting.base.DoubleProto', 'apphosting.base.BytesProto', 'apphosting.base.VoidProto'], ['goog.proto2.Message']); 33 | goog.addDependency('../../apphosting/base/capabilities.pb.js', ['apphosting.CapabilityConfigList', 'apphosting.CapabilityConfig', 'apphosting.CapabilityConfig.Status'], ['goog.proto2.Message']); 34 | goog.addDependency('../../apphosting/api/images/images_service.pb.js', ['apphosting.ImagesServiceError', 'apphosting.ImagesServiceError.ErrorCode', 'apphosting.ImagesServiceTransform', 'apphosting.ImagesServiceTransform.Type', 'apphosting.Transform', 'apphosting.ImageData', 'apphosting.InputSettings', 'apphosting.InputSettings.ORIENTATION_CORRECTION_TYPE', 'apphosting.OutputSettings', 'apphosting.OutputSettings.MIME_TYPE', 'apphosting.ImagesTransformRequest', 'apphosting.ImagesTransformResponse', 'apphosting.CompositeImageOptions', 'apphosting.CompositeImageOptions.ANCHOR', 'apphosting.ImagesCanvas', 'apphosting.ImagesCompositeRequest', 'apphosting.ImagesCompositeResponse', 'apphosting.ImagesHistogramRequest', 'apphosting.ImagesHistogram', 'apphosting.ImagesHistogramResponse', 'apphosting.ImagesGetUrlBaseRequest', 'apphosting.ImagesGetUrlBaseResponse', 'apphosting.ImagesDeleteUrlBaseRequest', 'apphosting.ImagesDeleteUrlBaseResponse'], ['goog.proto2.Message']); 35 | goog.addDependency('../../apphosting/api/blobstore/blobstore_service.pb.js', ['apphosting.BlobstoreServiceError', 'apphosting.BlobstoreServiceError.ErrorCode', 'apphosting.CreateUploadURLRequest', 'apphosting.CreateUploadURLResponse', 'apphosting.DeleteBlobRequest', 'apphosting.FetchDataRequest', 'apphosting.FetchDataResponse', 'apphosting.CloneBlobRequest', 'apphosting.CloneBlobResponse', 'apphosting.DecodeBlobKeyRequest', 'apphosting.DecodeBlobKeyResponse', 'apphosting.CreateEncodedGoogleStorageKeyRequest', 'apphosting.CreateEncodedGoogleStorageKeyResponse'], ['goog.proto2.Message']); 36 | goog.addDependency('../../net/proto2/contrib/WireSerializer.js', ['net.proto2.contrib.WireSerializer'], ['goog.asserts', 'goog.math.Long', 'goog.proto2.Message', 'goog.proto2.Serializer']); 37 | -------------------------------------------------------------------------------- /lib/net/proto2/contrib/WireSerializer.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /** 16 | * @fileoverview Protocol Buffer 2 Serializer which serializes and deserializes 17 | * messages using the wire format. Note that this serializer requires protocol 18 | * buffer reflection, which carries some overhead. 19 | * @supported any browser with DataView implemented. For now Chrome9, FF15, IE10 20 | * 21 | * @see https://developers.google.com/protocol-buffers/docs/encoding 22 | */ 23 | 24 | 25 | goog.provide('net.proto2.contrib.WireSerializer'); 26 | 27 | goog.require('goog.asserts'); 28 | goog.require('goog.math.Long'); 29 | goog.require('goog.proto2.Message'); 30 | goog.require('goog.proto2.Serializer'); 31 | 32 | 33 | 34 | /** 35 | * Wire format serializer. 36 | * 37 | * @constructor 38 | * @extends {goog.proto2.Serializer} 39 | */ 40 | net.proto2.contrib.WireSerializer = function() { 41 | /** 42 | * This array is where proto bytes go during serialization. 43 | * It must be reset for each serialization. 44 | * @type {!Array.} 45 | * @private 46 | */ 47 | this.buffer_ = []; 48 | 49 | /** 50 | * Scratch workspace to avoid allocations during serialization. 51 | * @type {{value: number, length: number}} 52 | * @private 53 | */ 54 | this.scratchTag32_ = {value: 0, length: 0}; 55 | 56 | /** 57 | * Scratch workspace to avoid allocations during serialization. 58 | * @type {{value: !goog.math.Long, length: number}} 59 | * @private 60 | */ 61 | this.scratchTag64_ = {value: goog.math.Long.ZERO, length: 0}; 62 | 63 | /** 64 | * Scratch data view for coding/decoding little-endian numbers. 65 | * @type {!DataView} 66 | * @private 67 | */ 68 | this.dataView_ = new DataView(new ArrayBuffer(8)); 69 | }; 70 | goog.inherits(net.proto2.contrib.WireSerializer, goog.proto2.Serializer); 71 | 72 | 73 | /** 74 | * @return {!Array.} The serialized form of the message. 75 | * @override 76 | */ 77 | net.proto2.contrib.WireSerializer.prototype.serialize = function(message) { 78 | if (message == null) { 79 | return []; 80 | } 81 | 82 | this.buffer_ = []; 83 | 84 | var descriptor = message.getDescriptor(); 85 | var fields = descriptor.getFields(); 86 | 87 | // Add the known fields. 88 | for (var i = 0; i < fields.length; i++) { 89 | var field = fields[i]; 90 | 91 | if (!message.has(field)) { 92 | continue; 93 | } 94 | 95 | if (field.isRepeated()) { 96 | for (var j = 0, n = message.countOf(field); j < n; j++) { 97 | var val = message.get(field, j); 98 | this.getSerializedValue(field, val); 99 | } 100 | } else { 101 | this.getSerializedValue(field, message.get(field)); 102 | } 103 | } 104 | 105 | return this.buffer_; 106 | }; 107 | 108 | 109 | /** 110 | * Append the serialized field tag to our serialization buffer. 111 | * @param {goog.proto2.FieldDescriptor} field The field to serialize. 112 | * @return {boolean} Whether the field tag was serialized. 113 | * @private 114 | */ 115 | net.proto2.contrib.WireSerializer.prototype.serializeFieldTag_ = 116 | function(field) { 117 | var wireType = 0; 118 | switch (field.getFieldType()) { 119 | default: 120 | return false; 121 | case goog.proto2.Message.FieldType.SINT32: 122 | case goog.proto2.Message.FieldType.SINT64: 123 | case goog.proto2.Message.FieldType.BOOL: 124 | case goog.proto2.Message.FieldType.INT64: 125 | case goog.proto2.Message.FieldType.ENUM: 126 | case goog.proto2.Message.FieldType.INT32: 127 | case goog.proto2.Message.FieldType.UINT32: 128 | case goog.proto2.Message.FieldType.UINT64: 129 | wireType = 0; 130 | break; 131 | case goog.proto2.Message.FieldType.FIXED64: 132 | case goog.proto2.Message.FieldType.SFIXED64: 133 | case goog.proto2.Message.FieldType.DOUBLE: 134 | wireType = 1; 135 | break; 136 | case goog.proto2.Message.FieldType.STRING: 137 | case goog.proto2.Message.FieldType.BYTES: 138 | case goog.proto2.Message.FieldType.MESSAGE: 139 | wireType = 2; 140 | break; 141 | case goog.proto2.Message.FieldType.GROUP: 142 | wireType = 3; 143 | break; 144 | case goog.proto2.Message.FieldType.FIXED32: 145 | case goog.proto2.Message.FieldType.SFIXED32: 146 | case goog.proto2.Message.FieldType.FLOAT: 147 | wireType = 5; 148 | break; 149 | } 150 | this.serializeVarint_((field.getTag() << 3) | wireType); 151 | return true; 152 | }; 153 | 154 | /** @override */ 155 | net.proto2.contrib.WireSerializer.prototype.getSerializedValue = 156 | function(field, value) { 157 | if (!this.serializeFieldTag_(field)) { 158 | return false; 159 | } 160 | 161 | switch (field.getFieldType()) { 162 | default: 163 | throw new Error('Unknown field type ' + field.getFieldType()); 164 | case goog.proto2.Message.FieldType.SINT32: 165 | this.serializeVarint_(this.zigZagEncode(/** @type {number} */ (value))); 166 | break; 167 | case goog.proto2.Message.FieldType.SINT64: 168 | this.serializeVarint64_(this.zigZagEncode64_( 169 | goog.math.Long.fromString(/** @type {string} */(value)))); 170 | break; 171 | case goog.proto2.Message.FieldType.BOOL: 172 | this.serializeVarint_(value ? 1 : 0); 173 | break; 174 | case goog.proto2.Message.FieldType.INT64: 175 | this.serializeVarint64_( 176 | goog.math.Long.fromString(/** @type {string} */(value))); 177 | break; 178 | case goog.proto2.Message.FieldType.ENUM: 179 | case goog.proto2.Message.FieldType.INT32: 180 | case goog.proto2.Message.FieldType.UINT32: 181 | case goog.proto2.Message.FieldType.UINT64: 182 | this.serializeVarint_(/** @type {number} */ (value)); 183 | break; 184 | case goog.proto2.Message.FieldType.FIXED64: 185 | case goog.proto2.Message.FieldType.SFIXED64: 186 | this.serializeFixed_(/** @type {number} */ (value), 8); 187 | break; 188 | case goog.proto2.Message.FieldType.DOUBLE: 189 | this.serializeDouble_(/** @type {number} */ (value)); 190 | break; 191 | case goog.proto2.Message.FieldType.STRING: 192 | case goog.proto2.Message.FieldType.BYTES: 193 | this.serializeString(value); 194 | break; 195 | case goog.proto2.Message.FieldType.GROUP: 196 | var serialized = new net.proto2.contrib.WireSerializer().serialize( 197 | /** @type {goog.proto2.Message} */ (value)); 198 | Array.prototype.push.apply(this.buffer_, serialized); 199 | this.serializeVarint_((field.getTag() << 3) | 4); 200 | break; 201 | case goog.proto2.Message.FieldType.MESSAGE: 202 | var serialized = new net.proto2.contrib.WireSerializer().serialize( 203 | /** @type {goog.proto2.Message} */ (value)); 204 | this.serializeVarint_(serialized.length); 205 | Array.prototype.push.apply(this.buffer_, serialized); 206 | break; 207 | case goog.proto2.Message.FieldType.FIXED32: 208 | case goog.proto2.Message.FieldType.SFIXED32: 209 | this.serializeFixed_(/** @type {number} */ (value), 4); 210 | break; 211 | case goog.proto2.Message.FieldType.FLOAT: 212 | this.serializeFloat_(/** @type {number} */ (value)); 213 | break; 214 | } 215 | // To avoid allocations, this method serializes into a pre-existing buffer, 216 | // rather than serializing into a new value object. 217 | return null; 218 | }; 219 | 220 | 221 | /** @override */ 222 | net.proto2.contrib.WireSerializer.prototype.deserializeTo = 223 | function(message, buffer) { 224 | if (buffer == null) { 225 | // Since value double-equals null, it may be either null or undefined. 226 | // Ensure we return the same one, since they have different meanings. 227 | return buffer; 228 | } 229 | 230 | var descriptor = message.getDescriptor(); 231 | 232 | while (true) { 233 | var tag = this.parseUnsignedVarInt_(buffer); 234 | var tagValue = tag.value; 235 | var tagLength = tag.length; 236 | var index = tagValue >> 3; 237 | // For future reference, the wiretype is tagValue & 0x7. 238 | var value = {value: undefined, length: 0}; 239 | var field = descriptor.findFieldByTag(index); 240 | if (field) { 241 | value = this.getDeserializedValue(field, buffer.subarray(tagLength)); 242 | if (value && value.value !== null) { 243 | if (field.isRepeated()) { 244 | message.add(field, value.value); 245 | } else { 246 | message.set(field, value.value); 247 | } 248 | } 249 | } 250 | if (buffer.length < tagLength + value.length) { 251 | break; 252 | } 253 | buffer = buffer.subarray(tagLength + value.length); 254 | } 255 | }; 256 | 257 | 258 | /** 259 | * Deserializes a message from the expected format and places the 260 | * data in the message. The message must correspond to a group. Moreover 261 | * the buffer must be positioned after the initial START_GROUP tag for the 262 | * group. The message will be terminated by the first END_GROUP tag at the 263 | * same nesting level. It is the responsibility of the caller to validate that 264 | * its field index matches the one in the opening START_GROUP tag. Since groups 265 | * are not length-delimited, this method returns the length of the parsed 266 | * data excluding the END_GROUP tag. 267 | * 268 | * @param {goog.proto2.Message} message The message in which to 269 | * place the information. 270 | * @param {*} buffer The data of the message. 271 | * @return {number} the length of the parsed message, excluding the closing tag. 272 | * @protected 273 | */ 274 | net.proto2.contrib.WireSerializer.prototype.deserializeGroupTo = 275 | function(message, buffer) { 276 | if (buffer == null) { 277 | return 0; 278 | } 279 | 280 | var descriptor = message.getDescriptor(); 281 | var parsedLength = 0; 282 | 283 | while (true) { 284 | var tag = this.parseUnsignedVarInt_(buffer); 285 | var tagValue = tag.value; 286 | var tagLength = tag.length; 287 | var index = tagValue >> 3; 288 | var wiretype = tagValue & 7; 289 | if (wiretype == 4) { 290 | // Got an end group. 291 | break; 292 | } 293 | parsedLength += tagLength; 294 | var value = {value: undefined, length: 0}; 295 | var field = descriptor.findFieldByTag(index); 296 | if (field) { 297 | value = this.getDeserializedValue(field, buffer.subarray(tagLength)); 298 | if (value && value.value !== null) { 299 | if (field.isRepeated()) { 300 | message.add(field, value.value); 301 | } else { 302 | message.set(field, value.value); 303 | } 304 | } 305 | } 306 | parsedLength += value.length; 307 | if (buffer.length < tagLength + value.length) { 308 | break; 309 | } 310 | buffer = buffer.subarray(tagLength + value.length); 311 | } 312 | return parsedLength; 313 | }; 314 | 315 | 316 | /** 317 | * @override 318 | */ 319 | net.proto2.contrib.WireSerializer.prototype.getDeserializedValue = 320 | function(field, buffer) { 321 | var value = null; 322 | var t = field.getFieldType(); 323 | var varInt = this.parseVarInt64_(buffer); 324 | var length = varInt.length; 325 | switch (t) { 326 | case goog.proto2.Message.FieldType.SINT32: 327 | value = this.zigZagDecode_(varInt.value.toInt()); 328 | break; 329 | case goog.proto2.Message.FieldType.SINT64: 330 | value = this.zigZagDecode64_(varInt.value).toString(); 331 | break; 332 | case goog.proto2.Message.FieldType.BOOL: 333 | value = varInt.value.equals(goog.math.Long.ONE); 334 | break; 335 | case goog.proto2.Message.FieldType.INT64: 336 | case goog.proto2.Message.FieldType.UINT64: 337 | value = varInt.value.toString(); 338 | break; 339 | case goog.proto2.Message.FieldType.ENUM: 340 | case goog.proto2.Message.FieldType.INT32: 341 | case goog.proto2.Message.FieldType.UINT32: 342 | value = varInt.value.toInt(); 343 | break; 344 | case goog.proto2.Message.FieldType.FIXED64: 345 | case goog.proto2.Message.FieldType.SFIXED64: 346 | value = this.parseFixed_(buffer.subarray(0, 8)).toString(); 347 | length = 8; 348 | break; 349 | case goog.proto2.Message.FieldType.DOUBLE: 350 | value = this.parseDouble_(buffer.subarray(0, 8)); 351 | length = 8; 352 | break; 353 | case goog.proto2.Message.FieldType.STRING: 354 | var strBuffer = 355 | buffer.subarray(varInt.length, varInt.length + varInt.value.toInt()); 356 | value = String.fromCharCode.apply(null, strBuffer); 357 | length = varInt.length + varInt.value.toInt(); 358 | break; 359 | case goog.proto2.Message.FieldType.BYTES: 360 | var strBuffer = 361 | buffer.subarray(varInt.length, varInt.length + varInt.value.toInt()); 362 | value = String.fromCharCode.apply(null, strBuffer); 363 | length = varInt.length + varInt.value.toInt(); 364 | break; 365 | case goog.proto2.Message.FieldType.GROUP: 366 | value = field.getFieldMessageType().createMessageInstance(); 367 | var groupLength = this.deserializeGroupTo(value, buffer); 368 | var next = buffer.subarray(groupLength); 369 | var closingTag = this.parseVarInt64_(next); 370 | var expected = (field.getTag() << 3) | 4; 371 | goog.asserts.assert(closingTag.value.toInt() == expected, 372 | 'Error deserializing group'); 373 | length = groupLength + closingTag.length; 374 | break; 375 | case goog.proto2.Message.FieldType.MESSAGE: 376 | length = varInt.length + varInt.value.toInt(); 377 | var data = buffer.subarray(varInt.length, length); 378 | value = field.getFieldMessageType().createMessageInstance(); 379 | this.deserializeTo(value, data); 380 | break; 381 | case goog.proto2.Message.FieldType.FIXED32: 382 | case goog.proto2.Message.FieldType.SFIXED32: 383 | value = this.parseFixed_(buffer.subarray(0, 4)); 384 | length = 4; 385 | break; 386 | case goog.proto2.Message.FieldType.FLOAT: 387 | value = this.parseFloat_(buffer.subarray(0, 4)); 388 | length = 4; 389 | break; 390 | } 391 | return {value: value, length: length}; 392 | }; 393 | 394 | 395 | /** 396 | * @param {*} value String that needs to be converted to bytes. 397 | */ 398 | net.proto2.contrib.WireSerializer.prototype.serializeString = function(value) { 399 | if (goog.isDefAndNotNull(value)) { 400 | // Serialize length. 401 | this.serializeVarint_(value.length); 402 | for (var i = 0; i < value.length; i++) { 403 | this.buffer_.push(value.charCodeAt(i)); 404 | } 405 | } 406 | }; 407 | 408 | 409 | /** 410 | * @param {*} buffer to parse as String. 411 | * @return {{value: string, length: number}} 412 | */ 413 | net.proto2.contrib.WireSerializer.prototype.parseString = function(buffer) { 414 | var length = this.parseUnsignedVarInt_(buffer); 415 | var strBuffer = buffer.subarray(length.length, length.length + length.value); 416 | return { 417 | value: String.fromCharCode.apply(null, strBuffer), 418 | length: length.length + length.value 419 | }; 420 | }; 421 | 422 | 423 | /** 424 | * @param {number} number signed number that needs to be converted to unsigned. 425 | * @return {number} 426 | */ 427 | net.proto2.contrib.WireSerializer.prototype.zigZagEncode = 428 | function(number) { 429 | var sign = number >>> 31; 430 | return (number << 1) ^ -sign; 431 | }; 432 | 433 | 434 | /** 435 | * @param {number} number Unsigned number in zigzag format that needs 436 | to be converted to signed. 437 | * @return {number} signed. 438 | * @private 439 | */ 440 | net.proto2.contrib.WireSerializer.prototype.zigZagDecode_ = 441 | function(number) { 442 | return (number >>> 1) ^ -(number & 1); 443 | }; 444 | 445 | 446 | /** 447 | * @param {!goog.math.Long} number signed number that needs to be converted to 448 | * unsigned. 449 | * @return {!goog.math.Long} 450 | * @private 451 | */ 452 | net.proto2.contrib.WireSerializer.prototype.zigZagEncode64_ = 453 | function(number) { 454 | var sign = number.shiftRightUnsigned(63); 455 | return number.shiftLeft(1).xor(sign.negate()); 456 | }; 457 | 458 | 459 | /** 460 | * @param {!goog.math.Long} number Unsigned number in zigzag format that needs 461 | to be converted to signed. 462 | * @return {!goog.math.Long} 463 | * @private 464 | */ 465 | net.proto2.contrib.WireSerializer.prototype.zigZagDecode64_ = 466 | function(number) { 467 | return number.shiftRightUnsigned(1).xor( 468 | number.and(goog.math.Long.ONE).negate()); 469 | }; 470 | 471 | 472 | /** 473 | * Serialize the given number as a varint into our buffer. 474 | * @param {number} number that needs to be converted to varint. 475 | * @private 476 | */ 477 | net.proto2.contrib.WireSerializer.prototype.serializeVarint_ = 478 | function(number) { 479 | do { 480 | var chunk = number & 0x7F; 481 | number = number >>> 7; 482 | if (number > 0) { 483 | chunk = chunk | 0x80; 484 | } 485 | this.buffer_.push(chunk); 486 | } while (number > 0); 487 | }; 488 | 489 | 490 | /** 491 | * Serialize the given 64-bit number as a varint into our buffer. 492 | * @param {!goog.math.Long} number that needs to be encoded as varint. 493 | * @private 494 | */ 495 | net.proto2.contrib.WireSerializer.prototype.serializeVarint64_ = 496 | function(number) { 497 | var mask = goog.math.Long.fromInt(0x7F); 498 | do { 499 | var chunk = number.and(mask).toInt(); 500 | number = number.shiftRightUnsigned(7); 501 | if (number.greaterThan(goog.math.Long.ZERO)) { 502 | chunk = chunk | 0x80; 503 | } 504 | this.buffer_.push(chunk); 505 | } while (number.greaterThan(goog.math.Long.ZERO)); 506 | }; 507 | 508 | 509 | /** 510 | * @param {*} buffer from which field number and type needs to be extracted. 511 | * @return {{value: !goog.math.Long, length: number}} 512 | * @private 513 | */ 514 | net.proto2.contrib.WireSerializer.prototype.parseVarInt64_ = function(buffer) { 515 | var valueInfo = this.scratchTag64_; 516 | var number = goog.math.Long.fromNumber(0); 517 | var i = 0; 518 | for (; i < buffer.length; i++) { 519 | var bits = goog.math.Long.fromInt(buffer[i] & 0x7F).shiftLeft(i * 7); 520 | number = number.or(bits); 521 | if ((buffer[i] & 0x80) == 0) { 522 | break; 523 | } 524 | } 525 | valueInfo.value = number; 526 | valueInfo.length = i + 1; 527 | return valueInfo; 528 | }; 529 | 530 | 531 | /** 532 | * A special case parser for unsigned 32-bit varints, which can fit comfortably 533 | * in 32 bits during decoding. 534 | * @param {*} buffer from which field number and type needs to be extracted. 535 | * @return {{value: number, length: number}} 536 | * @private 537 | */ 538 | net.proto2.contrib.WireSerializer.prototype.parseUnsignedVarInt_ = 539 | function(buffer) { 540 | var valueInfo = this.scratchTag32_; 541 | var result = 0; 542 | var i = 0; 543 | for (; i < buffer.length; i++) { 544 | result = result | ((buffer[i] & 0x7F) << (i * 7)); 545 | if ((buffer[i] & 0x80) == 0) { 546 | break; 547 | } 548 | } 549 | valueInfo.value = result; 550 | valueInfo.length = i + 1; 551 | return valueInfo; 552 | }; 553 | 554 | 555 | /** 556 | * @param {number} number that needs to be converted to little endian order. 557 | * @param {number} size of the result array (4 = 32bit, 8 = 64bit). 558 | * @private 559 | */ 560 | net.proto2.contrib.WireSerializer.prototype.serializeFixed_ = 561 | function(number, size) { 562 | for (var i = 0; i < size; i++) { 563 | this.buffer_.push(number & 0xFF); 564 | number = number >>> 8; 565 | } 566 | }; 567 | 568 | 569 | /** 570 | * @param {*} buffer from which field number and type needs 571 | * to be extracted. 572 | * @return {number} 573 | * @private 574 | */ 575 | net.proto2.contrib.WireSerializer.prototype.parseFixed_ = function(buffer) { 576 | var number = 0; 577 | for (var i = 0; i < buffer.length; i++) { 578 | number = number | (buffer[i] << (i * 8)); 579 | } 580 | return number; 581 | }; 582 | 583 | 584 | /** 585 | * @param {*} buffer from which double needs to be extracted. 586 | * @return {number} 587 | * @private 588 | */ 589 | net.proto2.contrib.WireSerializer.prototype.parseDouble_ = function(buffer) { 590 | for (var i = 0; i < 8; i++) { 591 | this.dataView_.setUint8(i, buffer[i]); 592 | } 593 | return this.dataView_.getFloat64(0, true); // little-endian 594 | }; 595 | 596 | 597 | /** 598 | * @param {*} buffer from which float needs to be extracted. 599 | * @return {number} 600 | * @private 601 | */ 602 | net.proto2.contrib.WireSerializer.prototype.parseFloat_ = function(buffer) { 603 | for (var i = 0; i < 4; i++) { 604 | this.dataView_.setUint8(i, buffer[i]); 605 | } 606 | return this.dataView_.getFloat32(0, true); // little-endian 607 | }; 608 | 609 | 610 | /** 611 | * @param {number} number to be serialized to 8 bytes. 612 | * @private 613 | */ 614 | net.proto2.contrib.WireSerializer.prototype.serializeDouble_ = 615 | function(number) { 616 | this.dataView_.setFloat64(0, number, true); // little-endian 617 | for (var i = 0; i < 8; i++) { 618 | this.buffer_.push(this.dataView_.getUint8(i)); 619 | } 620 | }; 621 | 622 | 623 | /** 624 | * @param {number} number to be serialized to 4 bytes. 625 | * @private 626 | */ 627 | net.proto2.contrib.WireSerializer.prototype.serializeFloat_ = function(number) { 628 | this.dataView_.setFloat32(0, number, true); // little-endian 629 | for (var i = 0; i < 4; i++) { 630 | this.buffer_.push(this.dataView_.getUint8(i)); 631 | } 632 | }; 633 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | 'use strict'; 16 | 17 | module.exports = { 18 | numberArrayToString: numberArrayToString, 19 | bufferToUint8Array: bufferToUint8Array, 20 | stringToUint8Array: stringToUint8Array, 21 | }; 22 | 23 | /** 24 | * Convert an array of numbers to a string. 25 | * 26 | * @param {Array.} a array to convert 27 | * @return {!string} resulting string 28 | */ 29 | function numberArrayToString(a) { 30 | var s = ''; 31 | for (var i in a) { 32 | s += String.fromCharCode(a[i]); 33 | } 34 | return s; 35 | } 36 | 37 | /** 38 | * Convert a node.js Buffer to a UInt8Array. 39 | * 40 | * @param {!Buffer} buffer buffer to convert 41 | * @return {!Uint8Array} resulting array 42 | */ 43 | function bufferToUint8Array(buffer) { 44 | var ab = new ArrayBuffer(buffer.length); 45 | var view = new Uint8Array(ab); 46 | for (var i = 0; i < buffer.length; ++i) { 47 | view[i] = buffer[i]; 48 | } 49 | return view; 50 | } 51 | 52 | /** 53 | * Convert a string to a Uint8Array. 54 | * @param {!string} s string to convert 55 | * @return {UInt8Array} resulting array 56 | */ 57 | function stringToUint8Array(s) { 58 | var a = new Uint8Array(s.length); 59 | for(var i = 0, j = s.length; i < j; ++i) { 60 | a[i] = s.charCodeAt(i); 61 | } 62 | return a; 63 | } 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appengine", 3 | "version": "0.3.0", 4 | "description": "Appengine client library for node.js", 5 | "author": "Google Inc.", 6 | "contributors": { 7 | "name": "Roberto Chinnici", 8 | "email": "rrch@google.com" 9 | }, 10 | "main": "./lib/index", 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/googlecloudplatform/appengine-nodejs.git" 14 | }, 15 | "license": "Apache 2", 16 | "dependencies": { 17 | "winston": "^0.8.1" 18 | }, 19 | "devDependencies": { 20 | "istanbul": "^0.3.0", 21 | "jshint": "^2.5.2", 22 | "mocha": "^1.21.3", 23 | "tmp": "^0.0.24" 24 | }, 25 | "scripts": { 26 | "lint": "jshint lib/*.js test/*.js", 27 | "test": "mocha --recursive --reporter spec", 28 | "cover": "istanbul cover _mocha -- --reporter spec" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/utils.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 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 | /* global describe, it */ 16 | 17 | 'use strict'; 18 | 19 | var assert = require('assert'); 20 | var utils = require('../lib/utils.js'); 21 | 22 | describe('numberArrayToString', function() { 23 | it('should convert a non-empty array', function() { 24 | var a = [65, 66]; 25 | var s = utils.numberArrayToString(a); 26 | assert.strictEqual(s, 'AB'); 27 | }); 28 | 29 | it('should convert an empty array', function() { 30 | var a = []; 31 | var s = utils.numberArrayToString(a); 32 | assert.strictEqual(s, ''); 33 | }); 34 | }); 35 | 36 | describe('bufferToUint8Array', function() { 37 | it('should convert a non-empty buffer', function() { 38 | var b = new Buffer(2); 39 | b.writeUInt16BE(0x1234); 40 | var a = utils.bufferToUint8Array(b); 41 | assert.deepEqual(a, new Uint8Array([0x12, 0x34])); 42 | }); 43 | 44 | it('should convert an empty buffer', function() { 45 | var b = new Buffer(0); 46 | var a = utils.bufferToUint8Array(b); 47 | assert.deepEqual(a, new Uint8Array([])); 48 | }); 49 | }); 50 | 51 | describe('stringToUint8Array', function() { 52 | it('should convert a non-empty string', function() { 53 | var a = utils.stringToUint8Array('AB'); 54 | assert.deepEqual(a, new Uint8Array([65, 66])); 55 | }); 56 | 57 | it('should convert an empty string', function() { 58 | var a = utils.stringToUint8Array(''); 59 | assert.deepEqual(a, new Uint8Array([])); 60 | }); 61 | }); 62 | --------------------------------------------------------------------------------