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