Raml Basics -Part1

Mule 4 Indepth Api led connectivity and RAML Design
27 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.35
List Price:  €96.21
You save:  €28.86
£55.83
List Price:  £79.77
You save:  £23.93
CA$100.76
List Price:  CA$143.95
You save:  CA$43.19
A$112.23
List Price:  A$160.33
You save:  A$48.10
S$95.14
List Price:  S$135.93
You save:  S$40.78
HK$543.62
List Price:  HK$776.63
You save:  HK$233.01
CHF 63.04
List Price:  CHF 90.06
You save:  CHF 27.02
NOK kr797.48
List Price:  NOK kr1,139.30
You save:  NOK kr341.82
DKK kr502.49
List Price:  DKK kr717.87
You save:  DKK kr215.38
NZ$124.10
List Price:  NZ$177.29
You save:  NZ$53.19
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,361.55
List Price:  ৳11,945.58
You save:  ৳3,584.03
₹5,962.79
List Price:  ₹8,518.63
You save:  ₹2,555.84
RM314.04
List Price:  RM448.65
You save:  RM134.61
₦108,335.42
List Price:  ₦154,771.52
You save:  ₦46,436.10
₨19,495.71
List Price:  ₨27,852.21
You save:  ₨8,356.49
฿2,390.81
List Price:  ฿3,415.60
You save:  ฿1,024.78
₺2,467.44
List Price:  ₺3,525.07
You save:  ₺1,057.62
B$434.14
List Price:  B$620.23
You save:  B$186.09
R1,296.68
List Price:  R1,852.48
You save:  R555.80
Лв131.68
List Price:  Лв188.12
You save:  Лв56.44
₩102,198.93
List Price:  ₩146,004.73
You save:  ₩43,805.79
₪256.56
List Price:  ₪366.53
You save:  ₪109.97
₱4,090.81
List Price:  ₱5,844.26
You save:  ₱1,753.45
¥10,994.99
List Price:  ¥15,707.80
You save:  ¥4,712.81
MX$1,408.98
List Price:  MX$2,012.91
You save:  MX$603.93
QR255.09
List Price:  QR364.43
You save:  QR109.34
P967.82
List Price:  P1,382.66
You save:  P414.84
KSh9,046.20
List Price:  KSh12,923.70
You save:  KSh3,877.50
E£3,562.49
List Price:  E£5,089.49
You save:  E£1,527
ብር8,907.19
List Price:  ብር12,725.10
You save:  ብር3,817.91
Kz63,830.88
List Price:  Kz91,190.88
You save:  Kz27,360
CLP$69,323.69
List Price:  CLP$99,038.09
You save:  CLP$29,714.40
CN¥510.80
List Price:  CN¥729.75
You save:  CN¥218.94
RD$4,245.36
List Price:  RD$6,065.06
You save:  RD$1,819.70
DA9,465.07
List Price:  DA13,522.10
You save:  DA4,057.03
FJ$162.39
List Price:  FJ$232
You save:  FJ$69.60
Q539.11
List Price:  Q770.19
You save:  Q231.08
GY$14,638.77
List Price:  GY$20,913.42
You save:  GY$6,274.65
ISK kr9,772.70
List Price:  ISK kr13,961.60
You save:  ISK kr4,188.90
DH703.98
List Price:  DH1,005.73
You save:  DH301.75
L1,291.33
List Price:  L1,844.84
You save:  L553.50
ден4,143.97
List Price:  ден5,920.21
You save:  ден1,776.24
MOP$559.97
List Price:  MOP$800
You save:  MOP$240.02
N$1,289.45
List Price:  N$1,842.15
You save:  N$552.70
C$2,574.80
List Price:  C$3,678.44
You save:  C$1,103.64
रु9,534.71
List Price:  रु13,621.60
You save:  रु4,086.89
S/260.99
List Price:  S/372.86
You save:  S/111.86
K283.85
List Price:  K405.52
You save:  K121.66
SAR262.91
List Price:  SAR375.60
You save:  SAR112.69
ZK1,936.45
List Price:  ZK2,766.47
You save:  ZK830.02
L335.12
List Price:  L478.77
You save:  L143.64
Kč1,694.03
List Price:  Kč2,420.15
You save:  Kč726.12
Ft27,771.44
List Price:  Ft39,675.18
You save:  Ft11,903.74
SEK kr774.38
List Price:  SEK kr1,106.30
You save:  SEK kr331.92
ARS$71,792.58
List Price:  ARS$102,565.23
You save:  ARS$30,772.64
Bs484.55
List Price:  Bs692.24
You save:  Bs207.69
COP$307,165.41
List Price:  COP$438,826.54
You save:  COP$131,661.12
₡35,530.54
List Price:  ₡50,760.09
You save:  ₡15,229.55
L1,777.33
List Price:  L2,539.15
You save:  L761.82
₲546,250
List Price:  ₲780,390.60
You save:  ₲234,140.59
$U3,115.91
List Price:  $U4,451.49
You save:  $U1,335.58
zł287.82
List Price:  zł411.19
You save:  zł123.37
Already have an account? Log In

