Hash type

Hash type. Maps unique keys to their values. Key-Value pairs are stored and iterated in insertion order. Currently Hash type has several limitations: Hash keys are hashed using internal hash() function which can not be overwritten. The internal hash() multimethod exposed to NGS code but adding methods to it or setting "hash" to some other function will not affect operation of Hashes. Hash values are compared using internal is_equal() function which can not be overwritten. Both hash() and is_equal() currently handle only Int, Str and arbitrary objects. Comparison of arbitrary objects is done by comparing their addresses in memory.

Example

x = {"a": 1, "b": 2}
echo(x)
# Output:
#   {a=1, b=2}

echo(x.keys())
# Output:
#   ['a','b']

echo(x.values())
# Output:
#   [1,2]

x = {"a": 1, "b": 2}
x.a = 10
echo(x)
# Output:
#   {a=10, b=2}

Direct parent types

Eachable2
Eachable which each() calls the callback with two arguments
Direct subtypes: 2

Constructors

Hash(obj:NormalTypeInstance)
Get all fields and their values as key-value pairs in the resulting Hash.

Returns

Hash

Example

(1..10).Hash()  # Hash {start=1, end=10, step=1}
Hash() Source: stdlib.ngs:181
Make empty hash

Returns

{}
Hash(hl:HashLike) Source: stdlib.ngs:846
Get the underlying Hash with all the keys/values of the HashLike. Note: the returned value is not a copy.

Returns

Hash
Hash(arr:Arr) Source: stdlib.ngs:2628
Create a Hash from Arr of Arr[2]

Parameters

arrArray of Arrays. Each one of the sub-arrays must have exactly two elements.

Returns

Hash

Example

Hash([['a', 1], ['c', 3]])  # {'a': 1, 'c': 3}
Hash(arr:Arr, field:Str) Source: stdlib.ngs:2639
Create Hash with keys being the given field of array elements and the values being corresponding arr elements.

Returns

Hash

Example

Hash([{'x': 1}, {'x': 2}], 'x')  # {1: {'x': 1}, 2: {'x': 2}}
Hash(arr:Arr, cb:Fun) Source: stdlib.ngs:2650
Create a Hash from keys in arr using cb for values calculation

Parameters

arrKeys of the hash to build
cbFunction to be called with one key at a time. Should calculate a value for the given key.

Returns

Hash

Example

Hash([1,2], F(x) x*2)  # {1: 2, 2: 4}
Hash(keys:Arr, values:Arr) Source: stdlib.ngs:2662
Create a Hash from keys in "keys" and corresponding values in "values"

Parameters

keysKeys for the new Hash
valuesValues for the new Hash

Returns

Hash

Example

Hash(["a", "b", "c"], [1,2,3])  # {"a": 1, "b": 2, "c": 3}
Hash(e:Eachable1, key_field:Str, val_field:Str) Source: stdlib.ngs:2674
Create Hash from Arr of something that has key and value fields

Parameters

eEachable1 with all the keys and values
key_fieldName of the field holding the keys of newly created Hash
val_fieldName of the field holding the values of newly created Hash

Returns

Hash

Example

Hash([{"Name": "n1", "Value": "v1"},{"Name": "n2", "Value": "v2"}], "Name", "Value")  # {"n1": "v1", "n2": "v2"}

Methods

+(a:Hash, b:Hash) Source: stdlib.ngs:2704
Add Hashes. Builds new hash with key-value pairs from both a and b. If same key is present in both a and b, the value from b is used.

Returns

Hash

Example

{'a': 1, 'b': 2, 'c': 3} + {'b': 20, 'd': 40}  # {'a': 1, 'b': 20, 'c': 3, 'd': 40}
.(h:Hash, field:Str) Source: stdlib.ngs:1540
Get hash key.

Example

h = {"a": 1}
h.a  # 1, Same as h["a"]
.=(h:Hash, field:Str, v:Any) Source: stdlib.ngs:1546
Set hash key.

Returns

v

Example

