Skip to content

Commit 5b63acb

Browse files
wmwonglesv
authored andcommitted
Adds an Endpoints sample with multiple versions. (GoogleCloudPlatform#627)
* Adds an Endpoints sample with multiple versions. * Updates licenses, pom.xml, and whitespacing. * Removes the old maven plugin.
1 parent a6d6fa3 commit 5b63acb

15 files changed

+789
-0
lines changed

endpoints/multiple-versions/README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Google Cloud Endpoints & Java with Multiple Versions
2+
This sample demonstrates how to use Google Cloud Endpoints using a Java backend
3+
that supports multiple versions.
4+
5+
For more information, see the Google Cloud Endpoints documentation on
6+
[Running multiple API versions](https://cloud.google.com/endpoints/docs/multiple-api-versions).
7+
8+
## Calling your API
9+
10+
Please refer to the Google Cloud Endpoints
11+
[documentation](https://cloud.google.com/endpoints/docs/app-engine/) for App
12+
Engine Flexible Environment to learn about creating an API Key and calling your
13+
API.
14+
15+
## Viewing the Endpoints graphs
16+
17+
By using Endpoints, you get access to several metrics that are displayed
18+
graphically in the Cloud Console.
19+
20+
To view the Endpoints graphs:
21+
22+
1. Go to the [Endpoints section in Cloud Console](https://console.cloud.google.com/endpoints)
23+
of the project you deployed your API to.
24+
2. Click on your API to view more detailed information about the metrics
25+
collected.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: v1
16+
kind: Service
17+
metadata:
18+
name: esp-echo
19+
spec:
20+
ports:
21+
- port: 80
22+
targetPort: 8081
23+
protocol: TCP
24+
name: http
25+
selector:
26+
app: esp-echo
27+
type: LoadBalancer
28+
---
29+
apiVersion: extensions/v1beta1
30+
kind: Deployment
31+
metadata:
32+
name: esp-echo
33+
spec:
34+
replicas: 1
35+
template:
36+
metadata:
37+
labels:
38+
app: esp-echo
39+
spec:
40+
containers:
41+
# [START esp]
42+
- name: esp
43+
image: gcr.io/endpoints-release/endpoints-runtime:1
44+
args: [
45+
"-p", "8081",
46+
"-a", "127.0.0.1:8080",
47+
"-s", "SERVICE_NAME",
48+
"-v", "SERVICE_CONFIG_ID",
49+
]
50+
# [END esp]
51+
ports:
52+
- containerPort: 8081
53+
- name: echo
54+
image: gcr.io/google-samples/echo-java:1.0
55+
ports:
56+
- containerPort: 8080
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START swagger]
16+
swagger: "2.0"
17+
info:
18+
description: "A simple Google Cloud Endpoints API example."
19+
title: "Endpoints Example"
20+
version: "2.0.0"
21+
host: "echo-api.endpoints.YOUR-PROJECT-ID.cloud.goog"
22+
# [END swagger]
23+
basePath: "/v2"
24+
consumes:
25+
- "application/json"
26+
produces:
27+
- "application/json"
28+
schemes:
29+
- "https"
30+
paths:
31+
"/echo":
32+
post:
33+
description: "Echo back a given message."
34+
operationId: "echo"
35+
produces:
36+
- "application/json"
37+
responses:
38+
200:
39+
description: "Echo"
40+
schema:
41+
$ref: "#/definitions/echoMessage"
42+
parameters:
43+
-
44+
description: "Message to echo"
45+
in: body
46+
name: message
47+
required: true
48+
schema:
49+
$ref: "#/definitions/echoMessage"
50+
"/auth/info/googlejwt":
51+
get:
52+
description: "Returns the requests' authentication information."
53+
operationId: "auth_info_google_jwt"
54+
produces:
55+
- "application/json"
56+
responses:
57+
200:
58+
description: "Authenication info."
59+
schema:
60+
$ref: "#/definitions/authInfoResponse"
61+
x-security:
62+
-
63+
google_jwt:
64+
audiences:
65+
# This must match the "aud" field in the JWT. You can add multiple
66+
# audiences to accept JWTs from multiple clients.
67+
- "echo.endpoints.sample.google.com"
68+
"/auth/info/googleidtoken":
69+
get:
70+
description: "Returns the requests' authentication information."
71+
operationId: "authInfoGoogleIdToken"
72+
produces:
73+
- "application/json"
74+
responses:
75+
200:
76+
description: "Authenication info."
77+
schema:
78+
$ref: "#/definitions/authInfoResponse"
79+
x-security:
80+
-
81+
google_id_token:
82+
audiences:
83+
# Your OAuth2 client's Client ID must be added here. You can add
84+
# multiple client IDs to accept tokens from multiple clients.
85+
- "YOUR-CLIENT-ID"
86+
definitions:
87+
echoMessage:
88+
properties:
89+
msg:
90+
type: "string"
91+
authInfoResponse:
92+
properties:
93+
id:
94+
type: "string"
95+
email:
96+
type: "string"
97+
# This section requires all requests to any path to require an API key.
98+
security:
99+
- api_key: []
100+
securityDefinitions:
101+
# This section configures basic authentication with an API key.
102+
api_key:
103+
type: "apiKey"
104+
name: "key"
105+
in: "query"
106+
# This section configures authentication using Google API Service Accounts
107+
# to sign a json web token. This is mostly used for server-to-server
108+
# communication.
109+
google_jwt:
110+
authorizationUrl: ""
111+
flow: "implicit"
112+
type: "oauth2"
113+
# This must match the 'iss' field in the JWT.
114+
x-google-issuer: "jwt-client.endpoints.sample.google.com"
115+
# Update this with your service account's email address.
116+
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL"
117+
# This section configures authentication using Google OAuth2 ID Tokens.
118+
# ID Tokens can be obtained using OAuth2 clients, and can be used to access
119+
# your API on behalf of a particular user.
120+
google_id_token:
121+
authorizationUrl: ""
122+
flow: "implicit"
123+
type: "oauth2"
124+
x-google-issuer: "accounts.google.com"
125+
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs"
+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Copyright 2015 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# [START swagger]
16+
swagger: "2.0"
17+
info:
18+
description: "A simple Google Cloud Endpoints API example."
19+
title: "Endpoints Example"
20+
version: "1.0.0"
21+
host: "echo-api.endpoints.YOUR-PROJECT-ID.cloud.goog"
22+
# [END swagger]
23+
basePath: "/v1"
24+
consumes:
25+
- "application/json"
26+
produces:
27+
- "application/json"
28+
schemes:
29+
- "https"
30+
paths:
31+
"/echo":
32+
post:
33+
description: "Echo back a given message."
34+
operationId: "echo"
35+
produces:
36+
- "application/json"
37+
responses:
38+
200:
39+
description: "Echo"
40+
schema:
41+
$ref: "#/definitions/echoMessage"
42+
parameters:
43+
-
44+
description: "Message to echo"
45+
in: body
46+
name: message
47+
required: true
48+
schema:
49+
$ref: "#/definitions/echoMessage"
50+
"/auth/info/googlejwt":
51+
get:
52+
description: "Returns the requests' authentication information."
53+
operationId: "auth_info_google_jwt"
54+
produces:
55+
- "application/json"
56+
responses:
57+
200:
58+
description: "Authenication info."
59+
schema:
60+
$ref: "#/definitions/authInfoResponse"
61+
x-security:
62+
-
63+
google_jwt:
64+
audiences:
65+
# This must match the "aud" field in the JWT. You can add multiple
66+
# audiences to accept JWTs from multiple clients.
67+
- "echo.endpoints.sample.google.com"
68+
"/auth/info/googleidtoken":
69+
get:
70+
description: "Returns the requests' authentication information."
71+
operationId: "authInfoGoogleIdToken"
72+
produces:
73+
- "application/json"
74+
responses:
75+
200:
76+
description: "Authenication info."
77+
schema:
78+
$ref: "#/definitions/authInfoResponse"
79+
x-security:
80+
-
81+
google_id_token:
82+
audiences:
83+
# Your OAuth2 client's Client ID must be added here. You can add
84+
# multiple client IDs to accept tokens from multiple clients.
85+
- "YOUR-CLIENT-ID"
86+
definitions:
87+
echoMessage:
88+
properties:
89+
message:
90+
type: "string"
91+
authInfoResponse:
92+
properties:
93+
id:
94+
type: "string"
95+
email:
96+
type: "string"
97+
# This section requires all requests to any path to require an API key.
98+
security:
99+
- api_key: []
100+
securityDefinitions:
101+
# This section configures basic authentication with an API key.
102+
api_key:
103+
type: "apiKey"
104+
name: "key"
105+
in: "query"
106+
# This section configures authentication using Google API Service Accounts
107+
# to sign a json web token. This is mostly used for server-to-server
108+
# communication.
109+
google_jwt:
110+
authorizationUrl: ""
111+
flow: "implicit"
112+
type: "oauth2"
113+
# This must match the 'iss' field in the JWT.
114+
x-google-issuer: "jwt-client.endpoints.sample.google.com"
115+
# Update this with your service account's email address.
116+
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL"
117+
# This section configures authentication using Google OAuth2 ID Tokens.
118+
# ID Tokens can be obtained using OAuth2 clients, and can be used to access
119+
# your API on behalf of a particular user.
120+
google_id_token:
121+
authorizationUrl: ""
122+
flow: "implicit"
123+
type: "oauth2"
124+
x-google-issuer: "accounts.google.com"
125+
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs"

0 commit comments

Comments
 (0)