Hi folks, I'm doing some boto3 work in Python and I have the following lines:
paginator = client.get_paginator('list_objects_v2')
page_iterator = paginator.paginate(Bucket=bucket_name) # PaginationConfig MaxItems & PageSize left off intentionally
filtered_iterator = page_iterator.search("Contents[?contains(Key, `{0}`)][]".format(mgrs_square))
I get the following warning:
jmespath/lexer.py:170: PendingDeprecationWarning: deprecated string literal syntax PendingDeprecationWarning)
Is there a way I can change my JMESPath to not give that warning? - Completely new to this as it's not a functionality I've used before.
Thanks!
Hello,
I want to yield priority value if a substring in TargetGroupArn matches from following JSON
[
{
"Priority": "4",
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:app1/957d07a4bb7b4c3b"
},
{
"Priority": "5",
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:app2/11f33cd58c040b74"
},
{
"Priority": "default",
"TargetGroupArn": "arn:aws:elasticloadbalancing:us-east-1:app3/b0a01b36e3cb45be"
}
]
I'm leaving this here as a puzzle someone might help me solve. I have a netplan (converted from yaml), and I haven't quite figured out how to combine searches in these types of nested dicts.
{
"ethernets": {
"enp3s0f0": {
"match": {
"macaddress": "01:23:45:67:89:ab"
},
"set-name": "eth0"
},
"enp3s0f1": {
"match": {
"macaddress": "cd:ef:01:23:45:67"
},
"set-name": "eth1"
},
"enp4s0f0": {
"match": {
"macaddress": "89:ab:cd:ef:01:23"
},
"set-name": "eth2"
},
"enp4s0f1": {
"match": {
"macaddress": "45:67:89:ab:cd:ef"
},
"set-name": "eth3",
"addresses": [
"172.16.0.3/24"
]
}
},
"bonds": {
"bond0": {
"interfaces": [
"eth0",
"eth1"
],
"parameters": {
"mode": "802.3ad"
}
}
},
"vlans": [
"bond0.1202",
"bond0.203",
"bond0.204",
"bond0.205"
],
"bridges": {
"br-maas": {
"addresses": [
"172.16.1.3/24"
],
"interfaces": [
"bond0"
]
},
"br-mgmt": {
"addresses": [
"172.16.2.3/24"
],
"interfaces": [
"bond0.1202"
]
},
"br-storage": {
"addresses": [
"172.16.3.3/24"
],
"interfaces": [
"bond0.203"
]
},
"br-vxlan": {
"addresses": [
"172.16.4.3/24"
],
"interfaces": [
"bond0.204"
]
},
"br-iscsi": {
"addresses": [
"172.16.5.3/24"
],
"interfaces": [
"bond0.205"
]
},
"br-vlan": {
"interfaces": [
"eth2"
]
}
}
}
*.*.addresses
will yield addresses, I can flatten it with []
but I suppose a [?addresses]
type filter would be a better approach, so we only look for those with addresses. [keys(@)]
gives me [ethernets, bonds, vlans, bridges]
, but *.[keys(@)]
doesn't seem to give me the interface-names. But then *.*[keys(@)]
gives me keys inside the interfaces.
I'd like to get something that returns interface-name + address in some kind of combination. Like [ ["enp4s0f1", "172.16.0.3/24"], ["br-maas", "172.16.1.3/24"], ...]
or [ {"enp4s0f1": ["172.16.0.3/24"]},{"br-maas":["172.16.1.3/24"]}, ...]
hey guys, not sure if this is the proper place, but just a suggestion in the contains examples would also be good to explain this syntax
machines[?contains(guest_fullname, `Windows`) == `false`]
for dicts like:
{
"machines": [
{
"guest_fullname": "Other (32-bit)",
"age": 30
},
{
"guest_fullname": "Microsoft Windows 10 (64-bit)",
"age": 50
},
{
"name": "Ubuntu",
"age": 40
}
]
}
I needed to do it, but it was really hard to come up with the proper syntax, wasn't even sure if it was possible.
Hi, there!
I'm trying to convert the result of AWS CloudWatch Logs Insights, but I can't.
Like this:
{
"results": [
[
{
"field": "@timestamp",
"value": "2020-02-03 15:03:26.315"
},
{
"field": "@message",
"value": "some messages 1"
},
{
"field": "@ptr",
"value": "xxx"
}
],
[
{
"field": "@timestamp",
"value": "2020-02-03 15:03:27.495"
},
{
"field": "@message",
"value": "some messages 2"
},
{
"field": "@ptr",
"value": "xxx"
}
]
],
"statistics": {
"recordsMatched": 887.0,
"recordsScanned": 887.0,
"bytesScanned": 101532.0
},
"status": "Complete"
}
To this:
[
[ "2020-02-03 15:03:26.315", "some messages 1" ],
[ "2020-02-03 15:03:27.495", "some messages 2" ]
]
Can anyone help me?
I feel really dumb, but can't seem to figure out how to transform this:
{
"Foo": "somekey",
"Bar": "somevalue"
}
into:
{ "somekey": "somevalue" }
the closest I can get is like:
{ Foo : Bar }
but that yields:
{
"Foo": "somevalue"
}
so it's the key in the hash part I cant figure out how to get
(I want to make the new hash's key, the value of an existing key in the input hash)
so I have read somewhere this may not be possible w/ stock JMESPath
Jmespath does not allow to use dynamic names in multi select hashes.
but there is some extension:
https://github.com/grofers/go-codon/wiki/Jmespath-extensions#5-support-for--expressions-as-key-when-performing-multi-select-hash
(wanted to be able to do this in aws cli --query )
{animal: {ant: 1, bee: 2, cat: 3}, vegetable: {apple: 4, banana: 5}, mineral: {axe: 6, bell; 7}}
into [{key1: "animal", key2: "ant", value: }, {key1: "animal", key2: "bee", value: 2}, ... {key1: "mineral", key2: "bell", value: 7}]
composer require aws/aws-sdk-php
Using version ^3.133 for aws/aws-sdk-php
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for mtdowling/jmespath.php (installed at 2.4.0) -> satisfiable by mtdowling/jmespath.php[2.4.0].
- aws/aws-sdk-php 3.133.0 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.1 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.10 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.11 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.2 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.3 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.4 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.5 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.6 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.7 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.8 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- aws/aws-sdk-php 3.133.9 requires mtdowling/jmespath.php ^2.5 -> satisfiable by mtdowling/jmespath.php[2.5.0].
- Conclusion: don't install mtdowling/jmespath.php 2.5.0
- Installation request for aws/aws-sdk-php ^3.133 -> satisfiable by aws/aws-sdk-php[3.133.0, 3.133.1, 3.133.10, 3.133.11, 3.133.2, 3.133.3, 3.133.4, 3.133.5, 3.133.6, 3.133.7, 3.133.8, 3.133.9].
Installation failed, deleting ./composer.json.
composer why --tree mtdowling/jmespath
to see why it is locked to 2.4.0
locations[0].state == 'NY' && 'a' || 'b'
search
to work in the opposite way? I mean, instead to search
a key:value, to exclude the key:value passed and return all the rest
{"peers": {"ns1.sys.cloudsys.tmcs": {"delay": [ 0.476, 0.371 ]}, "insert": { "10.75.33.5": { "delay": [ 0.384 ]}}, "delete": {"ns2.sys.cloudsys.tmcs": { "delay": [ 0.465 ]}}}
insert
and delete
, is it possible to do with wildcards? kind of peer.[insert|delete]
?