h = {"a": 1}
h.a = 2  # 2, Same as h["a"] = 2
::(h:Hash, k:Any) Source: stdlib.ngs:108
Get Hash key. Useful when calling method stored in a Hash key. Useful for working with namespaces, which are implemented as Hash instances.

Example

elb = AWS::Elb(...).converge(...)
::=(h:Hash, k:Any, v:Any) Source: stdlib.ngs:113
Set Hash key. It's implemented to complete the :: operator. There is no particular use case.
==(a:Hash, b:Hash) Source: stdlib.ngs:2384
Compare two Hashes. Hashes must have same keys with same values in same order to return true. Both hashes must not be modified during comparison. This was not tested.

Returns

Bool
[](h:Hash, k:Any)
Get hash value by key. Throws KeyNotFound.

Returns

Any

Example

h = {"a": 1}
h["a"]  # 1
h["b"]  # KeyNotFound exception thrown
[]=(h:Hash, k:Any, v:Any)
Set hash value.

Parameters

hTarget hash
kKey
vValue

Returns

v

Example

h = {"a": 1}
h["a"] = 2
h["a"]  # 2
[]=(h:Hash, k:Any, v:Any)
Setting same key twice is a bug. If it happens, augment_types() works on one objects but other objects are used later.
\(name:Str, attributes:Hash, children:Arr)experimental Source: stdlib.ngs:6576
Undocumented

Automatically called by NGS for syntax

\name attr1=val1 attr2=val2 ... [ ... ]
Argv(h:Hash) Source: stdlib.ngs:4938
Convert a Hash, describing command line arguments, to array of strings, appropriate for using as argument to external process. Key-value pairs with values of type NoData (null, EmptyBox) are discarded. Key-value pairs with empty array values are discarded. Values of type Box are unboxed. For keys which are arrays of two elements, Bool value selects first (for true) or second (for false) element. For keys which are arrays of a single element, Bool value selects whether the key is present or absent in the output. For keys which are arrays of a single element, Eachable1 value causes the switch to br repeated for each element, building switch name and switch value pairs.

Example

# Typical usage:
argv = Argv({'name1': value1, 'name2': value2, ...})
$(my_command $*argv)
# Handling of key-value pairs
Argv({"--a": 1, "-b": null})                         # ['--a', 1]
Argv({["-y1", "-n1"]: true, ["-y2", "-n2"]: false})  # ['-y1', '-n2']
Argv({["-y3"]: true, ["-y4"]: false})                # ["-y3"]
Argv({["--repeat"]: ["a", "b"]})                     # ["--repeat", "a", "--repeat", "b"]
Argv({"-a1": [], "-a2": [1,2,3]})                    # ["-a2", 1, 2, 3]
Arr(h:Hash) Source: stdlib.ngs:1999
Make Arr from Hash. Each key/value pair becomes two-items array.

Returns

Arr of form [[k1, v1], [k2, v2], ...]

Example

Arr({'x': 7, 'y': 8})  # [['x', 7], ['y', 8]]
assert_hash_keys_values(actual:Any, expected:Hash, title:Str='Must be a hash with keys and values') Source: autoload/test.ngs:148
Assert actual is a Hash and it has the expected keys with expected values. Throws TestFail.

Returns

actual

Example

assert_hash_keys_values({'kk': 7}, {'ll': 7})  # Throws TestFail
assert_hash_keys_values({'kk': 7, 'll': 8}, {'kk': 7})  # OK
Box(h:Hash, k:Any) Source: stdlib.ngs:2962
Convert hash value indexed by the given key to a Box

Parameters

kkey to look in hash

Returns

Box. FullBox if the hash has the element referenced by k, EmptyBox otherwise.

Example

my_hash = {"a": 10, "b": 300}
my_hash.Box("a").map(X*2).each(echo)
# output: 20
my_hash.Box("nope").map(X*2).each(echo)
# no output
code(h:Hash) Source: stdlib.ngs:2749
Convert a Hash to NGS code that would produce the given Hash when executed. Not fully functional yet.

Returns

Str
collector(h:Hash, body:Fun) Source: stdlib.ngs:1461
Defines collector { ... collect(...) ... } behaviour for hashes

