Documentation
¶
Index ¶
- func BasicAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func CalculatePagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, ...) (interface{}, bool)
- func CollapseJson(returnsList map[string]interface{}, errorsList map[string]interface{}) []byte
- func CustomHeaderAndBasicAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func CustomHeaderAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func CustomQuerystringAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func DefaultJsonPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, ...) (interface{}, bool)
- func DefaultJsonPostProcess(apiResponseMap map[generic_structs.ComparableApiRequest][]byte, ...) []byte
- func DefaultXmlPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, ...) (interface{}, bool)
- func JwtAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func LogError(function string, texts ...interface{})
- func LogInfo(function string, texts ...interface{})
- func LogOutput(level string, function string, texts ...interface{})
- func LogWarning(function string, texts ...interface{})
- func Oauth2TwoLegAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func OneloginAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func ParseJsonSubStructure(kSet []string, count int, subStructure interface{}) []interface{}
- func ParsePostProcessedJson(response generic_structs.ComparableApiRequest, jsonKeys []map[string]string, ...) (map[string]interface{}, map[string]interface{})
- func PopulateYamlSlice(rawYaml string, varsData map[string][]string) [][]byte
- func RegexJsonPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, ...) (interface{}, bool)
- func RemoveXmlTagFromJson(tag string, jsonBody []byte) []byte
- func SessionTokenAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
- func StringInSlice(a string, list []string) int
- func XmlResponseProcess(apiResponse []byte) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for basic username/password auth implementations. Takes a
username and password and constructs the Authorization header.
Vars: apiRequest = The ApiRequest to be used. authParams = JWT params in the order of:
[0] => username [1] => password
func CalculatePagingPeek ¶
func CalculatePagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, peekParams []string) (interface{}, bool)
Peeks at a standard JSON response for paging indicators that need to be
calculated.
Vars: response = The JSON response in []byte form. responseKeys = The split list of keys to find the paging value.
[0] => Length of current page value key and length of per page value key in csv [1..X] => Key parts for current page value key [X..Y] => Key parts for per page value key [Y..Z] => Key parts for total results value key
oldPageValue = The previous page value. peekParams = Unused, plugin-specific params.
func CollapseJson ¶
This function collapses two map[string]interface{} json representations into
a single one. WARNING (TODO): This does not handle key collisions gracefully.
func CustomHeaderAndBasicAuth ¶
func CustomHeaderAndBasicAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for custom header auth implementations that also require basic
auth. Takes the basic auth keys username/password and an alternating list of keys/values and constructs the header.
Vars: apiRequest = The ApiRequest to be used. authParams = Auth params in any quantity, alternating key then value:
[0] => username [1] => password [x] => header key [x+1] => header value
func CustomHeaderAuth ¶
func CustomHeaderAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for custom header auth implementations. Takes an alternating
list of keys/values and constructs the header.
Vars: apiRequest = The ApiRequest to be used. authParams = Auth params in any quantity, alternating key then value:
[x] => header key [x+1] => header value
func CustomQuerystringAuth ¶
func CustomQuerystringAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for custom querystring auth implementations. Takes an
alternating list of keys/values and constructs the querystring.
Vars: apiRequest = The ApiRequest to be used. authParams = Auth params in any quantity, alternating key then value:
[x] => header key [x+1] => header value
func DefaultJsonPagingPeek ¶
func DefaultJsonPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, peekParams []string) (interface{}, bool)
Peeks at a standard JSON response for paging indicators. Vars: response = The JSON response in []byte form. responseKeys = The split list of keys to find the paging value. oldPageValue = The previous page value. peekParams = Unused, plugin-specific params.
func DefaultJsonPostProcess ¶
func DefaultJsonPostProcess(apiResponseMap map[generic_structs.ComparableApiRequest][]byte, jsonKeys []map[string]string) []byte
Takes a map of requests to their []byte responses, iterates through them to
pull the desired data (and errors), and compiles the final result.
Vars: apiResponseMap = A map of API requests made and their corresponding responses
func DefaultXmlPagingPeek ¶
func DefaultXmlPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, peekParams []string) (interface{}, bool)
Peeks at a standard XML response for paging indicators. Vars: response = The XML response in []byte form. responseKeys = The split list of keys to find the paging value. oldPageValue = The previous page value. peekParams = Unused, plugin-specific params.
func JwtAuth ¶
func JwtAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for JWT implementations. Takes JWT params and preps the http
client attached to the ApiRequest.
Vars: apiRequest = The ApiRequest to be used. authParams = JWT params in the order of:
[0] => email [1] => private key [2] => private key id [3] => scopes (comma delimited string) [4] => token url
func LogWarning ¶ added in v0.3.3
func LogWarning(function string, texts ...interface{})
func Oauth2TwoLegAuth ¶
func Oauth2TwoLegAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for Oauth 2 2-legged implementations. Takes Oauth params and
preps the http client attached to the ApiRequest.
Vars: apiRequest = The ApiRequest to be used. authParams = Oauth2 params in the order of:
[0] => client ID [1] => client secret [2] => scopes (csv) [3] => token url [4] => endpoint params (string with ":" key/value separator and "," between entries => e.g. x:y,x:z,a:b)
func OneloginAuth ¶ added in v0.2.4
func OneloginAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
OneloginAuth performs some additional magic that is specific to OneLogin
func ParseJsonSubStructure ¶
Recursively drill down into JSON to find the value of a specific key set
(e.g. {"X": { "Y": { "Z": [ 1, 2, 3 ] } } } with key set "X.Y.Z" would return [ 1, 2, 3 ]).
Vars: kSet = Key set being searched for. count = Recursive depth count. subStructure = Structure being plumbed.
func ParsePostProcessedJson ¶
func ParsePostProcessedJson(response generic_structs.ComparableApiRequest, jsonKeys []map[string]string, processedJson []byte, parsedStructure map[string]interface{}, parsedErrorStructure map[string]interface{}) (map[string]interface{}, map[string]interface{})
Recursively searches through a JSON response using a given set of keys
indicating a valid response and/or error response. It then updates the provided structures with the new data.
Vars: response = A ComparableApiRequest representing the request which
gave this response.
processedJson = The JSON response from the API request that we are
parsing.
parsedStructure = Map we store response data in. parsedErrorStructure = Map we store error data in.
func PopulateYamlSlice ¶
Used to expand out the shorthand YAMLs with expansion vars into a series of
individual, expanded YAML []byte's for consumption by Epico.
Args: rawYaml = raw YAML []byte that will be tranformed into a slice of []bytes varsData = vars data to be expanded
func RegexJsonPagingPeek ¶
func RegexJsonPagingPeek(response []byte, responseKeys []string, oldPageValue interface{}, peekParams []string) (interface{}, bool)
Peeks at a standard JSON response for paging indicators. Vars: response = The JSON response in []byte form. responseKeys = The split list of keys to find the paging value. oldPageValue = The previous page value. peekParams = Params specific to this function - expecting:
[0] => Valid regex with paging param located in the first subexpression group in ()s ex: <([^>]*)>; rel=\"next\"
func RemoveXmlTagFromJson ¶
Loops through a JSON response (usually one converted from XML) and removes
the unnecessary/repeating tags often used by XML structures.
Vars: tag = Unwanted tag to be removed from the structure. jsonBody = JSON that we want to remove the tag from.
func SessionTokenAuth ¶
func SessionTokenAuth(apiRequest generic_structs.ApiRequest, authParams []string) generic_structs.ApiRequest
Auth function for session auth implementations. Takes provided params and
retrieves the session token from the designated key then updates the header of the ApiRequest.
Vars: apiRequest = The ApiRequest to be used. authParams = Session params in the order of:
[0] => Where the token is in the response e.g. "data.token" [1] => Custom header key e.g. "Authorization" or "Auth-Token" [2] => Custom header pre-token value e.g. "token " [3] => Session token URL [x] => Session key [x+1] => Session value
func StringInSlice ¶ added in v0.2.8
func XmlResponseProcess ¶
This function simply takes an XML response and converts it to JSON (the
preferred internal form of Epico).
Args: apiResponse = A []byte representation of the XML API response.
Types ¶
This section is empty.