github.com/zorawar87/trillian@v1.2.1/quota/etcd/quotapb/quotapb.proto (about)

     1  // Copyright 2017 Google Inc. All Rights Reserved.
     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 quotapb;
    18  
    19  import "google/api/annotations.proto";
    20  import "google/protobuf/empty.proto";
    21  import "google/protobuf/field_mask.proto";
    22  
    23  // Configuration of a quota.
    24  //
    25  // Quotas contain a certain number of tokens that get applied to their
    26  // corresponding entities. Global quotas apply to all operations, tree and user
    27  // quotas to certain trees and users, respectively.
    28  //
    29  // Performing an operation costs a certain number of tokens (usually one). Once
    30  // a quota has no more tokens available, requests that would subtract from it
    31  // are denied with a resource_exhausted error.
    32  //
    33  // Tokens may be replenished in two different ways: either by passage of time or
    34  // sequencing progress. Time-based replenishment adds a fixed amount of tokens
    35  // after a certain interval. Sequencing-based adds a token for each leaf
    36  // processed by the sequencer. Sequencing-based replenishment may only be used
    37  // with global and tree quotas.
    38  //
    39  // A quota may be disabled or removed at any time. The effect is the same: a
    40  // disabled or non-existing quota is considered infinite by the quota system.
    41  // (Disabling is handy if you plan to re-enable a quota later on.)
    42  message Config {
    43    // Possible states of a quota configuration.
    44    enum State {
    45      // Unknown quota state. Invalid.
    46      UNKNOWN_CONFIG_STATE = 0;
    47  
    48      // Quota is enabled.
    49      ENABLED = 1;
    50  
    51      // Quota is disabled (considered infinite).
    52      DISABLED = 2;
    53    }
    54  
    55    // Name of the config, eg, “quotas/trees/1234/read/config”.
    56    // Readonly.
    57    string name = 1;
    58  
    59    // State of the config.
    60    State state = 2;
    61  
    62    // Max number of tokens available for the config.
    63    int64 max_tokens = 3;
    64  
    65    // Replenishment strategy used by the config.
    66    oneof replenishment_strategy {
    67  
    68      // Sequencing-based replenishment settings.
    69      SequencingBasedStrategy sequencing_based = 4;
    70  
    71      // Time-based replenishment settings.
    72      TimeBasedStrategy time_based = 5;
    73    }
    74  
    75    // Current number of tokens available for the config.
    76    // May be higher than max_tokens for DISABLED configs, which are considered to
    77    // have "infinite" tokens.
    78    // Readonly.
    79    int64 current_tokens = 6;
    80  }
    81  
    82  // Sequencing-based replenishment strategy settings.
    83  //
    84  // Only global/write and trees/write quotas may use sequencing-based
    85  // replenishment.
    86  message SequencingBasedStrategy {}
    87  
    88  // Time-based replenishment strategy settings.
    89  message TimeBasedStrategy {
    90    // Number of tokens to replenish at every replenish_interval_seconds.
    91    int64 tokens_to_replenish = 1;
    92  
    93    // Interval at which tokens_to_replenish get replenished.
    94    int64 replenish_interval_seconds = 2;
    95  }
    96  
    97  // CreateConfig request.
    98  message CreateConfigRequest {
    99    // Name of the config to create.
   100    // For example, "quotas/global/read/config" (global/read quota) or
   101    // "quotas/trees/1234/write/config" (write quota for tree 1234).
   102    string name = 1;
   103  
   104    // Config to be created.
   105    Config config = 2;
   106  }
   107  
   108  // DeleteConfig request.
   109  message DeleteConfigRequest {
   110    // Name of the config to delete.
   111    string name = 1;
   112  }
   113  
   114  // GetConfig request.
   115  message GetConfigRequest {
   116    // Name of the config to retrieve.
   117    // For example, "quotas/global/read/config".
   118    string name = 1;
   119  }
   120  
   121  // ListConfig request.
   122  message ListConfigsRequest {
   123    // Possible views for ListConfig.
   124    enum ListView {
   125      // Only the Config name gets returned.
   126      BASIC = 0;
   127  
   128      // Complete Config.
   129      FULL = 1;
   130    }
   131  
   132    // Names of the config to retrieve. For example, "quotas/global/read/config".
   133    // If empty, all configs are listed.
   134    // Name components may be substituted by "-" to search for all variations of
   135    // that component. For example:
   136    // - "quotas/global/-/config" (both read and write global quotas)
   137    // - "quotas/trees/-/-/config" (all tree quotas)
   138    repeated string names = 1;
   139  
   140    // View specifies how much data to return.
   141    ListView view = 2;
   142  }
   143  
   144  // ListConfig response.
   145  message ListConfigsResponse {
   146    // Configs matching the request filter.
   147    repeated Config configs = 1;
   148  }
   149  
   150  // Updates a quota config according to the update_mask provided.
   151  //
   152  // Some config changes will cause the current number of tokens to be updated, as
   153  // listed below:
   154  //
   155  // * If max_tokens is reduced and the current number of tokens is greater than
   156  //   the new max_tokens, the current number of tokens is reduced to max_tokens.
   157  //   This happens so the quota is immediately conformant to the new
   158  //   configuration.
   159  //
   160  // * A state transition from disabled to enabled causes the quota to be fully
   161  //   replenished. This happens so the re-enabled quota will enter in action in a
   162  //   known, predictable state.
   163  //
   164  // A "full replenish", also called "reset", may be forced via the reset_quota
   165  // parameter, regardless of any other changes. For convenience, reset only
   166  // requests (name and reset_quota = true) are allowed.
   167  message UpdateConfigRequest {
   168    // Name of the config to update.
   169    string name = 1;
   170  
   171    // Config to update. Only the fields specified by update_mask need to be
   172    // filled.
   173    Config config = 2;
   174  
   175    // Fields modified by the update request.
   176    // For example: "state" or "max_tokens".
   177    google.protobuf.FieldMask update_mask = 3;
   178  
   179    // If true the updated quota is reset, regardless of the update's contents.
   180    // A reset quota is replenished to its maximum number of tokens.
   181    bool reset_quota = 4;
   182  }
   183  
   184  // Quota administrative interface.
   185  //
   186  // Allows creation and management of quotas.
   187  service Quota {
   188    // Creates a new quota.
   189    rpc CreateConfig(CreateConfigRequest) returns (Config) {
   190      option (google.api.http) = {
   191        post: "/v1beta1/{name=quotas/**/config}"
   192        body: "*"
   193      };
   194    }
   195  
   196    // Deletes an existing quota. Non-existing quotas are considered infinite by
   197    // the quota system.
   198    rpc DeleteConfig(DeleteConfigRequest) returns (google.protobuf.Empty) {
   199      option (google.api.http).delete = "/v1beta1/{name=quotas/**/config}";
   200    }
   201  
   202    // Retrieves a quota by name.
   203    rpc GetConfig(GetConfigRequest) returns (Config) {
   204      option (google.api.http).get = "/v1beta1/{name=quotas/**/config}";
   205    }
   206  
   207    // Lists quotas according to the specified criteria.
   208    rpc ListConfigs(ListConfigsRequest) returns (ListConfigsResponse) {
   209      option (google.api.http).get = "/v1beta1/quotas";
   210    }
   211  
   212    // Updates a quota.
   213    rpc UpdateConfig(UpdateConfigRequest) returns (Config) {
   214      option (google.api.http) = {
   215        patch: "/v1beta1/{name=quotas/**/config}"
   216        body: "*"
   217      };
   218    }
   219  }