You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param params.topic {String} The name of the MQTT topic.
132
+
* @param params.payload {Buffer|TypedArray|Blob|String} The payload to be sent.
133
+
* @param params.queueFullPolicy {'AllOrError'|'BestEffort'} Specify whether to enforce message delivery to all destinations. Options are 'AllOrError' and 'BestEffort'. Defaults to 'BestEffort' when omitted.
134
+
* @param callback {iotDataCallback} The callback.
135
+
*
136
+
* @example <caption>Calling the publish operation</caption>
137
+
* var params = {
138
+
* topic: 'STRING_VALUE', // required
139
+
* payload: new Buffer('...') || 'STRING_VALUE',
140
+
* queueFullPolicy: 'AllOrError' || 'BestEffort'
141
+
* };
142
+
* iotdata.publish(params, function(err, data) {
143
+
* if (err) console.log(err, err.stack); // an error occurred
144
+
* else console.log(data); // successful response
145
+
* });
146
+
*/
75
147
publish(params,callback){
76
-
/*
77
-
* Publishes state information.
78
-
* @param {object} params object contains parameters for the call
79
-
* REQUIRED: 'topic' the topic name to be published
80
-
* 'payload' the state information in JSON format
81
-
* OPTIONAL: 'queueFullPolicy' the policy for GGC to take when its internal queue is full
82
-
*/
83
148
consttopic=Util.getParameter(params,'topic');
84
149
if(topic===undefined){
85
150
callback(newError('"topic" is a required parameter'),null);
* Constructs a service interface object. Each API operation is exposed as a function on service.
16
+
* @class
17
+
* @memberOf aws-greengrass-core-sdk
18
+
*/
14
19
classLambda{
20
+
/**
21
+
* Constructs a service object. This object has one method for each API operation.
22
+
*
23
+
* @example <caption>Constructing a Lambda object</caption>
24
+
* var lambda = new GG.Lambda();
25
+
*/
15
26
constructor(){
16
27
this.ipc=newIPCClient(AUTH_TOKEN);
17
28
}
18
29
30
+
/**
31
+
* Called when a response from the service is returned.
32
+
*
33
+
* @callback lambdaCallback
34
+
* @param err {Error} The error object returned from the request. Set to <tt>null</tt> if the request is successful.
35
+
* @param data {Object} The de-serialized data returned from the request. Set to <tt>null</tt> if a request error occurs.
36
+
* @param data.StatusCode {Integer} The HTTP status code will be in the 200 range for successful request. For the <tt>RequestResponse</tt> invocation type this status code will be 200.
37
+
* For the <tt>Event</tt> invocation type this status code will be 202.
38
+
* @param data.FunctionError {String} Indicates whether an error occurred while executing the Lambda function. If an error occurred this field will have one of two values; <tt>Handled</tt> or <tt>Unhandled</tt>.
39
+
* <tt>Handled</tt> errors are errors that are reported by the function while the Unhandled errors are those detected and reported by AWS Lambda.
40
+
* <tt>Unhandled</tt> errors include out of memory errors and function timeouts. For information about how to report an <tt>Handled</tt> error,
41
+
* see <a href="http://docs.aws.amazon.com/lambda/latest/dg/programming-model.html">Programming Model</a>.
42
+
* @param data.Payload {Buffer|TypedArray|Blob|String} It is the result returned by the Lambda function. This is present only if the invocation type is <tt>RequestResponse</tt>.
43
+
* <br/>In the event of a function error this field contains a message describing the error. For the <tt>Handled</tt> errors the Lambda function will report this message. For <tt>Unhandled</tt> errors AWS Lambda reports the message.
44
+
*/
45
+
46
+
/**
47
+
* Invokes a specific Lambda function.<br/>
48
+
* In Greengrass, version of the Lambda which you would like to invoke needs to be provided.
49
+
*
50
+
* @param params {Object}
51
+
* @param params.FunctionName {String} The Lambda function name. You can specify Amazon Resource Name (ARN) of the function (for example, <tt>arn:aws:lambda:us-west-2:account-id:function:ThumbNail</tt>).
52
+
* @param params.InvocationType {String?} By default, the <tt>Invoke</tt> API assumes <tt>RequestResponse</tt> invocation type.
53
+
* You can optionally request asynchronous execution by specifying <tt>Event</tt> as the <tt>InvocationType</tt>. Possible values include:
* @param params.ClientContext {String?} Using the <tt>ClientContext</tt> you can pass client-specific information to the Lambda function you are invoking.
56
+
* You can then process the client information in your Lambda function as you choose through the context variable.
57
+
* For an example of a <tt>ClientContext</tt> JSON, see the main page or an example folder for an example.
58
+
* <br/>The <tt>ClientContext</tt> JSON must be base64-encoded.
59
+
* @param params.Payload {Buffer|TypedArray|Blob|String} Payload that you want to provide to your Lambda function as input.
60
+
* @param params.Qualifier {String?} You can use this optional parameter to specify a Lambda function version if it was not included in the FunctionName field.
61
+
* If you specify a function version, the API uses the qualified function ARN to invoke a specific Lambda function.
62
+
* <br/>If you don't provide this parameter, then the API uses the FunctionName field only. If it does not have a version number of the target lambda, the call will fail.
63
+
* @param callback {lambdaCallback} The callback.
64
+
*
65
+
* @example <caption>To invoke a Lambda function</caption>
66
+
* //This operation invokes a Lambda function
67
+
*
68
+
* var params = {
69
+
* ClientContext: "MyApp",
70
+
* FunctionName: "MyFunction",
71
+
* InvocationType: "Event",
72
+
* Payload: <json | binary>,
73
+
* Qualifier: "1"
74
+
* };
75
+
* lambda.invoke(params, function(err, data) {
76
+
* if (err) console.log(err, err.stack); // an error occurred
77
+
* else console.log(data); // successful response
78
+
* });
79
+
*
80
+
* @example <caption>Calling the invoke operation</caption>
81
+
* var params = {
82
+
* FunctionName: 'STRING_VALUE', // required
83
+
* ClientContext: 'STRING_VALUE',
84
+
* InvocationType: Event | RequestResponse,
85
+
* Payload: <json | binary>,
86
+
* Qualifier: 'STRING_VALUE'
87
+
* };
88
+
* lambda.invoke(params, function(err, data) {
89
+
* if (err) console.log(err, err.stack); // an error occurred
0 commit comments