-
Notifications
You must be signed in to change notification settings - Fork 132
/
types_dbaas_logs_input.go
134 lines (114 loc) · 4.34 KB
/
types_dbaas_logs_input.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package ovh
import (
"fmt"
"html"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/ovh/terraform-provider-ovh/ovh/helpers"
)
type DbaasLogsInput struct {
AllowedNetworks []string `json:"allowedNetworks"`
CreatedAt string `json:"createdAt"`
Description string `json:"description"`
EngineId string `json:"engineId"`
ExposedPort *string `json:"exposedPort"`
Hostname string `json:"hostname"`
InputId string `json:"inputId"`
IsRestartRequired bool `json:"isRestartRequired"`
NbInstance *int64 `json:"nbInstance"`
PublicAddress string `json:"publicAddress"`
SslCertificate string `json:"sslCertificate"`
Status string `json:"status"`
StreamId string `json:"streamId"`
Title string `json:"title"`
UpdatedAt string `json:"updatedAt"`
}
func (v DbaasLogsInput) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["created_at"] = v.CreatedAt
obj["description"] = v.Description
obj["engine_id"] = v.EngineId
obj["hostname"] = v.Hostname
obj["input_id"] = v.InputId
obj["is_restart_required"] = v.IsRestartRequired
obj["public_address"] = v.PublicAddress
obj["ssl_certificate"] = v.SslCertificate
obj["status"] = v.Status
obj["stream_id"] = v.StreamId
obj["title"] = v.Title
obj["updated_at"] = v.UpdatedAt
if v.AllowedNetworks != nil {
obj["allowed_networks"] = v.AllowedNetworks
}
if v.ExposedPort != nil {
obj["exposed_port"] = *v.ExposedPort
}
if v.NbInstance != nil {
obj["nb_instance"] = *v.NbInstance
}
return obj
}
type DbaasLogsInputOpts struct {
Description string `json:"description"`
EngineId string `json:"engineId"`
StreamId string `json:"streamId"`
Title string `json:"title"`
AllowedNetworks []string `json:"allowedNetworks,omitempty"`
ExposedPort *string `json:"exposedPort,omitempty"`
NbInstance *int64 `json:"nbInstance,omitempty"`
}
func (opts *DbaasLogsInputOpts) FromResource(d *schema.ResourceData) *DbaasLogsInputOpts {
opts.Description = d.Get("description").(string)
opts.EngineId = d.Get("engine_id").(string)
opts.StreamId = d.Get("stream_id").(string)
opts.Title = d.Get("title").(string)
networks := d.Get("allowed_networks").([]interface{})
if networks != nil && len(networks) > 0 {
networksString := make([]string, len(networks))
for i, net := range networks {
networksString[i] = net.(string)
}
opts.AllowedNetworks = networksString
}
opts.ExposedPort = helpers.GetNilStringPointerFromData(d, "exposed_port")
opts.NbInstance = helpers.GetNilInt64PointerFromData(d, "nb_instance")
return opts
}
type DbaasLogsInputConfigurationLogstash struct {
FilterSection *string `json:"filterSection"`
InputSection string `json:"inputSection"`
PatternSection *string `json:"patternSection"`
}
func (v DbaasLogsInputConfigurationLogstash) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["input_section"] = html.UnescapeString(v.InputSection)
if v.FilterSection != nil {
obj["filter_section"] = html.UnescapeString(*v.FilterSection)
}
if v.PatternSection != nil {
obj["pattern_section"] = html.UnescapeString(*v.PatternSection)
}
return obj
}
func (opts *DbaasLogsInputConfigurationLogstash) FromResourceWithPath(d *schema.ResourceData, path string) *DbaasLogsInputConfigurationLogstash {
opts.InputSection = d.Get(fmt.Sprintf("%s.input_section", path)).(string)
filterSection := d.Get(fmt.Sprintf("%s.filter_section", path)).(string)
opts.FilterSection = &filterSection
patternSection := d.Get(fmt.Sprintf("%s.pattern_section", path)).(string)
opts.PatternSection = &patternSection
return opts
}
type DbaasLogsInputConfigurationFlowgger struct {
LogFormat string `json:"logFormat"`
LogFraming string `json:"logFraming"`
}
func (v DbaasLogsInputConfigurationFlowgger) ToMap() map[string]interface{} {
obj := make(map[string]interface{})
obj["log_format"] = html.UnescapeString(v.LogFormat)
obj["log_framing"] = html.UnescapeString(v.LogFraming)
return obj
}
func (opts *DbaasLogsInputConfigurationFlowgger) FromResourceWithPath(d *schema.ResourceData, path string) *DbaasLogsInputConfigurationFlowgger {
opts.LogFormat = d.Get(fmt.Sprintf("%s.log_framing", path)).(string)
opts.LogFraming = d.Get(fmt.Sprintf("%s.log_format", path)).(string)
return opts
}