Transcript

In this video, we will understand how to design or rambles using Design Center in any point platform. But before we go ahead and design, let's talk about a simple requirement. Let's assume that I am developing applications for bank. And we want to do an API, which will expose the bank's assets like customers and one customer can have multiple accounts and one account can have multiple transactions. So if you are defining if we are defining an API or designing an API for this customer account management is trying to identify the resources, the resources, what we want to expose our customers, accounts and transactions. So even before we Go to design first let us identify one of the you are eyes We are going to expose in this REST API.

So how do you represent customers? By using what you are right? every resource must be uniquely identified by URL. So how do you identify customers as the reverse? Maybe by using slash customers? Is it?

Yes. And how do you identify accounts slash accounts? And how do you identify transactions slash transaction so I'm just listing out right now. So that we can actually write the same thing in ramify later. Now another thing is how to get a list of all customers in bank what can be the Ura and what can be the method may be something like slash customers. Slash iD iD is a You are a variable.

And what SDP method get is it GET request to slash customer slash customer ID may give our customers how to register a customer. Normally we use post to actually create a new resource for us to watch what slash customers, okay? How to get people, this one was slash customers, I won't get all customers, right. So this one was slash customers, and how to get customer information for a specific customer ID slash customer customers slash ad. And what good is the method get? How to update the customer information, maybe batch requests or put requests I write my patch to, again, slash customers.

Slash customer ID How to delete a customer should be same right? So slash customers slash ID but now the method will be what? Delete is it similarly how to get accounts are accounts of a specific customer, hey, I don't want all accounts. I want all accounts for a specific customer ID is very tricky tricky. First of all, let me identify customer by ad, it should be less customers slash ad. See, this identifies a particular customer.

Now what we want for this customer, we want account so slash accounts section the best practice would be to navigate from parent touching. customer has accounts you can say customer entity is a parent of accounts. It's always better to navigate from parent to So, first you identify the customer by using slash customers slash ID and you all the accounts. So, again here the method can be get, how to create a new account of course, put request for a POST request to slash accounts. Okay. Then how to get information of a specific account 30 maybe it is slash accounts, slash ID and methods what get right get similarly How to delete a particular account with specific account ID.

First of all slash accounts, slash ID will identify the account and then applying a delete method on it will delete an account out update upon On a specific ID First of all, again identify the account by using our consciousness. And my third, I can say put our patch patch. Similarly, how to create a new transaction post request to slash transactions. First how to get transactions of a specific account ID now I think you should be able to visualize, I don't know all transactions, I want transactions by account ID. So first of all identify the account by using slash accounts slash ID. Then for this account, I want transactions or slash transactions and the methods I can get.

How to get transactions for specific transaction ID so it's simple class transactions slash transaction rates. GET request, right? So we want to design an API using ramble for this one. Let us get started. Actually, now I'll go to design center. to design your API's, we always go to design center.

In this design center, I need to create an API specification. So here go to create, create what? Create API specification. Actually on Design Center, you can always create a mule application also, till we have created our new applications in studio itself, but we can also create new applications in design center as well. I'm going to show you how to create a new application using design central right now. Let's go and create an API specification.

Okay, I want to give a name, I will say my bank API create certain going to create an APA specification project. Okay, you can see that in design center. It has opened the ID for designing your API's. And here you can see that on the left side the files are the main file name is my bank API dot ramble. I don't want this tip so I'll carry the tips. And here in the middle, you can see the first line is saying that we're going to use a ramble versus this one point zero and tight lock my API is given as my bank API can modify it.

