Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
## 2.11.0

ENHANCEMENTS
* Use GO SDK v1.9.0

FEATURES
* **New Resource:** `checkpoint_management_syslog_server`
* **New Resource:** `checkpoint_management_securid_server`
* **New Resource:** `checkpoint_management_securemote_dns_server`
* **New Resource:** `checkpoint_management_resource_uri_for_qos`
* **New Resource:** `checkpoint_management_resource_tcp`
* **New Resource:** `checkpoint_management_resource_mms`
* **New Resource:** `checkpoint_management_log_exporter`
* **New Resource:** `checkpoint_management_ldap_group`
* **New Resource:** `checkpoint_management_identity_provider`
* **New Resource:** `checkpoint_management_if_map_server`
* **New Resource:** `checkpoint_management_set_anti_malware_update_schedule`
* **New Resource:** `checkpoint_management_set_app_control_update_schedule`
* **New Resource:** `checkpoint_management_run_app_control_update`
* **New Resource:** `checkpoint_management_set_sync_with_user_center`
* **New Data Source:** `checkpoint_management_hosts`
* **New Data Source:** `checkpoint_management_networks`
* **New Data Source:** `checkpoint_management_services_tcp`
* **New Data Source:** `checkpoint_management_services_udp`
* **New Data Source:** `checkpoint_management_syslog_server`
* **New Data Source:** `checkpoint_management_securid_server`
* **New Data Source:** `checkpoint_management_securemote_dns_server`
* **New Data Source:** `checkpoint_management_resource_uri_for_qos`
* **New Data Source:** `checkpoint_management_resource_tcp`
* **New Data Source:** `checkpoint_management_resource_mms`
* **New Data Source:** `checkpoint_management_log_exporter`
* **New Data Source:** `checkpoint_management_ldap_group`
* **New Data Source:** `checkpoint_management_identity_provider`
* **New Data Source:** `checkpoint_management_if_map_server`
* **New Data Source:** `checkpoint_management_anti_malware_update_schedule`
* **New Data Source:** `checkpoint_management_app_control_status`
* **New Data Source:** `checkpoint_management_app_control_update_schedule`
* **New Data Source:** `checkpoint_management_sync_with_user_center`

## 2.10.0 (May 29, 2025)

ENHANCEMENTS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package checkpoint

import (
"fmt"
checkpoint "github.com/CheckPointSW/cp-mgmt-api-go-sdk/APIFiles"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

func dataSourceManagementAntiMalwareUpdateSchedule() *schema.Resource {
return &schema.Resource{
Read: dataSourceManagementAntiMalwareUpdateScheduleRead,
Schema: map[string]*schema.Schema{
"uid": {
Type: schema.TypeString,
Computed: true,
Description: "Object unique identifier.",
},
"enabled": {
Type: schema.TypeBool,
Computed: true,
Description: "Enable/Disable Anti-Malware Update Schedule.",
},
"schedule": {
Type: schema.TypeList,
Computed: true,
Description: "Schedule Configuration.",
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"time": {
Type: schema.TypeString,
Computed: true,
Description: "Time in format HH:mm.",
},
"recurrence": {
Type: schema.TypeList,
Computed: true,
Description: "Days recurrence.",
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"pattern": {
Type: schema.TypeString,
Computed: true,
Description: "Days recurrence pattern.",
},
"interval_hours": {
Type: schema.TypeInt,
Computed: true,
Description: "The amount of hours between updates. <font color=\"red\">Required only when</font> pattern is set to 'Interval'.",
},
"interval_minutes": {
Type: schema.TypeInt,
Computed: true,
Description: "The amount of minutes between updates. <font color=\"red\">Required only when</font> pattern is set to 'Interval'.",
},
"interval_seconds": {
Type: schema.TypeInt,
Computed: true,
Description: "The amount of seconds between updates. <font color=\"red\">Required only when</font> pattern is set to 'Interval'.",
},
"weekdays": {
Type: schema.TypeSet,
Computed: true,
Description: "Days of the week to run the update.<br> Valid values: group of values from {'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'}. <font color=\"red\">Required only when</font> pattern is set to 'Weekly'.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"days": {
Type: schema.TypeSet,
Computed: true,
Description: "Days of the month to run the update.<br> Valid values: interval in the range of 1 to 31. <font color=\"red\">Required only when</font> pattern is set to 'Monthly'.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
},
},
},
},
}
}

func dataSourceManagementAntiMalwareUpdateScheduleRead(d *schema.ResourceData, m interface{}) error {

client := m.(*checkpoint.ApiClient)

var payload = map[string]interface{}{}

antiMalwareUpdateScheduleRes, err := client.ApiCallSimple("show-anti-malware-update-schedule", payload)
if err != nil {
return fmt.Errorf(err.Error())
}
if !antiMalwareUpdateScheduleRes.Success {
return fmt.Errorf(antiMalwareUpdateScheduleRes.ErrorMsg)
}
antiMalwareUpdateScheduleData := antiMalwareUpdateScheduleRes.GetData()

if v := antiMalwareUpdateScheduleData["uid"]; v != nil {
_ = d.Set("uid", v)
d.SetId(v.(string))
}

if v := antiMalwareUpdateScheduleData["enabled"]; v != nil {
_ = d.Set("enabled", v)
}

if v := antiMalwareUpdateScheduleData["schedule"]; v != nil {

innerMap := v.(map[string]interface{})

mapToReturn := make(map[string]interface{})

if v := innerMap["time"]; v != nil {
mapToReturn["time"] = v
}

if v := innerMap["recurrence"]; v != nil {

innerRecurrenceMap := v.(map[string]interface{})

recurrenceMapToReturn := make(map[string]interface{})

if v := innerRecurrenceMap["pattern"]; v != nil {
recurrenceMapToReturn["pattern"] = v
}

if v := innerRecurrenceMap["interval-hours"]; v != nil {
recurrenceMapToReturn["interval_hours"] = v
}

if v := innerRecurrenceMap["interval-minutes"]; v != nil {
recurrenceMapToReturn["interval_minutes"] = v
}

if v := innerRecurrenceMap["interval-seconds"]; v != nil {
recurrenceMapToReturn["interval_seconds"] = v
}

if v := innerRecurrenceMap["weekdays"]; v != nil {
recurrenceMapToReturn["weekdays"] = v.(*schema.Set).List()
}

if v := innerRecurrenceMap["days"]; v != nil {
recurrenceMapToReturn["days"] = v.(*schema.Set).List()
}

mapToReturn["recurrence"] = []interface{}{recurrenceMapToReturn}
}

_ = d.Set("schedule", []interface{}{mapToReturn})
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package checkpoint

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"os"
"testing"
)

func TestAccDataSourceCheckpointManagementAntiMalwareUpdateSchedule_basic(t *testing.T) {

dataSourceName := "data.checkpoint_management_anti_malware_update_schedule.data"

context := os.Getenv("CHECKPOINT_CONTEXT")
if context != "web_api" {
t.Skip("Skipping management test")
}

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceManagementAntiMalwareUpdateScheduleConfig(),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "name", dataSourceName, "name"),
),
},
},
})

}

