-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 an Endpoints sample with multiple versions. #627
Changes from 3 commits
8ba239f
07c58e0
944d5ce
0ab28d1
f6f2127
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Google Cloud Endpoints & Java with Multiple Versions | ||
This sample demonstrates how to use Google Cloud Endpoints using a Java backend | ||
that supports multiple versions. | ||
|
||
For more information, see the Google Cloud Endpoints documentation on | ||
[Running multiple API versions](https://cloud.google.com/endpoints/docs/multiple-api-versions). | ||
|
||
## Calling your API | ||
|
||
Please refer to the Google Cloud Endpoints | ||
[documentation](https://cloud.google.com/endpoints/docs/app-engine/) for App | ||
Engine Flexible Environment to learn about creating an API Key and calling your | ||
API. | ||
|
||
## Viewing the Endpoints graphs | ||
|
||
By using Endpoints, you get access to several metrics that are displayed | ||
graphically in the Cloud Console. | ||
|
||
To view the Endpoints graphs: | ||
|
||
1. Go to the [Endpoints section in Cloud Console](https://console.cloud.google.com/endpoints) | ||
of the project you deployed your API to. | ||
2. Click on your API to view more detailed information about the metrics | ||
collected. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright 2015 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. | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: esp-echo | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: 8081 | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: esp-echo | ||
type: LoadBalancer | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: esp-echo | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: esp-echo | ||
spec: | ||
containers: | ||
# [START esp] | ||
- name: esp | ||
image: gcr.io/endpoints-release/endpoints-runtime:1 | ||
args: [ | ||
"-p", "8081", | ||
"-a", "127.0.0.1:8080", | ||
"-s", "SERVICE_NAME", | ||
"-v", "SERVICE_CONFIG_ID", | ||
] | ||
# [END esp] | ||
ports: | ||
- containerPort: 8081 | ||
- name: echo | ||
image: gcr.io/google-samples/echo-java:1.0 | ||
ports: | ||
- containerPort: 8080 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Copyright 2015 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. | ||
|
||
# [START swagger] | ||
swagger: "2.0" | ||
info: | ||
description: "A simple Google Cloud Endpoints API example." | ||
title: "Endpoints Example" | ||
version: "2.0.0" | ||
host: "echo-api.endpoints.YOUR-PROJECT-ID.cloud.goog" | ||
# [END swagger] | ||
basePath: "/v2" | ||
consumes: | ||
- "application/json" | ||
produces: | ||
- "application/json" | ||
schemes: | ||
- "https" | ||
paths: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some whitespace would make this a bit more readable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I indented all the lists using https://github.com/OAI/OpenAPI-Specification/tree/master/examples/v2.0/yaml as examples. They seem to indent '-'. Also, if the item is more than one line, the '-' is on its own line. |
||
"/echo": | ||
post: | ||
description: "Echo back a given message." | ||
operationId: "echo" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Echo" | ||
schema: | ||
$ref: "#/definitions/echoMessage" | ||
parameters: | ||
- | ||
description: "Message to echo" | ||
in: body | ||
name: message | ||
required: true | ||
schema: | ||
$ref: "#/definitions/echoMessage" | ||
"/auth/info/googlejwt": | ||
get: | ||
description: "Returns the requests' authentication information." | ||
operationId: "auth_info_google_jwt" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Authenication info." | ||
schema: | ||
$ref: "#/definitions/authInfoResponse" | ||
x-security: | ||
- | ||
google_jwt: | ||
audiences: | ||
# This must match the "aud" field in the JWT. You can add multiple | ||
# audiences to accept JWTs from multiple clients. | ||
- "echo.endpoints.sample.google.com" | ||
"/auth/info/googleidtoken": | ||
get: | ||
description: "Returns the requests' authentication information." | ||
operationId: "authInfoGoogleIdToken" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Authenication info." | ||
schema: | ||
$ref: "#/definitions/authInfoResponse" | ||
x-security: | ||
- | ||
google_id_token: | ||
audiences: | ||
# Your OAuth2 client's Client ID must be added here. You can add | ||
# multiple client IDs to accept tokens from multiple clients. | ||
- "YOUR-CLIENT-ID" | ||
definitions: | ||
echoMessage: | ||
properties: | ||
msg: | ||
type: "string" | ||
authInfoResponse: | ||
properties: | ||
id: | ||
type: "string" | ||
email: | ||
type: "string" | ||
# This section requires all requests to any path to require an API key. | ||
security: | ||
- api_key: [] | ||
securityDefinitions: | ||
# This section configures basic authentication with an API key. | ||
api_key: | ||
type: "apiKey" | ||
name: "key" | ||
in: "query" | ||
# This section configures authentication using Google API Service Accounts | ||
# to sign a json web token. This is mostly used for server-to-server | ||
# communication. | ||
google_jwt: | ||
authorizationUrl: "" | ||
flow: "implicit" | ||
type: "oauth2" | ||
# This must match the 'iss' field in the JWT. | ||
x-google-issuer: "jwt-client.endpoints.sample.google.com" | ||
# Update this with your service account's email address. | ||
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL" | ||
# This section configures authentication using Google OAuth2 ID Tokens. | ||
# ID Tokens can be obtained using OAuth2 clients, and can be used to access | ||
# your API on behalf of a particular user. | ||
google_id_token: | ||
authorizationUrl: "" | ||
flow: "implicit" | ||
type: "oauth2" | ||
x-google-issuer: "accounts.google.com" | ||
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Copyright 2015 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. | ||
|
||
# [START swagger] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. License & vertical whitespace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
swagger: "2.0" | ||
info: | ||
description: "A simple Google Cloud Endpoints API example." | ||
title: "Endpoints Example" | ||
version: "1.0.0" | ||
host: "echo-api.endpoints.YOUR-PROJECT-ID.cloud.goog" | ||
# [END swagger] | ||
basePath: "/v1" | ||
consumes: | ||
- "application/json" | ||
produces: | ||
- "application/json" | ||
schemes: | ||
- "https" | ||
paths: | ||
"/echo": | ||
post: | ||
description: "Echo back a given message." | ||
operationId: "echo" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Echo" | ||
schema: | ||
$ref: "#/definitions/echoMessage" | ||
parameters: | ||
- | ||
description: "Message to echo" | ||
in: body | ||
name: message | ||
required: true | ||
schema: | ||
$ref: "#/definitions/echoMessage" | ||
"/auth/info/googlejwt": | ||
get: | ||
description: "Returns the requests' authentication information." | ||
operationId: "auth_info_google_jwt" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Authenication info." | ||
schema: | ||
$ref: "#/definitions/authInfoResponse" | ||
x-security: | ||
- | ||
google_jwt: | ||
audiences: | ||
# This must match the "aud" field in the JWT. You can add multiple | ||
# audiences to accept JWTs from multiple clients. | ||
- "echo.endpoints.sample.google.com" | ||
"/auth/info/googleidtoken": | ||
get: | ||
description: "Returns the requests' authentication information." | ||
operationId: "authInfoGoogleIdToken" | ||
produces: | ||
- "application/json" | ||
responses: | ||
200: | ||
description: "Authenication info." | ||
schema: | ||
$ref: "#/definitions/authInfoResponse" | ||
x-security: | ||
- | ||
google_id_token: | ||
audiences: | ||
# Your OAuth2 client's Client ID must be added here. You can add | ||
# multiple client IDs to accept tokens from multiple clients. | ||
- "YOUR-CLIENT-ID" | ||
definitions: | ||
echoMessage: | ||
properties: | ||
message: | ||
type: "string" | ||
authInfoResponse: | ||
properties: | ||
id: | ||
type: "string" | ||
email: | ||
type: "string" | ||
# This section requires all requests to any path to require an API key. | ||
security: | ||
- api_key: [] | ||
securityDefinitions: | ||
# This section configures basic authentication with an API key. | ||
api_key: | ||
type: "apiKey" | ||
name: "key" | ||
in: "query" | ||
# This section configures authentication using Google API Service Accounts | ||
# to sign a json web token. This is mostly used for server-to-server | ||
# communication. | ||
google_jwt: | ||
authorizationUrl: "" | ||
flow: "implicit" | ||
type: "oauth2" | ||
# This must match the 'iss' field in the JWT. | ||
x-google-issuer: "jwt-client.endpoints.sample.google.com" | ||
# Update this with your service account's email address. | ||
x-google-jwks_uri: "https://www.googleapis.com/service_accounts/v1/jwk/YOUR-SERVICE-ACCOUNT-EMAIL" | ||
# This section configures authentication using Google OAuth2 ID Tokens. | ||
# ID Tokens can be obtained using OAuth2 clients, and can be used to access | ||
# your API on behalf of a particular user. | ||
google_id_token: | ||
authorizationUrl: "" | ||
flow: "implicit" | ||
type: "oauth2" | ||
x-google-issuer: "accounts.google.com" | ||
x-google-jwks_uri: "https://www.googleapis.com/oauth2/v1/certs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have a license
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done