1
00:00:00,210 --> 00:00:06,990
In this video we are going to test product microservices synchronous flow with including the API Gateway,

2
00:00:07,020 --> 00:00:10,380
Lambda function and dynamo DB table edge.

3
00:00:10,380 --> 00:00:18,120
You remember that we have already provision all these services on the cloud and upload the lambda function

4
00:00:18,120 --> 00:00:20,940
code in the product microservices.

5
00:00:21,030 --> 00:00:28,000
So let's see in the main console, see that we have uploaded our lambda function code.

6
00:00:28,020 --> 00:00:29,760
This is the our latest code.

7
00:00:29,760 --> 00:00:36,660
And if you go to API Gateway, you can see the deployed API Gateway and these are the resource and HTTP

8
00:00:36,660 --> 00:00:39,630
methods that expose from the API Gateway.

9
00:00:39,660 --> 00:00:44,310
We will trigger these URLs and invoke lambda functions and lambda function.

10
00:00:44,310 --> 00:00:50,010
Interact with the dynamic DB table to perform product microservices, cut operations.

11
00:00:50,040 --> 00:00:57,420
Please open the Visual Studio code and remember that this is the our main folder structure and I have

12
00:00:57,420 --> 00:00:59,320
created a postman folder.

13
00:00:59,340 --> 00:01:02,760
If you expand this folder, you can see the product collection.

14
00:01:02,760 --> 00:01:07,110
This is the postman collection that you can import this collection.

15
00:01:07,140 --> 00:01:08,420
Let me open the postman.

16
00:01:08,430 --> 00:01:14,430
If you come here and click the import statement and drag and drop in here, you can see these product

17
00:01:14,430 --> 00:01:19,560
microservices HTTP methods that we can run one by one.

18
00:01:19,560 --> 00:01:22,050
So let me start with the gate product.

19
00:01:22,050 --> 00:01:30,210
These URLs get from the API gateway and I'm going to send a HTTP method, as you can see that this is

20
00:01:30,210 --> 00:01:36,420
triggering the HTTP gate method and there is no product on product dynamo DB table yet.

21
00:01:36,420 --> 00:01:39,990
So these HTP get triggered get all products.

22
00:01:39,990 --> 00:01:42,510
So that means it is performed scan operation.

23
00:01:42,510 --> 00:01:46,010
You can see that we run these get all product function.

24
00:01:46,380 --> 00:01:53,110
Okay, if you come back to HTTP post request, we will create a new product onto our product dynamo

25
00:01:53,130 --> 00:01:53,970
DB table.

26
00:01:54,000 --> 00:01:57,810
To do that, I'm going to send the post request with this URL.

27
00:01:57,810 --> 00:02:03,480
And in here you can see that in the body section we provide this product JSON object.

28
00:02:03,600 --> 00:02:07,950
It is including the name, description, image file category and price.

29
00:02:07,950 --> 00:02:14,700
So if you look at the body JSON object, we don't send ID attribute for our product table on Dynamo

30
00:02:14,700 --> 00:02:15,900
DB are wrong.

31
00:02:15,900 --> 00:02:21,510
The function code should be generate naive ID with using the UUID library and create a new product item

32
00:02:21,510 --> 00:02:22,770
into our product table.

33
00:02:22,800 --> 00:02:29,370
If you check our create product method, go to method and you can see that the product ID will be generated

34
00:02:29,370 --> 00:02:30,210
into the method.

35
00:02:30,210 --> 00:02:37,440
So that's why we don't send any ID information and the other attributes will be saved on table, which

36
00:02:37,440 --> 00:02:43,500
is the product table and the ID is partition key and we have to send ID information and this will be

37
00:02:43,530 --> 00:02:45,390
handled in the create product method.

38
00:02:45,510 --> 00:02:46,230
Okay.

39
00:02:46,230 --> 00:02:46,980
Very good.

40
00:02:46,980 --> 00:02:51,780
So let me click the send button and perform the HTTP post operation.

41
00:02:52,020 --> 00:02:57,720
See that we have successfully finished this operation and this is the body information we including

42
00:02:57,720 --> 00:02:58,770
other details.

43
00:02:59,130 --> 00:03:03,690
Now we have one product on product table to check this operation.

44
00:03:03,690 --> 00:03:10,800
Please open the A management console and go to Dynamo DB table and I'm going to check product table.

45
00:03:11,820 --> 00:03:14,430
Explore items and run this command.

46
00:03:14,460 --> 00:03:21,060
See that we have created an item on the product table and the ID is generated from our Node.js Lambda

47
00:03:21,060 --> 00:03:26,760
Function code and we have successfully insert a new item into product table with using lambda function

48
00:03:26,760 --> 00:03:28,500
and triggering from the API gateway.

49
00:03:28,860 --> 00:03:34,140
So if we check the cloud looks to understand which methods are triggered.

