In this video, we are going to develop put events on Amazon event using the SDK libraries.
You can see the image we are in the first use case, which is the events in Amazon Event Village and
we will perform these use case with using the Amazon event SDK package.
If you go to the documentation, we can see that in the event which client library we will use a SDK
JavaScript event, which client library and you can scroll down, you can see that how we can install
and how we can import and use this library in order to interact with the event page.
So let's get started.
I'm going to create a separate lecture and section folder into our pseudocode, and here you can find
the our steps.
We will use these commands.
And first of all, we should create a Node.js application with creating package JSON file.
And after that we will install the required event package in order to interact with the event page.
For that purpose, please open the terminal and go to locate project folder of the section.
This is a section 42 and lecture is event page.
Okay, now I am going to copy this NPM command and hit enter.
And first of all we have create a package JSON file and the first thing we should do that is set a type
as a module in order to gain a script six standard, please save the package JSON file, come back to
commands and copy paste from the second command which is the installer required NPM package for the
event bridge SDK Library.
Okay.
This will take some time to install required SDK package and yes, it is created successfully.
Modules are created and also package JSON file.
If you scroll down, you can see the dependencies.
Now we are going to start implementation so I can close this window.
And now as you can see that the first thing we should create a client object in the Node.js module to
interact with the event API.
So for that purpose I'm going to create a new file which is the event client JavaScript.
So if you create a new JavaScript file, basically we will create an event with each client in order
to interact with event page.
And this is the best practice when we are using these operations, see that we have created using the
event client object and we have created new object and we are exporting EB client for event operation.
Click Save this file.
And after that, if you come back to our common text, basically we will start the implementation,
put event command in order to do it.
I'm going to create a need your secret file, which is a put event, but JS And in this file we will
implement these put event command.
But before that let's review and check the documentation.
So if you open the documentation again and in the right hand side, you can search for the commands.
As I put event commands, go to put event commands and see the details and see the example usage.
We should import required command and client object and after that we will send the command in here
to see input and outputs.
I'm going to open the put events command input.
The properties is expecting entities and also the output is returned back to entries and failed entry
count.
Okay, now let's start the implementation on Visual Studio code.
Please open the visual code and start implementation.
If you open the input event that JS file, I have developed the required codes you can see in here.
Basically this is very similar what we have done in the previous interactions with the SDK.
The first two import statements regarding to client event which we will use put events command.
And here you can see the EB client for interaction for event bridge.
So after that we provide the parameters for the event commands in the parameters as you remember that
we have entities array and every array has the type of the detail, tail type and source of the event.
I have put here some of the random values for the detail, detail type and the source.
And after that you can see the our actual run method that we are going to interact with the event bridge.
So basically we will use event sent to send put event codes with passing these parameters and this will
be put event to our event page, which is the default event.
Plus in order to test this function, you can come to terminal and run the node command, not put event.
JS If you hit the enter, this will be put event to the default event pass.
You can see the service goes to 100 and if you scroll down you can see the entries and the event ID
is created successfully.