Documentation ¶
Overview ¶
package util implements helper built-ins.
Index ¶
- func NewBase64Module() *isopod.Module
- func NewHTTPModule() *isopod.Module
- func NewUUIDModule() *isopod.Module
- func ParseCommaSeparatedParams(params string) (map[string]string, error)
- func Predeclared() starlark.StringDict
- func StructFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, ...) (starlark.Value, error)
- func ValueFromJSON(v interface{}) (starlark.Value, error)
- func ValueFromNestedMap(m map[string]interface{}) (starlark.Value, error)
- func WriteJSON(out *bytes.Buffer, v starlark.Value) error
- type Struct
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBase64Module ¶
NewBase64Module returns a base64 module.
func NewHTTPModule ¶
NewHTTPModule returns new Isopod built-in module for HTTP calls. Supports these methods:
- http.get - Performs HTTP GET call
- http.post - Performs HTTP POST call
- http.put - Performs HTTP PUT call
- http.patch - Performs HTTP PATCH call
- http.delete - Performs HTTP DELETE call
Args: url - required URL to send request to. headers - optional headers provided as Starlark dict. Values can be either
Starlark strings (for single value headers) or lists (for multiple ones).
data - optional data sent in request body (take Starlark string).
Returns: Starlark string of response body. If response body is empty, returns starlark.None.
Errors out on non-2XX response codes.
func ParseCommaSeparatedParams ¶
ParseCommaSeparatedParams slipts params in the form of "foo=bar,baz=qux" in to a map {"foo": "bar", "baz": "qux"}
func Predeclared ¶
func Predeclared() starlark.StringDict
Predeclared returns a starlark.StringDict containing predeclared modules from util:
func StructFn ¶
func StructFn(t *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
StructFn implements the built-in function that instantiates and extends the starlark struct to support to_json().
func ValueFromJSON ¶
ValueFromJSON converts JSON value to starlark.Value.
func ValueFromNestedMap ¶
ValueFromNestedMap converts nested JSON map oject to starlark.Value.