func testAccDataSourceManagementAntiMalwareUpdateScheduleConfig() string {
return fmt.Sprintf(`
data "checkpoint_management_anti_malware_update_schedule" "data" {

}
`)
}
127 changes: 127 additions & 0 deletions checkpoint/data_source_checkpoint_management_app_control_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package checkpoint

import (
"fmt"
checkpoint "github.com/CheckPointSW/cp-mgmt-api-go-sdk/APIFiles"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"log"
)

func dataSourceManagementAppControlStatus() *schema.Resource {
return &schema.Resource{
Read: dataSourceManagementAppControlStatusRead,
Schema: map[string]*schema.Schema{
"uid": {
Type: schema.TypeString,
Computed: true,
Description: "Object unique identifier.",
},
"last_updated": {
Type: schema.TypeList,
Computed: true,
Description: "The last time Application Control & URL Filtering was updated on the management server.",
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"iso_8601": {
Type: schema.TypeString,
Computed: true,
Description: "Date and time represented in international ISO 8601 format.",
},
"posix": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of milliseconds that have elapsed since 00:00:00, 1 January 1970.",
},
},
},
},
"installed_version": {
Type: schema.TypeString,
Computed: true,
Description: "Installed Application Control & URL Filtering version.",
},
"installed_version_creation_time": {
Type: schema.TypeList,
Computed: true,
Description: "Installed Application Control & URL Filtering version creation time.",
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"iso_8601": {
Type: schema.TypeString,
Computed: true,
Description: "Date and time represented in international ISO 8601 format.",
},
"posix": {
Type: schema.TypeInt,
Computed: true,
Description: "Number of milliseconds that have elapsed since 00:00:00, 1 January 1970.",
},
},
},
},
},
}
}

func dataSourceManagementAppControlStatusRead(d *schema.ResourceData, m interface{}) error {
client := m.(*checkpoint.ApiClient)

payload := make(map[string]interface{})

showAppControlStatusRes, err := client.ApiCallSimple("show-app-control-status", payload)
if err != nil {
return fmt.Errorf(err.Error())
}
if !showAppControlStatusRes.Success {
return fmt.Errorf(showAppControlStatusRes.ErrorMsg)
}

appControlStatus := showAppControlStatusRes.GetData()

log.Println("Read App Control Status - Show JSON = ", appControlStatus)

if v := appControlStatus["uid"]; v != nil {
_ = d.Set("uid", v)
d.SetId(v.(string))
}

if v := appControlStatus["last-updated"]; v != nil {

mapToReturn := make(map[string]interface{})

innerMap := v.(map[string]interface{})

if v := innerMap["iso-8601"]; v != nil {
mapToReturn["iso_8601"] = v
}
if v := innerMap["posix"]; v != nil {
mapToReturn["posix"] = v
}

_ = d.Set("last_updated", []interface{}{mapToReturn})
}

if v := appControlStatus["installed-version"]; v != nil {
_ = d.Set("installed_version", v)
}

if v := appControlStatus["installed-version-creation-time"]; v != nil {

mapToReturn := make(map[string]interface{})

innerMap := v.(map[string]interface{})

if v := innerMap["iso-8601"]; v != nil {
mapToReturn["iso_8601"] = v
}
if v := innerMap["posix"]; v != nil {
mapToReturn["posix"] = v
}

_ = d.Set("installed_version_creation_time", []interface{}{mapToReturn})
}

return nil
}
Loading