@@ -4,12 +4,11 @@ import (
44 "fmt"
55
66 golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
7- "github.com/opentelekomcloud/gophertelekomcloud/openstack/cbr/v3/vaults "
7+ "github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags "
88)
99
10- func ShowVaultProjectTag (client * golangsdk.ServiceClient ) (r TagResult ) {
11- _ , r .Err = client .Get (showVaultProjectTagURL (client ), & r .Body , nil )
12- return
10+ func ShowVaultProjectTag (client * golangsdk.ServiceClient ) (r tags.ListResult ) {
11+ return tags .List (client , baseURL )
1312}
1413
1514// ----------------------------------------------------------------------------
@@ -39,23 +38,23 @@ type ResourceInstancesRequest struct {
3938 // If this parameter is set to true, all resources without tags are queried.
4039 WithoutAnyTag bool `json:"without_any_tag,omitempty"`
4140 // Returns the full amount of data when there are no filter conditions
42- Tags []Tag `json:"tags,omitempty"`
41+ Tags []tags. ListedTag `json:"tags,omitempty"`
4342 // Backups with any tags in this list will be filtered.
44- TagsAny []Tag `json:"tags_any,omitempty"`
43+ TagsAny []tags. ListedTag `json:"tags_any,omitempty"`
4544 // Backups without these tags will be filtered.
46- NotTags []Tag `json:"not_tags,omitempty"`
45+ NotTags []tags. ListedTag `json:"not_tags,omitempty"`
4746 // Backups without any tags in this list will be filtered.
48- NotTagsAny []Tag `json:"not_tags_any,omitempty"`
47+ NotTagsAny []tags. ListedTag `json:"not_tags_any,omitempty"`
4948 // Number of search records, default is 1000, the minimum value of limit is 1, the maximum value of limit is 1000
5049 Limit string `json:"limit,omitempty"`
5150 // Index position (no this parameter when action is count)
5251 Offset string `json:"offset,omitempty"`
5352 // filter is a paginated query. count simply returns the total number of items according to the criteria
5453 Action ActionType `json:"action"`
5554 // Query conditions supported by the resource itself
56- Matches []vaults. Tag `json:"matches,omitempty"`
57- CloudType CloudType `json:"cloud_type,omitempty"`
58- ObjectType ObjectType `json:"object_type,omitempty"`
55+ Matches []tags. ResourceTag `json:"matches,omitempty"`
56+ CloudType CloudType `json:"cloud_type,omitempty"`
57+ ObjectType ObjectType `json:"object_type,omitempty"`
5958}
6059
6160func ShowVaultResourceInstances (client * golangsdk.ServiceClient , req ResourceInstancesRequest ) (r InstancesResult ) {
@@ -73,59 +72,18 @@ func ShowVaultResourceInstances(client *golangsdk.ServiceClient, req ResourceIns
7372
7473// ----------------------------------------------------------------------------
7574
76- func ShowVaultTag (client * golangsdk.ServiceClient , id string ) (r ShowVaultTagResult ) {
77- _ , r .Err = client .Get (vaultTagsURL (client , id ), & r .Body , nil )
78- return
75+ func ShowVaultTag (client * golangsdk.ServiceClient , id string ) (r tags.GetResult ) {
76+ return tags .Get (client , baseURL , id )
7977}
8078
8179// ----------------------------------------------------------------------------
8280
83- func CreateVaultTags (client * golangsdk.ServiceClient , id string , req vaults.Tag ) (r golangsdk.ErrWithResult ) {
84- reqBody , err := golangsdk .BuildRequestBody (req , "tag" )
85- if err != nil {
86- r .Err = fmt .Errorf ("failed to create vault map: %s" , err )
87- return
88- }
89- _ , err = client .Post (vaultTagsURL (client , id ), reqBody , & r .Body , & golangsdk.RequestOpts {
90- OkCodes : []int {204 },
91- })
92- r .Err = err
93- return
94- }
95-
96- // ----------------------------------------------------------------------------
97-
98- func DeleteVaultTag (client * golangsdk.ServiceClient , id string , key string ) (r golangsdk.ErrResult ) {
99- _ , err := client .Delete (deleteVaultTagURL (client , id , key ), & golangsdk.RequestOpts {
100- OkCodes : []int {204 },
101- })
102- r .Err = err
103- return
81+ func CreateVaultTags (client * golangsdk.ServiceClient , id string , req []tags.ResourceTag ) (r tags.ActionResult ) {
82+ return tags .Create (client , baseURL , id , req )
10483}
10584
10685// ----------------------------------------------------------------------------
10786
108- type BulkCreateAndDeleteVaultTagsRequest struct {
109- Tags []vaults.Tag `json:"tags,omitempty"`
110- Action BulkActionType `json:"action"`
111- }
112-
113- type BulkActionType string
114-
115- const (
116- Create = "create"
117- Delete = "delete"
118- )
119-
120- func BatchCreateAndDeleteVaultTags (client * golangsdk.ServiceClient , id string , req BulkCreateAndDeleteVaultTagsRequest ) (r golangsdk.ErrWithResult ) {
121- reqBody , err := golangsdk .BuildRequestBody (req , "" )
122- if err != nil {
123- r .Err = fmt .Errorf ("failed to create vault map: %s" , err )
124- return
125- }
126- _ , err = client .Post (batchCreateAndDeleteVaultTagsURL (client , id ), reqBody , & r .Body , & golangsdk.RequestOpts {
127- OkCodes : []int {204 },
128- })
129- r .Err = err
130- return
87+ func DeleteVaultTag (client * golangsdk.ServiceClient , id string , req []tags.ResourceTag ) (r tags.ActionResult ) {
88+ return tags .Delete (client , baseURL , id , req )
13189}
0 commit comments