Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | /* eslint-disable no-unused-vars */ |
| 6 | |
| 7 | /** |
| 8 | * Creates a ComponentDef. |
| 9 | * @param {string} projectName The resource name of the parent project. |
| 10 | * @param {string} value The name of the component |
| 11 | * e.g. "Triage" or "Triage>Security". |
| 12 | * @param {string=} docstring Short description of the ComponentDef. |
| 13 | * @param {Array<string>=} admins Array of User resource names to set as admins. |
| 14 | * @param {Array<string>=} ccs Array of User resources names to set as auto-ccs. |
| 15 | * @param {Array<string>=} labels Array of labels. |
| 16 | * @return {ComponentDef} |
| 17 | */ |
| 18 | function createComponentDef( |
| 19 | projectName, value, docstring, admins, ccs, labels) { |
| 20 | const componentDef = { |
| 21 | 'value': value, |
| 22 | 'docstring': docstring, |
| 23 | }; |
| 24 | if (admins) { |
| 25 | componentDef['admins'] = admins; |
| 26 | } |
| 27 | if (ccs) { |
| 28 | componentDef['ccs'] = ccs; |
| 29 | } |
| 30 | if (labels) { |
| 31 | componentDef['labels'] = labels; |
| 32 | } |
| 33 | const message = { |
| 34 | 'parent': projectName, |
| 35 | 'componentDef': componentDef, |
| 36 | }; |
| 37 | const url = URL + 'monorail.v3.Projects/CreateComponentDef'; |
| 38 | return run_(url, message); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Deletes a ComponentDef. |
| 43 | * @param {string} componentName Resource name of the ComponentDef to delete. |
| 44 | * @return {EmptyProto} |
| 45 | */ |
| 46 | function deleteComponentDef(componentName) { |
| 47 | const message = { |
| 48 | 'name': componentName, |
| 49 | }; |
| 50 | const url = URL + 'monorail.v3.Projects/DeleteComponentDef'; |
| 51 | return run_(url, message); |
| 52 | } |