/
data_source_illumio_organization_settings.go
66 lines (55 loc) · 1.67 KB
/
data_source_illumio_organization_settings.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
// Copyright 2021 Illumio, Inc. All Rights Reserved.
package illumiocore
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func datasourceIllumioOrganizationSettings() *schema.Resource {
return &schema.Resource{
ReadContext: datasourceIllumioOrganizationSettingsRead,
SchemaVersion: 1,
Description: "Represents Illumio Organization Settings",
Schema: map[string]*schema.Schema{
"audit_event_retention_seconds": {
Type: schema.TypeInt,
Computed: true,
Description: "The time in seconds an audit event is stored in the database",
},
"audit_event_min_severity": {
Type: schema.TypeString,
Computed: true,
Description: "Minimum severity level of audit event messages",
},
"format": {
Type: schema.TypeString,
Computed: true,
Description: "The log format (JSON, CEF, LEEF), which applies to all remote Syslog destinations",
},
},
}
}
func datasourceIllumioOrganizationSettingsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diagnostics diag.Diagnostics
pConfig, _ := m.(Config)
illumioClient := pConfig.IllumioClient
orgID := illumioClient.OrgID
_, data, err := illumioClient.Get(fmt.Sprintf("/orgs/%v/settings/events", orgID), nil)
if err != nil {
return diag.FromErr(err)
}
d.SetId(fmt.Sprintf("/orgs/%v/settings/events", orgID))
for _, key := range []string{
"audit_event_retention_seconds",
"audit_event_min_severity",
"format",
} {
if data.Exists(key) {
d.Set(key, data.S(key).Data())
} else {
d.Set(key, nil)
}
}
return diagnostics
}