1
00:00:00,390 --> 00:00:07,590
In this video, we are going to understand how rest API triggered a lambda with even an object.

2
00:00:07,710 --> 00:00:13,130
And after that we will develop our lambda function with incoming event from the rest API.

3
00:00:13,140 --> 00:00:20,640
So we will in this stage we will get the event JSON object from rest API to a lambda with different

4
00:00:20,640 --> 00:00:25,470
active methods, get product, get product, buy ID, post product, delayed product ID.

5
00:00:25,560 --> 00:00:30,270
We will get all these events, objects and the loop are a lambda function.

6
00:00:30,330 --> 00:00:32,010
So let's get started.

7
00:00:32,130 --> 00:00:37,290
In order to do that, I'm going to create an EVE lecture folder into our visual code.

8
00:00:37,290 --> 00:00:45,270
So as you can see that we will send these requests to our API, Gateway Rest API and we will call this

9
00:00:45,300 --> 00:00:49,230
event get get py ID and post JSON document.

10
00:00:49,230 --> 00:00:50,820
So let's get started.

11
00:00:50,820 --> 00:00:57,420
In order to do that, in the last video we have invoke our API, we digital copy this URL, you can

12
00:00:57,420 --> 00:00:58,890
copy from the API gateway.

13
00:00:58,890 --> 00:01:04,200
Also go to API Gateway and get the ID from here.

14
00:01:04,200 --> 00:01:07,170
Let me show copy product API.

15
00:01:07,200 --> 00:01:13,590
If you go to the product and get you can get the ID from in here.

16
00:01:13,590 --> 00:01:20,580
Let me go to the stage under the plot, under the product, in the get method, you can see the inaugural

17
00:01:20,580 --> 00:01:22,950
copy this URL and go to the postman.

18
00:01:22,950 --> 00:01:29,160
So we will perform a HTTP, get operation to the product and click the send button.

19
00:01:29,430 --> 00:01:31,770
So this will respond back to us.

20
00:01:31,770 --> 00:01:37,920
Hello from Lambda because we didn't implement Lambda function yet, but it is we will collect the incoming

21
00:01:37,920 --> 00:01:38,670
event JSON.

22
00:01:38,670 --> 00:01:46,170
So go to lambda function to get this HTTP, get product method log information for that purpose, go

23
00:01:46,170 --> 00:01:51,180
to lambda function and go to monitoring v cloud watch looks.

24
00:01:53,990 --> 00:02:02,210
And go to the latest lucid dream and come here as remember that we are put to console log operation

25
00:02:02,210 --> 00:02:04,070
into our lambda function.

26
00:02:04,070 --> 00:02:08,960
So that's why we can copy incoming event and pass to our.

27
00:02:09,840 --> 00:02:17,370
We used to do code event, get JSON file, go on top of this page, remove the first line and save this

28
00:02:17,370 --> 00:02:18,240
JSON file.

29
00:02:18,450 --> 00:02:25,620
As you can see that this is the get product operation from rest API to Lambda function and see that

30
00:02:25,620 --> 00:02:30,270
the parameters are really different from the HTTP API.

31
00:02:30,300 --> 00:02:35,010
This time we have resource, PID and HTTP method that we can understand.

32
00:02:35,010 --> 00:02:40,500
This is the gate product method and if you scroll down, you can see different and additional delays

33
00:02:40,500 --> 00:02:40,980
in here.

34
00:02:40,980 --> 00:02:44,850
For example, query parameters, request context.

35
00:02:44,880 --> 00:02:51,930
If you scroll down by the information and so on, this is a bit different from triggering the HTTP API.

36
00:02:51,960 --> 00:02:59,220
This time we will take it from the rest API and we will consider about these important parameters which

37
00:02:59,220 --> 00:03:05,290
are the HTP method, pet parameters and setting parameters, resource, PET and so on.

38
00:03:05,310 --> 00:03:10,400
So let's continue to our test to complete all JSON files.

39
00:03:10,410 --> 00:03:16,530
So let me go back to Postman and copy this URL, create any request.

