1
00:00:00,150 --> 00:00:07,170
In this section, we are going to create an delete topic on Amazon since using K libraries.

2
00:00:07,590 --> 00:00:13,980
So we will create a Node.js application to perform, create list and delete Amazon Essence topics.

3
00:00:13,980 --> 00:00:20,760
So these Node.js application will be used a basic JavaScript version three libraries and especially

4
00:00:20,760 --> 00:00:27,000
we will use client sass library to perform these operation pasting these create topic command list,

5
00:00:27,000 --> 00:00:31,500
topic, command and delete topic command to the Amazon sass and perform these actions.

6
00:00:32,010 --> 00:00:32,700
Okay.

7
00:00:32,760 --> 00:00:37,230
Before we proceed, it is good to check the our documentation.

8
00:00:37,350 --> 00:00:44,880
If you open the SDK documentation for the SAS client, we will use the SAS client to perform actions.

9
00:00:44,880 --> 00:00:50,010
First of all, we will install the required SDK packages for the client SAS, and after that we will

10
00:00:50,010 --> 00:00:53,130
import the required command to perform our actions.

11
00:00:53,130 --> 00:00:55,560
So here you can see the example usage.

12
00:00:55,560 --> 00:01:02,100
And if we come here and see that the commands you can search for the create topic command, we will

13
00:01:02,100 --> 00:01:05,070
use create topic command to perform create operations.

14
00:01:05,070 --> 00:01:08,850
You can see in here this is the input commands for the create topic.

15
00:01:08,850 --> 00:01:11,400
So let's get started one by one.

16
00:01:11,400 --> 00:01:13,950
Implement these logics in our application.

17
00:01:13,950 --> 00:01:17,070
For that purpose, please open the Visual Studio code.

18
00:01:17,100 --> 00:01:22,110
I have created a separate section folder in here and also separate lecture folder.

19
00:01:22,110 --> 00:01:25,140
So lecture 270 sense topic.

20
00:01:25,140 --> 00:01:31,410
From now on we will develop all these SAS related use cases in this lecture folder and we will create

21
00:01:31,410 --> 00:01:35,970
these Node.js application into this folder and follow the documentation.

22
00:01:35,970 --> 00:01:40,820
So basically we will use this command, create topic, command list, topic, command and lead topic

23
00:01:40,830 --> 00:01:43,140
command and we will create a client object.

24
00:01:43,140 --> 00:01:47,070
But let's get start with the installing required packages.

25
00:01:47,070 --> 00:01:52,320
So I'm going to convert this folder as a Node.js application.

26
00:01:52,320 --> 00:01:55,620
In order to do that, it is good to run NPM in command.

27
00:01:55,650 --> 00:01:58,260
NPM in a dash way, hit enter.

28
00:01:58,290 --> 00:02:04,320
This will create a package JSON file for our application and this will be become a Node.js application.

29
00:02:04,320 --> 00:02:10,710
So if you come here, the first thing we should do that we should add the type as a module to use execute

30
00:02:10,770 --> 00:02:11,880
six standards.

31
00:02:11,880 --> 00:02:16,800
And after that now we are ready for the install required package for installation part.

32
00:02:16,800 --> 00:02:22,950
You can go to the documentation and copy from the NPM, install command and paste in here and make sure

33
00:02:22,950 --> 00:02:25,110
that you are in the correct folder structure.

34
00:02:25,140 --> 00:02:26,400
Hit the enter.

35
00:02:26,430 --> 00:02:32,790
This will be create node modules folder into our Node.js application and add the required package.

36
00:02:32,790 --> 00:02:36,030
So if you open the package, JSON will come to dependencies.

37
00:02:36,030 --> 00:02:40,170
You can see that we have successfully installed client since library.

38
00:02:40,260 --> 00:02:44,850
So you can see that node modules folder also added in our application.

39
00:02:44,850 --> 00:02:45,690
So very good.

40
00:02:45,690 --> 00:02:47,850
Now we can follow the other operations.

41
00:02:47,850 --> 00:02:53,100
If you open the command text, the first thing we should do that before implementing these commands,

42
00:02:53,130 --> 00:02:57,630
we are going to create a client object for the separate Node.js module.

43
00:02:57,630 --> 00:03:05,370
For that purpose, I'm going to create a SANS client that JS file and in this file we will follow the

44
00:03:05,370 --> 00:03:09,990
same steps that we have done for the S3 client and also Dynamo DB client.

45
00:03:10,020 --> 00:03:14,730
You remember these codes from the HDD client and the Dynamo DB client.

