Skip to content

Commit 1be3ede

Browse files
authored
V2.1.0 (#126)
New Resource: resource_checkpoint_management_command_get_interfaces New Resource: resource_checkpoint_management_command_abort_get_interfaces New Resource: resource_checkpoint_management_command_export_management New Resource: resource_checkpoint_management_command_import_management New Resource: resource_checkpoint_management_command_export_smart_task New Resource: resource_checkpoint_management_command_import_smart_task New Resource: resource_checkpoint_management_command_gaia_api New Resource: resource_checkpoint_management_command_lock_object New Resource: resource_checkpoint_management_command_unlock_object New Resource: resource_checkpoint_management_command_login_to_domain New Resource: resource_checkpoint_management_command_vsx_run_operation New Resource: resource_checkpoint_management_command_set_policy_settings New Resource: resource_checkpoint_management_command_set_threat_advanced_settings New Resource: resource_checkpoint_management_command_set_global_properties New Data Source: data_source_checkpoint_management_task New Data Source: data_source_checkpoint_management_global_domain New Data Source: data_source_checkpoint_management_automatic_purge New Data Source: data_source_checkpoint_management_objects New Data Source: data_source_checkpoint_management_login_message New Data Source: data_source_checkpoint_management_threat_advanced_settings New Data Source: data_source_checkpoint_management_policy_settings New Data Source: data_source_checkpoint_management_ips_protection_extended_attribute New Data Source: data_source_checkpoint_management_ips_update_schedule New Data Source: data_source_checkpoint_management_smart_task_trigger New Data Source: data_source_checkpoint_management_api_settings
1 parent 26ef674 commit 1be3ede

File tree

90 files changed

+11930
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+11930
-0
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
## 2.1.0 (September 20, 2022)
2+
3+
FEATURES
4+
5+
* **New Resource:** `resource_checkpoint_management_command_get_interfaces`
6+
* **New Resource:** `resource_checkpoint_management_command_abort_get_interfaces`
7+
* **New Resource:** `resource_checkpoint_management_command_export_management`
8+
* **New Resource:** `resource_checkpoint_management_command_import_management`
9+
* **New Resource:** `resource_checkpoint_management_command_export_smart_task`
10+
* **New Resource:** `resource_checkpoint_management_command_import_smart_task`
11+
* **New Resource:** `resource_checkpoint_management_command_gaia_api`
12+
* **New Resource:** `resource_checkpoint_management_command_lock_object`
13+
* **New Resource:** `resource_checkpoint_management_command_unlock_object`
14+
* **New Resource:** `resource_checkpoint_management_command_login_to_domain`
15+
* **New Resource:** `resource_checkpoint_management_command_vsx_run_operation`
16+
* **New Resource:** `resource_checkpoint_management_command_set_policy_settings`
17+
* **New Resource:** `resource_checkpoint_management_command_set_threat_advanced_settings`
18+
* **New Resource:** `resource_checkpoint_management_command_set_global_properties`
19+
* **New Data Source:** `data_source_checkpoint_management_task`
20+
* **New Data Source:** `data_source_checkpoint_management_global_domain`
21+
* **New Data Source:** `data_source_checkpoint_management_automatic_purge`
22+
* **New Data Source:** `data_source_checkpoint_management_objects`
23+
* **New Data Source:** `data_source_checkpoint_management_login_message`
24+
* **New Data Source:** `data_source_checkpoint_management_threat_advanced_settings`
25+
* **New Data Source:** `data_source_checkpoint_management_policy_settings`
26+
* **New Data Source:** `data_source_checkpoint_management_ips_protection_extended_attribute`
27+
* **New Data Source:** `data_source_checkpoint_management_ips_update_schedule`
28+
* **New Data Source:** `data_source_checkpoint_management_smart_task_trigger`
29+
* **New Data Source:** `data_source_checkpoint_management_api_settings`
30+
31+
32+
33+
134
## 2.0.0 (June 23, 2022)
235

336
ENHANCEMENTS
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package checkpoint
2+
3+
import (
4+
"fmt"
5+
checkpoint "github.com/CheckPointSW/cp-mgmt-api-go-sdk/APIFiles"
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8+
"log"
9+
)
10+
11+
func dataSourceManagementApiSettings() *schema.Resource {
12+
return &schema.Resource{
13+
Read: dataSourceManagementApiSettingsRead,
14+
Schema: map[string]*schema.Schema{
15+
"name": {
16+
Type: schema.TypeString,
17+
Computed: true,
18+
Description: "Object name. Must be unique in the domain.",
19+
},
20+
"uid": {
21+
Type: schema.TypeString,
22+
Computed: true,
23+
Description: "Object unique identifier.",
24+
},
25+
"type": {
26+
Type: schema.TypeString,
27+
Computed: true,
28+
Description: "Object type.",
29+
},
30+
"accepted_api_calls_from": {
31+
Type: schema.TypeString,
32+
Computed: true,
33+
Description: "Clients allowed to connect to the API Server.",
34+
},
35+
"automatic_start": {
36+
Type: schema.TypeBool,
37+
Computed: true,
38+
Description: "MGMT API will start after server will start.",
39+
},
40+
"tags": {
41+
Type: schema.TypeSet,
42+
Computed: true,
43+
Description: "Collection of tag identifiers.",
44+
Elem: &schema.Schema{
45+
Type: schema.TypeString,
46+
},
47+
},
48+
"color": {
49+
Type: schema.TypeString,
50+
Computed: true,
51+
Description: "Color of the object. Should be one of existing colors.",
52+
},
53+
"comments": {
54+
Type: schema.TypeString,
55+
Computed: true,
56+
Description: "Comments string.",
57+
},
58+
},
59+
}
60+
}
61+
62+
func dataSourceManagementApiSettingsRead(d *schema.ResourceData, m interface{}) error {
63+
client := m.(*checkpoint.ApiClient)
64+
65+
payload := make(map[string]interface{})
66+
67+
showApiSettingsRes, err := client.ApiCall("show-api-settings", payload, client.GetSessionID(), true, client.IsProxyUsed())
68+
if err != nil {
69+
return fmt.Errorf(err.Error())
70+
}
71+
if !showApiSettingsRes.Success {
72+
return fmt.Errorf(showApiSettingsRes.ErrorMsg)
73+
}
74+
75+
apiSettings := showApiSettingsRes.GetData()
76+
77+
log.Println("Read Api Settings - Show JSON = ", apiSettings)
78+
79+
d.SetId("show-api-settings-" + acctest.RandString(10))
80+
81+
if v := apiSettings["name"]; v != nil {
82+
_ = d.Set("name", v)
83+
}
84+
85+
if v := apiSettings["uid"]; v != nil {
86+
_ = d.Set("uid", v)
87+
}
88+
89+
if v := apiSettings["type"]; v != nil {
90+
_ = d.Set("type", v)
91+
}
92+
93+
if v := apiSettings["accepted-api-calls-from"]; v != nil {
94+
_ = d.Set("accepted_api_calls_from", v)
95+
}
96+
97+
if v := apiSettings["automatic-start"]; v != nil {
98+
_ = d.Set("automatic_start", v)
99+
}
100+
101+
if apiSettings["tags"] != nil {
102+
tagsJson := apiSettings["tags"].([]interface{})
103+
var tagsIds = make([]string, 0)
104+
if len(tagsJson) > 0 {
105+
// Create slice of tag names
106+
for _, tag := range tagsJson {
107+
tag := tag.(map[string]interface{})
108+
tagsIds = append(tagsIds, tag["name"].(string))
109+
}
110+
}
111+
_ = d.Set("tags", tagsIds)
112+
} else {
113+
_ = d.Set("tags", nil)
114+
}
115+
116+
if v := apiSettings["color"]; v != nil {
117+
_ = d.Set("color", v)
118+
}
119+
120+
if v := apiSettings["comments"]; v != nil {
121+
_ = d.Set("comments", v)
122+
}
123+
124+
return nil
125+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
package checkpoint
2+
3+
import (
4+
"fmt"
5+
checkpoint "github.com/CheckPointSW/cp-mgmt-api-go-sdk/APIFiles"
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8+
"log"
9+
)
10+
11+
func dataSourceManagementAutomaticPurge() *schema.Resource {
12+
return &schema.Resource{
13+
Read: dataSourceManagementAutomaticPurgeRead,
14+
Schema: map[string]*schema.Schema{
15+
"enabled": {
16+
Type: schema.TypeBool,
17+
Computed: true,
18+
Description: "Turn on/off the automatic-purge feature.",
19+
},
20+
"keep_sessions_by_count": {
21+
Type: schema.TypeBool,
22+
Computed: true,
23+
Description: "Whether or not to keep the latest N sessions.",
24+
},
25+
"number_of_sessions_to_keep": {
26+
Type: schema.TypeInt,
27+
Computed: true,
28+
Description: "The number of newest sessions to preserve, by the sessions's publish date.",
29+
},
30+
"keep_sessions_by_days": {
31+
Type: schema.TypeBool,
32+
Computed: true,
33+
Description: "Whether or not to keep the sessions for D days.",
34+
},
35+
"number_of_days_to_keep": {
36+
Type: schema.TypeInt,
37+
Computed: true,
38+
Description: "When \"keep-sessions-by-days = true\" this sets the number of days to keep the sessions.",
39+
},
40+
"scheduling": {
41+
Type: schema.TypeList,
42+
Computed: true,
43+
MaxItems: 1,
44+
Description: "When to purge sessions that do not meet the \"keep\" criteria. Note: when the automatic purge feature is enabled, this field must be set.",
45+
Elem: &schema.Resource{
46+
Schema: map[string]*schema.Schema{
47+
"start_date": {
48+
Type: schema.TypeString,
49+
Computed: true,
50+
Description: "The first time to check whether or not there are sessions to purge. ISO 8601. If timezone isn't specified in the input, the Management server's timezone is used. Instead - If you want to start immediately, type: \"now\". Note: when the automatic purge feature is enabled, this field must be set.",
51+
},
52+
"time_units": {
53+
Type: schema.TypeString,
54+
Computed: true,
55+
Description: "Note: when the automatic purge feature is enabled, this field must be set.",
56+
},
57+
"check_interval": {
58+
Type: schema.TypeInt,
59+
Computed: true,
60+
Description: "Number of time-units between two purge checks. Note: when the automatic purge feature is enabled, this field must be set.",
61+
},
62+
"last_check": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
Description: "Last time purge check was executed.",
66+
},
67+
"next_check": {
68+
Type: schema.TypeString,
69+
Computed: true,
70+
Description: "Next time purge check will be executed.",
71+
},
72+
},
73+
},
74+
},
75+
},
76+
}
77+
}
78+
79+
func dataSourceManagementAutomaticPurgeRead(d *schema.ResourceData, m interface{}) error {
80+
client := m.(*checkpoint.ApiClient)
81+
82+
payload := make(map[string]interface{})
83+
84+
showAutomaticPurgeRes, err := client.ApiCall("show-automatic-purge", payload, client.GetSessionID(), true, client.IsProxyUsed())
85+
if err != nil {
86+
return fmt.Errorf(err.Error())
87+
}
88+
if !showAutomaticPurgeRes.Success {
89+
return fmt.Errorf(showAutomaticPurgeRes.ErrorMsg)
90+
}
91+
92+
automaticPurge := showAutomaticPurgeRes.GetData()
93+
94+
log.Println("Read Automatic Purge - Show JSON = ", automaticPurge)
95+
96+
d.SetId("show-automatic-purge-" + acctest.RandString(10))
97+
98+
if v := automaticPurge["enabled"]; v != nil {
99+
_ = d.Set("enabled", v)
100+
}
101+
102+
if v := automaticPurge["keep-sessions-by-count"]; v != nil {
103+
_ = d.Set("keep_sessions_by_count", v)
104+
}
105+
106+
if v := automaticPurge["number-of-sessions-to-keep"]; v != nil {
107+
_ = d.Set("number_of_sessions_to_keep", v)
108+
}
109+
110+
if v := automaticPurge["keep-sessions-by-days"]; v != nil {
111+
_ = d.Set("keep_sessions_by_days", v)
112+
}
113+
114+
if v := automaticPurge["number-of-days-to-keep"]; v != nil {
115+
_ = d.Set("number_of_days_to_keep", v)
116+
}
117+
118+
if automaticPurge["scheduling"] != nil {
119+
schedulingMap := automaticPurge["scheduling"].(map[string]interface{})
120+
schedulingList := make([]interface{}, 0)
121+
122+
schedulingMapToReturn := make(map[string]interface{})
123+
124+
if v, _ := schedulingMap["start-date"]; v != nil {
125+
schedulingMapToReturn["start_date"] = v
126+
}
127+
if v, _ := schedulingMap["time-units"]; v != nil {
128+
schedulingMapToReturn["time_units"] = v
129+
}
130+
if v, _ := schedulingMap["check-interval"]; v != nil {
131+
schedulingMapToReturn["check_interval"] = v
132+
}
133+
if v, _ := schedulingMap["last-check"]; v != nil {
134+
schedulingMapToReturn["last_check"] = v
135+
}
136+
if v, _ := schedulingMap["next-check"]; v != nil {
137+
schedulingMapToReturn["next_check"] = v
138+
}
139+
schedulingList = append(schedulingList, schedulingMapToReturn)
140+
_ = d.Set("scheduling", schedulingList)
141+
} else {
142+
_ = d.Set("scheduling", nil)
143+
}
144+
145+
return nil
146+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package checkpoint
2+
3+
import (
4+
"fmt"
5+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
6+
"os"
7+
"testing"
8+
)
9+
10+
func TestAccDataSourceCheckpointManagementAutomaticPurge_basic(t *testing.T) {
11+
12+
dataSourceName := "data.checkpoint_management_automatic_purge.auto"
13+
14+
context := os.Getenv("CHECKPOINT_CONTEXT")
15+
if context != "web_api" {
16+
t.Skip("Skipping management test")
17+
}
18+
19+
resource.Test(t, resource.TestCase{
20+
PreCheck: func() { testAccPreCheck(t) },
21+
Providers: testAccProviders,
22+
Steps: []resource.TestStep{
23+
{
24+
Config: testAccDataSourceManagementAutomaticPurgeConfig(),
25+
Check: resource.ComposeTestCheckFunc(
26+
resource.TestCheckResourceAttrPair(dataSourceName, "name", dataSourceName, "name"),
27+
),
28+
},
29+
},
30+
})
31+
32+
}
33+
34+
func testAccDataSourceManagementAutomaticPurgeConfig() string {
35+
return fmt.Sprintf(`
36+
data "checkpoint_management_automatic_purge" "auto" {
37+
38+
}
39+
`)
40+
}

0 commit comments

Comments
 (0)