40
00:03:16,530 --> 00:03:23,940
And this time I'm going to send, for example, different ID information if I get the query string,

41
00:03:23,940 --> 00:03:26,630
for example, category equal form.

42
00:03:26,670 --> 00:03:30,720
Let's see how it is triggered to our lambda function.

43
00:03:30,780 --> 00:03:32,430
Eat the send button.

44
00:03:32,700 --> 00:03:36,540
So as you can set this, return the same text message.

45
00:03:36,540 --> 00:03:40,560
And now let's see the latest looks for the purpose.

46
00:03:40,560 --> 00:03:48,660
Go to cloud voice logs, go to product function, open the latest log stream and copy from the last

47
00:03:48,660 --> 00:03:49,890
log stream.

48
00:03:49,890 --> 00:03:54,580
Copy from here and open the our visitor code and paste in here.

49
00:03:54,600 --> 00:03:55,710
Get by ID.

50
00:03:57,320 --> 00:04:00,380
On top of this page, remove the first line, save this file.

51
00:04:00,410 --> 00:04:08,480
So as you can see that this time I have in tested product get product by ID so resource and pet is seems

52
00:04:08,480 --> 00:04:15,290
different way and this time if you scroll down we can see create setting parameters and if you scroll

53
00:04:15,290 --> 00:04:17,480
down we can also see pet parameters.

54
00:04:17,480 --> 00:04:24,590
So we understand how the trigger from the rest API and how we can get these parameters from these events

55
00:04:24,590 --> 00:04:25,190
and file.

56
00:04:25,220 --> 00:04:27,050
Let's continue to our test.

57
00:04:27,050 --> 00:04:33,410
So if you check the command text, we will follow these two one and now I am going to send a post payload

58
00:04:33,410 --> 00:04:34,610
for that purpose.

59
00:04:34,640 --> 00:04:43,790
Go to our postman copy URL from here, create new request and paste in here.

60
00:04:43,820 --> 00:04:48,230
This will be post method, so change the method as a post.

61
00:04:49,260 --> 00:04:58,860
And now we are going to set body information, body roll, JSON and copy from our payload in here.

62
00:04:58,890 --> 00:05:00,240
We can put the run on payload.

63
00:05:00,240 --> 00:05:07,350
Also, it is not important since we didn't develop the product lambda function OC just sent the HTTP

64
00:05:07,380 --> 00:05:09,450
post request to the product domain.

65
00:05:09,480 --> 00:05:13,290
Yes, the text message comes successfully.

66
00:05:13,290 --> 00:05:16,260
That means lambda function invoke successfully.

67
00:05:16,290 --> 00:05:20,130
Go to cloud watch logs and come to latest look.

68
00:05:21,320 --> 00:05:28,730
Copy from the latest look and taste to the hour, which is the code to the event post JSON, go on top

69
00:05:28,730 --> 00:05:29,870
and remove design.

70
00:05:30,290 --> 00:05:33,950
This time you can see the method is post and the resource is product.

71
00:05:33,980 --> 00:05:39,020
If you scroll down this time you will see the body information in here we will.

72
00:05:39,050 --> 00:05:45,350
These body parts, this information and use this information when using post operation into the product

73
00:05:45,350 --> 00:05:45,950
domain.

74
00:05:46,100 --> 00:05:47,540
Okay, very good.

75
00:05:47,720 --> 00:05:53,840
As you can see that we have sent different parameters and different ways to our application lambda function

76
00:05:53,840 --> 00:05:56,120
and see incoming event json object.

77
00:05:56,120 --> 00:06:04,220
So the important parameter is in here resource pet and estimated and we can also check the parameters

78
00:06:04,220 --> 00:06:09,110
in the get by ID and we can also check the information when we send the post information.

79
00:06:09,320 --> 00:06:15,200
So if there is a post request, we should pass the information in order to get payload and insert product

80
00:06:15,200 --> 00:06:15,770
record.

81
00:06:16,070 --> 00:06:22,880
As you can see that we have understood how this API triggered the lambda function with even JSON object.

82
00:06:22,910 --> 00:06:26,060
Now it is time to develop our lambda function with these payloads.
