Skip to content

Commit c99e28c

Browse files
committed
api: Add optional CategoryID,TagID fields for category and tag creation
Fixes #3706 Signed-off-by: Doug MacEachern <[email protected]>
1 parent b154c78 commit c99e28c

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

vapi/tags/categories.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
/*
2-
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// © Broadcom. All Rights Reserved.
2+
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
3+
// SPDX-License-Identifier: Apache-2.0
164

175
package tags
186

@@ -34,6 +22,7 @@ type Category struct {
3422
Cardinality string `json:"cardinality,omitempty"`
3523
AssociableTypes []string `json:"associable_types,omitempty"`
3624
UsedBy []string `json:"used_by,omitempty"`
25+
CategoryID string `json:"category_id,omitempty"`
3726
}
3827

3928
func (c *Category) hasType(kind string) bool {
@@ -74,6 +63,7 @@ func (c *Manager) CreateCategory(ctx context.Context, category *Category) (strin
7463
Description string `json:"description"`
7564
Cardinality string `json:"cardinality"`
7665
AssociableTypes []string `json:"associable_types"`
66+
CategoryID string `json:"category_id,omitempty"`
7767
}
7868
spec := struct {
7969
Category create `json:"create_spec"`
@@ -83,6 +73,7 @@ func (c *Manager) CreateCategory(ctx context.Context, category *Category) (strin
8373
Description: category.Description,
8474
Cardinality: category.Cardinality,
8575
AssociableTypes: category.AssociableTypes,
76+
CategoryID: category.CategoryID,
8677
},
8778
}
8879
if spec.Category.AssociableTypes == nil {

vapi/tags/tags.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
/*
2-
Copyright (c) 2018 VMware, Inc. All Rights Reserved.
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// © Broadcom. All Rights Reserved.
2+
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
3+
// SPDX-License-Identifier: Apache-2.0
164

175
package tags
186

@@ -50,6 +38,7 @@ type Tag struct {
5038
Name string `json:"name,omitempty"`
5139
CategoryID string `json:"category_id,omitempty"`
5240
UsedBy []string `json:"used_by,omitempty"`
41+
TagID string `json:"tag_id,omitempty"`
5342
}
5443

5544
// Patch merges updates from the given src.
@@ -73,6 +62,7 @@ func (c *Manager) CreateTag(ctx context.Context, tag *Tag) (string, error) {
7362
Name string `json:"name"`
7463
Description string `json:"description"`
7564
CategoryID string `json:"category_id"`
65+
TagID string `json:"tag_id,omitempty"`
7666
}
7767
spec := struct {
7868
Tag create `json:"create_spec"`
@@ -81,6 +71,7 @@ func (c *Manager) CreateTag(ctx context.Context, tag *Tag) (string, error) {
8171
Name: tag.Name,
8272
Description: tag.Description,
8373
CategoryID: tag.CategoryID,
74+
TagID: tag.TagID,
8475
},
8576
}
8677
if isName(tag.CategoryID) {

0 commit comments

Comments
 (0)