diff --git a/fortimanager2/config/config.go b/fortimanager2/config/config.go index 729da946..97181610 100644 --- a/fortimanager2/config/config.go +++ b/fortimanager2/config/config.go @@ -3,7 +3,7 @@ package config import ( "net/http" - "github.com/fortinetdev/forti-sdk-go/fortimanager2/auth" + "github.com/romanromanovv/forti-sdk-go/fortimanager2/auth" ) // Config provides configuration to a FMG client instance diff --git a/fortimanager2/sdkcore/forticlient.go b/fortimanager2/sdkcore/forticlient.go index e62edbe6..f630c644 100644 --- a/fortimanager2/sdkcore/forticlient.go +++ b/fortimanager2/sdkcore/forticlient.go @@ -6,15 +6,15 @@ import ( "fmt" "io/ioutil" "log" - "os" "net/http" "net/url" - "strings" + "os" "regexp" + "strings" - "github.com/fortinetdev/forti-sdk-go/fortimanager2/auth" "github.com/fortinetdev/forti-sdk-go/fortimanager2/config" "github.com/fortinetdev/forti-sdk-go/fortimanager2/request" + "github.com/romanromanovv/forti-sdk-go/fortimanager2/auth" // "strconv" ) @@ -114,7 +114,6 @@ func login(auth *auth.Auth, c *FortiSDKClient) { v2 = append(v2, paramItem) data["params"] = v2 - locJSON, err := json.Marshal(data) if err != nil { log.Fatal(err) @@ -137,7 +136,6 @@ func login(auth *auth.Auth, c *FortiSDKClient) { return } - var result map[string]interface{} json.Unmarshal([]byte(string(body)), &result) @@ -208,7 +206,7 @@ func (c *FortiSDKClient) GetDeviceVersion() (version string, err error) { if err != nil { return "", err } - + if version, ok := result["result"].([]interface{})[0].(map[string]interface{})["data"].(map[string]interface{})["Version"].(string); ok { regexp, err := regexp.Compile(`v([\d.]+)`) match := regexp.FindStringSubmatch(version) diff --git a/fortimanager2/sdkcore/sdkfos.go b/fortimanager2/sdkcore/sdkfos.go index 38a5017d..26c00719 100644 --- a/fortimanager2/sdkcore/sdkfos.go +++ b/fortimanager2/sdkcore/sdkfos.go @@ -12,8 +12,6 @@ import ( "fmt" ) - - // UpdateDvmCmdAddDevice API operation for FortiManager updates the specified CmdAddDevice. // Returns the index value of the CmdAddDevice and execution result when the request executes successfully. // Returns error for service API and SDK errors. @@ -20120,6 +20118,73 @@ func (c *FortiSDKClient) ReadPackagesFirewallPolicy(mkey string, paradict map[st return } + +// CreatePackagesFirewallPolicy API operation for FortiManager creates a new FirewallPolicy. +// Returns the index value of the FirewallPolicy and execution result when the request executes successfully. +// Returns error for service API and SDK errors. +// See the packages - firewall policy chapter in the FortiManager Handbook - CLI Reference. +func (c *FortiSDKClient) CreatePackagesFirewallPolicyBlock(params *map[string]interface{}, paradict map[string]string) (output map[string]interface{}, err error) { + path := "/pm/config/[*]/pblock/{pblock}/firewall/policy" + path, err = replaceParaWithValue(path, paradict) + if err != nil { + return nil, fmt.Errorf("%v", err) + } + + output, err = createUpdate(c, path, "add", params, false) + return +} + +// UpdatePackagesFirewallPolicy API operation for FortiManager updates the specified FirewallPolicy. +// Returns the index value of the FirewallPolicy and execution result when the request executes successfully. +// Returns error for service API and SDK errors. +// See the packages - firewall policy chapter in the FortiManager Handbook - CLI Reference. +func (c *FortiSDKClient) UpdatePackagesFirewallPolicyBlock(params *map[string]interface{}, mkey string, paradict map[string]string) (output map[string]interface{}, err error) { + path := "/pm/config/[*]/pblock/{pblock}/firewall/policy" + path, err = replaceParaWithValue(path, paradict) + if err != nil { + return nil, fmt.Errorf("%v", err) + } + + path += "/" + escapeURLString(mkey) + + output, err = createUpdate(c, path, "set", params, false) + return +} + +// DeletePackagesFirewallPolicy API operation for FortiManager deletes the specified FirewallPolicy. +// Returns error for service API and SDK errors. +// See the packages - firewall policy chapter in the FortiManager Handbook - CLI Reference. +func (c *FortiSDKClient) DeletePackagesFirewallPolicyBlock(mkey string, paradict map[string]string) (err error) { + path := "/pm/config/[*]/pblock/{pblock}/firewall/policy" + path, err = replaceParaWithValue(path, paradict) + if err != nil { + return fmt.Errorf("%v", err) + } + + path += "/" + escapeURLString(mkey) + + err = delete(c, path, "delete", false) + return +} + +// ReadPackagesFirewallPolicy API operation for FortiManager gets the FirewallPolicy +// with the specified index value. +// Returns the requested FirewallPolicy value when the request executes successfully. +// Returns error for service API and SDK errors. +// See the packages - firewall policy chapter in the FortiManager Handbook - CLI Reference. +func (c *FortiSDKClient) ReadPackagesFirewallPolicyBlock(mkey string, paradict map[string]string) (mapTmp map[string]interface{}, err error) { + path := "/pm/config/[*]/pblock/{pblock}/firewall/policy" + path, err = replaceParaWithValue(path, paradict) + if err != nil { + return nil, fmt.Errorf("%v", err) + } + + path += "/" + escapeURLString(mkey) + + mapTmp, err = read(c, path, "get", false) + return +} + // CreatePackagesFirewallPolicy46 API operation for FortiManager creates a new FirewallPolicy46. // Returns the index value of the FirewallPolicy46 and execution result when the request executes successfully. // Returns error for service API and SDK errors.