Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chkp-royl committed Oct 1, 2020
1 parent 497f081 commit 255f9f8
Show file tree
Hide file tree
Showing 233 changed files with 11,733 additions and 447 deletions.
41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
## 1.1.0 (Unreleased)
## 1.2.0 (Unreleased)

## 1.1.0 (October 1, 2020)

FEATURES

* **New Resource:** `checkpoint_management_access_point_name`
* **New Resource:** `checkpoint_management_checkpoint_host`
* **New Resource:** `checkpoint_management_gsn_handover_group`
* **New Resource:** `checkpoint_management_identity_tag`
* **New Resource:** `checkpoint_management_mds`
* **New Resource:** `checkpoint_management_service_citrix_tcp`
* **New Resource:** `checkpoint_management_service_compound_tcp`
* **New Resource:** `checkpoint_management_user`
* **New Resource:** `checkpoint_management_user_group`
* **New Resource:** `checkpoint_management_user_template`
* **New Resource:** `checkpoint_management_vpn_community_remote_access`
* **New Resource:** `checkpoint_management_ha_full_sync`
* **New Resource:** `checkpoint_management_set_automatic_purge`
* **New Resource:** `checkpoint_management_set_ha_state`
* **New Resource:** `checkpoint_management_get_attachment`
* **New Data Source:** `checkpoint_management_access_point_name`
* **New Data Source:** `checkpoint_management_checkpoint_host`
* **New Data Source:** `checkpoint_management_mds`
* **New Data Source:** `checkpoint_management_gsn_handover_group`
* **New Data Source:** `checkpoint_management_identity_tag`
* **New Data Source:** `checkpoint_management_service_citrix_tcp`
* **New Data Source:** `checkpoint_management_service_compound_tcp`
* **New Data Source:** `checkpoint_management_user`
* **New Data Source:** `checkpoint_management_user_group`
* **New Data Source:** `checkpoint_management_user_template`
* **New Data Source:** `checkpoint_management_vpn_community_remote_access`

ENHANCEMENTS

* Resources of type command that returns asynchronous task-id(s), will save task-id(s) in state.

BUG FIXES

* Resources of type command are execute as part of 'add' method and are one-use only.


## 1.0.5 (September 9, 2020)
Expand Down
150 changes: 150 additions & 0 deletions checkpoint/data_source_checkpoint_management_access_point_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
package checkpoint

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

func dataSourceManagementAccessPointName() *schema.Resource {
return &schema.Resource{
Read: dataSourceManagementAccessPointNameRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Optional: true,
Description: "Object name.",
},
"uid": {
Type: schema.TypeString,
Optional: true,
Description: "Object unique identifier.",
},
"apn": {
Type: schema.TypeString,
Computed: true,
Description: "APN name.",
},
"enforce_end_user_domain": {
Type: schema.TypeBool,
Computed: true,
Description: "Enable enforce end user domain.",
},
"block_traffic_other_end_user_domains": {
Type: schema.TypeBool,
Computed: true,
Description: "Block MS to MS traffic between this and other APN end user domains.",
},
"block_traffic_this_end_user_domain": {
Type: schema.TypeBool,
Computed: true,
Description: "Block MS to MS traffic within this end user domain.",
},
"end_user_domain": {
Type: schema.TypeString,
Computed: true,
Description: "End user domain name or UID.",
},
"tags": {
Type: schema.TypeSet,
Computed: true,
Description: "Collection of tag identifiers.",
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"color": {
Type: schema.TypeString,
Computed: true,
Description: "Color of the object. Should be one of existing colors.",
},
"comments": {
Type: schema.TypeString,
Computed: true,
Description: "Comments string.",
},
},
}
}
func dataSourceManagementAccessPointNameRead(d *schema.ResourceData, m interface{}) error {
client := m.(*checkpoint.ApiClient)

name := d.Get("name").(string)
uid := d.Get("uid").(string)

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

if name != "" {
payload["name"] = name
} else if uid != "" {
payload["uid"] = uid
}

showAccessPointNameRes, err := client.ApiCall("show-access-point-name", payload, client.GetSessionID(), true, false)
if err != nil {
return fmt.Errorf(err.Error())
}
if !showAccessPointNameRes.Success {
return fmt.Errorf(showAccessPointNameRes.ErrorMsg)
}

accessPointName := showAccessPointNameRes.GetData()

log.Println("Read AccessPointName - Show JSON = ", accessPointName)

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

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

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

if v := accessPointName["enforce-end-user-domain"]; v != nil {
_ = d.Set("enforce_end_user_domain", v)
}

if v := accessPointName["block-traffic-other-end-user-domains"]; v != nil {
_ = d.Set("block_traffic_other_end_user_domains", v)
}

if v := accessPointName["block-traffic-this-end-user-domain"]; v != nil {
_ = d.Set("block_traffic_this_end_user_domain", v)
}

if v := accessPointName["end-user-domain"]; v != nil {
_ = d.Set("end_user_domain", v)
}

if accessPointName["tags"] != nil {
tagsJson, ok := accessPointName["tags"].([]interface{})
if ok {
tagsIds := make([]string, 0)
if len(tagsJson) > 0 {
for _, tags := range tagsJson {
tags := tags.(map[string]interface{})
tagsIds = append(tagsIds, tags["name"].(string))
}
}
_ = d.Set("tags", tagsIds)
}
} else {
_ = d.Set("tags", nil)
}

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

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

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

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

func TestAccDataSourceCheckpointManagementAccessPointName_basic(t *testing.T) {
objName := "tfTestManagementDataAccessPointName_" + acctest.RandString(6)
resourceName := "checkpoint_management_access_point_name.access_point_name"
dataSourceName := "data.checkpoint_management_access_point_name.data_access_point_name"

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: testAccDataSourceManagementAccessPointNameConfig(objName, "apnname", true, "All_Internet"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "name", resourceName, "name"),
),
},
},
})

}

func testAccDataSourceManagementAccessPointNameConfig(name string, apn string, enforceEndUserDomain bool, endUserDomain string) string {
return fmt.Sprintf(`
resource "checkpoint_management_access_point_name" "access_point_name" {
name = "%s"
apn = "%s"
enforce_end_user_domain = %t
end_user_domain = "%s"
}
data "checkpoint_management_access_point_name" "data_access_point_name" {
name = "${checkpoint_management_access_point_name.access_point_name.name}"
}
`, name, apn, enforceEndUserDomain, endUserDomain)
}
Loading

0 comments on commit 255f9f8

Please sign in to comment.