Parameters

hInitial hash
bodyThe body after collector keyword and initial value, wrapped in a function "collector/{'my': 'hash'} THIS_CODE"

Returns

Constructed array

Example

arr = [{"Name": "n1", "Value": "v1"},{"Name": "n2", "Value": "v2"}]
my_hash = collector/{}
	arr.each(F(elt) collect(elt.Name, elt.Value))
echo(my_hash)  # Outputs: {n1=v1, n2=v2}
copy(h:Hash) Source: stdlib.ngs:2741
Make shallow copy of a Hash

Returns

Hash
created(rd:ResDef, resources:Arr, props:Hash) Source: autoload/Res.ngs:201
Called by create() on new resources. Appends the new resources to the list and runs update(). Don't call directly.

Parameters

resourcesArr of Res
decode(s:Str, hints:Hash={}) Source: stdlib.ngs:5286
Attempt to decode JSON. Uses decode_json().
decode(s:Str, hints:Hash) Source: stdlib.ngs:5295
EXPERIMENTAL. KVS (key-value separator) hint for decode()

Example

decode('a b\nc d', {'KVS': ' '}) == {'a': 'b', 'c': 'd'}
decode(s:Str, hints:Hash) Source: stdlib.ngs:5304
EXPERIMENTAL. FS (field separator) hint for decode()

Example

decode('a b\nc d', {'FS': ' '})  # [['a', 'b'], ['c', 'd']]
decode(s:Str, hints:Hash) Source: stdlib.ngs:5314
EXPERIMENTAL! Do not use! Handle fields_names hint - run decode() and make Arr[Hash] from Arr[Arr] using provided fields_names

Example

backup_list = fetch('backup.list', {'FS': ' ', 'fields_names': %[env role]})
decode(s:Str, hints:Hash) Source: stdlib.ngs:5402
Parse the output of "aws" command. Extracts the array (see "s" below"). For "describe-instances", flattens the instance list.

Parameters

sStr containing JSON with a Hash at top level with exactly one Arr as value
hintshints.process.command.argv[0] must be 'aws'

Returns

data structure, tyically an Arr at top level. If s is empty string - null.
decode(s:Str, hints:Hash) Source: stdlib.ngs:5464
Parse the output of "find" command which does not use "-printf". Handles "-print0".

Parameters

hintshints.process.command.argv[0] must be 'find'

Returns

Arr of Str
decode(s:Str, hints:Hash) Source: stdlib.ngs:5475
Parse the output of "locate" command.

Parameters

hintshints.process.command.argv[0] must be 'locate'

Returns

Arr of Str
del(h:Hash, k:Any)
Delete hash key. Throws KeyNotFound if k is not in h. WARNING: this method will probably be renamed to "delete" in future versions.

Parameters

hTarget hash
kKey

Returns

h

Example

h={"a": 1}; h.del("a"); h  # {}
h={}; h.del("a"); # KeyNotFound exception
h={"a": 1, "b": 2}; h.del("a"); h  # {"b": 2}
dflt(h:Hash, k:Any, v:Any) Source: stdlib.ngs:2756
Set a key in a Hash if it's not already set

Returns

Hash value, the already-existed or new.

Example

my_hash.dflt(k, []).push(elt)
Diff(a:Hash, b:Hash) Source: stdlib.ngs:3249
Compare hashes

Example

diff = Diff(current_tags, target_tags)
if (tags = AWS::cli_tags(diff.add + diff.change)) {
	r.run('update_tags/add', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags))
}
if (tags = diff.remove / "Key=$X") {
	r.run('update_tags/remove', %(aws ec2 delete-tags --resources ${r.id()} --tags $*tags))
}
each(h:Hash, cb:Fun) Source: stdlib.ngs:2428
Iterate a Hash.

Parameters

hHash to iterate
cbFunction to call with successive keys and values

Returns

h

Example

{"a": 1, "b": 2}.each(F(k, v) echo("$k=$v"))  # Outputs: "a=1" and on the next line "b=2"
each_idx_key_val(h:Hash, cb:Fun) Source: stdlib.ngs:2470
Iterate a Hash.

