1package ecs
2
3import "github.com/denverdino/aliyungo/common"
4
5type CreateSnatEntryArgs struct {
6	RegionId        common.Region
7	SnatTableId     string
8	SourceVSwitchId string
9	SnatIp          string
10}
11
12type CreateSnatEntryResponse struct {
13	common.Response
14	SnatEntryId string
15}
16
17type SnatEntrySetType struct {
18	RegionId        common.Region
19	SnatEntryId     string
20	SnatIp          string
21	SnatTableId     string
22	SourceCIDR      string
23	SourceVSwitchId string
24	Status          string
25}
26
27type DescribeSnatTableEntriesArgs struct {
28	RegionId    common.Region
29	SnatTableId string
30	common.Pagination
31}
32
33type DescribeSnatTableEntriesResponse struct {
34	common.Response
35	common.PaginationResult
36	SnatTableEntries struct {
37		SnatTableEntry []SnatEntrySetType
38	}
39}
40
41type ModifySnatEntryArgs struct {
42	RegionId    common.Region
43	SnatTableId string
44	SnatEntryId string
45	SnatIp      string
46}
47
48type ModifySnatEntryResponse struct {
49	common.Response
50}
51
52type DeleteSnatEntryArgs struct {
53	RegionId    common.Region
54	SnatTableId string
55	SnatEntryId string
56}
57
58type DeleteSnatEntryResponse struct {
59	common.Response
60}
61
62func (client *Client) CreateSnatEntry(args *CreateSnatEntryArgs) (resp *CreateSnatEntryResponse, err error) {
63	response := CreateSnatEntryResponse{}
64	err = client.Invoke("CreateSnatEntry", args, &response)
65	if err != nil {
66		return nil, err
67	}
68	return &response, err
69}
70
71func (client *Client) DescribeSnatTableEntries(args *DescribeSnatTableEntriesArgs) (snatTableEntries []SnatEntrySetType,
72	pagination *common.PaginationResult, err error) {
73	response, err := client.DescribeSnatTableEntriesWithRaw(args)
74	if err != nil {
75		return nil, nil, err
76	}
77
78	return response.SnatTableEntries.SnatTableEntry, &response.PaginationResult, nil
79}
80
81func (client *Client) DescribeSnatTableEntriesWithRaw(args *DescribeSnatTableEntriesArgs) (response *DescribeSnatTableEntriesResponse, err error) {
82	args.Validate()
83	response = &DescribeSnatTableEntriesResponse{}
84
85	err = client.Invoke("DescribeSnatTableEntries", args, response)
86
87	if err != nil {
88		return nil, err
89	}
90
91	return response, nil
92}
93
94func (client *Client) ModifySnatEntry(args *ModifySnatEntryArgs) error {
95	response := ModifySnatEntryResponse{}
96	return client.Invoke("ModifySnatEntry", args, &response)
97}
98
99func (client *Client) DeleteSnatEntry(args *DeleteSnatEntryArgs) error {
100	response := DeleteSnatEntryResponse{}
101	err := client.Invoke("DeleteSnatEntry", args, &response)
102	return err
103}
104