resource.proto 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. // Copyright 2019 Google LLC.
  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. syntax = "proto3";
  16. package google.api;
  17. import "google/protobuf/descriptor.proto";
  18. option cc_enable_arenas = true;
  19. option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "ResourceProto";
  22. option java_package = "com.google.api";
  23. option objc_class_prefix = "GAPI";
  24. extend google.protobuf.FieldOptions {
  25. // An annotation that describes a resource reference, see
  26. // [ResourceReference][].
  27. google.api.ResourceReference resource_reference = 1055;
  28. }
  29. extend google.protobuf.FileOptions {
  30. // An annotation that describes a resource definition without a corresponding
  31. // message; see [ResourceDescriptor][].
  32. repeated google.api.ResourceDescriptor resource_definition = 1053;
  33. }
  34. extend google.protobuf.MessageOptions {
  35. // An annotation that describes a resource definition, see
  36. // [ResourceDescriptor][].
  37. google.api.ResourceDescriptor resource = 1053;
  38. }
  39. // A simple descriptor of a resource type.
  40. //
  41. // ResourceDescriptor annotates a resource message (either by means of a
  42. // protobuf annotation or use in the service config), and associates the
  43. // resource's schema, the resource type, and the pattern of the resource name.
  44. //
  45. // Example:
  46. //
  47. // message Topic {
  48. // // Indicates this message defines a resource schema.
  49. // // Declares the resource type in the format of {service}/{kind}.
  50. // // For Kubernetes resources, the format is {api group}/{kind}.
  51. // option (google.api.resource) = {
  52. // type: "pubsub.googleapis.com/Topic"
  53. // name_descriptor: {
  54. // pattern: "projects/{project}/topics/{topic}"
  55. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  56. // parent_name_extractor: "projects/{project}"
  57. // }
  58. // };
  59. // }
  60. //
  61. // The ResourceDescriptor Yaml config will look like:
  62. //
  63. // resources:
  64. // - type: "pubsub.googleapis.com/Topic"
  65. // name_descriptor:
  66. // - pattern: "projects/{project}/topics/{topic}"
  67. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  68. // parent_name_extractor: "projects/{project}"
  69. //
  70. // Sometimes, resources have multiple patterns, typically because they can
  71. // live under multiple parents.
  72. //
  73. // Example:
  74. //
  75. // message LogEntry {
  76. // option (google.api.resource) = {
  77. // type: "logging.googleapis.com/LogEntry"
  78. // name_descriptor: {
  79. // pattern: "projects/{project}/logs/{log}"
  80. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  81. // parent_name_extractor: "projects/{project}"
  82. // }
  83. // name_descriptor: {
  84. // pattern: "folders/{folder}/logs/{log}"
  85. // parent_type: "cloudresourcemanager.googleapis.com/Folder"
  86. // parent_name_extractor: "folders/{folder}"
  87. // }
  88. // name_descriptor: {
  89. // pattern: "organizations/{organization}/logs/{log}"
  90. // parent_type: "cloudresourcemanager.googleapis.com/Organization"
  91. // parent_name_extractor: "organizations/{organization}"
  92. // }
  93. // name_descriptor: {
  94. // pattern: "billingAccounts/{billing_account}/logs/{log}"
  95. // parent_type: "billing.googleapis.com/BillingAccount"
  96. // parent_name_extractor: "billingAccounts/{billing_account}"
  97. // }
  98. // };
  99. // }
  100. //
  101. // The ResourceDescriptor Yaml config will look like:
  102. //
  103. // resources:
  104. // - type: 'logging.googleapis.com/LogEntry'
  105. // name_descriptor:
  106. // - pattern: "projects/{project}/logs/{log}"
  107. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  108. // parent_name_extractor: "projects/{project}"
  109. // - pattern: "folders/{folder}/logs/{log}"
  110. // parent_type: "cloudresourcemanager.googleapis.com/Folder"
  111. // parent_name_extractor: "folders/{folder}"
  112. // - pattern: "organizations/{organization}/logs/{log}"
  113. // parent_type: "cloudresourcemanager.googleapis.com/Organization"
  114. // parent_name_extractor: "organizations/{organization}"
  115. // - pattern: "billingAccounts/{billing_account}/logs/{log}"
  116. // parent_type: "billing.googleapis.com/BillingAccount"
  117. // parent_name_extractor: "billingAccounts/{billing_account}"
  118. //
  119. // For flexible resources, the resource name doesn't contain parent names, but
  120. // the resource itself has parents for policy evaluation.
  121. //
  122. // Example:
  123. //
  124. // message Shelf {
  125. // option (google.api.resource) = {
  126. // type: "library.googleapis.com/Shelf"
  127. // name_descriptor: {
  128. // pattern: "shelves/{shelf}"
  129. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  130. // }
  131. // name_descriptor: {
  132. // pattern: "shelves/{shelf}"
  133. // parent_type: "cloudresourcemanager.googleapis.com/Folder"
  134. // }
  135. // };
  136. // }
  137. //
  138. // The ResourceDescriptor Yaml config will look like:
  139. //
  140. // resources:
  141. // - type: 'library.googleapis.com/Shelf'
  142. // name_descriptor:
  143. // - pattern: "shelves/{shelf}"
  144. // parent_type: "cloudresourcemanager.googleapis.com/Project"
  145. // - pattern: "shelves/{shelf}"
  146. // parent_type: "cloudresourcemanager.googleapis.com/Folder"
  147. message ResourceDescriptor {
  148. // A description of the historical or future-looking state of the
  149. // resource pattern.
  150. enum History {
  151. // The "unset" value.
  152. HISTORY_UNSPECIFIED = 0;
  153. // The resource originally had one pattern and launched as such, and
  154. // additional patterns were added later.
  155. ORIGINALLY_SINGLE_PATTERN = 1;
  156. // The resource has one pattern, but the API owner expects to add more
  157. // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents
  158. // that from being necessary once there are multiple patterns.)
  159. FUTURE_MULTI_PATTERN = 2;
  160. }
  161. // The resource type. It must be in the format of
  162. // {service_name}/{resource_type_kind}. The `resource_type_kind` must be
  163. // singular and must not include version numbers.
  164. //
  165. // Example: `storage.googleapis.com/Bucket`
  166. //
  167. // The value of the resource_type_kind must follow the regular expression
  168. // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
  169. // should use PascalCase (UpperCamelCase). The maximum number of
  170. // characters allowed for the `resource_type_kind` is 100.
  171. string type = 1;
  172. // Optional. The relative resource name pattern associated with this resource
  173. // type. The DNS prefix of the full resource name shouldn't be specified here.
  174. //
  175. // The path pattern must follow the syntax, which aligns with HTTP binding
  176. // syntax:
  177. //
  178. // Template = Segment { "/" Segment } ;
  179. // Segment = LITERAL | Variable ;
  180. // Variable = "{" LITERAL "}" ;
  181. //
  182. // Examples:
  183. //
  184. // - "projects/{project}/topics/{topic}"
  185. // - "projects/{project}/knowledgeBases/{knowledge_base}"
  186. //
  187. // The components in braces correspond to the IDs for each resource in the
  188. // hierarchy. It is expected that, if multiple patterns are provided,
  189. // the same component name (e.g. "project") refers to IDs of the same
  190. // type of resource.
  191. repeated string pattern = 2;
  192. // Optional. The field on the resource that designates the resource name
  193. // field. If omitted, this is assumed to be "name".
  194. string name_field = 3;
  195. // Optional. The historical or future-looking state of the resource pattern.
  196. //
  197. // Example:
  198. //
  199. // // The InspectTemplate message originally only supported resource
  200. // // names with organization, and project was added later.
  201. // message InspectTemplate {
  202. // option (google.api.resource) = {
  203. // type: "dlp.googleapis.com/InspectTemplate"
  204. // pattern:
  205. // "organizations/{organization}/inspectTemplates/{inspect_template}"
  206. // pattern: "projects/{project}/inspectTemplates/{inspect_template}"
  207. // history: ORIGINALLY_SINGLE_PATTERN
  208. // };
  209. // }
  210. History history = 4;
  211. // The plural name used in the resource name, such as 'projects' for
  212. // the name of 'projects/{project}'. It is the same concept of the `plural`
  213. // field in k8s CRD spec
  214. // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
  215. string plural = 5;
  216. // The same concept of the `singular` field in k8s CRD spec
  217. // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
  218. // Such as "project" for the `resourcemanager.googleapis.com/Project` type.
  219. string singular = 6;
  220. }
  221. // Defines a proto annotation that describes a string field that refers to
  222. // an API resource.
  223. message ResourceReference {
  224. // The resource type that the annotated field references.
  225. //
  226. // Example:
  227. //
  228. // message Subscription {
  229. // string topic = 2 [(google.api.resource_reference) = {
  230. // type: "pubsub.googleapis.com/Topic"
  231. // }];
  232. // }
  233. string type = 1;
  234. // The resource type of a child collection that the annotated field
  235. // references. This is useful for annotating the `parent` field that
  236. // doesn't have a fixed resource type.
  237. //
  238. // Example:
  239. //
  240. // message ListLogEntriesRequest {
  241. // string parent = 1 [(google.api.resource_reference) = {
  242. // child_type: "logging.googleapis.com/LogEntry"
  243. // };
  244. // }
  245. string child_type = 2;
  246. }