46
00:03:14,760 --> 00:03:21,090
We basically import required package and using the client, passing to Region one, creating a client

47
00:03:21,090 --> 00:03:25,320
object and export sense client for our other Node.js modules.

48
00:03:25,320 --> 00:03:32,460
So now we can start to implement our actual logics, which is the create delete topics in Amazon SAS.

49
00:03:32,460 --> 00:03:36,300
For that purpose we are starting to documentation.

50
00:03:36,300 --> 00:03:42,750
If you come here and click the Create Topic Command, you can see the documentation of the create topic

51
00:03:42,750 --> 00:03:43,290
command.

52
00:03:43,290 --> 00:03:48,780
Basically it is create an object to place the name for the topic to the create topic command method

53
00:03:48,780 --> 00:03:50,520
of the client object.

54
00:03:50,670 --> 00:03:57,030
So it is called the create topic method and create a synchronous function invoking on Amazon service

55
00:03:57,030 --> 00:04:00,150
object and pasting the parameters to this object.

56
00:04:00,150 --> 00:04:05,100
So it is the turn back to data that contains the area of the newly created topic.

57
00:04:05,100 --> 00:04:07,950
So you can see the example implementation in here.

58
00:04:07,950 --> 00:04:13,530
And if you look at the input parameters, you can see the important input parameter is the name of the

59
00:04:13,530 --> 00:04:14,160
topic.

60
00:04:14,310 --> 00:04:16,230
Okay, let's start with the implementation.

61
00:04:16,230 --> 00:04:20,730
If you open the our we used to do code and come to commerce text.

62
00:04:20,730 --> 00:04:21,630
We are in here.

63
00:04:21,630 --> 00:04:25,530
We are going to create topic command to perform this create topic command.

64
00:04:25,530 --> 00:04:33,150
I'm going to create a new JavaScript file which is a separate Node.js module and write down create topic

65
00:04:33,150 --> 00:04:37,440
that JS and we will implement these create topic operation in here.

66
00:04:37,470 --> 00:04:42,000
Basically, I'm going to start with the import statement, as you remember that we are using the create

67
00:04:42,000 --> 00:04:49,560
topic command from our SAS SDK library and after that we are using SAS client to sending the required

68
00:04:49,560 --> 00:04:50,160
commands.

69
00:04:50,160 --> 00:04:55,890
So this is a separate SAS client JS file that we create in the in the in this video.

70
00:04:55,890 --> 00:04:59,730
So also now I'm going to create a.

71
00:04:59,940 --> 00:05:02,700
Amateurs that is pacing to our creative command.

72
00:05:02,710 --> 00:05:08,580
We have one put parameters, which is the name, and the name of the topic is a new topic.

73
00:05:08,590 --> 00:05:14,200
So after that we will implement our actual logic, which is the run method you already familiar with

74
00:05:14,410 --> 00:05:19,990
method when we implement the S3 and also Dynamo DB SDK libraries.

75
00:05:19,990 --> 00:05:27,010
So as you remember that we have a synchronous function and we have a wait sense client send method and

76
00:05:27,010 --> 00:05:31,810
in the parameter of this method is a create topic command with passing these parameters.

77
00:05:31,810 --> 00:05:37,900
So the response of the data we are looking as a success and if there is any error, we see the error

78
00:05:37,900 --> 00:05:39,040
and logging terror.

79
00:05:39,130 --> 00:05:45,340
Okay, now we have implemented the create topic command that we can run this operation.

80
00:05:45,340 --> 00:05:53,410
If you open the terminal in the correct folder structure, we can run the node command and create topic

81
00:05:53,410 --> 00:05:54,190
operation.

82
00:05:54,190 --> 00:05:59,560
If you run the node create topic, this will be run this Node.js module and implement to create topic

83
00:05:59,560 --> 00:06:01,510
on a cloud environment.

84
00:06:01,540 --> 00:06:03,490
Hit enter and see what's happened.

85
00:06:03,520 --> 00:06:09,820
We can see that it is returning a success response to 100 success once and it is returned to us topic

86
00:06:09,830 --> 00:06:14,950
again that is created from the A list and the name of the topic is a new topic.

87
00:06:14,950 --> 00:06:19,150
Okay, now we will continue the second use case, which is the list topic.

88
00:06:19,150 --> 00:06:22,060
So for that purpose, I'm going to open the documentation.

89
00:06:22,060 --> 00:06:31,090
If you come to our documentation and if you search for the list topic, you can see the command that

90
00:06:31,090 --> 00:06:33,070
we will use for this operation.

91
00:06:33,070 --> 00:06:39,250
If you open the list of command, it is basically returning a list of the topics from the Amazon SAS.

