GET /vehicles/{id}/command/honk_horn
As seen in this post:
https://news.ycombinator.com/item?id=7961944
There is a debate about what verb should be used for the honk_horn resource. Answers include:
GET, because you're not changing the resource state
POST and not PUT because honking twice is not idempotent
PUT, because honking twice might be considered idempotent :S
Perhaps the root of the problem here is that honk_horn is really an action and not a resource, and so in this particular case how should one define as API to issue a command while remaining RESTful?
Perhaps the root of the problem here is that honk_horn is really an action and not a resource
Yes, I would say so, that's the core of the problem. A resource oriented and hypermedia based approach could look like this (using Mason https://github.com/JornWildt/Mason to describe actions):
GET /vehicles/12345/horn => return status of horn (a resource in itself)
{
volume: 5,
numberOfHonks: 1025,
#actions:
{
"honk":
{
type: "void",
href: "/vehicles/12345/horn/honks",
method: "POST",
title: "POST here to honk horn once"
}
}
}
GET /vehicles/12345/horn/honks => return previous honks (a resource in itself)
{
numberOfHonks: 1025,
honks:
[
{ date: "2010-12-24T10:24:12" },
{ date: "2010-12-24T10:24:14" },
{ date: "2010-12-24T10:24:20" },
... 1022 other honks (or perhaps only latest top 100 honks)
]
}
POST /vehicles/12345/horn/honks => Add one honk (empty payload - or maybe even include volume and pitch ...)
Fun exercise :-)
Related
I've currently been handling batch operations with a for loop, but obviously, this is not the best approach, especially as I'm adding an 'upload by CSV' option, which will take 1000+ putItems.
I searched around for the best ways to implement this, specifically this link:
https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-batch.html
However, even after following those steps mentioned I'm not able to achieve a batch operation. Below is my code for a 'batch delete' operation.
Here is my schema.graphql file:
type Client #model #auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
company: String
phone: String
email: String
}
type Mutation {
batchDelete(ids: [ID]): [Client]
}
I then create two new files. One request mapping template and one response mapping template.
#set($clientsdata = [])
#foreach($item in ${ctx.args.clients})
$util.qr($clientsdata.delete($util.dynamodb.toMapValues($item)))
#end
{
"version" : "2018-05-29",
"operation" : "BatchDeleteItem",
"tables" : {
"Clients": $utils.toJson($clientsdata)
}
}
and then as per the tutorial a "simple pass through" response mapping template:
$util.toJson($ctx.result.data.Posts)
However now when I run the batchdelete command, I keep getting nothing returned.
Would really appreciate guidance on this!
When it comes to performing DynamoDB batch operations in tandem with Amplify, note that the table name specified in the schema is actually different per environment, i.e. your "Client" table wouldn't be recognized as "Clients" as you have stated it in the request mapping template, but rather the name it is given on Amplify push, per environment.
E.g. Client-<some alphanumeric number>-envName
Add the full name of the table to your request and response mapping templates.
Also your foreach statement should read:
#foreach($item in ${ctx.args.clientsdata}) wherein you iterate through each of the items in the array that is passed as the argument to the context object.
Hope this helps.
I have a problem with Action on google and my alpha - beta test users and the production version. I am using the Dialogflow-V2, when I use my app in a test mode, with the simulator or with my phone linked with my dev account everything works fine and I don't have any problem.
But I have tested my project with alpha - beta test users. I sent the Opt-in Link to my users, they can accept to be alpha - beta testers and they can launch the agent with the Invocation sample.
The Welcome intent launch is ok and then the problem appear, when use the context, because in the logs of request body exist, but it doesn't exit in the Fulfillment.
Any context exits. Also I change the Array context and now I use a parameter with only one word. I have the same problem.
package.json
{
"name": "dialogflowCFPUPVASISTENTE",
"description": "This is the dialogflowCFPUPVASISTENTE for a Dialogflow agents using Cloud Functions for Firebase",
"version": "0.0.1",
"private": true,
"license": "Apache Version 2.0",
"author": "Google Inc.",
"engines": {
"node": "8"
},
"scripts": {
"start": "firebase serve --only functions:dialogflowCFPUPVASISTENTE",
"deploy": "firebase deploy --only functions:dialogflowCFPUPVASISTENTE"
},
"dependencies": {
"actions-on-google": "^2.2.0",
"firebase-admin": "^5.13.1",
"firebase-functions": "^2.0.2",
"dialogflow": "^0.6.0",
"dialogflow-fulfillment": "^0.6.0",
"axios": "^0.18.0",
"i18next": "^15.0.5",
"moment": "^2.24.0",
"crypto-js": "^4.0.0",
"google-auth-library": "^5.10.0"
}
}
index.js
const numero = agent.parameters.numero;
conole.log(numero);
console.log('prueba6666666 cursos1 context');
//prueba
let contexto_busqueda = agent.context.get('busqueda1');
console.log(contexto_busqueda); //HERE is UNDEFINED WHEN USE TESTER PHONE
let busqueda = contexto_busqueda.parameters.busqueda;
dialogflowFirebaseFulfillment (request body) with context "busqueda1" simple parameter "busqueda"
{
textPayload: "Dialogflow Request body: {"responseId":"5c2cb699-3ca5-4062-9e12-7dc31f0b15b6-eec93b43","queryResult":{"queryText":"el curso 2","action":"MasInfoIntent","parameters":{"numero":2},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/enviar_email1","lifespanCount":5,"parameters":{"idtoken":"xxxxx","palabra":"Java","palabra.original":"Java","numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/info_curso1","lifespanCount":5,"parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_web_browser","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_audio_output","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_account_linking","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_media_response_audio","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/actions_capability_screen_output","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/google_assistant_input_type_voice","parameters":{"numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/busqueda1","lifespanCount":4,"parameters":{"palabra":"Java","palabra.original":"Java","busqueda":"Java","numero":2,"numero.original":"2"}},{"name":"projects/cfpupv-ojcaew/agent/environments/__aog-36/users/-/sessions/ABwppHFnTiCqjO9DEr-LPHi2SuK1Inxq2I69iMx-SPntmFZm-1zaZZrYanmh54bQ19yDPuTpvpYlmCUyBw/contexts/__system_counters__","parameters":{"no-input":0,"no-match":0,"numero":2,"numero.original":"2"}}],"intent":{"name":"projects/cfpupv-ojcaew/agent/intents/b74cc78e-8c1c-420e-ba0d-3b6da6e18dd9","displayName":"MasInfoIntent"},"intentDetectionConfidence":1,"languageCode":"es"},"originalDetectIntentRequest":{"source":"google","version":"2","payload":{"user":{"locale":"es-ES","lastSeen":"2020-04-24T11:37:19Z","idToken":"xxxxx"
insertId: "000001-5cbd2792-582d-45b5-a99c-62c51c1daae8"
resource: {
type: "cloud_function"
labels: {3}
}
timestamp: "2020-04-24T11:37:39.685Z"
severity: "INFO"
labels: {
execution_id: "o8obosdy5d5z"
}
logName: "projects/cfpupv-ojcaew/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
trace: "projects/cfpupv-ojcaew/traces/b0fb3fa3c628d8cbaef2b73c09b64775"
receiveTimestamp: "2020-04-24T11:37:40.571089537Z"
}
dialogflowFirebaseFulfillment (request body) with context "busqueda1" simple parameter "busqueda" IS WORKING
{
textPayload: "Dialogflow Request body: {"responseId":"a3703a6d-9fca-4e4d-91f3-ecb58212a0f3-eec93b43","queryResult":{"queryText":"el curso 3","action":"MasInfoIntent","parameters":{"numero":3},"allRequiredParamsPresent":true,"outputContexts":[{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/enviar_email1","lifespanCount":5,"parameters":{"idtoken":"xxxxx","palabra":"java","palabra.original":"java","numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/info_curso1","lifespanCount":5,"parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_screen_output","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_account_linking","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_media_response_audio","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/actions_capability_audio_output","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/google_assistant_input_type_voice","parameters":{"numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/busqueda1","lifespanCount":4,"parameters":{"palabra":"java","palabra.original":"java","busqueda":"java","numero":3,"numero.original":"3"}},{"name":"projects/cfpupv-ojcaew/agent/sessions/ABwppHEYyiNzdo2qmZnOOb7FKufwyuTJ6tetAC7KkGYLp7PBEleCLaO6QIrC91Ql1a9DgWormHN_HNVb8Q/contexts/__system_counters__","parameters":{"no-input":0,"no-match":0,"numero":3,"numero.original":"3"}}],"intent":{"name":"projects/cfpupv-ojcaew/agent/intents/b74cc78e-8c1c-420e-ba0d-3b6da6e18dd9","displayName":"MasInfoIntent"},"intentDetectionConfidence":1,"languageCode":"es"},"originalDetectIntentRequest":{"source":"google","version":"2","payload":{"user":{"locale":"es-ES","lastSeen":"2020-04-24T12:07:58Z","idToken":"xxxxx","userVerificationStatus":"VERIFIED"},"conversation":{"conversationId":"ABwppHEYyiNzdo2"
insertId: "000001-3770d84b-b3e1-4610-a4e1-91f9c27573a5"
resource: {
type: "cloud_function"
labels: {3}
}
timestamp: "2020-04-24T12:08:09.311Z"
severity: "INFO"
labels: {
execution_id: "0hxf6o3oumx8"
}
logName: "projects/cfpupv-ojcaew/logs/cloudfunctions.googleapis.com%2Fcloud-functions"
trace: "projects/cfpupv-ojcaew/traces/ee0e462e5b7fcab9b45d7ef9acdcebe8"
receiveTimestamp: "2020-04-24T12:08:10.552786312Z"
}
"TypeError: Cannot read property 'parameters' of undefined
at masInfo (/srv/index.js:122:29)
at WebhookClient.handleRequest (/srv/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:313:44)
at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/srv/index.js:173:9)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:57:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)"
I think this is a problem of permissions in google cloud platform. Any idea?
Permissions cloud
Do I need another permission for alpha tester and production for using contexts?
https://cloud.google.com/dialogflow/docs/fulfillment-inline-editor
https://cloud.google.com/dialogflow/docs/fulfillment-webhook
If I use other alpha tester the project doesn't work, because although the dialogflow context exist in the request body of google cloud platform in the program is undefined.
Do I must do something in action google to use the program in alpha testing or production?
Can you help me?
you might be hitting a maximum size for the context as you are storing a lot of information on it. I haven't been able to find a documented limit for the contexts, but I think is worth trying to reproduce the problem with a smaller parameter count to see if it goes through.
It looks like the parameter "listado" has a JavaScript array as the value. The documentation for Context parameters indicate that the value in the map should either be a composite type (ie - another map) in some limited cases, but generally should be a string.
So it may be possible that while you think you're setting an array - when it is read back in, since it isn't a string, it is being emptied out or the entire context is considered invalid.
Answer of Action Google Assitant Support:
Thank you for providing the requested information and for adding my account as an Alpha tester. Based on these, we can understand that the "parameters" property caused the Action to crash. Upon checking the code snippet provided, we noticed that you used "agent" instead of "conv". What you can do is update "agent" to "conv". The reason for this is agent is more of for other integrations of Dialogflow. This is also coordinated with the Dialogflow team and they suggested the same. Please refer to the code snippets below on how to get the value of a parameter directly or in a context in webhook.
// Handle the Dialogflow intent named 'Curso Intent' without context.
// The intent collects a parameter named 'numero'.
app.intent('Curso Intent', (conv, {numero}) => {
const numero = numero;
});
// Handle the Dialogflow intent named 'Curso Intent' with context "curso_out".
// The intent collects a parameter named 'numero'.
app.intent('Curso Intent', (conv, {conv}) => {
const cCursoOut = conv.contexts.get('curso_out');
const pCursoOut = cCursoOut.parameters;
const numero = pCursoOut.numero;
});
Using 'conv' the project works perfectly !!!!!!!!!!!!
Thank yoy very much
I'm running an AWS step function with parallel execution branches.
Each branch succeeds individually, however the overall function fails with the following error:
States.DataLimitExceeded - The state/task returned a result with a size exceeding the maximum number of characters service limit.
I then found an article from AWS that describes this issue and suggests a work around:
https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html
That article says:
The Lambda invoke API includes logs in the response by default. Multiple Lambda invocations in a workflow can trigger States.DataLimitExceeded errors. To avoid this, include "LogType" = "None" as a parameter when you invoke your Lambda functions.
My question is where exactly do I put it? I've tried putting it various places in the state machine definition, however I get the following error:
The field 'LogType' is not supported by Step Functions
That error seems contrary to the support article, so perhaps I'm doing it wrong!
Any advice is appreciated, thanks in advance!
Cheers
UPDATE 1 :
To be clear, this is a parallel function, with 26 parallel branches. Each branch has a small output as per the example below. The biggest item in this data is the LogResult, which (when base64 decoded) is just the billing info. I think this info multiplied by 26 has led to the error, so I just want to turn this LogResult off!!!
{
"ExecutedVersion": "$LATEST",
"LogResult": "U1RBUlQgUmVxdWVzdElkOiBlODJjZTRkOS0zMjk2LTRlNDctYjcyZC1iYmEwMzI1YmM3MGUgVmVyc2lvbjogJExBVEVTVApFTkQgUmVxdWVzdElkOiBlODJjZTRkOS0zMjk2LTRlNDctYjcyZC1iYmEwMzI1YmM3MGUKUkVQT1JUIFJlcXVlc3RJZDogZTgyY2U0ZDktMzI5Ni00ZTQ3LWI3MmQtYmJhMDMyNWJjNzBlCUR1cmF0aW9uOiA3NzI5Ljc2IG1zCUJpbGxlZCBEdXJhdGlvbjogNzgwMCBtcwlNZW1vcnkgU2l6ZTogMTAyNCBNQglNYXggTWVtb3J5IFVzZWQ6IDEwNCBNQglJbml0IER1cmF0aW9uOiAxMTY0Ljc3IG1zCQo=",
"Payload": {
"statusCode": 200,
"body": {
"signs": 63,
"nil": ""
}
},
"SdkHttpMetadata": {
"HttpHeaders": {
"Connection": "keep-alive",
"Content-Length": "53",
"Content-Type": "application/json",
"Date": "Thu, 21 Nov 2019 04:00:42 GMT",
"X-Amz-Executed-Version": "$LATEST",
"X-Amz-Log-Result": "U1RBUlQgUmVxdWVzdElkOiBlODJjZTRkOS0zMjk2LTRlNDctYjcyZC1iYmEwMzI1YmM3MGUgVmVyc2lvbjogJExBVEVTVApFTkQgUmVxdWVzdElkOiBlODJjZTRkOS0zMjk2LTRlNDctYjcyZC1iYmEwMzI1YmM3MGUKUkVQT1JUIFJlcXVlc3RJZDogZTgyY2U0ZDktMzI5Ni00ZTQ3LWI3MmQtYmJhMDMyNWJjNzBlCUR1cmF0aW9uOiA3NzI5Ljc2IG1zCUJpbGxlZCBEdXJhdGlvbjogNzgwMCBtcwlNZW1vcnkgU2l6ZTogMTAyNCBNQglNYXggTWVtb3J5IFVzZWQ6IDEwNCBNQglJbml0IER1cmF0aW9uOiAxMTY0Ljc3IG1zCQo=",
"x-amzn-Remapped-Content-Length": "0",
"x-amzn-RequestId": "e82ce4d9-3296-4e47-b72d-bba0325bc70e",
"X-Amzn-Trace-Id": "root=1-5dd60be1-47c4669ce54d5208b92b52a4;sampled=0"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "e82ce4d9-3296-4e47-b72d-bba0325bc70e"
},
"StatusCode": 200
}
I ran into exactly the same problem as you recently. You haven't said what your lambdas are doing or returning however I found that AWS refers to limits that tasks have within executions https://docs.aws.amazon.com/step-functions/latest/dg/limits.html#service-limits-task-executions.
What I found was that my particular lambda had an extremely long response with 10s of thousands of characters. Amending that so that the response from the lambda was more reasonable got past the error in the step function.
I had the problem a week ago.
I way I solved is like below:
You can define which portion of the result that is transmitted to the next step.
For that you have to use
"OutputPath": "$.part2",
In your json input you have
"part1": {
"portion1": {
"procedure": "Delete_X"
},
"portion2":{
"procedure": "Load_X"
}
},
"part2": {
"portion1": {
"procedure": "Delete_Y"
},
"portion2":{
"procedure": "Load_Y"
}
}
Once part1 is processed, you make sure that part1 is not sent in the output and the resultpath related to it. Just part 2 which is needed for the following steps is sent for the next steps.
With this: "OutputPath": "$.part2",
let me know if that helps
I got stuck on the same issue. Step function imposes a limit of 32,768 characters on the data that can be passed around between two states.
https://docs.aws.amazon.com/step-functions/latest/dg/limits.html
Maybe you need to think and breakdown your problem in a different way? That's what I did. Because removing the log response would give you some elasticity but your solution will not scale after a certain limit.
I handle large data in my Step Functions by storing the result in an S3 bucket, and then having my State Machine return the path to the result-file (and a brief summary of the data or a status like PASS/FAIL).
The same could be done using a DB if that's more comfortable.
This way won't have to modify your results' current format, you can just pass the reference around instead of a huge amount of data, and they are persisted as long as you'd like to have them.
The start of the Lambdas looks something like this to figure out if the input is from a file or plain data:
bucket_name = util.env('BUCKET_NAME')
if 'result_path' in input_data.keys():
# Results are in a file that is referenced.
try:
result_path = input_data['result_path']
result_data = util.get_file_content(result_path, bucket_name)
except Exception as e:
report.append(f'Failed to parse JSON from {result_path}: {e}')
else:
# Results are just raw data, not a reference.
result_data = input_data
Then at the end of the Lambda they will upload their results and return directions to that file:
import boto3
def upload_results_to_s3(bucket_name, filename, result_data_to_upload):
try:
s3 = boto3.resource('s3')
results_prefix = 'Path/In/S3/'
results_suffix = '_Results.json'
result_file_path = '' + results_prefix + filename + results_suffix
s3.Object(bucket_name, result_file_path).put(
Body=(bytes(json.dumps(result_data_to_upload, indent=2).encode('UTF-8')))
)
return result_file_path
result_path = upload_results_to_s3(bucket_name, filename, result_data_to_upload)
result_obj = {
"result_path": result_path,
"bucket_name": bucket_name
}
return result_obj
Then the next Lambda will have the first code snippet in it, in order to get the input from the file.
The Step Function Nodes look like this, where the Result will be result_obj in the python code above:
"YOUR STATE":
{
"Comment": "Call Lambda that puts results in file",
"Type": "Task",
"Resource": "arn:aws:lambda:YOUR LAMBDA ARN",
"InputPath": "$.next_function_input",
"ResultPath": "$.next_function_input",
"Next": "YOUR-NEXT-STATE"
}
Something you can do is, add "emptyOutputPath": "" to your json,
"emptyOutputPath": "",
"part1": { "portion1": { "procedure": "Delete_X"
}, "portion2":{ "procedure": "Load_X" } },
"part2": { "portion1": { "procedure": "Delete_Y"
}, "portion2":{ "procedure": "Load_Y" } }
That will allow you to do "OutputPath":"$.emptyOutputPath" which is empty and will clear ResultPath.
Hope that helps
Just following up on this issue to close the loop.
I basically gave up on using parallel lambdas in favour of using AQS message queues instead
Is there a prescribed way to create a custom validator in loopback? As an example, assume that I want to create something like:
Validatable.validatesRange('aProperty', {min: 0, max: 1000})
Please note that I am aware of:
Validatable.validates(propertyName, validFn, options)
The problem I have with validates() is that validFn does not have access to the options. So, I'm forced to hard code this logic; and create a custom method for every property that needs this type of validation. This is undesirable.
Similarly, I am familiar with:
Model.observes('before save', hookFn)
Unfortunately, I see no way to even declare options for the hookFn(). I don't have this specific need (at least, not yet). It was just an avenue I explored as a possible alternative to solve my problem.
Any advice is appreciated. Thanks in advance!
There is a mention of how to do this over at https://docs.strongloop.com/display/public/LB/Validating+model+data
You can also call validate() or validateAsync() with custom validation
functions.
That leads you to this page https://apidocs.strongloop.com/loopback-datasource-juggler/#validatable-validate
Which provides an example.
I tried it out on my own ...
Question.validate('points', customValidator, {message: 'Negative Points'});
function customValidator(err) {
if (this.points <0) err();
}
And since that function name isn't really used anywhere else and (in this case) the function is short, I also tried it out with anonymous function:
Question.validate('points',
function (err) { if (this.points <0) err(); },
{message: 'Question has a negative value'})
When points are less than zero, it throws the validation error shown below.
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The `Question` instance is not valid. Details: `points` Negative Points (value: -100).",
"statusCode": 422,
"details": {
"context": "Question",
"codes": {
"points": [
"custom"
]
},
"messages": {
"points": [
"Negative Points"
]
}
What you are looking for is validatesLengthOf(). For example:
Validatable.validatesLengthOf('aProperty', {min: 0, max: 1000});
Here is the documentation links:
All the methods of Validatable class and
Model-wise validation.
I am used to get check-ins with
https://api.foursquare.com/v2/venues/4b64c88af964a520d4cf2ae3/herenow?oauth_token=XXXXXXX&v=20120725
but yesterday, I realize that my app is not working properly. I can not get the items[](people who cheked in specific venue). Web service retrieving json like this;
{
meta: {
code: 200
}
notifications: [
{
type: "notificationTray"
item: {
unreadCount: 0
}
}
]
response: {
hereNow: {
count: 16
items: [ ]
}
}
}
seriakillaz is right -- the behavior you're seeing is intentional, and is described by the email he links to.
In general though, the hereNow is working as before if you're checking into a place (the official foursquare apps use the same endpoints we document publicly).
If you're having trouble with it after accounting for the new policy, checkout my response to seriakillaz question:
hereNow not working as expected
They've just changed the hereNow endpoint: https://groups.google.com/forum/?fromgroups#!topic/foursquare-api/rmS0DbKKOHo
However it is not working for me even if I check-in to a place...