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 Description *string `json:"description,omitempty"` 23} 24 25// FirewallListResponse defines the schema of the response when listing Firewalls. 26type FirewallListResponse struct { 27 Firewalls []Firewall `json:"firewalls"` 28} 29 30// FirewallGetResponse defines the schema of the response when retrieving a single Firewall. 31type FirewallGetResponse struct { 32 Firewall Firewall `json:"firewall"` 33} 34 35// FirewallCreateRequest defines the schema of the request to create a Firewall. 36type FirewallCreateRequest struct { 37 Name string `json:"name"` 38 Labels *map[string]string `json:"labels,omitempty"` 39 Rules []FirewallRule `json:"rules,omitempty"` 40 ApplyTo []FirewallResource `json:"apply_to,omitempty"` 41} 42 43// FirewallResource defines the schema of a resource to apply the new Firewall on. 44type FirewallResource struct { 45 Type string `json:"type"` 46 Server *FirewallResourceServer `json:"server,omitempty"` 47 LabelSelector *FirewallResourceLabelSelector `json:"label_selector,omitempty"` 48} 49 50// FirewallResourceLabelSelector defines the schema of a LabelSelector to apply a Firewall on. 51type FirewallResourceLabelSelector struct { 52 Selector string `json:"selector"` 53} 54 55// FirewallResourceServer defines the schema of a Server to apply a Firewall on. 56type FirewallResourceServer struct { 57 ID int `json:"id"` 58} 59 60// FirewallCreateResponse defines the schema of the response when creating a Firewall. 61type FirewallCreateResponse struct { 62 Firewall Firewall `json:"firewall"` 63 Actions []Action `json:"actions"` 64} 65 66// FirewallUpdateRequest defines the schema of the request to update a Firewall. 67type FirewallUpdateRequest struct { 68 Name *string `json:"name,omitempty"` 69 Labels *map[string]string `json:"labels,omitempty"` 70} 71 72// FirewallUpdateResponse defines the schema of the response when updating a Firewall. 73type FirewallUpdateResponse struct { 74 Firewall Firewall `json:"firewall"` 75} 76 77// FirewallActionSetRulesRequest defines the schema of the request when setting Firewall rules. 78type FirewallActionSetRulesRequest struct { 79 Rules []FirewallRule `json:"rules"` 80} 81 82// FirewallActionSetRulesResponse defines the schema of the response when setting Firewall rules. 83type FirewallActionSetRulesResponse struct { 84 Actions []Action `json:"actions"` 85} 86 87// FirewallActionApplyToResourcesRequest defines the schema of the request when applying a Firewall on resources. 88type FirewallActionApplyToResourcesRequest struct { 89 ApplyTo []FirewallResource `json:"apply_to"` 90} 91 92// FirewallActionApplyToResourcesResponse defines the schema of the response when applying a Firewall on resources. 93type FirewallActionApplyToResourcesResponse struct { 94 Actions []Action `json:"actions"` 95} 96 97// FirewallActionRemoveFromResourcesRequest defines the schema of the request when removing a Firewall from resources. 98type FirewallActionRemoveFromResourcesRequest struct { 99 RemoveFrom []FirewallResource `json:"remove_from"` 100} 101 102// FirewallActionRemoveFromResourcesResponse defines the schema of the response when removing a Firewall from resources. 103type FirewallActionRemoveFromResourcesResponse struct { 104 Actions []Action `json:"actions"` 105} 106