go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/common/proto/googleapis/google/api/resource.proto (about)

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