[MUSIC] In this module, we're going to create an API. We're going to begin with an API description and we'll load that into API gateway. And then we'll use that description to create a Mock Deployment. But before we do that, let's go ahead and talk about what this entails. Key element of creating an API is to be able to prototype that API. But we can create a description of the API. Ultimately we're going to implement that API by creating a web service. However, that web service may not immediately be available after we've designed our API. Often times a team has to come and implement that web service on the back end in parallel with the team that's using the API on the front end. So what we can do is use the API gateway. By loading our description into API gateway, we can very quickly create a stock response deployment in API gateway. API gateway will serve the API. It will return the example response for clients invoking that API. This is also useful to be able to test that API to validate that it is meeting the requirements for the project. Once the back end web services implemented, then that can be connected in API gateway to serve the ultimate requests. So to create and prototype and API, you create an open API description and you can use any tool that you wish. You can load this into your API gateway, then you can deploy the API. An API gateway will automatically define it as a stock response and use your example in your open API description. Then you can test it out with your client. Let's go into API Gateway, we'll build an API description loaded into API Gateway, deploy it as a stock response, and test it out. Here we are in the OCI Console will navigate over to API Gateway under developer services, API management, and will choose APIs. APIs represent a repository of API descriptions. I'm going to go into an existing compartment and we can see someone that we already have loaded. We can support both open API 2.0 and open API 3.0 definitions. So this is an example of one such definition that we have loaded. What I'm going to do is go ahead and work on one of these APIs or show how we might be able to edit one of these APIs. Very simple, there's many tools on the market. One such tool as Swagger editor, I pulled this up in my web browser and I have an API definition. But you can see here is this is a fieldService API, a sample ticketing system. So in this API we have a definition of services such as to get tickets. It includes information about the required parameters for the service. It also includes some example data that can be used for generating samples. So what we're going to do is we're going to deploy this or load this into API gateway. So within the API gateway, I'm going to choose my compartment that I want to work with. And I work with my L100 compartment now go to my development compartment. So what I'm going to do is I'm going to go ahead and create an API. And I'll call this field service. And what I'm going to do is I'm going to choose my file. So here's a copy of my API description. This was written with a file name of swagger.yaml. Swagger is old name that we used to call open API definitions. There's still swagger tools that we work with and that's what swagger now stands for today as swagger tools. Open API is the new term. So if it's open API 2.0, that's what was formerly called swagger. And if it's open API 3.0, that's the next format of open API. API Gateway does support both. In this particular file, I have opened API 2.0. So I've loaded this into API gateway. And a couple of things are happening. One is the API gateway is validating the file that I've loaded to make sure that it is semantically correct. And then what it will do, is it will create a predefined deployment object that can be used to quickly create API definitions for this API. So it's validated, and now the deployment specification is generated. So I'll go ahead and deploy this to a gateway. So I can choose deploy. And I can go ahead and choose my gateway. This is my L100 training gateway that I created. So I'll use that. I'll call his FieldService. And I'll give this a path prefix. So I'll just call this /fs/v1 and call it whatever I want. Now what I have here is a number of policies. And we'll get into detail with the different policies that we're going to be using. But what I'm going to do is I'm going to go ahead and add one necessary rule for a test client that I'm going to use in a moment. And I'll explain that shortly. So what I'm going to do is I'm going to go ahead and say I want to allow all origins. I want to allow all methods. And I'm going to allow loud header of x-api-key. This is a header that is included with that API definition. So I'm including that. This is to make a test client work that I'm going to use. There's many different test clients, many different ways, and I'll explain that as we go through. I'm going to go ahead and apply that change. I'm going to go to my next screen. What we can see here is there's a stock response that's automatically pre populated for us. This was the example that was within that definition. So when I load this into API Gateway, it automatically creates or pre populates my route for me. This is the method that I have defined which is just to get and of course this is a stock response. This can go against oracle functions or it can also go against http back ends. So I'm going to go ahead and create my API. This will take roughly about 30 seconds on average, 30 seconds or less to go ahead and create the deployment and we'll go ahead and test it. So in this case, what I'm going to do is, I'm going to copy the deployment and I'm going to go into my test client while it's playing. So I can come back here to swagger editor. There's two elements here that I've left not populated. And I'll go ahead and start populating these. So I'm just going to paste the end point that I have. And go ahead and make some changes. So here we have the host value and then we have the base path value. Which I'll go ahead and take these. And I'll put these in place in my file. And I'll go ahead and on comment these take out the to do. And I'll also take out the to do here at the base path, okay. So I have this created, this is said, and so what I can see here is in swagger editor, I have my code or my swagger file which is written in yaml. Could also be written in JASON. And then I have on my right hand side, dynamically generated documentation that includes a tester. So what I can do is go ahead and select this. And I'm just going to give us a API key, not doing anything with the API key right now, I'm just using a dissatisfied the request. So we see here as I've made the request, so it's called the service, and I've gotten a response. Now there's no back end service implemented, it's just within the gateway. And the gateway is returning a response. So what I can do is work with my team and I can work with my front end developers and my back end developers. And we can make sure that this the API definition is doing what we want. And as long as we're all comfortable with what's happening and the kind of the behavior, then what we can do is send the front end developer teams off to go build the front end apps. The back end developer teams can work on the back end developer apps, and then they can go ahead and tie the API gateway to the actual back end when they implement it. That's just for an example, I'm going to go ahead and copy this syntax here. And we'll go ahead and open up a terminal window. And if I were to paste this, what we should see of course is a return. Make this a little bit nicer. Let me see if I can get this as well. Let's go ahead and paste this. There you go. So I get that nice formatted that we can see here the response. So this is a live service. We can go ahead and call this start writing front end applications and work against the API. Now, this is one tool that I've shown with Swagger editor, you can use multiple tools. So like for example, we can go in the stoplight. We have this service here that we're working within. It's the same thing. All we're doing is just taking the file, the swagger file, or the open API definition, we're just loading it into our OCI, API Gateway. Another example just to call out real quick to kind of show how open everything is and how you can use different tools is we can go ahead and take this end point here. And we could go over to another popular tool called postman. So here I am in postman. And so what I can go ahead and do is create a new requests. I can go ahead and call the request here. Now what you'll notice is I'm not really doing anything with that API key, I'm not validating that API key yet. This is just a stock response that's giving me that response. So with this I've created an API description. I have loaded that API description, API Gateway. And I've gone ahead and created a deployment among stock response and tested it within my test clients. And so that's the demo.