resources.proto 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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.cloud.runtimeconfig.v1beta1;
  16. import "google/api/annotations.proto";
  17. import "google/protobuf/duration.proto";
  18. import "google/protobuf/timestamp.proto";
  19. import "google/rpc/status.proto";
  20. option java_multiple_files = true;
  21. option java_package = "com.google.cloud.runtimeconfig.v1beta1";
  22. // A RuntimeConfig resource is the primary resource in the Cloud RuntimeConfig
  23. // service. A RuntimeConfig resource consists of metadata and a hierarchy of
  24. // variables.
  25. message RuntimeConfig {
  26. // The resource name of a runtime config. The name must have the format:
  27. //
  28. // projects/[PROJECT_ID]/configs/[CONFIG_NAME]
  29. //
  30. // The `[PROJECT_ID]` must be a valid project ID, and `[CONFIG_NAME]` is an
  31. // arbitrary name that matches RFC 1035 segment specification. The length of
  32. // `[CONFIG_NAME]` must be less than 64 bytes.
  33. //
  34. // You pick the RuntimeConfig resource name, but the server will validate that
  35. // the name adheres to this format. After you create the resource, you cannot
  36. // change the resource's name.
  37. string name = 1;
  38. // An optional description of the RuntimeConfig object.
  39. // The length of the description must be less than 256 bytes.
  40. string description = 2;
  41. }
  42. // Describes a single variable within a RuntimeConfig resource.
  43. // The name denotes the hierarchical variable name. For example,
  44. // `ports/serving_port` is a valid variable name. The variable value is an
  45. // opaque string and only leaf variables can have values (that is, variables
  46. // that do not have any child variables).
  47. message Variable {
  48. // The name of the variable resource, in the format:
  49. //
  50. // projects/[PROJECT_ID]/configs/[CONFIG_NAME]/variables/[VARIABLE_NAME]
  51. //
  52. // The `[PROJECT_ID]` must be a valid project ID, `[CONFIG_NAME]` must be a
  53. // valid RuntimeConfig reource and `[VARIABLE_NAME]` follows Unix file system
  54. // file path naming.
  55. //
  56. // The `[VARIABLE_NAME]` can contain ASCII letters, numbers, slashes and
  57. // dashes. Slashes are used as path element separators and are not part of the
  58. // `[VARIABLE_NAME]` itself, so `[VARIABLE_NAME]` must contain at least one
  59. // non-slash character. Multiple slashes are coalesced into single slash
  60. // character. Each path segment should follow RFC 1035 segment specification.
  61. // The length of a `[VARIABLE_NAME]` must be less than 256 bytes.
  62. //
  63. // Once you create a variable, you cannot change the variable name.
  64. string name = 1;
  65. // The the value of the variable. It can be either a binary or a string
  66. // value. Specifying both will cause server to issue an error.
  67. oneof contents {
  68. // The binary value of the variable. The length of the value must be less
  69. // than 4096 bytes. Empty values are also accepted. The value must be
  70. // Base64 encoded.
  71. // NB: Only one of value and string_value can be set at the same time.
  72. bytes value = 2;
  73. // The textual value of the variable. The length of the value must be less
  74. // than 4096 bytes. Empty values are also accepted.
  75. // NB: Only one of value and string_value can be set at the same time.
  76. string text = 5;
  77. }
  78. // [Output Only] The time of the last variable update.
  79. google.protobuf.Timestamp update_time = 3;
  80. // [Ouput only] The current state of the variable. The variable state indicates
  81. // the outcome of the `variables().watch` call and is visible through the
  82. // `get` and `list` calls.
  83. VariableState state = 4;
  84. }
  85. // The condition that a Waiter resource is waiting for.
  86. message EndCondition {
  87. // A Cardinality condition for the Waiter resource. A cardinality condition is
  88. // met when the number of variables under a specified path prefix reaches a
  89. // predefined number. For example, if you set a Cardinality condition where
  90. // the `path` is set to `/foo` and the number of paths is set to 2, the
  91. // following variables would meet the condition in a RuntimeConfig resource:
  92. //
  93. // + `/foo/variable1 = "value1"`
  94. // + `/foo/variable2 = "value2"`
  95. // + `/bar/variable3 = "value3"`
  96. //
  97. // It would not would not satisify the same condition with the `number` set to
  98. // 3, however, because there is only 2 paths that start with `/foo`.
  99. // Cardinality conditions are recursive; all subtrees under the specific
  100. // path prefix are counted.
  101. message Cardinality {
  102. // The root of the variable subtree to monitor. For example, `/foo`.
  103. string path = 1;
  104. // The number variables under the `path` that must exist to meet this
  105. // condition. Defaults to 1 if not specified.
  106. int32 number = 2;
  107. }
  108. // The condition oneof holds the available condition types for this
  109. // EndCondition. Currently, the only available type is Cardinality.
  110. oneof condition {
  111. // The cardinality of the `EndCondition`.
  112. Cardinality cardinality = 1;
  113. }
  114. }
  115. // A Waiter resource waits for some end condition within a RuntimeConfig resource
  116. // to be met before it returns. For example, assume you have a distributed
  117. // system where each node writes to a Variable resource indidicating the node's
  118. // readiness as part of the startup process.
  119. //
  120. // You then configure a Waiter resource with the success condition set to wait
  121. // until some number of nodes have checked in. Afterwards, your application
  122. // runs some arbitrary code after the condition has been met and the waiter
  123. // returns successfully.
  124. //
  125. // Once created, a Waiter resource is immutable.
  126. //
  127. // To learn more about using waiters, read the
  128. // [Creating a Waiter](/deployment-manager/runtime-configurator/creating-a-waiter)
  129. // documentation.
  130. message Waiter {
  131. // The name of the Waiter resource, in the format:
  132. //
  133. // projects/[PROJECT_ID]/configs/[CONFIG_NAME]/waiters/[WAITER_NAME]
  134. //
  135. // The `[PROJECT_ID]` must be a valid Google Cloud project ID,
  136. // the `[CONFIG_NAME]` must be a valid RuntimeConfig resource, the
  137. // `[WAITER_NAME]` must match RFC 1035 segment specification, and the length
  138. // of `[WAITER_NAME]` must be less than 64 bytes.
  139. //
  140. // After you create a Waiter resource, you cannot change the resource name.
  141. string name = 1;
  142. // [Required] Specifies the timeout of the waiter in seconds, beginning from
  143. // the instant that `waiters().create` method is called. If this time elapses
  144. // before the success or failure conditions are met, the waiter fails and sets
  145. // the `error` code to `DEADLINE_EXCEEDED`.
  146. google.protobuf.Duration timeout = 2;
  147. // [Optional] The failure condition of this waiter. If this condition is met,
  148. // `done` will be set to `true` and the `error` code will be set to `ABORTED`.
  149. // The failure condition takes precedence over the success condition. If both
  150. // conditions are met, a failure will be indicated. This value is optional; if
  151. // no failure condition is set, the only failure scenario will be a timeout.
  152. EndCondition failure = 3;
  153. // [Required] The success condition. If this condition is met, `done` will be
  154. // set to `true` and the `error` value will remain unset. The failure condition
  155. // takes precedence over the success condition. If both conditions are met, a
  156. // failure will be indicated.
  157. EndCondition success = 4;
  158. // [Output Only] The instant at which this Waiter resource was created. Adding
  159. // the value of `timeout` to this instant yields the timeout deadline for the
  160. // waiter.
  161. google.protobuf.Timestamp create_time = 5;
  162. // [Output Only] If the value is `false`, it means the waiter is still waiting
  163. // for one of its conditions to be met.
  164. //
  165. // If true, the waiter has finished. If the waiter finished due to a timeout
  166. // or failure, `error` will be set.
  167. bool done = 6;
  168. // [Output Only] If the waiter ended due to a failure or timeout, this value
  169. // will be set.
  170. google.rpc.Status error = 7;
  171. }
  172. // The `VariableState` describes the last known state of the variable and is
  173. // used during a `variables().watch` call to distinguish the state of the
  174. // variable.
  175. enum VariableState {
  176. // Default variable state.
  177. VARIABLE_STATE_UNSPECIFIED = 0;
  178. // The variable was updated, while `variables().watch` was executing.
  179. UPDATED = 1;
  180. // The variable was deleted, while `variables().watch` was executing.
  181. DELETED = 2;
  182. }