Parameters

hHash to iterate
cbFunction to call with successive indexes, keys and values

Returns

h

Example

{"a": 1, "b": 2}.each_idx_key_val(F(idx, k, v) echo("[$idx] $k=$v"))
# Outputs: "[0] a=1" and on the next line "[1] b=2"
eachk(h:Hash, cb:Fun) Source: stdlib.ngs:2441
Iterate a Hash.

Parameters

hHash to iterate
cbFunction to call with successive keys

Returns

h
eachv(h:Hash, cb:Fun) Source: stdlib.ngs:2454
Iterate a Hash.

Parameters

hHash to iterate
cbFunction to call with successive values

Returns

h
encode(data:Any, hints:Hash={}) Source: stdlib.ngs:5323
Encode data as JSON if hints say that "filename" ends with ".json"

Returns

Str
fetch(filename:Str, decode_hints:Hash={}) Source: stdlib.ngs:4608
read() and decode() the given file

Example

fetch("1.json")  # Data structure, the parsed JSON
fetch(url:Str, decode_hints:Hash={}) Source: stdlib.ngs:4616
Fetch HTTP(S) file and decode() it

Example

fetch('https://api.myip.com')  # Data structure, the parsed JSON
fetch(decode_hints:Hash={}) Source: stdlib.ngs:4622
Read standard input and decode() it, passing "source" equals "stdin" hint.

Example

fetch()  # Data structure, parsed stdin
fetch(p:Path, decode_hints:Hash={}) Source: stdlib.ngs:4626
read() and decode() the given file

Example

fetch(File("1.json"))  # Data structure, the parsed JSON
filter(h:Hash, predicate:Any) Source: stdlib.ngs:2558
Filter hash. Build new hash with kev-value pairs selected by predicate.

Parameters

hSource hash
predicateTest function to be called with one key and one value at a time

Example

{'a': 1, 'b': 2}.filter(F(k, v) k == 'a')  # {'a': 1}
get(h:Hash, k:Any, dflt:Any)
Get hash value by key or dflt if it does not exist

Returns

Any

Example

h = {"a": 1}
h.get("a", 10)  # 1
h.get("b", 10)  # 10
get(h:Hash, k:Any) Source: stdlib.ngs:1552
Get hash value by key or null if it does not exist

Example

h = {"a": 1}
h.get("a")  # 1
h.get("b")  # null
in(x:Any, h:Hash)
Check key presence in a Hash

Returns

Bool

Example

"a" in {"a": 1}  # true
"b" in {"a": 1}  # false
init(h:Hash) Source: stdlib.ngs:31
Trivial initialization helper for init(o, ...) Sets object fields from the supplied parameters

Example

# sets t.a and t.b
F init(t:MyType, a, b) init(args())
init(hl:HashLike, h:Hash=null) Source: stdlib.ngs:837
Create a HashLike.

Parameters

hIf provided, used as initial value.

Example

HashLike(%{a aha b bee}) # <HashLike a=aha b=bee>
init(i:HashIter, h:Hash) Source: autoload/Iter.ngs:336
HashIter constructor.

Example

i = HashIter({"a": 1, "b": 2})
init(r:Res, def:ResDef, props:Hash) Source: autoload/Res.ngs:124
Stores def and props in r
init(rd:AWS::ResDef, _ngs_tags:Hash) Source: autoload/AWS.ngs:183
Initialize ResDef from _ngs_tags. Sets .regions to null and .Tags to _ngs_tags.
init(rd:AWS2::ResDef, _ngs_tags:Hash) Source: autoload/AWS2.ngs:187
Initialize ResDef from _ngs_tags. Sets ._Region to null and .Tags to _ngs_tags.
init(pmy:ParamsMatchY, args:Arr, kwargs:Hash) Source: autoload/ArgvMatcher.ngs:15
Undocumented
init(mp:MethodParam, h:Hash) Source: autoload/MethodParam.ngs:23
Initialize MethodParam from params() array element
init(nd:NamespaceDescription, namespace:Hash)
Undocumented
init(nd:NamespaceDescription, containing_nd:NamespaceDescription, name:Str, namespace:Hash)
Undocumented
inspect(h:Hash) Source: stdlib.ngs:6023
Inspect Hash

