File: forward_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 (112 lines) | stat: -rw-r--r-- 2,789 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
104
105
106
107
108
109
110
111
112
package ecs

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

type CreateForwardEntryArgs struct {
	RegionId       common.Region
	ForwardTableId string
	ExternalIp     string
	ExternalPort   string
	IpProtocol     string
	InternalIp     string
	InternalPort   string
}

type CreateForwardEntryResponse struct {
	common.Response
	ForwardEntryId string
}

type DescribeForwardTableEntriesArgs struct {
	RegionId       common.Region
	ForwardTableId string
	common.Pagination
}

type ForwardTableEntrySetType struct {
	RegionId       common.Region
	ExternalIp     string
	ExternalPort   string
	ForwardEntryId string
	ForwardTableId string
	InternalIp     string
	InternalPort   string
	IpProtocol     string
	Status         string
}

type DescribeForwardTableEntriesResponse struct {
	common.Response
	common.PaginationResult
	ForwardTableEntries struct {
		ForwardTableEntry []ForwardTableEntrySetType
	}
}

type ModifyForwardEntryArgs struct {
	RegionId       common.Region
	ForwardTableId string
	ForwardEntryId string
	ExternalIp     string
	IpProtocol     string
	ExternalPort   string
	InternalIp     string
	InternalPort   string
}

type ModifyForwardEntryResponse struct {
	common.Response
}

type DeleteForwardEntryArgs struct {
	RegionId       common.Region
	ForwardTableId string
	ForwardEntryId string
}

type DeleteForwardEntryResponse struct {
	common.Response
}

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

func (client *Client) DescribeForwardTableEntries(args *DescribeForwardTableEntriesArgs) (forwardTableEntries []ForwardTableEntrySetType,
	pagination *common.PaginationResult, err error) {
	response, err := client.DescribeForwardTableEntriesWithRaw(args)
	if err != nil {
		return nil, nil, err
	}

	return response.ForwardTableEntries.ForwardTableEntry, &response.PaginationResult, nil
}

func (client *Client) DescribeForwardTableEntriesWithRaw(args *DescribeForwardTableEntriesArgs) (response *DescribeForwardTableEntriesResponse, err error) {
	args.Validate()
	response = &DescribeForwardTableEntriesResponse{}

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

	if err != nil {
		return nil, err
	}

	return response, nil
}

func (client *Client) ModifyForwardEntry(args *ModifyForwardEntryArgs) error {
	response := ModifyForwardEntryResponse{}
	return client.Invoke("ModifyForwardEntry", args, &response)
}

func (client *Client) DeleteForwardEntry(args *DeleteForwardEntryArgs) error {
	response := DeleteForwardEntryResponse{}
	err := client.Invoke("DeleteForwardEntry", args, &response)
	return err
}