resource.proto 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // Copyright 2024 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. // pattern: "projects/{project}/topics/{topic}"
  53. // };
  54. // }
  55. //
  56. // The ResourceDescriptor Yaml config will look like:
  57. //
  58. // resources:
  59. // - type: "pubsub.googleapis.com/Topic"
  60. // pattern: "projects/{project}/topics/{topic}"
  61. //
  62. // Sometimes, resources have multiple patterns, typically because they can
  63. // live under multiple parents.
  64. //
  65. // Example:
  66. //
  67. // message LogEntry {
  68. // option (google.api.resource) = {
  69. // type: "logging.googleapis.com/LogEntry"
  70. // pattern: "projects/{project}/logs/{log}"
  71. // pattern: "folders/{folder}/logs/{log}"
  72. // pattern: "organizations/{organization}/logs/{log}"
  73. // pattern: "billingAccounts/{billing_account}/logs/{log}"
  74. // };
  75. // }
  76. //
  77. // The ResourceDescriptor Yaml config will look like:
  78. //
  79. // resources:
  80. // - type: 'logging.googleapis.com/LogEntry'
  81. // pattern: "projects/{project}/logs/{log}"
  82. // pattern: "folders/{folder}/logs/{log}"
  83. // pattern: "organizations/{organization}/logs/{log}"
  84. // pattern: "billingAccounts/{billing_account}/logs/{log}"
  85. message ResourceDescriptor {
  86. // A description of the historical or future-looking state of the
  87. // resource pattern.
  88. enum History {
  89. // The "unset" value.
  90. HISTORY_UNSPECIFIED = 0;
  91. // The resource originally had one pattern and launched as such, and
  92. // additional patterns were added later.
  93. ORIGINALLY_SINGLE_PATTERN = 1;
  94. // The resource has one pattern, but the API owner expects to add more
  95. // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents
  96. // that from being necessary once there are multiple patterns.)
  97. FUTURE_MULTI_PATTERN = 2;
  98. }
  99. // A flag representing a specific style that a resource claims to conform to.
  100. enum Style {
  101. // The unspecified value. Do not use.
  102. STYLE_UNSPECIFIED = 0;
  103. // This resource is intended to be "declarative-friendly".
  104. //
  105. // Declarative-friendly resources must be more strictly consistent, and
  106. // setting this to true communicates to tools that this resource should
  107. // adhere to declarative-friendly expectations.
  108. //
  109. // Note: This is used by the API linter (linter.aip.dev) to enable
  110. // additional checks.
  111. DECLARATIVE_FRIENDLY = 1;
  112. }
  113. // The resource type. It must be in the format of
  114. // {service_name}/{resource_type_kind}. The `resource_type_kind` must be
  115. // singular and must not include version numbers.
  116. //
  117. // Example: `storage.googleapis.com/Bucket`
  118. //
  119. // The value of the resource_type_kind must follow the regular expression
  120. // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and
  121. // should use PascalCase (UpperCamelCase). The maximum number of
  122. // characters allowed for the `resource_type_kind` is 100.
  123. string type = 1;
  124. // Optional. The relative resource name pattern associated with this resource
  125. // type. The DNS prefix of the full resource name shouldn't be specified here.
  126. //
  127. // The path pattern must follow the syntax, which aligns with HTTP binding
  128. // syntax:
  129. //
  130. // Template = Segment { "/" Segment } ;
  131. // Segment = LITERAL | Variable ;
  132. // Variable = "{" LITERAL "}" ;
  133. //
  134. // Examples:
  135. //
  136. // - "projects/{project}/topics/{topic}"
  137. // - "projects/{project}/knowledgeBases/{knowledge_base}"
  138. //
  139. // The components in braces correspond to the IDs for each resource in the
  140. // hierarchy. It is expected that, if multiple patterns are provided,
  141. // the same component name (e.g. "project") refers to IDs of the same
  142. // type of resource.
  143. repeated string pattern = 2;
  144. // Optional. The field on the resource that designates the resource name
  145. // field. If omitted, this is assumed to be "name".
  146. string name_field = 3;
  147. // Optional. The historical or future-looking state of the resource pattern.
  148. //
  149. // Example:
  150. //
  151. // // The InspectTemplate message originally only supported resource
  152. // // names with organization, and project was added later.
  153. // message InspectTemplate {
  154. // option (google.api.resource) = {
  155. // type: "dlp.googleapis.com/InspectTemplate"
  156. // pattern:
  157. // "organizations/{organization}/inspectTemplates/{inspect_template}"
  158. // pattern: "projects/{project}/inspectTemplates/{inspect_template}"
  159. // history: ORIGINALLY_SINGLE_PATTERN
  160. // };
  161. // }
  162. History history = 4;
  163. // The plural name used in the resource name and permission names, such as
  164. // 'projects' for the resource name of 'projects/{project}' and the permission
  165. // name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception
  166. // to this is for Nested Collections that have stuttering names, as defined
  167. // in [AIP-122](https://google.aip.dev/122#nested-collections), where the
  168. // collection ID in the resource name pattern does not necessarily directly
  169. // match the `plural` value.
  170. //
  171. // It is the same concept of the `plural` field in k8s CRD spec
  172. // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
  173. //
  174. // Note: The plural form is required even for singleton resources. See
  175. // https://aip.dev/156
  176. string plural = 5;
  177. // The same concept of the `singular` field in k8s CRD spec
  178. // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
  179. // Such as "project" for the `resourcemanager.googleapis.com/Project` type.
  180. string singular = 6;
  181. // Style flag(s) for this resource.
  182. // These indicate that a resource is expected to conform to a given
  183. // style. See the specific style flags for additional information.
  184. repeated Style style = 10;
  185. }
  186. // Defines a proto annotation that describes a string field that refers to
  187. // an API resource.
  188. message ResourceReference {
  189. // The resource type that the annotated field references.
  190. //
  191. // Example:
  192. //
  193. // message Subscription {
  194. // string topic = 2 [(google.api.resource_reference) = {
  195. // type: "pubsub.googleapis.com/Topic"
  196. // }];
  197. // }
  198. //
  199. // Occasionally, a field may reference an arbitrary resource. In this case,
  200. // APIs use the special value * in their resource reference.
  201. //
  202. // Example:
  203. //
  204. // message GetIamPolicyRequest {
  205. // string resource = 2 [(google.api.resource_reference) = {
  206. // type: "*"
  207. // }];
  208. // }
  209. string type = 1;
  210. // The resource type of a child collection that the annotated field
  211. // references. This is useful for annotating the `parent` field that
  212. // doesn't have a fixed resource type.
  213. //
  214. // Example:
  215. //
  216. // message ListLogEntriesRequest {
  217. // string parent = 1 [(google.api.resource_reference) = {
  218. // child_type: "logging.googleapis.com/LogEntry"
  219. // };
  220. // }
  221. string child_type = 2;
  222. }