forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_rulesengineaction.go
39 lines (32 loc) · 1.21 KB
/
model_rulesengineaction.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
package frontdoors
import (
"encoding/json"
"fmt"
)
type RulesEngineAction struct {
RequestHeaderActions *[]HeaderAction `json:"requestHeaderActions,omitempty"`
ResponseHeaderActions *[]HeaderAction `json:"responseHeaderActions,omitempty"`
RouteConfigurationOverride RouteConfiguration `json:"routeConfigurationOverride"`
}
var _ json.Unmarshaler = &RulesEngineAction{}
func (s *RulesEngineAction) UnmarshalJSON(bytes []byte) error {
type alias RulesEngineAction
var decoded alias
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling into RulesEngineAction: %+v", err)
}
s.RequestHeaderActions = decoded.RequestHeaderActions
s.ResponseHeaderActions = decoded.ResponseHeaderActions
var temp map[string]json.RawMessage
if err := json.Unmarshal(bytes, &temp); err != nil {
return fmt.Errorf("unmarshaling RulesEngineAction into map[string]json.RawMessage: %+v", err)
}
if v, ok := temp["routeConfigurationOverride"]; ok {
impl, err := unmarshalRouteConfigurationImplementation(v)
if err != nil {
return fmt.Errorf("unmarshaling field 'RouteConfigurationOverride' for 'RulesEngineAction': %+v", err)
}
s.RouteConfigurationOverride = impl
}
return nil
}