app_yaml.proto 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // Copyright 2016 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. syntax = "proto3";
  15. package google.appengine.v1;
  16. import "google/api/annotations.proto";
  17. import "google/protobuf/duration.proto";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "AppYamlProto";
  20. option java_package = "com.google.appengine.v1";
  21. // [Google Cloud Endpoints](https://cloud.google.com/appengine/docs/python/endpoints/)
  22. // configuration for API handlers.
  23. message ApiConfigHandler {
  24. // Action to take when users access resources that require
  25. // authentication. Defaults to `redirect`.
  26. AuthFailAction auth_fail_action = 1;
  27. // Level of login required to access this resource. Defaults to
  28. // `optional`.
  29. LoginRequirement login = 2;
  30. // Path to the script from the application root directory.
  31. string script = 3;
  32. // Security (HTTPS) enforcement for this URL.
  33. SecurityLevel security_level = 4;
  34. // URL to serve the endpoint at.
  35. string url = 5;
  36. }
  37. // Custom static error page to be served when an error occurs.
  38. message ErrorHandler {
  39. // Error codes.
  40. enum ErrorCode {
  41. option allow_alias = true;
  42. // Not specified. ERROR_CODE_DEFAULT is assumed.
  43. ERROR_CODE_UNSPECIFIED = 0;
  44. // All other error types.
  45. ERROR_CODE_DEFAULT = 0;
  46. // Application has exceeded a resource quota.
  47. ERROR_CODE_OVER_QUOTA = 1;
  48. // Client blocked by the application's Denial of Service protection
  49. // configuration.
  50. ERROR_CODE_DOS_API_DENIAL = 2;
  51. // Deadline reached before the application responds.
  52. ERROR_CODE_TIMEOUT = 3;
  53. }
  54. // Error condition this handler applies to.
  55. ErrorCode error_code = 1;
  56. // Static file content to be served for this error.
  57. string static_file = 2;
  58. // MIME type of file. Defaults to `text/html`.
  59. string mime_type = 3;
  60. }
  61. // URL pattern and description of how the URL should be handled. App Engine can
  62. // handle URLs by executing application code or by serving static files
  63. // uploaded with the version, such as images, CSS, or JavaScript.
  64. message UrlMap {
  65. // Redirect codes.
  66. enum RedirectHttpResponseCode {
  67. // Not specified. `302` is assumed.
  68. REDIRECT_HTTP_RESPONSE_CODE_UNSPECIFIED = 0;
  69. // `301 Moved Permanently` code.
  70. REDIRECT_HTTP_RESPONSE_CODE_301 = 1;
  71. // `302 Moved Temporarily` code.
  72. REDIRECT_HTTP_RESPONSE_CODE_302 = 2;
  73. // `303 See Other` code.
  74. REDIRECT_HTTP_RESPONSE_CODE_303 = 3;
  75. // `307 Temporary Redirect` code.
  76. REDIRECT_HTTP_RESPONSE_CODE_307 = 4;
  77. }
  78. // URL prefix. Uses regular expression syntax, which means regexp
  79. // special characters must be escaped, but should not contain groupings.
  80. // All URLs that begin with this prefix are handled by this handler, using the
  81. // portion of the URL after the prefix as part of the file path.
  82. string url_regex = 1;
  83. // Type of handler for this URL pattern.
  84. oneof handler_type {
  85. // Returns the contents of a file, such as an image, as the response.
  86. StaticFilesHandler static_files = 2;
  87. // Executes a script to handle the request that matches this URL
  88. // pattern.
  89. ScriptHandler script = 3;
  90. // Uses API Endpoints to handle requests.
  91. ApiEndpointHandler api_endpoint = 4;
  92. }
  93. // Security (HTTPS) enforcement for this URL.
  94. SecurityLevel security_level = 5;
  95. // Level of login required to access this resource.
  96. LoginRequirement login = 6;
  97. // Action to take when users access resources that require
  98. // authentication. Defaults to `redirect`.
  99. AuthFailAction auth_fail_action = 7;
  100. // `30x` code to use when performing redirects for the `secure` field.
  101. // Defaults to `302`.
  102. RedirectHttpResponseCode redirect_http_response_code = 8;
  103. }
  104. // Files served directly to the user for a given URL, such as images, CSS
  105. // stylesheets, or JavaScript source files. Static file handlers describe which
  106. // files in the application directory are static files, and which URLs serve
  107. // them.
  108. message StaticFilesHandler {
  109. // Path to the static files matched by the URL pattern, from the
  110. // application root directory. The path can refer to text matched in groupings
  111. // in the URL pattern.
  112. string path = 1;
  113. // Regular expression that matches the file paths for all files that should be
  114. // referenced by this handler.
  115. string upload_path_regex = 2;
  116. // HTTP headers to use for all responses from these URLs.
  117. map<string, string> http_headers = 3;
  118. // MIME type used to serve all files served by this handler.
  119. //
  120. // Defaults to file-specific MIME types, which are derived from each file's
  121. // filename extension.
  122. string mime_type = 4;
  123. // Time a static file served by this handler should be cached
  124. // by web proxies and browsers.
  125. google.protobuf.Duration expiration = 5;
  126. // Whether this handler should match the request if the file
  127. // referenced by the handler does not exist.
  128. bool require_matching_file = 6;
  129. // Whether files should also be uploaded as code data. By default, files
  130. // declared in static file handlers are uploaded as static
  131. // data and are only served to end users; they cannot be read by the
  132. // application. If enabled, uploads are charged against both your code and
  133. // static data storage resource quotas.
  134. bool application_readable = 7;
  135. }
  136. // Executes a script to handle the request that matches the URL pattern.
  137. message ScriptHandler {
  138. // Path to the script from the application root directory.
  139. string script_path = 1;
  140. }
  141. // Uses Google Cloud Endpoints to handle requests.
  142. message ApiEndpointHandler {
  143. // Path to the script from the application root directory.
  144. string script_path = 1;
  145. }
  146. // Health checking configuration for VM instances. Unhealthy instances
  147. // are killed and replaced with new instances. Only applicable for
  148. // instances in App Engine flexible environment.
  149. message HealthCheck {
  150. // Whether to explicitly disable health checks for this instance.
  151. bool disable_health_check = 1;
  152. // Host header to send when performing an HTTP health check.
  153. // Example: "myapp.appspot.com"
  154. string host = 2;
  155. // Number of consecutive successful health checks required before receiving
  156. // traffic.
  157. uint32 healthy_threshold = 3;
  158. // Number of consecutive failed health checks required before removing
  159. // traffic.
  160. uint32 unhealthy_threshold = 4;
  161. // Number of consecutive failed health checks required before an instance is
  162. // restarted.
  163. uint32 restart_threshold = 5;
  164. // Interval between health checks.
  165. google.protobuf.Duration check_interval = 6;
  166. // Time before the health check is considered failed.
  167. google.protobuf.Duration timeout = 7;
  168. }
  169. // Third-party Python runtime library that is required by the application.
  170. message Library {
  171. // Name of the library. Example: "django".
  172. string name = 1;
  173. // Version of the library to select, or "latest".
  174. string version = 2;
  175. }
  176. // Actions to take when the user is not logged in.
  177. enum AuthFailAction {
  178. // Not specified. `AUTH_FAIL_ACTION_REDIRECT` is assumed.
  179. AUTH_FAIL_ACTION_UNSPECIFIED = 0;
  180. // Redirects user to "accounts.google.com". The user is redirected back to the
  181. // application URL after signing in or creating an account.
  182. AUTH_FAIL_ACTION_REDIRECT = 1;
  183. // Rejects request with a `401` HTTP status code and an error
  184. // message.
  185. AUTH_FAIL_ACTION_UNAUTHORIZED = 2;
  186. }
  187. // Methods to restrict access to a URL based on login status.
  188. enum LoginRequirement {
  189. // Not specified. `LOGIN_OPTIONAL` is assumed.
  190. LOGIN_UNSPECIFIED = 0;
  191. // Does not require that the user is signed in.
  192. LOGIN_OPTIONAL = 1;
  193. // If the user is not signed in, the `auth_fail_action` is taken.
  194. // In addition, if the user is not an administrator for the
  195. // application, they are given an error message regardless of
  196. // `auth_fail_action`. If the user is an administrator, the handler
  197. // proceeds.
  198. LOGIN_ADMIN = 2;
  199. // If the user has signed in, the handler proceeds normally. Otherwise, the
  200. // auth_fail_action is taken.
  201. LOGIN_REQUIRED = 3;
  202. }
  203. // Methods to enforce security (HTTPS) on a URL.
  204. enum SecurityLevel {
  205. option allow_alias = true;
  206. // Not specified.
  207. SECURE_UNSPECIFIED = 0;
  208. // Both HTTP and HTTPS requests with URLs that match the handler succeed
  209. // without redirects. The application can examine the request to determine
  210. // which protocol was used, and respond accordingly.
  211. SECURE_DEFAULT = 0;
  212. // Requests for a URL that match this handler that use HTTPS are automatically
  213. // redirected to the HTTP equivalent URL.
  214. SECURE_NEVER = 1;
  215. // Both HTTP and HTTPS requests with URLs that match the handler succeed
  216. // without redirects. The application can examine the request to determine
  217. // which protocol was used and respond accordingly.
  218. SECURE_OPTIONAL = 2;
  219. // Requests for a URL that match this handler that do not use HTTPS are
  220. // automatically redirected to the HTTPS URL with the same path. Query
  221. // parameters are reserved for the redirect.
  222. SECURE_ALWAYS = 3;
  223. }