1
00:00:00,300 --> 00:00:06,660
In this video, we are going to develop the late product method for our product Lambda Microservices

2
00:00:06,660 --> 00:00:08,670
using the HDC packages.

3
00:00:08,910 --> 00:00:16,140
So that means we will accommodate the HTTP delete request from the client and Amazon API gateway into

4
00:00:16,140 --> 00:00:22,020
our product microservices lambda function and to perform delete item in Dynamo DB table.

5
00:00:22,800 --> 00:00:26,610
So in order to do that, please open the widgets to the code.

6
00:00:26,610 --> 00:00:33,360
And in here in the indexes, we basically accommodate the HTTP delete method.

7
00:00:33,390 --> 00:00:37,740
We're checking the exit method and case delete operation.

8
00:00:37,740 --> 00:00:42,360
So which event JS object comes from our switch statement.

9
00:00:42,360 --> 00:00:46,590
You can go to events and go to delete by ID JSON object.

10
00:00:46,620 --> 00:00:50,910
This object is exactly the same event that we will trigger.

11
00:00:50,940 --> 00:00:56,850
The our lambda function method will be the delete and the resource and pet in here.

12
00:00:56,850 --> 00:01:02,910
So in order to get a pet parameters, you can scroll down and see that we can get the pet parameters

13
00:01:02,910 --> 00:01:09,930
from the event dot pet parameters that ID information in order to delete an item in the existing Dynamo

14
00:01:09,930 --> 00:01:10,770
DB table.

15
00:01:11,040 --> 00:01:11,670
Okay.

16
00:01:11,670 --> 00:01:15,780
So let's get start to accommodate this HTTP delete operation.

17
00:01:15,780 --> 00:01:18,120
To do so, go to index case file.

18
00:01:18,150 --> 00:01:23,550
And basically I'm going to add a new case block after the post operation.

19
00:01:23,550 --> 00:01:24,840
This will be the.

20
00:01:25,960 --> 00:01:27,940
KS delete operation.

21
00:01:27,940 --> 00:01:36,820
Please add the next block, which is the delete operation and give the body of the statement as a delete

22
00:01:36,820 --> 00:01:37,900
product method.

23
00:01:37,900 --> 00:01:44,350
And this method get a parameter which is a product ID is the same way to get product.

24
00:01:44,380 --> 00:01:46,810
In this case, we will delete product by ID.

25
00:01:46,810 --> 00:01:54,400
So that's why we are placing event parameters ID to delete and specific ID to dynamic DB table.

26
00:01:54,640 --> 00:02:03,610
So after we have performed the switch case below, we are going to develop the delete product method.

27
00:02:03,700 --> 00:02:08,000
But before we implement, let's check the documentation.

28
00:02:08,020 --> 00:02:12,030
If you go to the documentation, you can see that we will use the late item command.

29
00:02:12,040 --> 00:02:18,270
If you go to delete item command, you can read what it is going to do and scroll down.

30
00:02:18,280 --> 00:02:24,970
You can see the example implementation and if you go to the input object, you can see the available

31
00:02:24,970 --> 00:02:29,320
properties that we will send as a parameter of delete item command.

32
00:02:29,530 --> 00:02:34,450
So please go back to our indexes and save our index file.

33
00:02:34,480 --> 00:02:37,940
Now I'm going to implement this delete product.

34
00:02:37,960 --> 00:02:39,740
To do so, please go.

35
00:02:39,760 --> 00:02:45,310
At the end of these indexes and we will create a new method.

36
00:02:45,340 --> 00:02:46,420
You can come here.

37
00:02:46,420 --> 00:02:49,350
Let me copy paste in here and explain after that.

38
00:02:49,360 --> 00:02:55,120
So this is the delete product method, which is getting product ID as a parameter.

39
00:02:55,120 --> 00:03:00,560
And we will use this product ID when we are deleting an item.

40
00:03:00,580 --> 00:03:05,320
Before explaining these methods, let me add a required package.

41
00:03:05,320 --> 00:03:11,470
See that we have all of the import marshal and in this case, the only thing that we should import the

42
00:03:11,470 --> 00:03:17,980
delete item command, please copy this command or come here, click the control space and go on top

43
00:03:17,980 --> 00:03:25,900
of the page and make sure that you have edit delete item command into the client dynamic DB package

44
00:03:25,900 --> 00:03:32,650
and make sure that you have import successfully if you go back to our method at the end of the page.

45
00:03:32,650 --> 00:03:35,410
So let me explain this method one by one.

46
00:03:35,830 --> 00:03:44,410
So basically we will start with covering try case below to avoid any unexpected exception and follow

47
00:03:44,410 --> 00:03:49,900
the exception from the Amazon Cloud, which looks after that we perform the log operation to identify

48
00:03:49,900 --> 00:03:56,650
where in the delete product method and after that we basically create a parameter object.

49
00:03:56,950 --> 00:04:03,940
You can come here and see the parameter object and let me make it more clean.

50
00:04:03,940 --> 00:04:04,390
Okay.

51
00:04:04,540 --> 00:04:09,700
We have created a parameter object with pasting the table name and the key information.

52
00:04:09,700 --> 00:04:15,400
In the key information we basically passing the ID of the table because ID is partitioned and primary

53
00:04:15,400 --> 00:04:18,640
key and with using Marshall it is very simplify.

54
00:04:18,670 --> 00:04:22,330
Otherwise, for example, this is an example key definition.

55
00:04:22,360 --> 00:04:27,190
Otherwise we should pass the ID information as a specifying number and the value.

56
00:04:27,280 --> 00:04:33,010
Instead of that, we use the Marshall operation with directly passing the ID information without specifying

57
00:04:33,010 --> 00:04:34,480
any data type.

58
00:04:34,480 --> 00:04:40,930
And after we have completed the parameters, we pass these parameters into delete item command and using

59
00:04:40,930 --> 00:04:41,770
the dynamo db.

60
00:04:41,800 --> 00:04:48,490
Send a bait method in order to perform delete operation and response back to the later result logging

61
00:04:48,490 --> 00:04:52,720
and return back these delete that to the delete product function.

62
00:04:52,720 --> 00:04:58,300
So as you can see that we have developed this delete product function.

63
00:04:58,300 --> 00:05:00,850
So in the next video we will see other methods.
