folders.proto 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. syntax = "proto3";
  16. package google.cloud.resourcemanager.v2;
  17. import "google/api/annotations.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/api/resource.proto";
  21. import "google/iam/v1/iam_policy.proto";
  22. import "google/iam/v1/policy.proto";
  23. import "google/longrunning/operations.proto";
  24. import "google/protobuf/field_mask.proto";
  25. import "google/protobuf/timestamp.proto";
  26. option csharp_namespace = "Google.Cloud.ResourceManager.V2";
  27. option go_package = "google.golang.org/genproto/googleapis/cloud/resourcemanager/v2;resourcemanager";
  28. option java_multiple_files = true;
  29. option java_outer_classname = "FoldersProto";
  30. option java_package = "com.google.cloud.resourcemanager.v2";
  31. option php_namespace = "Google\\Cloud\\ResourceManager\\V2";
  32. // Manages Cloud Resource Folders.
  33. // Cloud Resource Folders can be used to organize the resources under an
  34. // organization and to control the IAM policies applied to groups of resources.
  35. service Folders {
  36. option (google.api.default_host) = "cloudresourcemanager.googleapis.com";
  37. option (google.api.oauth_scopes) =
  38. "https://www.googleapis.com/auth/cloud-platform,"
  39. "https://www.googleapis.com/auth/cloud-platform.read-only";
  40. // Lists the Folders that are direct descendants of supplied parent resource.
  41. // List provides a strongly consistent view of the Folders underneath
  42. // the specified parent resource.
  43. // List returns Folders sorted based upon the (ascending) lexical ordering
  44. // of their display_name.
  45. // The caller must have `resourcemanager.folders.list` permission on the
  46. // identified parent.
  47. rpc ListFolders(ListFoldersRequest) returns (ListFoldersResponse) {
  48. option (google.api.http) = {
  49. get: "/v2/folders"
  50. };
  51. option (google.api.method_signature) = "parent,show_deleted";
  52. }
  53. // Search for folders that match specific filter criteria.
  54. // Search provides an eventually consistent view of the folders a user has
  55. // access to which meet the specified filter criteria.
  56. //
  57. // This will only return folders on which the caller has the
  58. // permission `resourcemanager.folders.get`.
  59. rpc SearchFolders(SearchFoldersRequest) returns (SearchFoldersResponse) {
  60. option (google.api.http) = {
  61. post: "/v2/folders:search"
  62. body: "*"
  63. };
  64. option (google.api.method_signature) = "query";
  65. }
  66. // Retrieves a Folder identified by the supplied resource name.
  67. // Valid Folder resource names have the format `folders/{folder_id}`
  68. // (for example, `folders/1234`).
  69. // The caller must have `resourcemanager.folders.get` permission on the
  70. // identified folder.
  71. rpc GetFolder(GetFolderRequest) returns (Folder) {
  72. option (google.api.http) = {
  73. get: "/v2/{name=folders/*}"
  74. };
  75. option (google.api.method_signature) = "name";
  76. }
  77. // Creates a Folder in the resource hierarchy.
  78. // Returns an Operation which can be used to track the progress of the
  79. // folder creation workflow.
  80. // Upon success the Operation.response field will be populated with the
  81. // created Folder.
  82. //
  83. // In order to succeed, the addition of this new Folder must not violate
  84. // the Folder naming, height or fanout constraints.
  85. //
  86. // + The Folder's display_name must be distinct from all other Folder's that
  87. // share its parent.
  88. // + The addition of the Folder must not cause the active Folder hierarchy
  89. // to exceed a height of 4. Note, the full active + deleted Folder hierarchy
  90. // is allowed to reach a height of 8; this provides additional headroom when
  91. // moving folders that contain deleted folders.
  92. // + The addition of the Folder must not cause the total number of Folders
  93. // under its parent to exceed 100.
  94. //
  95. // If the operation fails due to a folder constraint violation, some errors
  96. // may be returned by the CreateFolder request, with status code
  97. // FAILED_PRECONDITION and an error description. Other folder constraint
  98. // violations will be communicated in the Operation, with the specific
  99. // PreconditionFailure returned via the details list in the Operation.error
  100. // field.
  101. //
  102. // The caller must have `resourcemanager.folders.create` permission on the
  103. // identified parent.
  104. rpc CreateFolder(CreateFolderRequest) returns (google.longrunning.Operation) {
  105. option (google.api.http) = {
  106. post: "/v2/folders"
  107. body: "folder"
  108. };
  109. option (google.api.method_signature) = "parent,folder";
  110. option (google.longrunning.operation_info) = {
  111. response_type: "Folder"
  112. metadata_type: "FolderOperation"
  113. };
  114. }
  115. // Updates a Folder, changing its display_name.
  116. // Changes to the folder display_name will be rejected if they violate either
  117. // the display_name formatting rules or naming constraints described in
  118. // the [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.
  119. //
  120. // The Folder's display name must start and end with a letter or digit,
  121. // may contain letters, digits, spaces, hyphens and underscores and can be
  122. // no longer than 30 characters. This is captured by the regular expression:
  123. // [\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.
  124. // The caller must have `resourcemanager.folders.update` permission on the
  125. // identified folder.
  126. //
  127. // If the update fails due to the unique name constraint then a
  128. // PreconditionFailure explaining this violation will be returned
  129. // in the Status.details field.
  130. rpc UpdateFolder(UpdateFolderRequest) returns (Folder) {
  131. option (google.api.http) = {
  132. patch: "/v2/{folder.name=folders/*}"
  133. body: "folder"
  134. };
  135. option (google.api.method_signature) = "folder,update_mask";
  136. }
  137. // Moves a Folder under a new resource parent.
  138. // Returns an Operation which can be used to track the progress of the
  139. // folder move workflow.
  140. // Upon success the Operation.response field will be populated with the
  141. // moved Folder.
  142. // Upon failure, a FolderOperationError categorizing the failure cause will
  143. // be returned - if the failure occurs synchronously then the
  144. // FolderOperationError will be returned via the Status.details field
  145. // and if it occurs asynchronously then the FolderOperation will be returned
  146. // via the Operation.error field.
  147. // In addition, the Operation.metadata field will be populated with a
  148. // FolderOperation message as an aid to stateless clients.
  149. // Folder moves will be rejected if they violate either the naming, height
  150. // or fanout constraints described in the
  151. // [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.
  152. // The caller must have `resourcemanager.folders.move` permission on the
  153. // folder's current and proposed new parent.
  154. rpc MoveFolder(MoveFolderRequest) returns (google.longrunning.Operation) {
  155. option (google.api.http) = {
  156. post: "/v2/{name=folders/*}:move"
  157. body: "*"
  158. };
  159. option (google.api.method_signature) = "name,destination_parent";
  160. option (google.longrunning.operation_info) = {
  161. response_type: "Folder"
  162. metadata_type: "FolderOperation"
  163. };
  164. }
  165. // Requests deletion of a Folder. The Folder is moved into the
  166. // [DELETE_REQUESTED][google.cloud.resourcemanager.v2.Folder.LifecycleState.DELETE_REQUESTED] state
  167. // immediately, and is deleted approximately 30 days later. This method may
  168. // only be called on an empty Folder in the
  169. // [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state, where a Folder is empty if
  170. // it doesn't contain any Folders or Projects in the
  171. // [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state.
  172. // The caller must have `resourcemanager.folders.delete` permission on the
  173. // identified folder.
  174. rpc DeleteFolder(DeleteFolderRequest) returns (Folder) {
  175. option (google.api.http) = {
  176. delete: "/v2/{name=folders/*}"
  177. };
  178. option (google.api.method_signature) = "name";
  179. option (google.api.method_signature) = "name,recursive_delete";
  180. }
  181. // Cancels the deletion request for a Folder. This method may only be
  182. // called on a Folder in the
  183. // [DELETE_REQUESTED][google.cloud.resourcemanager.v2.Folder.LifecycleState.DELETE_REQUESTED] state.
  184. // In order to succeed, the Folder's parent must be in the
  185. // [ACTIVE][google.cloud.resourcemanager.v2.Folder.LifecycleState.ACTIVE] state.
  186. // In addition, reintroducing the folder into the tree must not violate
  187. // folder naming, height and fanout constraints described in the
  188. // [CreateFolder][google.cloud.resourcemanager.v2.Folders.CreateFolder] documentation.
  189. // The caller must have `resourcemanager.folders.undelete` permission on the
  190. // identified folder.
  191. rpc UndeleteFolder(UndeleteFolderRequest) returns (Folder) {
  192. option (google.api.http) = {
  193. post: "/v2/{name=folders/*}:undelete"
  194. body: "*"
  195. };
  196. option (google.api.method_signature) = "name";
  197. }
  198. // Gets the access control policy for a Folder. The returned policy may be
  199. // empty if no such policy or resource exists. The `resource` field should
  200. // be the Folder's resource name, e.g. "folders/1234".
  201. // The caller must have `resourcemanager.folders.getIamPolicy` permission
  202. // on the identified folder.
  203. rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
  204. option (google.api.http) = {
  205. post: "/v2/{resource=folders/*}:getIamPolicy"
  206. body: "*"
  207. };
  208. option (google.api.method_signature) = "resource";
  209. }
  210. // Sets the access control policy on a Folder, replacing any existing policy.
  211. // The `resource` field should be the Folder's resource name, e.g.
  212. // "folders/1234".
  213. // The caller must have `resourcemanager.folders.setIamPolicy` permission
  214. // on the identified folder.
  215. rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
  216. option (google.api.http) = {
  217. post: "/v2/{resource=folders/*}:setIamPolicy"
  218. body: "*"
  219. };
  220. option (google.api.method_signature) = "resource,policy";
  221. }
  222. // Returns permissions that a caller has on the specified Folder.
  223. // The `resource` field should be the Folder's resource name,
  224. // e.g. "folders/1234".
  225. //
  226. // There are no permissions required for making this API call.
  227. rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
  228. option (google.api.http) = {
  229. post: "/v2/{resource=folders/*}:testIamPermissions"
  230. body: "*"
  231. };
  232. option (google.api.method_signature) = "resource,permissions";
  233. }
  234. }
  235. // A Folder in an Organization's resource hierarchy, used to
  236. // organize that Organization's resources.
  237. message Folder {
  238. option (google.api.resource) = {
  239. type: "cloudresourcemanager.googleapis.com/Folder"
  240. pattern: "folders/{folder}"
  241. };
  242. // Folder lifecycle states.
  243. enum LifecycleState {
  244. // Unspecified state.
  245. LIFECYCLE_STATE_UNSPECIFIED = 0;
  246. // The normal and active state.
  247. ACTIVE = 1;
  248. // The folder has been marked for deletion by the user.
  249. DELETE_REQUESTED = 2;
  250. }
  251. // Output only. The resource name of the Folder.
  252. // Its format is `folders/{folder_id}`, for example: "folders/1234".
  253. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  254. // Required. The Folder’s parent's resource name.
  255. // Updates to the folder's parent must be performed via
  256. // [MoveFolder][google.cloud.resourcemanager.v2.Folders.MoveFolder].
  257. string parent = 2 [(google.api.field_behavior) = REQUIRED];
  258. // The folder’s display name.
  259. // A folder’s display name must be unique amongst its siblings, e.g.
  260. // no two folders with the same parent can share the same display name.
  261. // The display name must start and end with a letter or digit, may contain
  262. // letters, digits, spaces, hyphens and underscores and can be no longer
  263. // than 30 characters. This is captured by the regular expression:
  264. // [\p{L}\p{N}]([\p{L}\p{N}_- ]{0,28}[\p{L}\p{N}])?.
  265. string display_name = 3;
  266. // Output only. The lifecycle state of the folder.
  267. // Updates to the lifecycle_state must be performed via
  268. // [DeleteFolder][google.cloud.resourcemanager.v2.Folders.DeleteFolder] and
  269. // [UndeleteFolder][google.cloud.resourcemanager.v2.Folders.UndeleteFolder].
  270. LifecycleState lifecycle_state = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  271. // Output only. Timestamp when the Folder was created. Assigned by the server.
  272. google.protobuf.Timestamp create_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  273. // Output only. Timestamp when the Folder was last modified.
  274. google.protobuf.Timestamp update_time = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
  275. }
  276. // The ListFolders request message.
  277. message ListFoldersRequest {
  278. // Required. The resource name of the Organization or Folder whose Folders are
  279. // being listed.
  280. // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
  281. // Access to this method is controlled by checking the
  282. // `resourcemanager.folders.list` permission on the `parent`.
  283. string parent = 1 [
  284. (google.api.field_behavior) = REQUIRED,
  285. (google.api.resource_reference) = {
  286. child_type: "*"
  287. }
  288. ];
  289. // Optional. The maximum number of Folders to return in the response.
  290. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  291. // Optional. A pagination token returned from a previous call to `ListFolders`
  292. // that indicates where this listing should continue from.
  293. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  294. // Optional. Controls whether Folders in the
  295. // [DELETE_REQUESTED][google.cloud.resourcemanager.v2.Folder.LifecycleState.DELETE_REQUESTED]
  296. // state should be returned. Defaults to false.
  297. bool show_deleted = 4 [(google.api.field_behavior) = OPTIONAL];
  298. }
  299. // The ListFolders response message.
  300. message ListFoldersResponse {
  301. // A possibly paginated list of Folders that are direct descendants of
  302. // the specified parent resource.
  303. repeated Folder folders = 1;
  304. // A pagination token returned from a previous call to `ListFolders`
  305. // that indicates from where listing should continue.
  306. string next_page_token = 2;
  307. }
  308. // The request message for searching folders.
  309. message SearchFoldersRequest {
  310. // Optional. The maximum number of folders to return in the response.
  311. int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];
  312. // Optional. A pagination token returned from a previous call to `SearchFolders`
  313. // that indicates from where search should continue.
  314. string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
  315. // Search criteria used to select the Folders to return.
  316. // If no search criteria is specified then all accessible folders will be
  317. // returned.
  318. //
  319. // Query expressions can be used to restrict results based upon displayName,
  320. // lifecycleState and parent, where the operators `=`, `NOT`, `AND` and `OR`
  321. // can be used along with the suffix wildcard symbol `*`.
  322. //
  323. // The displayName field in a query expression should use escaped quotes
  324. // for values that include whitespace to prevent unexpected behavior.
  325. //
  326. // Some example queries are:
  327. //
  328. // * Query `displayName=Test*` returns Folder resources whose display name
  329. // starts with "Test".
  330. // * Query `lifecycleState=ACTIVE` returns Folder resources with
  331. // `lifecycleState` set to `ACTIVE`.
  332. // * Query `parent=folders/123` returns Folder resources that have
  333. // `folders/123` as a parent resource.
  334. // * Query `parent=folders/123 AND lifecycleState=ACTIVE` returns active
  335. // Folder resources that have `folders/123` as a parent resource.
  336. // * Query `displayName=\\"Test String\\"` returns Folder resources with
  337. // display names that include both "Test" and "String".
  338. string query = 3;
  339. }
  340. // The response message for searching folders.
  341. message SearchFoldersResponse {
  342. // A possibly paginated folder search results.
  343. // the specified parent resource.
  344. repeated Folder folders = 1;
  345. // A pagination token returned from a previous call to `SearchFolders`
  346. // that indicates from where searching should continue.
  347. string next_page_token = 2;
  348. }
  349. // The GetFolder request message.
  350. message GetFolderRequest {
  351. // Required. The resource name of the Folder to retrieve.
  352. // Must be of the form `folders/{folder_id}`.
  353. string name = 1 [
  354. (google.api.field_behavior) = REQUIRED,
  355. (google.api.resource_reference) = {
  356. type: "cloudresourcemanager.googleapis.com/Folder"
  357. }
  358. ];
  359. }
  360. // The CreateFolder request message.
  361. message CreateFolderRequest {
  362. // Required. The resource name of the new Folder's parent.
  363. // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
  364. string parent = 1 [
  365. (google.api.field_behavior) = REQUIRED,
  366. (google.api.resource_reference) = {
  367. child_type: "*"
  368. }
  369. ];
  370. // Required. The Folder being created, only the display name will be consulted.
  371. // All other fields will be ignored.
  372. Folder folder = 2 [(google.api.field_behavior) = REQUIRED];
  373. }
  374. // The MoveFolder request message.
  375. message MoveFolderRequest {
  376. // Required. The resource name of the Folder to move.
  377. // Must be of the form folders/{folder_id}
  378. string name = 1 [
  379. (google.api.field_behavior) = REQUIRED,
  380. (google.api.resource_reference) = {
  381. type: "cloudresourcemanager.googleapis.com/Folder"
  382. }
  383. ];
  384. // Required. The resource name of the Folder or Organization to reparent
  385. // the folder under.
  386. // Must be of the form `folders/{folder_id}` or `organizations/{org_id}`.
  387. string destination_parent = 2 [
  388. (google.api.field_behavior) = REQUIRED,
  389. (google.api.resource_reference) = {
  390. child_type: "*"
  391. }
  392. ];
  393. }
  394. // The request message for updating a folder's display name.
  395. message UpdateFolderRequest {
  396. // Required. The new definition of the Folder. It must include a
  397. // a `name` and `display_name` field. The other fields
  398. // will be ignored.
  399. Folder folder = 1 [(google.api.field_behavior) = REQUIRED];
  400. // Required. Fields to be updated.
  401. // Only the `display_name` can be updated.
  402. google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
  403. }
  404. // The DeleteFolder request message.
  405. message DeleteFolderRequest {
  406. // Required. The resource name of the Folder to be deleted.
  407. // Must be of the form `folders/{folder_id}`.
  408. string name = 1 [
  409. (google.api.field_behavior) = REQUIRED,
  410. (google.api.resource_reference) = {
  411. type: "cloudresourcemanager.googleapis.com/Folder"
  412. }
  413. ];
  414. // Instructs DeleteFolderAction to delete a folder even when the folder is not
  415. // empty.
  416. bool recursive_delete = 2;
  417. }
  418. // The UndeleteFolder request message.
  419. message UndeleteFolderRequest {
  420. // Required. The resource name of the Folder to undelete.
  421. // Must be of the form `folders/{folder_id}`.
  422. string name = 1 [
  423. (google.api.field_behavior) = REQUIRED,
  424. (google.api.resource_reference) = {
  425. type: "cloudresourcemanager.googleapis.com/Folder"
  426. }
  427. ];
  428. }
  429. // Metadata describing a long running folder operation
  430. message FolderOperation {
  431. // The type of operation that failed.
  432. enum OperationType {
  433. // Operation type not specified.
  434. OPERATION_TYPE_UNSPECIFIED = 0;
  435. // A create folder operation.
  436. CREATE = 1;
  437. // A move folder operation.
  438. MOVE = 2;
  439. }
  440. // The display name of the folder.
  441. string display_name = 1;
  442. // The type of this operation.
  443. OperationType operation_type = 2;
  444. // The resource name of the folder's parent.
  445. // Only applicable when the operation_type is MOVE.
  446. string source_parent = 3;
  447. // The resource name of the folder or organization we are either creating
  448. // the folder under or moving the folder to.
  449. string destination_parent = 4;
  450. }