1package schema
2
3import "time"
4
5// Firewall defines the schema of a Firewall.
6type Firewall struct {
7	ID        int                `json:"id"`
8	Name      string             `json:"name"`
9	Labels    map[string]string  `json:"labels"`
10	Created   time.Time          `json:"created"`
11	Rules     []FirewallRule     `json:"rules"`
12	AppliedTo []FirewallResource `json:"applied_to"`
13}
14
15// FirewallRule defines the schema of a Firewall rule.
16type FirewallRule struct {
17	Direction      string   `json:"direction"`
18	SourceIPs      []string `json:"source_ips,omitempty"`
19	DestinationIPs []string `json:"destination_ips,omitempty"`
20	Protocol       string   `json:"protocol"`
21	Port           *string  `json:"port,omitempty"`
22}
23
24// FirewallListResponse defines the schema of the response when listing Firewalls.
25type FirewallListResponse struct {
26	Firewalls []Firewall `json:"firewalls"`
27}
28
29// FirewallGetResponse defines the schema of the response when retrieving a single Firewall.
30type FirewallGetResponse struct {
31	Firewall Firewall `json:"firewall"`
32}
33
34// FirewallCreateRequest defines the schema of the request to create a Firewall.
35type FirewallCreateRequest struct {
36	Name    string             `json:"name"`
37	Labels  *map[string]string `json:"labels,omitempty"`
38	Rules   []FirewallRule     `json:"rules,omitempty"`
39	ApplyTo []FirewallResource `json:"apply_to,omitempty"`
40}
41
42// FirewallResource defines the schema of a resource to apply the new Firewall on.
43type FirewallResource struct {
44	Type   string                  `json:"type"`
45	Server *FirewallResourceServer `json:"server"`
46}
47
48// FirewallResourceServer defines the schema of a Server to apply a Firewall on.
49type FirewallResourceServer struct {
50	ID int `json:"id"`
51}
52
53// FirewallCreateResponse defines the schema of the response when creating a Firewall.
54type FirewallCreateResponse struct {
55	Firewall Firewall `json:"firewall"`
56	Actions  []Action `json:"actions"`
57}
58
59// FirewallUpdateRequest defines the schema of the request to update a Firewall.
60type FirewallUpdateRequest struct {
61	Name   *string            `json:"name,omitempty"`
62	Labels *map[string]string `json:"labels,omitempty"`
63}
64
65// FirewallUpdateResponse defines the schema of the response when updating a Firewall.
66type FirewallUpdateResponse struct {
67	Firewall Firewall `json:"firewall"`
68}
69
70// FirewallActionSetRulesRequest defines the schema of the request when setting Firewall rules.
71type FirewallActionSetRulesRequest struct {
72	Rules []FirewallRule `json:"rules"`
73}
74
75// FirewallActionSetRulesResponse defines the schema of the response when setting Firewall rules.
76type FirewallActionSetRulesResponse struct {
77	Actions []Action `json:"actions"`
78}
79
80// FirewallActionApplyToResourcesRequest defines the schema of the request when applying a Firewall on resources.
81type FirewallActionApplyToResourcesRequest struct {
82	ApplyTo []FirewallResource `json:"apply_to"`
83}
84
85// FirewallActionApplyToResourcesResponse defines the schema of the response when applying a Firewall on resources.
86type FirewallActionApplyToResourcesResponse struct {
87	Actions []Action `json:"actions"`
88}
89
90// FirewallActionRemoveFromResourcesRequest defines the schema of the request when removing a Firewall from resources.
91type FirewallActionRemoveFromResourcesRequest struct {
92	RemoveFrom []FirewallResource `json:"remove_from"`
93}
94
95// FirewallActionRemoveFromResourcesResponse defines the schema of the response when removing a Firewall from resources.
96type FirewallActionRemoveFromResourcesResponse struct {
97	Actions []Action `json:"actions"`
98}
99