A newbie here. I'm trying to workout how I should go about extracting some specific values from a json output produced upon executing a particular boto3 method. Below is the code that works;
import json
import boto3
def lambda_handler(event, context):
client = boto3.client('apigateway')
response = client.get_usage_plans()['items']
return response
Above gives me the below output as expected.
Response:
[
{
"id": "p90xvt",
"name": "Basic",
"apiStages": [
{
"apiId": "g1gckiw2cj",
"stage": "prod"
}
],
"quota": {
"limit": 10,
"offset": 0,
"period": "DAY"
}
},
{
"id": "rt9k2q",
"name": "Prem",
"apiStages": [
{
"apiId": "g1gckiw2cj",
"stage": "prod"
}
],
"quota": {
"limit": 10,
"offset": 0,
"period": "DAY"
}
}
]
Request ID:
"4aa80ca1-c48d-11e8-95cf-f59e9444b72c"
Function Logs:
START RequestId: 4aa80ca1-c48d-11e8-95cf-f59e9444b72c Version: $LATEST
END RequestId: 4aa80ca1-c48d-11e8-95cf-f59e9444b72c
REPORT RequestId: 4aa80ca1-c48d-11e8-95cf-f59e9444b72c Duration: 631.18 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 31 MB
What I'm struggling to understand is that how to extract some specific key:values from the output? Say If I want to print YES if the limit of a quota belongs to a specific id(i.e:"p90xvt") equals to 10? Mind you I need to cover all ids.
Really appreciate your help on this people. Many thanks in advance. -B
d=response[0]; print(d["id"], d["quota"]["limit"])