How to search OpenSearch DB with nodejs lambda function ? #4082
-
Hello, I have a nodejs lambda function that have to search into an opensearch DB. I want to use the aws-sdk-v3. I have found the doc here for OpenSearchClient: But as you see, there is almost nothing explained there. For example, I have to create a AcceptInboundConnectionCommand with "params", but there are no explanations what are the properties required for this "params" object. When I search "AcceptInboundConnectionCommand" on google, there is only 3 results... Is this SDK usable ? Or is still a prototype or something ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @ouelletalexandre , The SDK is usable 😄 As a rule of thumb, every command in the SDK for example: So in your case so your code will look something like this: import { OpenSearchClient, AcceptInboundConnectionCommand } from "@aws-sdk/client-opensearch";
const client = new OpenSearchClient({ region: 'us-east-1' });
// to find what params we need you'll go to the docs and look for AcceptInboundConnectionCommandInput
const input = {
ConnectionId: myConnectionID
};
const command = new AcceptInboundConnectionCommand(input);
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} Let me know if that helps. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @ouelletalexandre ,
The SDK is usable 😄
Here is the link to the docs that you'll need to figure out which shapes the commands take in.
As a rule of thumb, every command in the SDK for example:
getSomethingCommand
will take a JS object of typegetSomethingCommandInput
as input, and return a JS object as output in the same conventiongetSomethingCommandOutput
So in your case
AcceptInboundConnectionCommand
will take in aAcceptInboundConnectionCommandInput
type. In this it takes in an object with this property:so your code will look something like this: