forked from dcwangmit01/meraki-cli
/
port_rule.go
84 lines (65 loc) · 2.07 KB
/
port_rule.go
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
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// PortRule PortRule
//
// swagger:model PortRule
type PortRule struct {
// Remote IP addresses or ranges that are permitted to access the internal resource via this port forwarding rule, or 'any'
AllowedIps []string `json:"allowedIps"`
// Local IP address to which traffic will be forwarded
LocalIP string `json:"localIp,omitempty"`
// Destination port of the forwarded traffic that will be sent from the MX to the specified host on the LAN. If you simply wish to forward the traffic without translating the port, this should be the same as the Public port
LocalPort string `json:"localPort,omitempty"`
// A description of the rule
Name string `json:"name,omitempty"`
// protocol
Protocol Protocol3 `json:"protocol,omitempty"`
// Destination port of the traffic that is arriving on the WAN
PublicPort string `json:"publicPort,omitempty"`
}
// Validate validates this port rule
func (m *PortRule) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateProtocol(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PortRule) validateProtocol(formats strfmt.Registry) error {
if swag.IsZero(m.Protocol) { // not required
return nil
}
if err := m.Protocol.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("protocol")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *PortRule) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PortRule) UnmarshalBinary(b []byte) error {
var res PortRule
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}