Every. Every API will have a base URL. So I want to the base URL. Actually, once I press enter, you can see at the bottom, what all keys are possible in Rommel are listed out. Basically, I want to give a base URL for my API. I'll click on base URL, and give my API URL so http colon slash slash localhost, or I can do anything any of the host but I'm giving localhost 801 slash API, I want this to be a base URL.

See, as I as I type in on this one on the right side, you can you can see that the UI is getting updated and shows that the base URL is this one. Okay, now, I want to write the URLs First of all, whatever I'm going to expose, so what we want less customers rate Now you're writing in grammar. Whenever you whenever you are is a lead, it has to be suffix with colon. So I want to expose class customers slash accounts. And then slash transactions. These are the high level resources, right?

So remember, syntax is very important in ramel, after every line how to use colon after the key of the Ura, right? Okay, under slash customers. Again, I want the sub resource class customer slash customer ID, right? I want to do that every. So you have to identify the sub arrays, and for every sub you array here to keep two spaces as delimiters. Remember, in Rational two spaces are de limiters for every line.

So under slash customers, I want slash ID and remember to use colon after this So he said, customer slash ID you can see the pain points slash customer slash customer slash already listed. And we also want slash customer slash ad slash accounts, is it the ad? Similarly, slash accounts slash account ID. And we also identified as transactions. Right? So again, slash transaction slash transaction ID.

So what I did is I listed out all the urs whatever I want to support in my rammer first, and I visualized the pain points that all the pain points listed on the right side is it then once I'm done, I need to decide what all methods I want to support what all MIME types I want to support, etc, and start expanding each of them step by step. So let's get started. Actually, I have created nice documentation. So in my lab docs, which you might have downloaded, there's a file called as 15 rambled part one, following this one. So step by step. Let me follow this one and I'll explain you.

So I have completed up to this part. Now I want to add the methods, whatever I want to support. So go back to my designer. I want to support getting post request for slash customers. So Learn it there are two spaces under that I will select Get. And again I will take my cursor to the same level and then I will say post.

So right now you can see first class customers on the right side I have configured getting post to be supported. And for slash customer slash, ID, I want to get requests so we'll type get calm. And for slash customer slash ID slash accounts I want to be in support get. So like that for each and every UI, identify what methods we want to support and write it for now, for saving time. What I will do is I'll copy paste. So what I have done is in my lab docs, I have given you a zip file called as ramel docs.

I have extracted this ramble docs here And there is a ramble file. I'll open this zero to Acme banking API ramble and I'll copy paste the whole content I'll explain you since of typing each and everything I'm copy pasting nothing here much the rational question is on Panzer as usual title is now changed to Acme banking API. And first class customers getting pushed or supported. First Class customers last Friday getting patches supported. Catch and delete are also supported. And forced slash customer slash account slash Id only slash ID slash accounts only get a support.

So like that I wrote what all methods I wanted support for each and every resource. Then I want to add the base URL And also media type let us see. So after this I learned this worry if I'm not adding here you can say that you can see on the right side base your is not defined read us now not worry about the base you will write I want to do something also called as a media type. So, basically for all the resources, I want a default MIME type or media type as application slash Jason. So, for all the, your eyes when a response is given, the default media type is application slash Jason. Okay.

But of course, they can override this one let me show you under slash customers slash get. I want I tapped it here. Once a tab after get here are the keys, whatever I can do response Second, describe responses. And under responses, what is the status code? Let's say 200 I want support. And also 404 Also, I want to support legislation 404 So here I'm seeing that for GET request 204 04 I am support.

So like that you can, you can, you can decide what all the status codes you want support for responses. Okay. Then what I want to do is for 200 response letters, I won't describe more about 200. So you won't actually, after I give the body what the body type, I can specify Jason and also XML I won't support both. So basically, here we can see that for response status code 200 the body and It can be either JSON or XML. If I don't specify anything by default it will be whatever I gave on the top.

Okay. So right now I left the body empty that means the MIME type by default should be Jason okay. select that. I want to add all the status codes up and I want to copy paste from this 03 let me just copy paste and I'll explain you just reverse trends of wasting time and explaining understand automatically. See here, I I configure here. The default media type is Jason.

And for GET request, I want to support 200 and body I didn't do it for post I want to support font status code 201. And when the response is 201 for post, I want a response header caller's location. So I described with that and body I didn't specify anything specifically. And under slash customer slash Id get request. I won't support response to the score 200 and body a MIME type it in specifically so the default one will be applied. Similarly for that request to slash customer slash Friday status code which I want to support is 204 for delete 200 so like that, for each and every UI, I configure the response success status codes and headers that I want you to understand one small thing.

