Allow users to send requests from CMK using POST requests.  (#161)

* Adding changes to reflect changes to Cloudstack that enforce POST and timestamps

* Making some changes

* Fixing some errors based off PR

* Changing postRequest from true to false

* Adding config

* Fixing confusion

---------

Co-authored-by: Kevin Li <kli74@apple.com>
diff --git a/cmd/network.go b/cmd/network.go
index b5f4bef..0dae39f 100644
--- a/cmd/network.go
+++ b/cmd/network.go
@@ -203,7 +203,11 @@
 			params.Add(key, value)
 		}
 	}
+	signatureversion := "3"
+	expiresKey := "expires"
 	params.Add("response", "json")
+	params.Add("signatureversion", signatureversion)
+	params.Add(expiresKey, time.Now().UTC().Add(15 * time.Minute).Format(time.RFC3339))
 
 	var encodedParams string
 	var err error
@@ -220,8 +224,13 @@
 		mac := hmac.New(sha1.New, []byte(secretKey))
 		mac.Write([]byte(strings.ToLower(encodedParams)))
 		signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))
-		encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
-		params = nil
+		if r.Config.Core.PostRequest {
+			params.Add("signature", signature)
+		} else {
+			encodedParams = encodedParams + fmt.Sprintf("&signature=%s", url.QueryEscape(signature))
+			params = nil
+		}
+
 	} else if len(r.Config.ActiveProfile.Username) > 0 && len(r.Config.ActiveProfile.Password) > 0 {
 		sessionKey, err := Login(r)
 		if err != nil {
@@ -287,7 +296,7 @@
 // we can implement further conditions to do POST or GET (or other http commands) here
 func executeRequest(r *Request, requestURL string, params url.Values) (*http.Response, error) {
 	config.SetupContext(r.Config)
-	if params.Has("password") || params.Has("userdata") {
+	if params.Has("password") || params.Has("userdata") || r.Config.Core.PostRequest {
 		requestURL = fmt.Sprintf("%s", r.Config.ActiveProfile.URL)
 		return r.Client().PostForm(requestURL, params)
 	} else {
diff --git a/config/config.go b/config/config.go
index e390c22..52ee9f0 100644
--- a/config/config.go
+++ b/config/config.go
@@ -67,6 +67,7 @@
 	VerifyCert   bool   `ini:"verifycert"`
 	ProfileName  string `ini:"profile"`
 	AutoComplete bool   `ini:"autocomplete"`
+	PostRequest  bool   `ini:postrequest`
 }
 
 // Config describes CLI config file and default options
@@ -151,6 +152,7 @@
 		VerifyCert:   true,
 		ProfileName:  "localcloud",
 		AutoComplete: true,
+		PostRequest:  true,
 	}
 }
 
@@ -282,6 +284,9 @@
 			core.AutoComplete = true
 			core.Output = JSON
 		}
+		if !conf.Section(ini.DEFAULT_SECTION).HasKey("postrequest") {
+			core.PostRequest = true
+		}
 		cfg.Core = core
 	}