From 2a29f6b122d026b2d6375beb49a2483ff96f6447 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Thu, 11 Aug 2016 17:49:02 -0500 Subject: [PATCH 01/12] Adds the Endpoints Frameworks v2 Echo Sample --- endpoints-frameworks-v2/backend/.gitignore | 1 + endpoints-frameworks-v2/backend/pom.xml | 119 ++++++++++++++++++ .../src/main/java/com/example/echo/Echo.java | 77 ++++++++++++ .../src/main/java/com/example/echo/Email.java | 30 +++++ .../main/java/com/example/echo/Message.java | 31 +++++ .../example/echo/UnauthorizedException.java | 30 +++++ .../src/main/webapp/WEB-INF/appengine-web.xml | 34 +++++ .../main/webapp/WEB-INF/logging.properties | 25 ++++ .../backend/src/main/webapp/WEB-INF/web.xml | 61 +++++++++ pom.xml | 1 + 10 files changed, 409 insertions(+) create mode 100644 endpoints-frameworks-v2/backend/.gitignore create mode 100644 endpoints-frameworks-v2/backend/pom.xml create mode 100644 endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java create mode 100644 endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java create mode 100644 endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java create mode 100644 endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java create mode 100644 endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml create mode 100644 endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties create mode 100644 endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml diff --git a/endpoints-frameworks-v2/backend/.gitignore b/endpoints-frameworks-v2/backend/.gitignore new file mode 100644 index 00000000000..168aa9434f5 --- /dev/null +++ b/endpoints-frameworks-v2/backend/.gitignore @@ -0,0 +1 @@ +swagger.json diff --git a/endpoints-frameworks-v2/backend/pom.xml b/endpoints-frameworks-v2/backend/pom.xml new file mode 100644 index 00000000000..027d35ce133 --- /dev/null +++ b/endpoints-frameworks-v2/backend/pom.xml @@ -0,0 +1,119 @@ + + + 4.0.0 + war + 1.0-SNAPSHOT + + com.example.echo + echo + + + doc-samples + com.google.cloud + 1.0.0 + ../.. + + + + 1 + UTF-8 + + 1.7 + 1.7 + + 1.9.40 + + 0.0.18-SNAPSHOT + + + + + internal-endpoints-testing + Internal Endpoints Testing + http://104.197.230.53:8081/nexus/content/repositories/snapshots/ + + + + + + + javax.servlet + servlet-api + 2.5 + provided + + + com.google.endpoints + endpoints-framework + 2.0.0-beta.2 + + + com.google.endpoints + endpoints-management-control-appengine + ${endpoints.management.version} + + + com.google.endpoints + endpoints-management-auth + ${endpoints.management.version} + + + + + + ${project.build.directory}/${project.build.finalName}/WEB-INF/classes + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + compile + + display-dependency-updates + display-plugin-updates + + + + + + + org.apache.maven.plugins + maven-war-plugin + 2.6 + + + + com.google.appengine + appengine-maven-plugin + ${appengine.plugin.version} + + false + + + + + + + + + diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java new file mode 100644 index 00000000000..9c7f0e6de98 --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.example.echo; + +import com.google.api.server.spi.auth.EspAuthenticator; +import com.google.api.server.spi.auth.common.User; +import com.google.api.server.spi.config.Api; +import com.google.api.server.spi.config.ApiMethod; +import com.google.api.server.spi.config.ApiNamespace; +import com.google.api.server.spi.config.AuthLevel; + +/** The Echo API which Endpoints will be exposing. */ +@Api( + name = "echo", + version = "v1", + namespace = + @ApiNamespace( + ownerDomain = "echo.example.com", + ownerName = "echo.example.com", + packagePath = "" + ) + ) +public class Echo { + /** + * Echoes the received message back. + * + * Note that name is specified and will override the default name of "{class name}.{method + * name}". For example, the default is "echo.echo". + * + * Note that httpMethod is not specified. This will default to a reasonable HTTP method + * depending on the API method name. In this case, the HTTP method will default to POST. + */ + @ApiMethod(name = "echo") + public Message echo(Message message) { + return message; + } + + /** + * Gets the authenticated user's email. If the user is not authenticated, this will return an HTTP + * 401. + * + * Note that name is not specified. This will default "{class name}.{method name}". For + * example, the default is "echo.getUserEmail". + * + * Note that httpMethod is not required here. Without httpMethod, this will default to GET due + * to the API method name. httpMethod is added here for example purposes. + */ + @ApiMethod( + httpMethod = ApiMethod.HttpMethod.GET, + authenticators = {EspAuthenticator.class}, + audiences = {"488010225785-6nbu9odsh377sl0r7gp1kvsa1l68ss6u.apps.googleusercontent.com"}, + authLevel = AuthLevel.REQUIRED + ) + public Email getUserEmail(User user) throws UnauthorizedException { + if (user == null) { + throw new UnauthorizedException(); + } + + Email response = new Email(); + response.setEmail(user.getEmail()); + return response; + } +} diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java new file mode 100644 index 00000000000..e7725a9d9cc --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.example.echo; + +/** The email bean that will be used in the getUserEmail response. */ +public class Email { + private String email; + + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java new file mode 100644 index 00000000000..64c043c8857 --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.example.echo; + +/** The message bean that will be used in the echo request and response. */ +public class Message { + + private String message; + + public String getMessage() { + return this.message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java new file mode 100644 index 00000000000..9d73e09ca06 --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.example.echo; + +import com.google.api.server.spi.ServiceException; + +/** + * Throw this when the user is unauthorized. + * + * Note that this must inherit from ServiceException. + */ +public class UnauthorizedException extends ServiceException { + public UnauthorizedException() { + super(401, "Unauthorized"); + } +} diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml new file mode 100644 index 00000000000..08acf837154 --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -0,0 +1,34 @@ + + + + your-app-id + 1 + true + false + + + 1 + + + + + + + + + + diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties new file mode 100644 index 00000000000..a375465b2fc --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties @@ -0,0 +1,25 @@ +# Copyright 2016 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License +# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express +# or implied. See the License for the specific language governing permissions and limitations under +# the License. + +# A default java.util.logging configuration. +# (All App Engine logging is through java.util.logging by default). +# +# To use this configuration, copy it into your application's WEB-INF +# folder and add the following to your appengine-web.xml: +# +# +# +# +# + +# Set the default logging level for all loggers to WARNING +.level = WARNING diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..e9e8588041a --- /dev/null +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,61 @@ + + + + + EndpointsServlet + com.google.api.server.spi.EndpointsServlet + + services + com.example.echo.Echo + + + + EndpointsServlet + /_ah/api/* + + + index.html + + + + endpoints-api-configuration + com.google.api.control.ServiceManagementConfigFilter + + + + endpoints-api-controller + com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter + + endpoints.projectId + your-app-id + + + endpoints.serviceName + your-app-id.appspot.com + + + + + endpoints-api-configuration + EndpointsServlet + + + + endpoints-api-controller + EndpointsServlet + + diff --git a/pom.xml b/pom.xml index faaab723c76..3215a2510d8 100644 --- a/pom.xml +++ b/pom.xml @@ -80,6 +80,7 @@ compute/mailjet compute/sendgrid datastore + endpoints-frameworks-2.0/backend logging managed_vms/analytics managed_vms/async-rest From c7af0482012f65f204895d7854f6d509593e58ba Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Fri, 12 Aug 2016 14:00:39 -0500 Subject: [PATCH 02/12] Remove unneeded properties and use appengine.sdk.version. --- endpoints-frameworks-v2/backend/pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/endpoints-frameworks-v2/backend/pom.xml b/endpoints-frameworks-v2/backend/pom.xml index 027d35ce133..d613384498d 100644 --- a/endpoints-frameworks-v2/backend/pom.xml +++ b/endpoints-frameworks-v2/backend/pom.xml @@ -29,14 +29,8 @@ - 1 UTF-8 - 1.7 - 1.7 - - 1.9.40 - 0.0.18-SNAPSHOT @@ -101,7 +95,7 @@ com.google.appengine appengine-maven-plugin - ${appengine.plugin.version} + ${appengine.sdk.version} false From f355ee0faea28faad92d35e12b90fa4f14d1fa1b Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Fri, 12 Aug 2016 16:35:26 -0500 Subject: [PATCH 03/12] Use Maven properties to specify project id and replace hardcoded oauth client id. --- endpoints-frameworks-v2/backend/pom.xml | 11 +++++++++++ .../backend/src/main/java/com/example/echo/Echo.java | 2 +- .../backend/src/main/webapp/WEB-INF/appengine-web.xml | 4 ++-- .../backend/src/main/webapp/WEB-INF/web.xml | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/endpoints-frameworks-v2/backend/pom.xml b/endpoints-frameworks-v2/backend/pom.xml index d613384498d..572207983cc 100644 --- a/endpoints-frameworks-v2/backend/pom.xml +++ b/endpoints-frameworks-v2/backend/pom.xml @@ -32,6 +32,8 @@ UTF-8 0.0.18-SNAPSHOT + + YOUR_PROJECT_ID @@ -90,6 +92,15 @@ org.apache.maven.plugins maven-war-plugin 2.6 + + + + ${basedir}/src/main/webapp/WEB-INF + true + WEB-INF + + + diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java index 9c7f0e6de98..ab5329c5ad5 100644 --- a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java +++ b/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java @@ -62,7 +62,7 @@ public Message echo(Message message) { @ApiMethod( httpMethod = ApiMethod.HttpMethod.GET, authenticators = {EspAuthenticator.class}, - audiences = {"488010225785-6nbu9odsh377sl0r7gp1kvsa1l68ss6u.apps.googleusercontent.com"}, + audiences = {"YOUR_OAUTH_CLIENT_ID"}, authLevel = AuthLevel.REQUIRED ) public Email getUserEmail(User user) throws UnauthorizedException { diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index 08acf837154..e92e3d8dcf8 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -15,7 +15,7 @@ limitations under the License. --> - your-app-id + ${endpoints.project.id} 1 true false @@ -29,6 +29,6 @@ - + diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml index e9e8588041a..56207af6899 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -41,11 +41,11 @@ com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter endpoints.projectId - your-app-id + ${endpoints.project.id} endpoints.serviceName - your-app-id.appspot.com + ${endpoints.project.id}.appspot.com From e97c06317d7195ecaff1e0273135d6e7a7128011 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Fri, 12 Aug 2016 17:31:36 -0500 Subject: [PATCH 04/12] Add comments about the different parts of web.xml. --- .../backend/src/main/webapp/WEB-INF/web.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml index 56207af6899..a8364316d40 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -15,6 +15,7 @@ limitations under the License. --> + EndpointsServlet com.google.api.server.spi.EndpointsServlet @@ -31,11 +32,13 @@ index.html + endpoints-api-configuration com.google.api.control.ServiceManagementConfigFilter + endpoints-api-controller com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter From 1f0e74ee735967be28d663ab07692dd2c5508992 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Fri, 12 Aug 2016 17:35:11 -0500 Subject: [PATCH 05/12] Add more comments to web.xml. --- .../backend/src/main/webapp/WEB-INF/web.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml index a8364316d40..66db1fda503 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -15,7 +15,7 @@ limitations under the License. --> - + EndpointsServlet com.google.api.server.spi.EndpointsServlet @@ -24,6 +24,7 @@ com.example.echo.Echo + EndpointsServlet /_ah/api/* From 602fc0a5dde71f9f0eea993f6287a06e1de34e9f Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Mon, 15 Aug 2016 12:25:12 -0500 Subject: [PATCH 06/12] Update root pom.xml with the correct path for endpoints-frameworks-v2. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3215a2510d8..810bb3dccb6 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,7 @@ compute/mailjet compute/sendgrid datastore - endpoints-frameworks-2.0/backend + endpoints-frameworks-v2/backend logging managed_vms/analytics managed_vms/async-rest From 4e9b419dc17d87f8f3cdabefee8c613cef4b688a Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Thu, 18 Aug 2016 16:21:46 -0500 Subject: [PATCH 07/12] Update versions and remove manual-scaling. --- endpoints-frameworks-v2/backend/pom.xml | 6 +++--- .../backend/src/main/webapp/WEB-INF/appengine-web.xml | 4 ---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/endpoints-frameworks-v2/backend/pom.xml b/endpoints-frameworks-v2/backend/pom.xml index 572207983cc..34a3cf705b6 100644 --- a/endpoints-frameworks-v2/backend/pom.xml +++ b/endpoints-frameworks-v2/backend/pom.xml @@ -31,7 +31,7 @@ UTF-8 - 0.0.18-SNAPSHOT + 0.0.20-SNAPSHOT YOUR_PROJECT_ID @@ -55,7 +55,7 @@ com.google.endpoints endpoints-framework - 2.0.0-beta.2 + 2.0.0-beta.4 com.google.endpoints @@ -64,7 +64,7 @@ com.google.endpoints - endpoints-management-auth + endpoints-framework-auth ${endpoints.management.version} diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index e92e3d8dcf8..bc207ba4433 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -20,10 +20,6 @@ true false - - 1 - - From 452b6d147b23d66b57b9bd7563458bce063b3244 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Thu, 18 Aug 2016 18:59:25 -0500 Subject: [PATCH 08/12] Add README to Endpoints Frameworks v2 sample. --- endpoints-frameworks-v2/backend/README.md | 77 +++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 endpoints-frameworks-v2/backend/README.md diff --git a/endpoints-frameworks-v2/backend/README.md b/endpoints-frameworks-v2/backend/README.md new file mode 100644 index 00000000000..019bc596510 --- /dev/null +++ b/endpoints-frameworks-v2/backend/README.md @@ -0,0 +1,77 @@ +# Google Cloud Endpoints Frameworks & Java + +This sample demonstrates how to use Google Cloud Endpoints Frameworks using +Java. + +## Adding the project ID to the sample API code + +You must add the project ID obtained when you created your project to the +sample's `pom.xml` before you can deploy the code. + +To add the project ID: + +0. Edit the file `pom.xml`. + +0. For ``, replace the value `YOUR_PROJECT_ID` with +your project ID. + +0. Save your changes. + +## Building the sample project + +To build the project: + + mvn clean package + +## Generating the swagger.json file + +To generate the required configuration file `swagger.json`: + +0. Download and unzip the [Endpoints Framework tools +package](http://search.maven.org/remotecontent?filepath=com/google/endpoints/endpoints-framework-tools/2.0.0-beta.4/endpoints-framework-tools-2.0.0-beta.4.zip). + +0. Invoke the Endpoints Tool using this command: + + path/to/endpoints-framework-tools-2.0.0-beta.4/bin/endpoints-framework-tools get-swagger-doc \ + -h .appspot.com \ + -w target/echo-1.0-SNAPSHOT com.example.echo.Echo + + Replace`` with your project ID. + +## Deploying the sample API to App Engine + +To deploy the sample API: + +0. Invoke the `gcloud` command to deploy the API configuration file: + + gcloud beta service-management deploy swagger.json + +0. Deploy the API implementation code by invoking: + + mvn appengine:update + + The first time you upload a sample app, you may be prompted to authorize the + deployment. Follow the prompts: when you are presented with a browser window + containing a code, copy it to the terminal window. + +0. Wait for the upload to finish. + +## Sending a request to the sample API + +After you deploy the API and its configuration file, you can send requests +to the API. + +To send a request to the API, from a command line, invoke the following `cURL` +command: + + curl \ + -H "Content-Type: application/json" \ + -X POST \ + -d '{"message":"echo"}' \ + https://$PROJECT_ID.appspot.com/_ah/api/echo/v1/echo + +You will get a 200 response with the following data: + + { + "message": "echo" + } From 425886f006f7aab7210bc0325c96fbc0767cc600 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Thu, 18 Aug 2016 19:08:26 -0500 Subject: [PATCH 09/12] Changes from auto-scaling to basic-scaling. --- .../backend/src/main/webapp/WEB-INF/appengine-web.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index bc207ba4433..c5ec84d8ad0 100644 --- a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -20,6 +20,10 @@ true false + + 2 + + From b8e87af61e7332877db583386a552b51570ed371 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Tue, 23 Aug 2016 11:52:56 -0500 Subject: [PATCH 10/12] Aligns Endpoints Frameworks v2 sample with other App Engine Standard samples. Moves Endpoints Frameworks v2 sample under appengine. Updates pom.xml. Updates root pom.xml. Updates README to mention App Engine Standard. --- .../endpoints-frameworks-v2}/backend/.gitignore | 0 .../endpoints-frameworks-v2}/backend/README.md | 4 ++-- .../endpoints-frameworks-v2}/backend/pom.xml | 2 +- .../backend/src/main/java/com/example/echo/Echo.java | 0 .../backend/src/main/java/com/example/echo/Email.java | 0 .../backend/src/main/java/com/example/echo/Message.java | 0 .../src/main/java/com/example/echo/UnauthorizedException.java | 0 .../backend/src/main/webapp/WEB-INF/appengine-web.xml | 0 .../backend/src/main/webapp/WEB-INF/logging.properties | 0 .../backend/src/main/webapp/WEB-INF/web.xml | 0 pom.xml | 2 +- 11 files changed, 4 insertions(+), 4 deletions(-) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/.gitignore (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/README.md (95%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/pom.xml (99%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/java/com/example/echo/Echo.java (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/java/com/example/echo/Email.java (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/java/com/example/echo/Message.java (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/java/com/example/echo/UnauthorizedException.java (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/webapp/WEB-INF/appengine-web.xml (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/webapp/WEB-INF/logging.properties (100%) rename {endpoints-frameworks-v2 => appengine/endpoints-frameworks-v2}/backend/src/main/webapp/WEB-INF/web.xml (100%) diff --git a/endpoints-frameworks-v2/backend/.gitignore b/appengine/endpoints-frameworks-v2/backend/.gitignore similarity index 100% rename from endpoints-frameworks-v2/backend/.gitignore rename to appengine/endpoints-frameworks-v2/backend/.gitignore diff --git a/endpoints-frameworks-v2/backend/README.md b/appengine/endpoints-frameworks-v2/backend/README.md similarity index 95% rename from endpoints-frameworks-v2/backend/README.md rename to appengine/endpoints-frameworks-v2/backend/README.md index 019bc596510..7190488b2ef 100644 --- a/endpoints-frameworks-v2/backend/README.md +++ b/appengine/endpoints-frameworks-v2/backend/README.md @@ -1,7 +1,7 @@ -# Google Cloud Endpoints Frameworks & Java +# App Engine Standard & Google Cloud Endpoints Frameworks & Java This sample demonstrates how to use Google Cloud Endpoints Frameworks using -Java. +Java on App Engine Standard. ## Adding the project ID to the sample API code diff --git a/endpoints-frameworks-v2/backend/pom.xml b/appengine/endpoints-frameworks-v2/backend/pom.xml similarity index 99% rename from endpoints-frameworks-v2/backend/pom.xml rename to appengine/endpoints-frameworks-v2/backend/pom.xml index 34a3cf705b6..cc441938dfc 100644 --- a/endpoints-frameworks-v2/backend/pom.xml +++ b/appengine/endpoints-frameworks-v2/backend/pom.xml @@ -25,7 +25,7 @@ doc-samples com.google.cloud 1.0.0 - ../.. + ../../.. diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java rename to appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java rename to appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Email.java diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java rename to appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Message.java diff --git a/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java rename to appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/UnauthorizedException.java diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml rename to appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties rename to appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/logging.properties diff --git a/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml rename to appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml diff --git a/pom.xml b/pom.xml index 810bb3dccb6..185fc3497b2 100644 --- a/pom.xml +++ b/pom.xml @@ -53,6 +53,7 @@ appengine/datastore/indexes appengine/datastore/indexes-exploding appengine/datastore/indexes-perfect + appengine/endpoints-frameworks-v2/backend appengine/firebase-event-proxy/gae-firebase-event-proxy appengine/guestbook-objectify appengine/helloworld @@ -80,7 +81,6 @@ compute/mailjet compute/sendgrid datastore - endpoints-frameworks-v2/backend logging managed_vms/analytics managed_vms/async-rest From 81ac3352467d6a7762547ed64c49909e27bc78b8 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Tue, 23 Aug 2016 17:57:55 -0500 Subject: [PATCH 11/12] Remove from appengine-web.xml. --- .../backend/src/main/webapp/WEB-INF/appengine-web.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index c5ec84d8ad0..8fb24caddb4 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -18,7 +18,6 @@ ${endpoints.project.id} 1 true - false 2 From fd92d811a904a5bf22adba4fbf4340393ec80068 Mon Sep 17 00:00:00 2001 From: Wesley Wong Date: Wed, 24 Aug 2016 17:22:04 -0500 Subject: [PATCH 12/12] Version bump and use framework only. --- .../endpoints-frameworks-v2/backend/README.md | 4 +-- .../endpoints-frameworks-v2/backend/pom.xml | 22 +------------- .../src/main/java/com/example/echo/Echo.java | 11 ++----- .../src/main/webapp/WEB-INF/appengine-web.xml | 4 --- .../backend/src/main/webapp/WEB-INF/web.xml | 30 ------------------- 5 files changed, 5 insertions(+), 66 deletions(-) diff --git a/appengine/endpoints-frameworks-v2/backend/README.md b/appengine/endpoints-frameworks-v2/backend/README.md index 7190488b2ef..18322cab66e 100644 --- a/appengine/endpoints-frameworks-v2/backend/README.md +++ b/appengine/endpoints-frameworks-v2/backend/README.md @@ -28,11 +28,11 @@ To build the project: To generate the required configuration file `swagger.json`: 0. Download and unzip the [Endpoints Framework tools -package](http://search.maven.org/remotecontent?filepath=com/google/endpoints/endpoints-framework-tools/2.0.0-beta.4/endpoints-framework-tools-2.0.0-beta.4.zip). +package](http://search.maven.org/remotecontent?filepath=com/google/endpoints/endpoints-framework-tools/2.0.0-beta.7/endpoints-framework-tools-2.0.0-beta.7.zip). 0. Invoke the Endpoints Tool using this command: - path/to/endpoints-framework-tools-2.0.0-beta.4/bin/endpoints-framework-tools get-swagger-doc \ + path/to/endpoints-framework-tools-2.0.0-beta.7/bin/endpoints-framework-tools get-swagger-doc \ -h .appspot.com \ -w target/echo-1.0-SNAPSHOT com.example.echo.Echo diff --git a/appengine/endpoints-frameworks-v2/backend/pom.xml b/appengine/endpoints-frameworks-v2/backend/pom.xml index cc441938dfc..3c4796f3294 100644 --- a/appengine/endpoints-frameworks-v2/backend/pom.xml +++ b/appengine/endpoints-frameworks-v2/backend/pom.xml @@ -31,19 +31,9 @@ UTF-8 - 0.0.20-SNAPSHOT - YOUR_PROJECT_ID - - - internal-endpoints-testing - Internal Endpoints Testing - http://104.197.230.53:8081/nexus/content/repositories/snapshots/ - - - @@ -55,17 +45,7 @@ com.google.endpoints endpoints-framework - 2.0.0-beta.4 - - - com.google.endpoints - endpoints-management-control-appengine - ${endpoints.management.version} - - - com.google.endpoints - endpoints-framework-auth - ${endpoints.management.version} + 2.0.0-beta.7 diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java index ab5329c5ad5..8a7d050051a 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java +++ b/appengine/endpoints-frameworks-v2/backend/src/main/java/com/example/echo/Echo.java @@ -16,12 +16,10 @@ package com.example.echo; -import com.google.api.server.spi.auth.EspAuthenticator; import com.google.api.server.spi.auth.common.User; import com.google.api.server.spi.config.Api; import com.google.api.server.spi.config.ApiMethod; import com.google.api.server.spi.config.ApiNamespace; -import com.google.api.server.spi.config.AuthLevel; /** The Echo API which Endpoints will be exposing. */ @Api( @@ -53,18 +51,13 @@ public Message echo(Message message) { * Gets the authenticated user's email. If the user is not authenticated, this will return an HTTP * 401. * - * Note that name is not specified. This will default "{class name}.{method name}". For + * Note that name is not specified. This will default to "{class name}.{method name}". For * example, the default is "echo.getUserEmail". * * Note that httpMethod is not required here. Without httpMethod, this will default to GET due * to the API method name. httpMethod is added here for example purposes. */ - @ApiMethod( - httpMethod = ApiMethod.HttpMethod.GET, - authenticators = {EspAuthenticator.class}, - audiences = {"YOUR_OAUTH_CLIENT_ID"}, - authLevel = AuthLevel.REQUIRED - ) + @ApiMethod(httpMethod = ApiMethod.HttpMethod.GET) public Email getUserEmail(User user) throws UnauthorizedException { if (user == null) { throw new UnauthorizedException(); diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml index 8fb24caddb4..274894e136b 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/appengine-web.xml @@ -26,8 +26,4 @@ - - - - diff --git a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml index 66db1fda503..53beffe8208 100644 --- a/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml +++ b/appengine/endpoints-frameworks-v2/backend/src/main/webapp/WEB-INF/web.xml @@ -32,34 +32,4 @@ index.html - - - - endpoints-api-configuration - com.google.api.control.ServiceManagementConfigFilter - - - - - endpoints-api-controller - com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter - - endpoints.projectId - ${endpoints.project.id} - - - endpoints.serviceName - ${endpoints.project.id}.appspot.com - - - - - endpoints-api-configuration - EndpointsServlet - - - - endpoints-api-controller - EndpointsServlet -