File: snat_entry.go

package info (click to toggle)
golang-github-denverdino-aliyungo 0.0~git20180921.13fa8aa-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,824 kB
  • sloc: xml: 1,359; makefile: 3
file content (103 lines) | stat: -rw-r--r-- 2,437 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package ecs

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

type CreateSnatEntryArgs struct {
	RegionId        common.Region
	SnatTableId     string
	SourceVSwitchId string
	SnatIp          string
}

type CreateSnatEntryResponse struct {
	common.Response
	SnatEntryId string
}

type SnatEntrySetType struct {
	RegionId        common.Region
	SnatEntryId     string
	SnatIp          string
	SnatTableId     string
	SourceCIDR      string
	SourceVSwitchId string
	Status          string
}

type DescribeSnatTableEntriesArgs struct {
	RegionId    common.Region
	SnatTableId string
	common.Pagination
}

type DescribeSnatTableEntriesResponse struct {
	common.Response
	common.PaginationResult
	SnatTableEntries struct {
		SnatTableEntry []SnatEntrySetType
	}
}

type ModifySnatEntryArgs struct {
	RegionId    common.Region
	SnatTableId string
	SnatEntryId string
	SnatIp      string
}

type ModifySnatEntryResponse struct {
	common.Response
}

type DeleteSnatEntryArgs struct {
	RegionId    common.Region
	SnatTableId string
	SnatEntryId string
}

type DeleteSnatEntryResponse struct {
	common.Response
}

func (client *Client) CreateSnatEntry(args *CreateSnatEntryArgs) (resp *CreateSnatEntryResponse, err error) {
	response := CreateSnatEntryResponse{}
	err = client.Invoke("CreateSnatEntry", args, &response)
	if err != nil {
		return nil, err
	}
	return &response, err
}

func (client *Client) DescribeSnatTableEntries(args *DescribeSnatTableEntriesArgs) (snatTableEntries []SnatEntrySetType,
	pagination *common.PaginationResult, err error) {
	response, err := client.DescribeSnatTableEntriesWithRaw(args)
	if err != nil {
		return nil, nil, err
	}

	return response.SnatTableEntries.SnatTableEntry, &response.PaginationResult, nil
}

func (client *Client) DescribeSnatTableEntriesWithRaw(args *DescribeSnatTableEntriesArgs) (response *DescribeSnatTableEntriesResponse, err error) {
	args.Validate()
	response = &DescribeSnatTableEntriesResponse{}

	err = client.Invoke("DescribeSnatTableEntries", args, response)

	if err != nil {
		return nil, err
	}

	return response, nil
}

func (client *Client) ModifySnatEntry(args *ModifySnatEntryArgs) error {
	response := ModifySnatEntryResponse{}
	return client.Invoke("ModifySnatEntry", args, &response)
}

func (client *Client) DeleteSnatEntry(args *DeleteSnatEntryArgs) error {
	response := DeleteSnatEntryResponse{}
	err := client.Invoke("DeleteSnatEntry", args, &response)
	return err
}