Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the Endpoints Frameworks v2 Echo Sample #284

Merged
merged 12 commits into from
Aug 25, 2016
Merged
4 changes: 2 additions & 2 deletions appengine/endpoints-frameworks-v2/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll ok this if you insist, however:

  1. You could do this from maven and then add a a -Pproperty or -Dflag that causes maven to execute this. There are examples of this runlocal or HelloWorldWrite that would be a better experience for first time users.

It would also be a bit more sustainable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion. I think we will go with what we have for now. I will create a bug to explore this solution and update the sample.

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 <PROJECT_ID>.appspot.com \
-w target/echo-1.0-SNAPSHOT com.example.echo.Echo

Expand Down
22 changes: 1 addition & 21 deletions appengine/endpoints-frameworks-v2/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<endpoints.management.version>0.0.20-SNAPSHOT</endpoints.management.version>

<endpoints.project.id>YOUR_PROJECT_ID</endpoints.project.id>
</properties>

<repositories>
<repository>
<id>internal-endpoints-testing</id>
<name>Internal Endpoints Testing</name>
<url>http://104.197.230.53:8081/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>

<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
Expand All @@ -55,17 +45,7 @@
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>2.0.0-beta.4</version>
</dependency>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine</artifactId>
<version>${endpoints.management.version}</version>
</dependency>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework-auth</artifactId>
<version>${endpoints.management.version}</version>
<version>2.0.0-beta.7</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

<env-variables>
<env-var name="ENDPOINTS_SERVICE_NAME" value="${endpoints.project.id}.appspot.com" />
</env-variables>
</appengine-web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,4 @@
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<!-- Add a filter that fetches the service config from service management. -->
<filter>
<filter-name>endpoints-api-configuration</filter-name>
<filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
</filter>

<!-- Add a filter that performs Endpoints logging and monitoring. -->
<filter>
<filter-name>endpoints-api-controller</filter-name>
<filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
<init-param>
<param-name>endpoints.projectId</param-name>
<param-value>${endpoints.project.id}</param-value>
</init-param>
<init-param>
<param-name>endpoints.serviceName</param-name>
<param-value>${endpoints.project.id}.appspot.com</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>endpoints-api-configuration</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>

<filter-mapping>
<filter-name>endpoints-api-controller</filter-name>
<servlet-name>EndpointsServlet</servlet-name>
</filter-mapping>
</web-app>