apikeys.proto 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. // Copyright 2022 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.apikeys.v2;
  16. import "google/api/annotations.proto";
  17. import "google/api/apikeys/v2/resources.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/api/resource.proto";
  21. import "google/longrunning/operations.proto";
  22. import "google/protobuf/field_mask.proto";
  23. option csharp_namespace = "Google.Cloud.ApiKeys.V2";
  24. option go_package = "google.golang.org/genproto/googleapis/api/apikeys/v2;apikeys";
  25. option java_multiple_files = true;
  26. option java_outer_classname = "ApiKeysProto";
  27. option java_package = "com.google.api.apikeys.v2";
  28. option php_namespace = "Google\\Cloud\\ApiKeys\\V2";
  29. option ruby_package = "Google::Cloud::ApiKeys::V2";
  30. // Manages the API keys associated with projects.
  31. service ApiKeys {
  32. option (google.api.default_host) = "apikeys.googleapis.com";
  33. option (google.api.oauth_scopes) =
  34. "https://www.googleapis.com/auth/cloud-platform,"
  35. "https://www.googleapis.com/auth/cloud-platform.read-only";
  36. // Creates a new API key.
  37. //
  38. // NOTE: Key is a global resource; hence the only supported value for
  39. // location is `global`.
  40. rpc CreateKey(CreateKeyRequest) returns (google.longrunning.Operation) {
  41. option (google.api.http) = {
  42. post: "/v2/{parent=projects/*/locations/*}/keys"
  43. body: "key"
  44. };
  45. option (google.api.method_signature) = "parent,key,key_id";
  46. option (google.longrunning.operation_info) = {
  47. response_type: "Key"
  48. metadata_type: "google.protobuf.Empty"
  49. };
  50. }
  51. // Lists the API keys owned by a project. The key string of the API key
  52. // isn't included in the response.
  53. //
  54. // NOTE: Key is a global resource; hence the only supported value for
  55. // location is `global`.
  56. rpc ListKeys(ListKeysRequest) returns (ListKeysResponse) {
  57. option (google.api.http) = {
  58. get: "/v2/{parent=projects/*/locations/*}/keys"
  59. };
  60. option (google.api.method_signature) = "parent";
  61. }
  62. // Gets the metadata for an API key. The key string of the API key
  63. // isn't included in the response.
  64. //
  65. // NOTE: Key is a global resource; hence the only supported value for
  66. // location is `global`.
  67. rpc GetKey(GetKeyRequest) returns (Key) {
  68. option (google.api.http) = {
  69. get: "/v2/{name=projects/*/locations/*/keys/*}"
  70. };
  71. option (google.api.method_signature) = "name";
  72. }
  73. // Get the key string for an API key.
  74. //
  75. // NOTE: Key is a global resource; hence the only supported value for
  76. // location is `global`.
  77. rpc GetKeyString(GetKeyStringRequest) returns (GetKeyStringResponse) {
  78. option (google.api.http) = {
  79. get: "/v2/{name=projects/*/locations/*/keys/*}/keyString"
  80. };
  81. option (google.api.method_signature) = "name";
  82. }
  83. // Patches the modifiable fields of an API key.
  84. // The key string of the API key isn't included in the response.
  85. //
  86. // NOTE: Key is a global resource; hence the only supported value for
  87. // location is `global`.
  88. rpc UpdateKey(UpdateKeyRequest) returns (google.longrunning.Operation) {
  89. option (google.api.http) = {
  90. patch: "/v2/{key.name=projects/*/locations/*/keys/*}"
  91. body: "key"
  92. };
  93. option (google.api.method_signature) = "key,update_mask";
  94. option (google.longrunning.operation_info) = {
  95. response_type: "Key"
  96. metadata_type: "google.protobuf.Empty"
  97. };
  98. }
  99. // Deletes an API key. Deleted key can be retrieved within 30 days of
  100. // deletion. Afterward, key will be purged from the project.
  101. //
  102. // NOTE: Key is a global resource; hence the only supported value for
  103. // location is `global`.
  104. rpc DeleteKey(DeleteKeyRequest) returns (google.longrunning.Operation) {
  105. option (google.api.http) = {
  106. delete: "/v2/{name=projects/*/locations/*/keys/*}"
  107. };
  108. option (google.api.method_signature) = "name";
  109. option (google.longrunning.operation_info) = {
  110. response_type: "Key"
  111. metadata_type: "google.protobuf.Empty"
  112. };
  113. }
  114. // Undeletes an API key which was deleted within 30 days.
  115. //
  116. // NOTE: Key is a global resource; hence the only supported value for
  117. // location is `global`.
  118. rpc UndeleteKey(UndeleteKeyRequest) returns (google.longrunning.Operation) {
  119. option (google.api.http) = {
  120. post: "/v2/{name=projects/*/locations/*/keys/*}:undelete"
  121. body: "*"
  122. };
  123. option (google.longrunning.operation_info) = {
  124. response_type: "Key"
  125. metadata_type: "google.protobuf.Empty"
  126. };
  127. }
  128. // Find the parent project and resource name of the API
  129. // key that matches the key string in the request. If the API key has been
  130. // purged, resource name will not be set.
  131. // The service account must have the `apikeys.keys.lookup` permission
  132. // on the parent project.
  133. rpc LookupKey(LookupKeyRequest) returns (LookupKeyResponse) {
  134. option (google.api.http) = {
  135. get: "/v2/keys:lookupKey"
  136. };
  137. }
  138. }
  139. // Request message for `CreateKey` method.
  140. message CreateKeyRequest {
  141. // Required. The project in which the API key is created.
  142. string parent = 1 [
  143. (google.api.field_behavior) = REQUIRED,
  144. (google.api.resource_reference) = {
  145. child_type: "apikeys.googleapis.com/Key"
  146. }
  147. ];
  148. // Required. The API key fields to set at creation time.
  149. // You can configure only the `display_name`, `restrictions`, and
  150. // `annotations` fields.
  151. Key key = 2 [(google.api.field_behavior) = REQUIRED];
  152. // User specified key id (optional). If specified, it will become the final
  153. // component of the key resource name.
  154. //
  155. // The id must be unique within the project, must conform with RFC-1034,
  156. // is restricted to lower-cased letters, and has a maximum length of 63
  157. // characters. In another word, the id must match the regular
  158. // expression: `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
  159. //
  160. // The id must NOT be a UUID-like string.
  161. string key_id = 3;
  162. }
  163. // Request message for `ListKeys` method.
  164. message ListKeysRequest {
  165. // Required. Lists all API keys associated with this project.
  166. string parent = 1 [
  167. (google.api.field_behavior) = REQUIRED,
  168. (google.api.resource_reference) = {
  169. child_type: "apikeys.googleapis.com/Key"
  170. }
  171. ];
  172. // Optional. Specifies the maximum number of results to be returned at a time.
  173. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  174. // Optional. Requests a specific page of results.
  175. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  176. // Optional. Indicate that keys deleted in the past 30 days should also be
  177. // returned.
  178. bool show_deleted = 6 [(google.api.field_behavior) = OPTIONAL];
  179. }
  180. // Response message for `ListKeys` method.
  181. message ListKeysResponse {
  182. // A list of API keys.
  183. repeated Key keys = 1;
  184. // The pagination token for the next page of results.
  185. string next_page_token = 2;
  186. }
  187. // Request message for `GetKey` method.
  188. message GetKeyRequest {
  189. // Required. The resource name of the API key to get.
  190. string name = 1 [
  191. (google.api.field_behavior) = REQUIRED,
  192. (google.api.resource_reference) = { type: "apikeys.googleapis.com/Key" }
  193. ];
  194. }
  195. // Request message for `GetKeyString` method.
  196. message GetKeyStringRequest {
  197. // Required. The resource name of the API key to be retrieved.
  198. string name = 1 [
  199. (google.api.field_behavior) = REQUIRED,
  200. (google.api.resource_reference) = { type: "apikeys.googleapis.com/Key" }
  201. ];
  202. }
  203. // Response message for `GetKeyString` method.
  204. message GetKeyStringResponse {
  205. // An encrypted and signed value of the key.
  206. string key_string = 1;
  207. }
  208. // Request message for `UpdateKey` method.
  209. message UpdateKeyRequest {
  210. // Required. Set the `name` field to the resource name of the API key to be
  211. // updated. You can update only the `display_name`, `restrictions`, and
  212. // `annotations` fields.
  213. Key key = 1 [(google.api.field_behavior) = REQUIRED];
  214. // The field mask specifies which fields to be updated as part of this
  215. // request. All other fields are ignored.
  216. // Mutable fields are: `display_name`, `restrictions`, and `annotations`.
  217. // If an update mask is not provided, the service treats it as an implied mask
  218. // equivalent to all allowed fields that are set on the wire. If the field
  219. // mask has a special value "*", the service treats it equivalent to replace
  220. // all allowed mutable fields.
  221. google.protobuf.FieldMask update_mask = 2;
  222. }
  223. // Request message for `DeleteKey` method.
  224. message DeleteKeyRequest {
  225. // Required. The resource name of the API key to be deleted.
  226. string name = 1 [
  227. (google.api.field_behavior) = REQUIRED,
  228. (google.api.resource_reference) = { type: "apikeys.googleapis.com/Key" }
  229. ];
  230. // Optional. The etag known to the client for the expected state of the key.
  231. // This is to be used for optimistic concurrency.
  232. string etag = 2 [(google.api.field_behavior) = OPTIONAL];
  233. }
  234. // Request message for `UndeleteKey` method.
  235. message UndeleteKeyRequest {
  236. // Required. The resource name of the API key to be undeleted.
  237. string name = 1 [
  238. (google.api.field_behavior) = REQUIRED,
  239. (google.api.resource_reference) = { type: "apikeys.googleapis.com/Key" }
  240. ];
  241. }
  242. // Request message for `LookupKey` method.
  243. message LookupKeyRequest {
  244. // Required. Finds the project that owns the key string value.
  245. string key_string = 1 [(google.api.field_behavior) = REQUIRED];
  246. }
  247. // Response message for `LookupKey` method.
  248. message LookupKeyResponse {
  249. // The project that owns the key with the value specified in the request.
  250. string parent = 1;
  251. // The resource name of the API key. If the API key has been purged,
  252. // resource name is empty.
  253. string name = 2;
  254. }