func getNameOfAction(actionOptionName string) string {
	if ActionIsCreate(actionOptionName) {
		return "create"
	} else if ActionIsDelete(actionOptionName) {
		return "delete"
	}
	return "obtain"
}
getNameOfAction returns the name of the action to be performed according to the value obtained
for the action parameter
package papertrail
import (
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"regexp"
	"strconv"
)
func CheckValidActionsConditions(action string) error {
	validActions := []string{"c", "create", "o", "obtain", "d", "delete"}
	_, found := find(validActions, action)
	if !found {
		return errors.New("Not valid option provided for action to perform, the only valid values are: \n" +
			"\t'c' or 'create': create new system/s, group and/or search\n" +
			"\t'd' or 'delete': create new system/s, group and/or search\n" +
			"\t'o'or 'obtain': obtain logs in base of parameters provided\n")
	}
	return nil
}
func checkStDateEndDateFmt(startDate string, endDate string) error {
	err := CheckDateFormat(startDate)
	if err != nil {
		return fmt.Errorf("cannot parse startdate: %v", err)
	}
	err = CheckDateFormat(endDate)
	if err != nil {
		return fmt.Errorf("cannot parse enddate: %v", err)
	}
	return nil
}
func cnvStDateEndDateToUnixTime(startDate string, endDate string) (int64, int64, error) {
	err := checkStDateEndDateFmt(startDate, endDate)
	if err != nil {
		return 0, 0, err
	}
	startDateUnix, err := GetTimeStampUnixFromDate(startDate)
	if err != nil {
		return 0, 0, err
	}
	endDateUnix, err := GetTimeStampUnixFromDate(endDate)
	if err != nil {
		return 0, 0, err
	}
	return startDateUnix, endDateUnix, nil
}
func checkNecessaryConditions(action string, systemType string, ipAddress string,
	destinationId int, destinationPort int, startDate int64, endDate int64) error {
	papertrailToken := os.Getenv("PAPERTRAIL_API_TOKEN")
	if len(papertrailToken) == 0 {
		return errors.New("Error getting value of PAPERTRAIL_API_TOKEN, " +
			"it's necessary to define this variable with your papertrail's API token ")
	}
	err := CheckValidActionsConditions(action)
	if err != nil {
		return err
	}
	err = checkValidSystemTypeConditions(systemType, ipAddress, destinationId, destinationPort, action)
	if err != nil {
		return err
	}
	if startDate > endDate {
		return fmt.Errorf("startdate > enddate - please set proper data boundaries")
	}
	return nil
}
func apiOperation(method string, url string, bodyToSend io.Reader) (*ApiResponse, error) {
	req, err := http.NewRequest(method, url, bodyToSend)
	if err != nil {
		return nil, err
	}
	req.Header.Add(papertrailTokenName, os.Getenv("PAPERTRAIL_API_TOKEN"))
	req.Header.Add("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	return &ApiResponse{
		Body:       body,
		StatusCode: resp.StatusCode,
		err:        err,
	}, nil
}
func systemTypeIsHostname(systemType string) bool {
	if systemType == "h" || systemType == "hostname" {
		return true
	}
	return false
}
func systemTypeIsIpAddress(systemType string) bool {
	if systemType == "i" || systemType == "ip-address" {
		return true
	}
	return false
}
func checkValidSystemTypeConditions(systemType string, ipAddress string, destinationId int,
	destinationPort int, actionType string) error {
	validSystemTypes := []string{"h", "hostname", "i", "ip-address"}
	_, found := find(validSystemTypes, systemType)
	if !found {
		return errors.New("Not valid option provided for system, the only valid values are: \n" +
			"\t'h' or 'hostname': system based in hostname\n" +
			"\t'i'or 'ip-address': system based in ip-address\n")
	} else if !ActionIsDelete(actionType) {
		if systemTypeIsHostname(systemType) {
			if destinationId != 0 && destinationPort != 0 {
				return errors.New("If the system is a hostname-type system, only destination " +
					"id or destination port can be specified\n")
			} else if !((destinationId != 0 && destinationPort == 0) ||
				(destinationId == 0 && destinationPort != 0)) {
				return errors.New("It's necessary provide a value distinct from default (0) to " +
					"destination id or destination port ")
			}
		} else if systemTypeIsIpAddress(systemType) {
			re := regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}`)
			if !re.MatchString(ipAddress) {
				return errors.New("The IP Address provided, " + ipAddress + " it's not a valid IP Address ")
			}
		}
	}
	return nil
}
func ActionIsCreate(actionOptionName string) bool {
	if actionOptionName == "c" || actionOptionName == "create" {
		return true
	}
	return false
}
func ActionIsDelete(actionOptionName string) bool {
	if actionOptionName == "d" || actionOptionName == "delete" {
		return true
	}
	return false
}
func ActionIsObtain(actionOptionName string) bool {
	if actionOptionName == "o" || actionOptionName == "obtain" {
		return true
	}
	return false
}