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
€65.39
List Price:  €93.41
You save:  €28.02
£55.92
List Price:  £79.90
You save:  £23.97
CA$96.01
List Price:  CA$137.16
You save:  CA$41.15
A$107.15
List Price:  A$153.08
You save:  A$45.93
S$95.13
List Price:  S$135.90
You save:  S$40.77
HK$547.14
List Price:  HK$781.66
You save:  HK$234.52
CHF 63.86
List Price:  CHF 91.23
You save:  CHF 27.37
NOK kr775.40
List Price:  NOK kr1,107.76
You save:  NOK kr332.36
DKK kr487.78
List Price:  DKK kr696.86
You save:  DKK kr209.07
NZ$118.01
List Price:  NZ$168.60
You save:  NZ$50.58
د.إ257.06
List Price:  د.إ367.24
You save:  د.إ110.18
৳7,680.49
List Price:  ৳10,972.60
You save:  ৳3,292.11
₹5,842.03
List Price:  ₹8,346.11
You save:  ₹2,504.08
RM332.86
List Price:  RM475.54
You save:  RM142.67
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,491.96
List Price:  ₨27,846.85
You save:  ₨8,354.89
฿2,586.09
List Price:  ฿3,694.58
You save:  ฿1,108.48
₺2,265.39
List Price:  ₺3,236.41
You save:  ₺971.02
B$363.53
List Price:  B$519.35
You save:  B$155.82
R1,302.64
List Price:  R1,861
You save:  R558.35
Лв127.90
List Price:  Лв182.73
You save:  Лв54.82
₩96,270.48
List Price:  ₩137,535.16
You save:  ₩41,264.67
₪262.29
List Price:  ₪374.71
You save:  ₪112.42
₱4,033.94
List Price:  ₱5,763.02
You save:  ₱1,729.07
¥10,867.12
List Price:  ¥15,525.12
You save:  ¥4,658
MX$1,187.12
List Price:  MX$1,695.96
You save:  MX$508.84
QR254.93
List Price:  QR364.20
You save:  QR109.27
P994.08
List Price:  P1,420.18
You save:  P426.09
KSh9,360.69
List Price:  KSh13,372.99
You save:  KSh4,012.30
E£3,358.63
List Price:  E£4,798.26
You save:  E£1,439.62
ብር4,003.77
List Price:  ብር5,719.92
You save:  ብር1,716.15
Kz58,546.63
List Price:  Kz83,641.63
You save:  Kz25,095
CLP$67,216.99
List Price:  CLP$96,028.39
You save:  CLP$28,811.40
CN¥506.70
List Price:  CN¥723.89
You save:  CN¥217.19
RD$4,073.53
List Price:  RD$5,819.58
You save:  RD$1,746.04
DA9,418.34
List Price:  DA13,455.35
You save:  DA4,037.01
FJ$158.31
List Price:  FJ$226.17
You save:  FJ$67.86
Q543.96
List Price:  Q777.12
You save:  Q233.16
GY$14,650.29
List Price:  GY$20,929.88
You save:  GY$6,279.59
ISK kr9,815.39
List Price:  ISK kr14,022.59
You save:  ISK kr4,207.20
DH707.71
List Price:  DH1,011.06
You save:  DH303.35
L1,237.78
List Price:  L1,768.33
You save:  L530.55
ден4,025.24
List Price:  ден5,750.59
You save:  ден1,725.35
MOP$563.96
List Price:  MOP$805.69
You save:  MOP$241.73
N$1,304.33
List Price:  N$1,863.42
You save:  N$559.08
C$2,570.38
List Price:  C$3,672.13
You save:  C$1,101.75
रु9,397.27
List Price:  रु13,425.24
You save:  रु4,027.97
S/263.43
List Price:  S/376.35
You save:  S/112.91
K270.11
List Price:  K385.89
You save:  K115.77
SAR262.49
List Price:  SAR375.01
You save:  SAR112.51
ZK1,873.89
List Price:  ZK2,677.10
You save:  ZK803.21
L325.37
List Price:  L464.84
You save:  L139.46
Kč1,643.47
List Price:  Kč2,347.91
You save:  Kč704.44
Ft25,458.03
List Price:  Ft36,370.18
You save:  Ft10,912.14
SEK kr764.90
List Price:  SEK kr1,092.76
You save:  SEK kr327.86
ARS$61,327.27
List Price:  ARS$87,614.14
You save:  ARS$26,286.87
Bs483.57
List Price:  Bs690.85
You save:  Bs207.27
COP$273,218.78
List Price:  COP$390,329.27
You save:  COP$117,110.49
₡35,710.66
List Price:  ₡51,017.42
You save:  ₡15,306.75
L1,733.65
List Price:  L2,476.75
You save:  L743.09
₲524,442.73
List Price:  ₲749,236.02
You save:  ₲224,793.28
$U2,683.09
List Price:  $U3,833.15
You save:  $U1,150.06
zł283.24
List Price:  zł404.64
You save:  zł121.40
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.