resource.proto 11 KB

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