googleanalytics
/
lib
/
analytics-admin
/
vendor
/
google
/
common-protos
/
src
/
Api
/
BackendRule
/
PathTranslation.php
googleanalytics
/
lib
/
analytics-admin
/
vendor
/
google
/
common-protos
/
src
/
Api
/
BackendRule
Last commit date
PathTranslation.php
3 years ago
PathTranslation.php
96 lines
| 1 | <?php |
| 2 | # Generated by the protocol buffer compiler. DO NOT EDIT! |
| 3 | # source: google/api/backend.proto |
| 4 | |
| 5 | namespace Google\Api\BackendRule; |
| 6 | |
| 7 | use UnexpectedValueException; |
| 8 | |
| 9 | /** |
| 10 | * Path Translation specifies how to combine the backend address with the |
| 11 | * request path in order to produce the appropriate forwarding URL for the |
| 12 | * request. |
| 13 | * Path Translation is applicable only to HTTP-based backends. Backends which |
| 14 | * do not accept requests over HTTP/HTTPS should leave `path_translation` |
| 15 | * unspecified. |
| 16 | * |
| 17 | * Protobuf type <code>google.api.BackendRule.PathTranslation</code> |
| 18 | */ |
| 19 | class PathTranslation |
| 20 | { |
| 21 | /** |
| 22 | * Generated from protobuf enum <code>PATH_TRANSLATION_UNSPECIFIED = 0;</code> |
| 23 | */ |
| 24 | const PATH_TRANSLATION_UNSPECIFIED = 0; |
| 25 | /** |
| 26 | * Use the backend address as-is, with no modification to the path. If the |
| 27 | * URL pattern contains variables, the variable names and values will be |
| 28 | * appended to the query string. If a query string parameter and a URL |
| 29 | * pattern variable have the same name, this may result in duplicate keys in |
| 30 | * the query string. |
| 31 | * # Examples |
| 32 | * Given the following operation config: |
| 33 | * Method path: /api/company/{cid}/user/{uid} |
| 34 | * Backend address: https://example.cloudfunctions.net/getUser |
| 35 | * Requests to the following request paths will call the backend at the |
| 36 | * translated path: |
| 37 | * Request path: /api/company/widgetworks/user/johndoe |
| 38 | * Translated: |
| 39 | * https://example.cloudfunctions.net/getUser?cid=widgetworks&uid=johndoe |
| 40 | * Request path: /api/company/widgetworks/user/johndoe?timezone=EST |
| 41 | * Translated: |
| 42 | * https://example.cloudfunctions.net/getUser?timezone=EST&cid=widgetworks&uid=johndoe |
| 43 | * |
| 44 | * Generated from protobuf enum <code>CONSTANT_ADDRESS = 1;</code> |
| 45 | */ |
| 46 | const CONSTANT_ADDRESS = 1; |
| 47 | /** |
| 48 | * The request path will be appended to the backend address. |
| 49 | * # Examples |
| 50 | * Given the following operation config: |
| 51 | * Method path: /api/company/{cid}/user/{uid} |
| 52 | * Backend address: https://example.appspot.com |
| 53 | * Requests to the following request paths will call the backend at the |
| 54 | * translated path: |
| 55 | * Request path: /api/company/widgetworks/user/johndoe |
| 56 | * Translated: |
| 57 | * https://example.appspot.com/api/company/widgetworks/user/johndoe |
| 58 | * Request path: /api/company/widgetworks/user/johndoe?timezone=EST |
| 59 | * Translated: |
| 60 | * https://example.appspot.com/api/company/widgetworks/user/johndoe?timezone=EST |
| 61 | * |
| 62 | * Generated from protobuf enum <code>APPEND_PATH_TO_ADDRESS = 2;</code> |
| 63 | */ |
| 64 | const APPEND_PATH_TO_ADDRESS = 2; |
| 65 | |
| 66 | private static $valueToName = [ |
| 67 | self::PATH_TRANSLATION_UNSPECIFIED => 'PATH_TRANSLATION_UNSPECIFIED', |
| 68 | self::CONSTANT_ADDRESS => 'CONSTANT_ADDRESS', |
| 69 | self::APPEND_PATH_TO_ADDRESS => 'APPEND_PATH_TO_ADDRESS', |
| 70 | ]; |
| 71 | |
| 72 | public static function name($value) |
| 73 | { |
| 74 | if (!isset(self::$valueToName[$value])) { |
| 75 | throw new UnexpectedValueException(sprintf( |
| 76 | 'Enum %s has no name defined for value %s', __CLASS__, $value)); |
| 77 | } |
| 78 | return self::$valueToName[$value]; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | public static function value($name) |
| 83 | { |
| 84 | $const = __CLASS__ . '::' . strtoupper($name); |
| 85 | if (!defined($const)) { |
| 86 | throw new UnexpectedValueException(sprintf( |
| 87 | 'Enum %s has no value defined for name %s', __CLASS__, $name)); |
| 88 | } |
| 89 | return constant($const); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | // Adding a class alias for backwards compatibility with the previous class name. |
| 94 | class_alias(PathTranslation::class, \Google\Api\BackendRule_PathTranslation::class); |
| 95 | |
| 96 |