├── .vscode └── settings.json ├── deploy.sh ├── .gcloudignore ├── .gitignore ├── tsconfig.json ├── src ├── gmp_client.ts ├── places.ts ├── directions.ts └── origins.ts ├── index.ts ├── package.json ├── CONTRIBUTING.md ├── README.md ├── tslint.json └── LICENSE /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/*.js": true, 4 | "**/*.d.ts": true 5 | } 6 | } -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gcloud functions deploy "function" --trigger-http --runtime=nodejs10 --env-vars-file .env.yaml -------------------------------------------------------------------------------- /.gcloudignore: -------------------------------------------------------------------------------- 1 | # Ignore git 2 | .git 3 | .gitignore 4 | 5 | # Ignore non-GCF files 6 | .gcloudignore 7 | *.ts 8 | node_modules 9 | .vscode 10 | *.md 11 | tsconfig.json 12 | tslint.json 13 | LICENSE 14 | *.sh -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # TypeScript 2 | *.js 3 | 4 | # Logs 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | 11 | # Dependency directories 12 | node_modules/ 13 | 14 | # dotenv environment variables file 15 | .env 16 | 17 | .DS_Store 18 | *.d.ts 19 | 20 | # Secret 21 | .env.yaml 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": true, 3 | "declaration": true, 4 | "compilerOptions": { 5 | "target": "es3", // mjs imports/modules aren't supported 6 | "lib": [ 7 | "es2015", 8 | "es5", 9 | "es6", 10 | "es2017" 11 | ], 12 | "strict": true, 13 | "allowSyntheticDefaultImports": true, 14 | }, 15 | "moduleResolution": "node", 16 | "include": [ 17 | "index.ts", 18 | "src/", 19 | ], 20 | "typings": "index.d.ts" 21 | } -------------------------------------------------------------------------------- /src/gmp_client.ts: -------------------------------------------------------------------------------- 1 | import {createClient} from '@google/maps'; 2 | 3 | /** 4 | * Gets the Google Maps API Client. 5 | * @throws {Error} If there is no `API_KEY` env var present. 6 | */ 7 | export const getClient = () => { 8 | // Parse the Google Maps API_KEY 9 | const API_KEY = process.env.API_KEY as string; 10 | if (!API_KEY) throw new Error('Error: API_KEY environment variable required.'); 11 | 12 | // Create the Maps Client 13 | const googleMapsClient = createClient({ 14 | key: API_KEY, 15 | Promise, 16 | }); 17 | return googleMapsClient; 18 | }; -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | import {Request, Response} from 'express'; 2 | 3 | import directions from './src/directions'; 4 | import origins from './src/origins'; 5 | import places from './src/places'; 6 | 7 | /** 8 | * Entry point into the Functions Framework. 9 | * @see https://github.com/GoogleCloudPlatform/functions-framework-nodejs 10 | */ 11 | exports.function = (req: Request, res: Response) => { 12 | const paths = { 13 | '/directions': directions, 14 | '/origins': origins, 15 | '/places': places, 16 | // Default route (at the end) 17 | '/': () => res.send(Object.keys(paths)), 18 | }; 19 | // Find the first route that matches 20 | for (const [path, route] of Object.entries(paths)) { 21 | if (req.path.startsWith(path)) { 22 | return route(req, res); 23 | } 24 | } 25 | 26 | // Allow CORS 27 | res.header('Access-Control-Allow-Origin', '*'); 28 | res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); 29 | 30 | res.send('No path found'); 31 | }; 32 | -------------------------------------------------------------------------------- /src/places.ts: -------------------------------------------------------------------------------- 1 | import {Request, Response} from 'express'; 2 | 3 | import {getClient} from './gmp_client'; 4 | 5 | /** 6 | * Returns place details at the specific location. 7 | * Requires an `API_KEY` environment variable. 8 | * @see https://github.com/googlemaps/google-maps-services-js#nodejs-client-for-google-maps-services 9 | */ 10 | export default async (req: Request, res: Response) => { 11 | // Get the Maps Client 12 | let googleMapsClient; 13 | try { 14 | googleMapsClient = getClient(); 15 | } catch (e) { 16 | return res.status(400).send(e); 17 | } 18 | 19 | // Validate origin 20 | const origin = req.query.origin; 21 | if (!origin) { 22 | return res.status(400).send('Error: origin must be provided. Example: origin=37.7841393,-122.404467'); 23 | } 24 | 25 | // Execute API request 26 | const response = await googleMapsClient.places({ 27 | query: origin, 28 | }).asPromise(); 29 | 30 | // Send the response 31 | res.send({ 32 | data: response.json, 33 | request: { 34 | query: req.query, 35 | params: req.path, 36 | }, 37 | }); 38 | }; 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@google-cloud/functions-as-a-service", 3 | "version": "1.0.0", 4 | "description": "A demo showing GMP + GCF.", 5 | "scripts": { 6 | "build": "tsc --watch --declaration", 7 | "watch": "npm-watch local", 8 | "local": "functions-framework", 9 | "deploy": "cd gcf && npm run deploy", 10 | "test": "cd gmp && npm run test", 11 | "clean": "find . -name '*.js' -type f -delete" 12 | }, 13 | "private": true, 14 | "repository": { 15 | "type": "git", 16 | "url": "sso://devrel/samples/cloud/sushi-as-a-service" 17 | }, 18 | "watch": { 19 | "local": "*.js" 20 | }, 21 | "keywords": [ 22 | "GCF", 23 | "GMP", 24 | "functions", 25 | "serverless", 26 | "maps" 27 | ], 28 | "author": "Grant Timmerman, Alex Muramoto, Angela Yu", 29 | "license": "MIT", 30 | "devDependencies": { 31 | "@google-cloud/functions-framework": "^1.1.0", 32 | "npm-watch": "^0.6.0", 33 | "tslint": "^5.16.0", 34 | "typescript": "^3.4.4" 35 | }, 36 | "dependencies": { 37 | "@google/maps": "^0.5.5", 38 | "@types/express": "^4.16.1", 39 | "@types/google__maps": "^0.5.5" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google.com/conduct/). -------------------------------------------------------------------------------- /src/directions.ts: -------------------------------------------------------------------------------- 1 | import {Request, Response} from 'express'; 2 | 3 | import {TravelMode} from '@google/maps'; 4 | import {getClient} from './gmp_client'; 5 | 6 | /** 7 | * Returns directions from the provided origin to the provided destination. 8 | * Requires an `API_KEY` environment variable. 9 | * @see https://github.com/googlemaps/google-maps-services-js#nodejs-client-for-google-maps-services 10 | */ 11 | export default async (req: Request, res: Response) => { 12 | // Get the Maps Client 13 | let googleMapsClient; 14 | try { 15 | googleMapsClient = getClient(); 16 | } catch (e) { 17 | return res.status(400).send(e); 18 | } 19 | 20 | // Validate travel mode 21 | const mode = req.query.mode; 22 | const VALID_MODES: TravelMode[] = ['driving', 'walking', 'bicycling', 'transit']; 23 | if (!VALID_MODES.includes(mode)) { 24 | return res.status(400).send(`Error: mode must be one of ${VALID_MODES.join(', ')}.`); 25 | } 26 | 27 | // Validate origin 28 | const origin = req.query.origin; 29 | if (!origin) { 30 | return res.status(400).send('Error: origin must be provided. Example: origin=37.7841393,-122.404467'); 31 | } 32 | 33 | // Execute API request 34 | const destination = '1600 Amphitheatre Parkway, Mountain View, CA'; 35 | const response = await googleMapsClient.directions({ 36 | origin, 37 | destination, 38 | mode, 39 | }).asPromise(); 40 | 41 | // Send the response 42 | res.send({ 43 | data: response.json, 44 | request: { 45 | query: req.query, 46 | params: req.path, 47 | }, 48 | }); 49 | }; 50 | -------------------------------------------------------------------------------- /src/origins.ts: -------------------------------------------------------------------------------- 1 | import {Request, Response} from 'express'; 2 | 3 | /** 4 | * Returns an array of lat/lng origin locations. 5 | * Simulates origin requests from many locations. 6 | */ 7 | export default (req: Request, res: Response) => { 8 | // Validate query parameter. 9 | const origin = req.query.origin; 10 | if (!origin) { 11 | return res.status(400).send({ 12 | error: 'Error: `origin` query parameter required. Example: /origins?origin=1', 13 | }); 14 | } 15 | 16 | // Select a random place around the origin. 17 | const getDotAroundOrigin = () => { 18 | const place0 = { lat: 37.621491, lng: -122.378912 }; // SFO 19 | const place1 = { lat: 37.826837, lng: -122.498978 }; // Marin 20 | const place2 = { lat: 37.769548, lng: -122.486010 }; // GG Park 21 | const place3 = { lat: 37.795455, lng: -122.393306 }; // Ferry Building 22 | const place4 = { lat: 37.808171, lng: -122.270019 }; // Fox Theatres 23 | const place5 = { lat: 37.750565, lng: -122.203004 }; // Oracle Arena 24 | const place6 = { lat: 37.715740, lng: -122.219267 }; // OAK 25 | const place7 = { lat: 37.521822, lng: -121.924796 }; // Old Mission Park 26 | const place8 = { lat: 37.368574, lng: -121.927630 }; // SJC 27 | const place9 = { lat: 37.422051, lng: -122.084025 }; // Googleplex 28 | const places = [place0, place1, place2, place3, place4, place5, place6, place7, place8, place9]; 29 | const place = places[+origin]; 30 | 31 | // Validate place 32 | if (!place) { 33 | return res.status(400).send('Error: Invalid `origin` query parameter. Example: /origins?origin=1'); 34 | } 35 | 36 | // Randomize the dot's location a bit 37 | const RANDOMNESS = 0.025; 38 | place.lat += ((Math.random() - 0.5) * RANDOMNESS); 39 | place.lng += ((Math.random() - 0.5) * RANDOMNESS); 40 | return place; 41 | }; 42 | 43 | // Select N dots 44 | const N = 10; 45 | const dots = []; 46 | for (let i = 0; i < N; ++i) { 47 | dots[i] = getDotAroundOrigin(); 48 | } 49 | res.send(dots); 50 | }; 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Functions as a Service 2 | 3 | ![](https://user-images.githubusercontent.com/744973/56170578-e5675b80-5f96-11e9-9ffe-9492512a0586.png) 4 | 5 | The demo shows calling Google Maps Platform APIs from Google Cloud Functions. 6 | 7 | ## Technologies 8 | 9 | - Cloud Functions (Node 10) 10 | - [Function Framework](https://github.com/GoogleCloudPlatform/functions-framework-nodejs) for local development. 11 | - Google Maps Services ([Node.js Client](https://github.com/googlemaps/google-maps-services-js)) 12 | - Directions API 13 | - TypeScript 14 | - Google Maps Types: https://www.npmjs.com/package/@types/google__maps 15 | - Google Cloud Functions Server (Express): https://www.npmjs.com/package/@types/express 16 | 17 | ## Develop 18 | 19 | First install dependencies: 20 | 21 | ```sh 22 | npm i 23 | ``` 24 | 25 | Then in one tab continually build the project with this command: 26 | 27 | ```sh 28 | npm run build 29 | ``` 30 | 31 | In another tab, start the web server (and watch if the source code changes): 32 | 33 | ```sh 34 | API_KEY= npm run watch 35 | ``` 36 | 37 | This uses [`npm-watch`](https://www.npmjs.com/package/npm-watch) with the [`functions-framework`](https://www.npmjs.com/package/@google-cloud/functions-framework) to auto re-build the server after changes. 38 | 39 | ### Test locally 40 | 41 | Go to `http://localhost:8080` to run your Google Cloud Function locally. 42 | 43 | Here are some example URL requests: 44 | 45 | ``` 46 | http://localhost:8080/directions?mode=driving&origin=37.7841393,-122.404467 47 | http://localhost:8080/origins?origin=6 48 | http://localhost:8080/places?origin=37.7841393,-122.114167 49 | ``` 50 | 51 | ### API Key 52 | 53 | To create an API key, use the Cloud Console credentials page: 54 | 55 | https://console.cloud.google.com/apis/credentials 56 | 57 | More detailed instructions can be found in the ["Get API Key" guide](https://developers.google.com/maps/documentation/javascript/get-api-key#detailed_guide). 58 | 59 | After creating an API key, enable these APIs: 60 | 61 | - [Directions API](http://console.cloud.google.com/google/maps-apis/apis/directions-backend.googleapis.com) 62 | - [Places API](http://console.cloud.google.com/google/maps-apis/apis/places-backend.googleapis.com) 63 | 64 | ### Deploy 65 | 66 | You must create a `.env.yaml` with your API Key: 67 | 68 | ```env 69 | API_KEY=AIsdfyCnTEiLTroDN14NTtpPm1n7jrBR844ID4A 70 | ``` 71 | 72 | You can deploy this project to Google Cloud Functions by running the following script: 73 | 74 | ```sh 75 | gcloud config set project $MY_PROJECT 76 | sh deploy.sh 77 | ``` 78 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "array-type": [ 4 | true, 5 | "array-simple" 6 | ], 7 | "arrow-return-shorthand": true, 8 | "ban": [ 9 | true, 10 | { 11 | "name": "parseInt", 12 | "message": "tsstyle#type-coercion" 13 | }, 14 | { 15 | "name": "parseFloat", 16 | "message": "tsstyle#type-coercion" 17 | }, 18 | { 19 | "name": "Array", 20 | "message": "tsstyle#array-constructor" 21 | } 22 | ], 23 | "ban-types": [ 24 | true, 25 | [ 26 | "Object", 27 | "Use {} instead." 28 | ], 29 | [ 30 | "String", 31 | "Use 'string' instead." 32 | ], 33 | [ 34 | "Number", 35 | "Use 'number' instead." 36 | ], 37 | [ 38 | "Boolean", 39 | "Use 'boolean' instead." 40 | ] 41 | ], 42 | "class-name": true, 43 | "curly": [ 44 | true, 45 | "ignore-same-line" 46 | ], 47 | "forin": true, 48 | "indent": [ 49 | true, 50 | "spaces", 51 | 2 52 | ], 53 | "interface-name": [ 54 | true, 55 | "never-prefix" 56 | ], 57 | "jsdoc-format": true, 58 | "label-position": true, 59 | "max-line-length": [ 60 | true, 61 | 110 62 | ], 63 | "member-access": [ 64 | true, 65 | "no-public" 66 | ], 67 | "new-parens": true, 68 | "no-angle-bracket-type-assertion": true, 69 | "no-arg": true, 70 | "no-any": false, 71 | "no-conditional-assignment": true, 72 | "no-consecutive-blank-lines": true, 73 | "no-construct": true, 74 | "no-debugger": true, 75 | "no-duplicate-variable": true, 76 | "no-inferrable-types": true, 77 | "no-namespace": [ 78 | true, 79 | "allow-declarations" 80 | ], 81 | "no-reference": true, 82 | "no-string-throw": true, 83 | "no-trailing-whitespace": true, 84 | "no-unused-expression": true, 85 | "no-var-keyword": true, 86 | "object-literal-key-quotes": [ 87 | true, 88 | "as-needed" 89 | ], 90 | "object-literal-shorthand": true, 91 | "only-arrow-functions": [ 92 | true, 93 | "allow-declarations", 94 | "allow-named-functions" 95 | ], 96 | "prefer-const": true, 97 | "quotemark": [ 98 | true, 99 | "single" 100 | ], 101 | "radix": true, 102 | "semicolon": [ 103 | true, 104 | "always", 105 | "ignore-bound-class-methods" 106 | ], 107 | "switch-default": true, 108 | "trailing-comma": [ 109 | true, 110 | { 111 | "multiline": "always", 112 | "singleline": "never" 113 | } 114 | ], 115 | "triple-equals": [ 116 | true, 117 | "allow-null-check" 118 | ], 119 | "use-isnan": true, 120 | "variable-name": [ 121 | true, 122 | "check-format", 123 | "ban-keywords", 124 | "allow-leading-underscore", 125 | "allow-trailing-underscore" 126 | ], 127 | "whitespace": [ 128 | true, 129 | "check-operator" 130 | ] 131 | } 132 | } -------------------------------------------------------------------------------- /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. --------------------------------------------------------------------------------