50
00:03:34,170 --> 00:03:41,790
If you go to product function and go to monitor and we've given cloud which looks we will see the logs

51
00:03:41,790 --> 00:03:45,300
that we trigger for the get and post operation.

52
00:03:45,300 --> 00:03:52,830
If you open the latest log stream, you can see that in the last request comes for the post product

53
00:03:52,830 --> 00:03:58,140
operation and if you scroll down you can see the whole body including in here.

54
00:03:58,140 --> 00:04:04,440
So and if you scroll down you can see that for that action we are triggering to create product method.

55
00:04:04,440 --> 00:04:07,080
And these are the other details which is the response.

56
00:04:07,080 --> 00:04:14,180
So if you scroll up before we are creating any product, we are running to get all product which sending

57
00:04:14,190 --> 00:04:21,180
the HTTP, get to the only product resources and we can verify that it is going to get all products.

58
00:04:21,360 --> 00:04:21,960
Okay.

59
00:04:21,960 --> 00:04:28,620
Now if you come back to our postman collection, we can continue to our test with creating a new item

60
00:04:28,620 --> 00:04:31,320
which is the product to in here.

61
00:04:31,320 --> 00:04:36,750
As you can see that we are creating an inserting any item, any form in our product table.

62
00:04:36,780 --> 00:04:43,740
Click the send button to verify the HTTP post operation we have successfully sent to finish operation.

63
00:04:43,740 --> 00:04:50,850
Now we have two items in our product table to verify that we can run the get all products methods again.

64
00:04:50,850 --> 00:04:53,460
Come here and click the send button.

65
00:04:53,460 --> 00:04:57,840
This time we will have two products in our product table.

66
00:04:57,840 --> 00:05:05,610
As you can see, that two JSON response is coming, this HTTP get method so we can get the ID informations

67
00:05:05,610 --> 00:05:06,240
in here.

68
00:05:06,690 --> 00:05:12,240
For example, I'm going to get these ID information and run the get product by ID.

69
00:05:12,270 --> 00:05:18,420
If you come to this get product by ID, the only thing we should change is the ID information.

70
00:05:18,420 --> 00:05:24,950
At the end of the URL, we can put Slash and the ID information that we get from the HTP certificate

71
00:05:24,960 --> 00:05:28,230
operation save this file and click the HTP sign method.

72
00:05:28,380 --> 00:05:35,760
And we have verified that we successfully run get product by ID with specifying ID and get all the tests

73
00:05:35,760 --> 00:05:37,890
in the body information of the response.

74
00:05:38,100 --> 00:05:39,420
Okay, very good.

75
00:05:39,420 --> 00:05:43,200
Now we can test the update function with the put command again.

76
00:05:43,200 --> 00:05:47,490
I have an id and put command is also running product by ID.

77
00:05:47,520 --> 00:05:50,370
We can specify the id information in here.

78
00:05:51,060 --> 00:05:58,440
Say this file, but this time we can also buddy and the Jason definition, which will be which attributes

79
00:05:58,440 --> 00:06:01,350
we are going to update with this update operation.

80
00:06:01,380 --> 00:06:07,760
As you can see that I would like to update the name of the phone and if you click this product, buy

81
00:06:07,770 --> 00:06:15,120
ID now the name is the iPhone X and in the put operation we are going to update with our iPhone X and

82
00:06:15,120 --> 00:06:15,630
Y.

83
00:06:15,630 --> 00:06:19,450
So let's again, I can add the updated.

84
00:06:20,920 --> 00:06:25,060
In here, save this request and click the HTTP send request.

85
00:06:25,210 --> 00:06:29,300
So we have successfully performed the put operation to verify that.

86
00:06:29,320 --> 00:06:33,940
Go back to product, buy ID and please check this name and click to send again.

87
00:06:33,940 --> 00:06:41,070
And this time name information updated successfully with the product by ID and sending the HTTP operation.

88
00:06:41,080 --> 00:06:48,970
And lastly, I'm going to delete this product if you come here and provide the ID in the URL and save

89
00:06:48,970 --> 00:06:56,350
this file and send the HTTP delete method, it is also successfully finished the delete operation if

90
00:06:56,350 --> 00:06:59,110
you come back to get product ID and send again.

91
00:06:59,140 --> 00:07:02,230
This time we don't have any product with these ID.

92
00:07:02,260 --> 00:07:08,410
You can verify that we have two items and if we send again with running the second command, we have

93
00:07:08,410 --> 00:07:09,280
only one item.

94
00:07:09,280 --> 00:07:11,860
So that means we have successfully delete operation.

95
00:07:12,190 --> 00:07:19,060
So as you can see that we have finished all CRUD operations on the product microservices bit following

96
00:07:19,060 --> 00:07:22,240
the API gateway, lambda function and dynamic DB.

97
00:07:22,300 --> 00:07:25,120
In the next video we will clear our resources.
