I have a SES Configset created and trying to add SNS Event-Destination using CLI, But I get always this error,
[root#me]# aws --version
aws-cli/1.18.51 Python/2.7.5 Linux/3.10.0-1062.18.1.el7.x86_64 botocore/1.16.1
[root#me]# aws ses update-configuration-set-event-destination --generate-cli-skeleton
{
"ConfigurationSetName": "",
"EventDestination": {
"Name": "",
"Enabled": true,
"MatchingEventTypes": [
"open"
],
"KinesisFirehoseDestination": {
"IAMRoleARN": "",
"DeliveryStreamARN": ""
},
"CloudWatchDestination": {
"DimensionConfigurations": [
{
"DimensionName": "",
"DimensionValueSource": "linkTag",
"DefaultDimensionValue": ""
}
]
},
"SNSDestination": {
"TopicARN": ""
}
}
}
[root#me]# aws ses list-configuration-sets
{
"ConfigurationSets": [
{
"Name": "my-ses-configset"
}
]
}
[root#me]# aws ses update-configuration-set-event-destination --cli-input-json { "ConfigurationSetName": "my-ses-configset", "EventDestination": { "Name": "my-sns-destination", "Enabled": true, "MatchingEventTypes": [ "reject" ], "SNSDestination": { "TopicARN": "<my SNS Topic ARN>" } } }
Unknown options: my-ses-configset,, EventDestination:, {, Name:, my-sns-destination,, Enabled:, true,, MatchingEventTypes:, [, bounce, ],, SNSDestination:, {, TopicARN:, <my SNS Topic ARN>, }, }, }, ConfigurationSetName:
What is wrong here? I am providing right SNS-topic-arn.
You need to surround your input json with single quotes, otherwise the space separated strings in json will be interpreted as command-line arguments. That's why you got the Unknown options error message.
Related
Is there a command to use jq to add onto this type of map?
append an array of maps using keys (ie, vm1, vm2, vm3)
Note: I have an existing vm_map {} in a json file and i want to add to the vm_map
this is my new_json.json file
{
"gcs_config": [
{
"bucket_name": "somebucket",
"bucket_readers": [],
"bucket_writers": []
}
],
"label_application": "someapp",
"label_environment": "dev",
"lits_vm_zone": "somezone",
"project_id": "someproject",
"region": "someregion",
"storage_bucket_required": true,
"vm_map" : {}
}
expected: using jq to add onto vm_maps map. I will have an empty vm_map and each time it runs, i will add a x amount of new entries.
{
"gcs_config": [
{
"bucket_name": "somebucket",
"bucket_readers": [],
"bucket_writers": []
}
],
"label_application": "someapp",
"label_environment": "dev",
"lits_vm_zone": "zone-a",
"project_id": "someproject",
"region": "someregion",
"storage_bucket_required": true,
"vm_map": {
"vm1": {
"host": "vm1",
"network": "10.1.1.1",
"name": "vm1"
},
"vm2": {
"host": "123",
"network": "10.1.12",
"name": "vm2"
}
}
}
The file you describe is not valid JSON. I'm assuming you mean
{
"vm_map": {
"vm1": {
"host": "vm1",
"network": "xxxxx",
"name": "xxxxxxx"
},
"vm2": {
"host": "vm2",
"network": "xxxxx",
"name": "xxxxxxx"
}
}
}
You can use this:
jq \
--arg VMHOST "$VMHOST" \
--arg NETWORK_IP "$NETWORK_IP" \
--arg VM_NAME "$VM_NAME" \
'
.vm_map[ $VMHOST ] = {
host: $VMHOST,
network: $NETWORK_IP,
name: $VM_NAME
}
'
I am trying to run a test suit in post man by json file upload, and executing test cases by .xl file upload.
my test.json file look like below,
{
"info": {
"_postman_id": "af0ea50c-4264-41a6-ac2c-bcacbf966394",
"name": "CCAPI TEST",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "API TEST",
"event": [
{
"listen": "test",
"script": {
"id": "c195d434-6bb6-4c00-ae21-3d71552b86f0",
"exec": [
"let expected_response = pm.variables.get(\"expected_response\");\r",
"\r",
"console.log(\"expected_response:\"+expected_response + \" ->responseBody:\"+responseBody);\r",
"pm.test(\"Body matches string\", function () {\r",
" pm.expect(responseBody).to.include(expected_response);\r",
"}); "
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
"Accept":"application/json",
"Content-Type":"application/json"
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{ip_port}}/CCAPI/subscription",
"host": [
"{{ip_port}}"
],
"path": [
"CCAPI",
"subscription"
],
}
},
"response": []
}
]
}
In postman I am passing below data in body,
{
"name":"abc",
"number":"919876567876",
"value":"ENABLE"
}
POSTMAN RESPONSE:
{
"description":"successfully added",
"status":"success"
}
I want to pass the same to the json file, I am not getting where should I add this,
for result once the test is created after uploading the file, I click on run , there I will upload the .xl file, from there It has to check for the output of the api is matching or not
.xl file contents :
name number value expected_response
abc 988988999 ENABLE {"description":"successfully
added","status":"success"}
I am not getting where to add the body of the json REQ in the .json file
If anyone tried running test suite in postman tool who knows this reply
I'm trying to get my mocked JSON data via GraphQL in Gatsby. The response shows the correct data, but also two null objects as well. Why is it happening?
I'm using the gatsby-transformer.json plugin to query my data and gatsby-source-filesystem to point the transformer to my json files.
categories.json
the mock file I'm trying to get to work :)
{
"categories": [
{
"title": "DEZERTY",
"path": "/dezerty",
"categoryItems": [
{
"categoryName": "CUKRIKY",
"image": "../../../../static/img/dessertcategories/cukriky.jpg"
},
{
"categoryName": "NAHODNE",
"image": "../../../../static/img/dessertcategories/nahodne.jpg"
},
]
},
{
"title": "CANDY BAR",
"path": "/candy-bar",
"categoryItems": [
{
"categoryName": "CHEESECAKY",
"image": "../../../../static/img/dessertcategories/cheesecaky.jpg"
},
{
"categoryName": "BEZLEPKOVÉ TORTY",
"image": "../../../../static/img/dessertcategories/bezlepkove-torty.jpg"
},
]
}
]
}
GraphQL query in GraphiQL
query Collections {
allMockJson {
edges {
node {
categories {
categoryItems {
categoryName
image
}
title
path
}
}
}
}
}
And the response GraphiQL gives me
{
"data": {
"allMockJson": {
"edges": [
{
"node": {
"categories": null
}
},
{
"node": {
"categories": null
}
},
{
"node": {
"categories": [
{
"categoryItems": [
{
"categoryName": "CHEESECAKY",
"image": "../../../../static/img/dessertcategories/cheesecaky.jpg"
},
{
"categoryName": "BEZLEPKOVÉ TORTY",
"image": "../../../../static/img/dessertcategories/bezlepkove-torty.jpg"
}
],
"title": "DEZERTY",
"path": "/dezerty"
},
{
"categoryItems": [
{
"categoryName": "CUKRIKY",
"image": "../../../../static/img/dessertcategories/CUKRIKY.jpg"
},
{
"categoryName": "NAHODNE",
"image": "../../../../static/img/dessertcategories/NAHODNE.jpg"
}
],
"title": "CANDY BAR",
"path": "/candy-bar"
}
]
}
}
]
}
}
}
I expected only to get the DEZERTY and CANDY BAR sections. Why are there null categories and how do I fix it?
Thanks in advance
Your JSON contains syntax errors in the objects DEZERTY and CANDY BAR. It silently fails without telling you. Try this json linter.
Error: Parse error on line 12: },
Error: Parse error on line 25: },
Try again. Your query should work now.
You should look into an IDE that highlights these types of errors and saves you time and frustration.
I need to update several documents in my Elasticsearch index and I tried the following using the the _update_by_query plugin.
What I need to do is to add a new field to several existing documents matching a certain condition. The new field is a nested JSON. So after adding it document source should look like
_source: {
...existing fields,
"new_field" : {
"attrName1" : "value",
"attrName2" : "value",
}
}
I tried using the _update_by_query API to get this done. But so far I only could add String fields and arrays with it. When trying to add a JSON with the following query it gives me an error.
Query
curl -XPOST "http://xxx.xxx.xxx.xxx:pppp/my_index_name/_update_by_query" -d'
{
"query": {
"bool": {
"must": [
{
"term": {
"team.keyword": "search_phrase"
}
}
]
}
},
"script" : {
"inline":"ctx._source.field_name = {\"a\":\"b\"}"
}
}'
Error
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"ctx._source.field_name = {\"a\":\"b\"}",
" ^---- HERE"
],
"script": "ctx._source.field_name = {\"a\":\"b\"}",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "compile error",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "invalid sequence of tokens near ['{'].",
"caused_by": {
"type": "no_viable_alt_exception",
"reason": null
}
},
"script_stack": [
"ctx._source.field_name = {\"a\":\"b\"}",
" ^---- HERE"
],
"script": "ctx._source.field_name = {\"a\":\"b\"}",
"lang": "painless"
},
"status": 500
}
So far I could only add Strings as a new field. What is the correct way to achieve this?
Instead of direct assignment, use params to achieve the same.
{
"query": {
"bool": {
"must": [
{
"term": {
"team.keyword": "search_phrase"
}
}
]
}
},
"script": {
"inline": "ctx._source.field_name = params.new_field",
"params": {
"new_field": {
"a": "b"
}
}
}
}
I am trying to index a document in elasticsearch. The json I have comes from the document being transformed from XML to JSON. It is valid JSON. Looks like this:
{
"shortcasename": {
"_attributes": {
"party1": "People",
"party2": "Johnson"
},
"_children": [
"People",
{
"connector": {
"_attributes": {
"normval": "v"
},
"_children": [
" v. "
]
}
},
"Johnson"
]
}
}
Elasitcsearch seems to have a problem with the shortcasename._children. The error I get is:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "mapper [shortcasename._children] of different type, current_type [string], merged_type [ObjectMapper]"
}
},
"status": 400
}
Is there a way to get the json to be indexed the way it is?
The JSON you have has a conflict with the _children field:
{
"shortcasename": {
"_attributes": {
"party1": "People",
"party2": "Johnson"
},
"_children": [
"People",
{
"connector": {
"_attributes": {
"normval": "v"
},
"_children": [
" v. "
]
}
},
"Johnson"
]
}
}
The top-level _children field is an array containing a mix of objects ({"connector": ...}) and strings ("People", "Johnson"). Elasticsearch doesn't support that, that's why it complains that it cannot merge string and Object