92
00:06:39,250 --> 00:06:44,890
Here you can see the example usage and if you open the command input, you can see that we can pass

93
00:06:44,890 --> 00:06:46,840
the next token, but it is not mandatory.

94
00:06:46,960 --> 00:06:53,380
So for that purpose we will use these list topic command to implement and listing topics from the Amazon

95
00:06:53,410 --> 00:06:54,010
SAS.

96
00:06:54,040 --> 00:06:57,460
Please open the widgets to the code and in here.

97
00:06:58,450 --> 00:07:03,610
I'm going to create a new file, which is the list topic.

98
00:07:03,880 --> 00:07:06,580
So if you create a new file this.

99
00:07:07,550 --> 00:07:13,000
Topic that is, and we will implement the several steps from the correct topic.

100
00:07:13,010 --> 00:07:20,060
If you copy paste quotes from the correct topic, I'm going to use this time as a list topic command.

101
00:07:20,060 --> 00:07:26,330
You can see that list topics command and is the same way I'm going to.

102
00:07:27,670 --> 00:07:32,830
I'm not placing any parameters because we would like to send all.

103
00:07:33,980 --> 00:07:36,800
Pace all the topics that we would like to see.

104
00:07:36,800 --> 00:07:41,180
So please remove the parameters part and that's all.

105
00:07:41,210 --> 00:07:47,570
We will use this top command and send this command to the client to see how it is returned to us.

106
00:07:47,570 --> 00:07:52,790
We can run the node command node list topics hit the enter.

107
00:07:53,870 --> 00:08:01,100
And see that we have only one topic that we create in the last operation so we can successfully listing

108
00:08:01,130 --> 00:08:03,060
topics commands from the Amazon SANS.

109
00:08:03,080 --> 00:08:10,670
If you open the console, go to topics, we can verify that we have one topic which name is new topic?

110
00:08:10,670 --> 00:08:13,250
And the run is the same that is returned to us.

111
00:08:13,370 --> 00:08:18,080
So now we are only one command left in here, which is the delay topic command.

112
00:08:18,080 --> 00:08:20,720
We're using the SDK libraries.

113
00:08:20,720 --> 00:08:27,200
In order to do that, please open the documentation if you come here and search for the delete topic

114
00:08:27,200 --> 00:08:27,890
command.

115
00:08:28,490 --> 00:08:30,650
So we will use this command in here.

116
00:08:30,650 --> 00:08:35,090
If you go to input parameters, you can see the parameters as topic area.

117
00:08:35,150 --> 00:08:38,960
So basically we will use the topic command in order to do that.

118
00:08:38,960 --> 00:08:40,430
Please open the OR.

119
00:08:40,430 --> 00:08:45,590
We just do code and create a new file, which is the delete topic.

120
00:08:46,680 --> 00:08:53,450
A JS file and I'm going to copy from the great topic and paste from the daily topic.

121
00:08:53,460 --> 00:08:56,970
So in this case we will use the topic command.

122
00:08:56,970 --> 00:08:59,670
So that's why I'm changing the first line of command.

123
00:08:59,790 --> 00:09:03,150
After that, in the parameters, we should pass the topic.

124
00:09:03,150 --> 00:09:04,590
Eireann topic.

125
00:09:06,120 --> 00:09:06,720
Aaron.

126
00:09:07,580 --> 00:09:10,780
The topic, Aaron, that we got from the last operation.

127
00:09:10,780 --> 00:09:13,090
I'm going to copy and paste in here.

128
00:09:14,150 --> 00:09:15,800
So now we are ready for the parameters.

129
00:09:15,800 --> 00:09:22,190
So we should pass these parameters as a delete the command and we will use sense client to send these

130
00:09:22,190 --> 00:09:26,660
command to perform deleting topic from our cloud environment.

131
00:09:26,690 --> 00:09:33,020
To do that, let's run this command and make sure that we have delete successfully save this file and

132
00:09:33,020 --> 00:09:33,970
come here.

133
00:09:34,160 --> 00:09:39,140
Run the mode delete topic that is command hit enter.

134
00:09:39,770 --> 00:09:42,960
So as you can see that we have successfully delete this topic.

135
00:09:42,980 --> 00:09:47,770
To verify that, please open the cloud environment and go to topics.

136
00:09:47,780 --> 00:09:53,210
You can see that we don't have any topic now, so that means we have performed successful.

137
00:09:53,210 --> 00:09:54,320
Delete our topic.

138
00:09:54,350 --> 00:10:00,410
As you can see that we have create list and delete topic on Amazon since using the SDK library.