Returns

Lines
Iter(h:Hash) Source: autoload/Iter.ngs:331
Undocumented
keys(h:Hash)
Get Hash keys as an array

Returns

Arr

Example

{"a": 1, "b": 2}.keys()  # ['a','b']
len(h:Hash)
Get number of key-value pairs in a Hash

Returns

Int

Example

{"a": 1, "b": 2}.len()  # 2
limit(h:Hash, l:Int) Source: stdlib.ngs:2723
Truncate a Hash if necessary so it would have maximum l key-value pairs.

Parameters

hSource hash
lMaximum elements

Returns

Hash

Example

{"a": 1, "b": 2}.limit(1)  # {"a": 1}
ll_hash_head(h:Hash)
Low level. Do not use directly.

Returns

LLHashEntry or null
ll_hash_tail(h:Hash)
Low level. Do not use directly.

Returns

LLHashEntry or null
map(h:Hash, mapper:Fun) Source: stdlib.ngs:2486
Map a Hash

Parameters

hHash with source keys and values
mapperFunction to be called with keys and values from h

Returns

Arr

Example

{'a': 1, 'b': 2}.map(F(k, v) "${k}-$v")  # ['a-1', 'b-2']
map_idx_key_val(h:Hash, mapper:Fun) Source: stdlib.ngs:2497
Map a Hash

Parameters

hHash with source keys and values
mapperFunction to be called with sequential zero-based index, keys and values from h

Returns

Arr

Example

{'a': 1, 'b': 2}.map_idx_key_val(F(i, k, v) "${i}-${k}-$v")  # ['0-a-1', '1-b-2']
mapk(h:Hash, mapper:Fun) Source: stdlib.ngs:2516
Map Hash keys. Build new Hash with same values as in h but keys mapped by mapper.

Parameters

hSource hash
mapperFunction to be called with keys

Returns

Hash

Example

mapk({"a": 1}, F(k) k+"z")  # {"az": 1}
mapkv(h:Hash, mapper:Fun) Source: stdlib.ngs:2547
Map Hash keys and values. Build new Hash with keys and values mapped by mapper.

Parameters

hSource hash
mapperFunction to be called with keys and values

Example

mapkv({"a": 1}, {[A+"zz", B+10]})  # {"azz": 11}
mapv(h:Hash, mapper:Fun) Source: stdlib.ngs:2535
Map Hash values. Build new Hash with same keys as in h but values mapped by mapper.

Parameters

hSource hash
mapperFunction to be called with values

Returns

Hash

Example

LEN = 3
lines_ = read("/usr/share/dict/words").lines()
long_lines = lines_.filter({A.len()>LEN})
prefix_to_lines = long_lines.group(F(line) line[0..LEN])  # {"pfx1": ["pfx1a", "pfx1b", ...], "pfx2": ["pfx2a", "pfx2b", ...], ...}
prefix_to_count = prefix_to_lines.mapv(len)  # {"pfx1": 30, "pfx2": 35, ...}
top = prefix_to_count.Arr().sort(F(a, b) b[1] <= a[1]).Hash()
top .= limit(10)
echo(top)  # Outputs: {con=1219, dis=1001, pro=808, pre=607, com=600, int=543, tra=498, ove=431, per=422, imp=421}
n(h:Hash)deprecated Source: stdlib.ngs:1561
Convert hash values to integers where possible

Returns

New Hash

Example

%{k 7 kk "a"}["k"] is Str      # true
%{k 7 kk "a"}.n()              # {'k': 7, 'kk': 'a'}
%{k 7 kk "a"}.n()["k"] is Int  # true
opt_prop(rd:ResDef, name:Str, props:Hash) Source: autoload/Res.ngs:211
Get optional resource property, looking up in properties first and then in anchor.

