resource.proto 8.8 KB

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