File: tags.go

package info (click to toggle)
golang-github-denverdino-aliyungo 0.0~git20180921.13fa8aa-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,824 kB
  • sloc: xml: 1,359; makefile: 3
file content (85 lines) | stat: -rw-r--r-- 1,861 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package slb

import "github.com/denverdino/aliyungo/common"

type TagItem struct {
	TagKey   string
	TagValue string
}

type AddTagsArgs struct {
	RegionId       common.Region
	LoadBalancerID string
	Tags           string
}

type AddTagsResponse struct {
	common.Response
}

// AddTags Add tags to resource
//
// You can read doc at https://help.aliyun.com/document_detail/42871.html
func (client *Client) AddTags(args *AddTagsArgs) error {
	response := AddTagsResponse{}
	err := client.Invoke("AddTags", args, &response)
	if err != nil {
		return err
	}
	return err
}

type RemoveTagsArgs struct {
	RegionId       common.Region
	LoadBalancerID string
	Tags           string
}

type RemoveTagsResponse struct {
	common.Response
}

// RemoveTags remove tags to resource
//
// You can read doc at https://help.aliyun.com/document_detail/42872.html
func (client *Client) RemoveTags(args *RemoveTagsArgs) error {
	response := RemoveTagsResponse{}
	err := client.Invoke("RemoveTags", args, &response)
	if err != nil {
		return err
	}
	return err
}

type TagItemType struct {
	TagItem
	InstanceCount int
}

type DescribeTagsArgs struct {
	RegionId       common.Region
	LoadBalancerID string
	Tags           string
	common.Pagination
}

type DescribeTagsResponse struct {
	common.Response
	common.PaginationResult
	TagSets struct {
		TagSet []TagItemType
	}
}

// DescribeResourceByTags describe resource by tags
//
// You can read doc at https://help.aliyun.com/document_detail/42873.html?spm=5176.doc42872.6.267.CP1iWu
func (client *Client) DescribeTags(args *DescribeTagsArgs) (tags []TagItemType, pagination *common.PaginationResult, err error) {
	args.Validate()
	response := DescribeTagsResponse{}
	err = client.Invoke("DescribeTags", args, &response)
	if err != nil {
		return nil, nil, err
	}
	return response.TagSets.TagSet, &response.PaginationResult, nil
}