Returns

Box
opt_prop(rd:ResDef, name:Str, props:Hash, cb:Fun) Source: autoload/Res.ngs:214
Run cb with optional resource property if it exists, uses opt_prop(ResDef, Str, Hash)
Pred(h:Hash) Source: stdlib.ngs:255
Convert Hash to a predicate. The predicate asserts that object fields named after h hash keys return true for predicates made of corresponding hash values. Inspired by underscorejs' "matcher"
push(t:Table, row_hash:Hash) Source: autoload/Table.ngs:76
Append given row to the table

Returns

t
req_prop(rd:ResDef, name:Str, props:Hash) Source: autoload/Res.ngs:218
Get resource property, looking up in properties first and then in anchor
shift(h:Hash, k:Any) Source: stdlib.ngs:2778
Get the given key from a Hash and remove it from the Hash. Underlying h[k] may throw KeyNotFound.

Example

h = {"a": 1}
s = h.shift("a")  # h == {} and s == 1
shift(h:Hash, k:Any, dflt:Any) Source: stdlib.ngs:2788
Get a key from a Hash and remove it from the Hash. If they key is not in the Hash, return dflt

Example

h = {}
h.shift("a", 7)  # 7
sort(h:Hash, lte:Fun=method) Source: stdlib.ngs:2767
Sort a Hash.

Parameters

lteLess-then-or-equal function to use for comparison of the keys in h

Returns

Hash

Example

{"b": 2, "c": 3, "a": 1}.sort()  # {"a": 1, "b": 2, "c": 3}
sortk(h:Hash, lte:Fun=method) Source: stdlib.ngs:2616
Sort Hash by keys

Returns

Hash

Example

{'b': 2, 'c': 11, 'a': 1}.sortk()  # {'a': 1, 'b': 2, 'c': 11}
stdlib_aws_straighten_tags(h:Hash) Source: stdlib.ngs:5383
Do not use directly. Subject to change. Convert "Tags" array in the given AWS resource (typically returned by AWS CLI) into Hash.

Example

t = {"Tags": [{"Key": "k", "Value": "v"},{"Key": "k2", "Value": "v2"}]}  # Not very convenient, is it?
t.stdlib_aws_straighten_tags()
t  # {Tags={k=v, k2=v2}}
store(filename:Str, data:Any, encode_hints:Hash={}) Source: stdlib.ngs:4631
encode() and write() the data to the file

Returns

null (but subject to change)
Str(h:Hash) Source: stdlib.ngs:3383
Convert Hash to string

Returns

Str
Strs(h:Hash) Source: stdlib.ngs:2714
Build array of Str where each resulting string is of the form "KEY=VALUE"

Parameters

hSource hash

Returns

Arr of Str

Example

{'a': 1, 'b': 2}.Strs()  # ['a=1', 'b=2']
subset(smaller:Hash, larger:Hash) Source: stdlib.ngs:2399
Undocumented
update(dst:Hash, src:Hash)
Update a Hash with key-value pairs from another Hash. For non destructive version use "dst + src".

Returns

dst

Example