See here post request first class customers is it not same as post request for slash seconds. See, I'm right entering for the first response status code which I want to support us to 01 and there should be at our current location and the body same thing here also this this duplicate is it and same thing also is therefore post request to slash transactions. Is it so, I want you to observe that there is some duplicate, even if you see request, maybe I guess could request also is m 202 01. And what about here? batch request 204. So that's not duplicate.

So there are some duplicates here right? For post at least you observed for all post. Whatever I wrote is looking like duplicate will eliminate it Next view observer if you observe on the right side it's mostly describing okay slash customers. We have gotten cost for slash customer slash customer ID we have get patch and delete. It's very nice that so till now, we have added success status codes for all the you are okay. Let me go to the document.

Next we want to add 404 status code under get customers let us see. For GET request to slash customers I want to also add 404 status code that again 404 body actually underbody I want to describe some properties and What I want is according to my document I want properties like status code. It should be of type string and message. And also I want to be of type string string is a predefined type. Actually what all three different types of data you can see here you can see string, integer Boolean daytime daytime only. These are all the standard types we'll see using all of them slowly.

Here I want methods to mystery. So, whenever 404 is going for slash customers, I want the body of 404 to contain this property status current message I updated according to my document. Similarly, I want to add 404 response body to all this slash customer slash customer, slash accounts and all sins of typing. What I do is I want to copy paste From the 04 banking API ramming so that I can explain you so copy and paste Okay. Now you observe that wherever required I configured 404 or slash customer customers first class customer slash Id also for zero for anything that is duplicate almost same thing like your I have given it here. Yes, I intentionally made duplicates to understand to tell you about some interesting things later, here was a four digit request also 404 same thing I added four GET request to slash accounts also added 4044 GET request to slash a construct it also added for delete request also added.

So, wherever possible I added all the 404 status code, but for all places wherever I have that at 404 is it not the same Same thing. Yes. Okay. So let me follow the next things. Similarly, if you want to add 500 status codes, so all 500 credit scores, I have our EML file again here. Copy paste this content so that can save some time.

So just understand that here I have added Pfizer of three status code. But one thing I want to observe the properties are same, like I haven't 404 officers. So, actually don't worry. How do you understand what all status codes might want to support? Maybe in your requirements document. You will be getting whatever status codes you want to support.

What should be the return body property, you'll be getting a document. So you need to understand how to write the syntax for Randall here. I'm not telling what are the standard status codes to be supported and how it should be. But once you identify the status course, this is a way to configure how to identify what are status codes for your APA to be defined. It's up to you to take a decision, is it okay? So I added all the 500 status codes also as per my document.

So long let us follow same document. I want to add XML and JSON to response body and also I want to add headers, let's see how to add headers. So coming back to slash customers for response for request, basically, for every GET request, there might be some request headers. So I want to configure all headers. So under the I can configure headers and I want some standard headers like accept, but I want to accept header to be optional. So if you want such accept added to be optional here do question mark.

So here I am describing that GET request for slash customers can have an optional Agricola x. Similarly, for GET requests of class customers want or define some query parameters, what you can do is, you can select query parameters. And let's say I want a query parameter called as name, customer name. I can define customer name and is it a mandatory one, I can specify required equals to false And what is a type of it here I can specify customer name as to be your string. And maybe I won't give a default value. Let's say default value is Siva and example I can do that also I can view everything these are all things which I can actually describe.

So like that I can define a number of query parameters also for a particular method, and also headers also you want it. So now what I want to do is I want to add headers for all other things and copy paste the document in 06 request Yep. So wherever possible headers are added as per the document like this. Okay, then what? I want to add caching related headers. So let me open this 07 and I'll show you how to add caching little headers.

So here is the one caching related headers. Let's see. fee for GET request in the response 200. I want to specify that there will be caching with current headers like cache control x class, etc. Just copy paste the same thing. So we configured some headers as well, like accept the request header, and in response, cache control headers, how to specify.

Here I'm specifying the expires is of type, date time. Is it like that? Step we have decided what will request response headers and we can create a document instead. So as a next step, we'll see how to define our own custom data types. In the next video, see you next video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.