{"a": 1, "b": 2}.update({"b": 10, "c": 20})  # {a=1, b=10, c=20}
update(r:AWS::VpcRes, props:Hash)internal Source: autoload/AWS.ngs:284
Declarative primitive for updating AWS VPC resources
update(r:AWS::IgwRes, props:Hash)internal Source: autoload/AWS.ngs:358
Declarative primitive for creating AWS InternetGateway resources
update(r:AWS::RouteTableRes, props:Hash)internal Source: autoload/AWS.ngs:433
Declarative primitive for updating AWS RouteTable resources
update(sg:AWS::SecGroupRes, props:Hash)internal Source: autoload/AWS.ngs:588
Declarative primitive for updating AWS Security Group resources
update(r:AWS::SubnetRes, props:Hash)internal Source: autoload/AWS.ngs:673
Declarative primitive for updating AWS Subnet resources
update(r:AWS::InstanceRes, props:Hash)internal Source: autoload/AWS.ngs:855
Declarative primitive for updating AWS Instance resources
update(elb:AWS::ElbRes, props:Hash)internal Source: autoload/AWS.ngs:1127
Declarative primitive for updating AWS Elastic Load Balancer resources
update(rrset:AWS::RecordSetRes, props:Hash)internal Source: autoload/AWS.ngs:1337
Declarative primitive for updating AWS Route53 RecordSet resources
update(r:AWS2::Res, orig_props:Hash) Source: autoload/AWS2.ngs:400
Undocumented
update(sg:AWS2::SecGroupRes, props:Hash)internal Source: autoload/AWS2.ngs:662
Declarative primitive for updating AWS Security Group resources
update(r:AWS2::SubnetRes, props:Hash)internal Source: autoload/AWS2.ngs:748
Declarative primitive for updating AWS Subnet resources
update(r:AWS2::InstanceRes, props:Hash)internal Source: autoload/AWS2.ngs:945
Declarative primitive for updating AWS Instance resources
update(elb:AWS2::ElbRes, props:Hash)internal Source: autoload/AWS2.ngs:1220
Declarative primitive for updating AWS Elastic Load Balancer resources
update(z:AWS2::ZoneRes, props:Hash) Source: autoload/AWS2.ngs:1390
Undocumented
update(rrset:AWS2::RecordSetRes, props:Hash)internal Source: autoload/AWS2.ngs:1503
Declarative primitive for updating AWS Route53 RecordSet resources
values(h:Hash)
Get Hash values as an array

Returns

Arr

Example

{"a": 1, "b": 2}.values()  # [1,2]
AWS::cli_tags(h:Hash) Source: autoload/AWS.ngs:52
Convert hash to Key=...,Value=... strings suitable for passing to AWS CLI.

Returns

Arr of Str

Example

diff = Diff(current_tags, target_tags)
if (tags = cli_tags(diff.add + diff.change)) {
	r.run('add tags', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags))
}
AWS::cli_filters(h:Hash) Source: autoload/AWS.ngs:59
Convert Hash with AWS filters to command line arguments. Key-value pairs in which value is null or an EmptyBox object are discarded. TODO: make it JSON when keys or values contain special characters such as = or ,

Returns

Arr of Str
AWS::cli_tags_filters(h:Hash) Source: autoload/AWS.ngs:70
Convert hash to Name=tag:...,Values=... strings suitable for passing to AWS CLI as filters.

Example

filters = AWS::cli_filters({'vpc-id': ...})
vpcs = ``aws ec2 describe-vpcs --filters $*filters``
AWS::update_tags(r:AWS::Res, props:Hash) Source: autoload/AWS.ngs:127
Don't call directly, use converge(). API subject to change. Update tags using AWS CLI "aws ec2 create-tags" and "aws ec2 delete-tags". The required AWS CLI is computed from current tags, which are expected to be in r.props.Tags, and props.Tags

Returns

Do not count on this value.
AWS2::cli_tags(h:Hash) Source: autoload/AWS2.ngs:52
Convert hash to Key=...,Value=... strings suitable for passing to AWS CLI.

Returns

Arr of Str

Example

diff = Diff(current_tags, target_tags)
if (tags = cli_tags(diff.add + diff.change)) {
	r.run('add tags', %(aws ec2 create-tags --resources ${r.id()} --tags $*tags))
}
AWS2::cli_filters(h:Hash) Source: autoload/AWS2.ngs:59
Convert Hash with AWS filters to command line arguments. Key-value pairs in which value is null or an EmptyBox object are discarded. TODO: make it JSON when keys or values contain special characters such as = or ,

Returns

Arr of Str
AWS2::cli_tags_filters(h:Hash) Source: autoload/AWS2.ngs:70
Convert hash to Name=tag:...,Values=... strings suitable for passing to AWS CLI as filters.

Example

filters = AWS::cli_filters({'vpc-id': ...})
vpcs = ``aws ec2 describe-vpcs --filters $*filters``
Doc::Transformer(x:Hash) Source: autoload/Doc.ngs:90
Undocumented