{{announcement.body}}
{{announcement.title}}

Build an API Using AWS API Gateway and Dell Boomi — Step 1

DZone 's Guide to

Build an API Using AWS API Gateway and Dell Boomi — Step 1

Step by step guide to creating an API using AWS API Gateway along with Dell Boomi for the HTTP service provider.

· Integration Zone ·
Free Resource

Introduction

Hi All, I hope you all had a long amazing 4th of July in the United States and a nice weekend everywhere else. Today, I thought, let me write a blog on a new technology, something that I have not written before in this platform or anywhere else. So, today, we will look into a step by step guide to creating an API using AWS API Gateway along with Dell Boomi for the HTTP service provider. Once again, I may take baby steps, if you are already aware of certain steps, and want to skip some steps, feel free to do so.

I will build an API on a couple of tables in Maria DB. You can use any other backend of your wish with your changes. For simplicity, I will split this blog into 2 parts, first part describing steps to create API in Dell Boomi and second part describing to connect the Boomi API with AWS API Gateway.

So, without any further ado, let us get started with the API building.

Prerequisites

  • Amazon AWS Account to build an API in AWS API Gateway. Take a close look at your AWS account to make sure you are not incurring charges.
  • Dell Boomi Platform
  • A backend Maria DB Server.
  • Understanding of YAML is good but not necessary.

Step 1: Define the API Contract using Open API Specification.

With the API First building approach, the first step in building an API is to create the contract. So, we will take our first step in building the API contract using Open API Specification in Swagger 2.0 format. We would use swagger 2.0 instead of the newer version of OAS 3.0 because this is recognized by both AWS and Dell Boomi.

You can write Swagger in various tools like Atom etc., but there is a website that is available and can be used for this case. We would use this website https://editor.swagger.io/ to build our API. So, you can open this website and there will already be a Swagger Petstore API example present over there. You may delete this and start creating your API here.

Following is the API Definition that I will use. Let us have 2 endpoints. One called /job and the other called /employee. I will create 4 Json in the example folder 2 objects and 2 arrays for each type. 

YAML
 




x
237


 
1
swagger: '2.0'
2
info:
3
  title: AWS & Boomi Demo Database API
4
  description: "This API is only meant for learning and cannot be used in any other way."
5
  version: '1.0'
6
host: 'localhost:8081'
7
basePath: /api/
8
schemes:
9
  - https
10
consumes:
11
  - application/json
12
produces:
13
  - application/json
14
 
          
15
tags:
16
- name: "employee"
17
  description: "Everything about Employee"
18
  externalDocs:
19
    description: "Find out more"
20
    url: "http://www.wedointegration.com"
21
- name: "jobs"
22
  description: "Everything about Jobs"
23
  externalDocs:
24
    description: "Find out more"
25
    url: "http://www.wedointegration.com"
26
 
          
27
definitions:
28
    employee:
29
      type: object
30
      properties:
31
        empId:
32
          minLength: 5
33
          type: string
34
        nationalIDNumber:
35
          minLength: 9
36
          maxLength: 9
37
          type: string
38
        eName:
39
          type: string
40
        addressLn:
41
          type: string
42
        addressCity:
43
          type: string
44
        addressZIP:
45
          type: string
46
        addressState:
47
          type: string
48
        addressCountry:
49
          type: string
50
        phone:
51
          type: string
52
        gender:
53
          enum:
54
            - Male
55
            - Female
56
          type: string
57
        birthDate:
58
          type: string
59
          format: date
60
      required:
61
        - empId
62
        - nationalIDNumber
63
        - eName
64
        - addressLn
65
        - addressCity
66
        - addressZIP
67
        - addressState
68
        - addressCountry
69
        - phone
70
        - gender
71
        - birthDate
72
    job:
73
      type: object
74
      properties:
75
        jobCode:
76
          type: string
77
        jobTitle:
78
          type: string
79
        jobDescription:
80
          type: string
81
        minQualification:
82
          type: string
83
        empClass:
84
          type: string
85
        minSalary:
86
          type: number
87
        maxSalary:
88
          type: number
89
        flsaStatus:
90
          type: string
91
      required:
92
        - jobCode
93
        - jobTitle
94
        - jobDescription
95
        - minQualification
96
        - empClass
97
        - minSalary
98
        - maxSalary
99
        - flsaStatus
100
    success:
101
      type: object
102
      properties:
103
        status:
104
          type: string
105
    badAuth:
106
      type: object
107
      properties:
108
        error:
109
          type: string
110
        description:
111
          type: string
112
    internalError:
113
      type: object
114
      properties:
115
        error:
116
          type: string
117
        description:
118
          type: string
119
 
          
120
paths:
121
  /employee:
122
    post:
123
      description: Create new Employee
124
      tags:
125
      - "employee"
126
      operationId: postEmployee
127
      parameters:
128
        - in: header
129
          name: x-api-key
130
          type: string
131
          required: true
132
        - in: body
133
          schema:
134
            $ref: '#/definitions/employee'
135
          name: body
136
          required: true      
137
      responses:
138
        201:
139
          description: 'Successful'
140
          schema:
141
            $ref: '#/definitions/success'
142
        403:
143
          description: Authentication error response.
144
          schema:
145
            $ref: '#/definitions/badAuth'
146
        500:
147
          description: Error response to indicate internal API error.
148
          schema:
149
            $ref: '#/definitions/internalError'
150
 
          
151
  /employee/{empId}:
152
    get:
153
      tags:
154
      - "employee"
155
      description: Get employee with employee Id.
156
      operationId: getEmployee
157
      parameters:
158
        - in: header
159
          name: x-api-key
160
          required: true
161
          type: string
162
        - in: path
163
          name: empId
164
          required: true
165
          type: string  
166
      responses:
167
        200:
168
          description: 'Employee Data'
169
          schema:
170
            $ref: '#/definitions/employee'
171
        403:
172
          description: Authentication error response.
173
          schema:
174
            $ref: '#/definitions/badAuth'
175
        500:
176
          description: Error response to indicate internal API error.
177
          schema:
178
            $ref: '#/definitions/internalError'
179
  /job:
180
    post:
181
      tags:
182
      - "jobs"
183
      description: Create new Job
184
      operationId: postJob
185
      parameters:
186
        - in: header
187
          name: x-api-key
188
          type: string
189
          required: true
190
        - in: body
191
          schema:
192
            $ref: '#/definitions/job'
193
          name: body
194
          required: true      
195
      responses:
196
        201:
197
          description: 'Successful'
198
          schema:
199
            $ref: '#/definitions/success'
200
        403:
201
          description: Authentication error response.
202
          schema:
203
            $ref: '#/definitions/badAuth'
204
        500:
205
          description: Error response to indicate internal API error.
206
          schema:
207
            $ref: '#/definitions/internalError'
208
 
          
209
 
          
210
  /job/{jobCode}:
211
    get:
212
      tags:
213
      - "jobs"
214
      description: Get Job by Job Code.
215
      operationId: getJob
216
      parameters:
217
        - in: header
218
          name: x-api-key
219
          required: true
220
          type: string
221
        - in: path
222
          name: jobCode
223
          required: true
224
          type: string  
225
      responses:
226
        200:
227
          description: 'Employee Data'
228
          schema:
229
            $ref: '#/definitions/job'
230
        403:
231
          description: Authentication error response.
232
          schema:
233
            $ref: '#/definitions/badAuth'
234
        500:
235
          description: Error response to indicate internal API error.
236
          schema:
237
            $ref: '#/definitions/internalError'


 

On completing this Swagger, you should be able to see all the endpoints in the tool. It would look something like this.

aws & boomi

Step 2: Build the API Scaffolder in Dell Boomi

 Now, let us build our backend API in Dell Boomi. We would head over to https://platform.boomi.com and go into the Integration page. Now to keep my project organized, I would create a folder in the platform. I will name it as MariaDB-API. Next, I will create one component which is needed to import our API. We should create an HTTP Client in our Folder and name it as HTTP Client.

create component

We will not fill up anything now and just save this Component by clicking Save and Close.

Next, we will create another component of type API and call it MariaDB-API. We will fill up the title description and version based on our details in the swagger file.

api service config Now we should move to the REST tab and click Help Me Create an Endpoint button and then select Import from an external service file. They should allow us to import the swagger file that we have already created. For process location, we have to select the folder we are using. On the next page, we will select the HTTP client component that we created earlier. let us continue with the Process Mode as General. We can now see that all the endpoints we defined earlier in our swagger file are now available. We will select all of them and click on Next.

Description automatically generated

We can validate the summary with all the information and click on next to finish creating all the necessary components. We will find a bunch of components that will be created along with some Connectors, operations, JSON profiles, and some processes corresponding to all our various endpoints. We should make sure to save the API itself.

rest configuration

At this stage, I will go over each endpoint and remove the client ID and Client Secret parameters from the Boomi API. This is because we will authenticate the Boomi API using a basic authentication which we will see later.

Step 3: Connect to our Database Backend.

Now, we will complete the backend Database connectivity to getJob processes. We would have to repeat the same for the getEmployee process as well. From the component explorer, we would click on the getJob process and add a Database Connector Component. connector component

 First, we will create a connection. To do that we will click on the + button beside the connection option. For the driver type, we will select MySQL and then fill up username, password, host, port, and database them respectively with our database details. Finally, we will click save and close.

database connection

Next, we will create a new operation. To do that we will click the + button beside the operation Option. I will change the name of the operation as getJob and then create a new database Profile by clicking the + button in the Profile field. We will change the name of the profile as getJob. Now we will click the Import button, select Use Boomi cloud in the Browse in field and the connection we previously created in the Connection field, then we will click next. we should see all the tables in our database being populated here. I will choose the job table and click next. I will select all the fields present in the table and click next again and finally click Finish.

Since we only want one job details based on the job code we will add a parameter in the query with the where clause and I will add one parameter called job code of type characters. statement details

We will arrange all the components in my process and bind the parameter in the Database Operation to the Dynamic Process Property called param_jobCode. connector shape

We also have to map the database profile to the response JSON profile, right? We will add a map shape and select the getjob Database Profile as a source and getJob-Response JSON profile as the target. The field names should match so it should be a one to one mapping and Boomi Suggest will do it for us. getjob

Now we will try to test this HTTP Service to check if we can retrieve the data. 

Step 4: Deploy Our Process

Our next step is to deploy all the processes that we have created into an Atom so that we can Call these HTTP endpoints and check if our service is working as expected. We should click on Create Packaged Component button on the top of the process window and then we should select all the processes and the API which is present in your folder and create a package component. 

deployments

Finally, we have to deploy our package component in an Atom. In my case, I am using a test Atom cloud.

select environment

After deployment Is complete, we can check the deployment status to see if all the components are successfully deployed. 

deployments

Step 5: Set up the Shared Web Server

The Shared Web Server panel appears on the Atom Management page (Manage > Atom Management). This panel is used to configure the selected Atom’s web server settings for web service publishing. The important property we need to change is API Type. We have to change it to Advanced instead of Basic or Intermediate.

API type

Next, we should move over to the user management tab and create a new user to authenticate to our API from the HTTP Client.

That should be it. Now we need to go to our favorite HTTP client like postman and test our API. We need to keep in mind that for now only Get job API is working.  

authorization

Step 6: Code for POST Job

Let us now get back to the Build tab in the Boomi platform and built the process postJob. Similar to the getJob process we will have to add a database connector and create a database profile for postJob.

connector shape

We will reuse the existing MariaDB connection and create a new operation. We will name our operation as postJob and create a database profile. For the database profile, we will use the Type Dynamic Insert and import our database table the same way we did it for the get job profile.

We will save and close each component that we have created and then add a map shape into our process. this map ship will convert the JSON profile into a database profile. Once again, the field names should be the same and hence there will be a one to one mapping.

postjob

We will also manually create a JSON profile named success – Response. This will have only one field called status and we will use this as a response to our post HTTP endpoints.

postjob

After creating this response JSON profile, we should go to our API Service MariaDB-API, manually edit the endpoints postJob and postEmployee.

Here we need to scroll down and change the Handling of Endpoint Responses to add the success-Response JSON profile as single Jason object.

endpoint requests 

We will use a branch shape to create a second branch and map to the success response since the database connection does not create any data and hence that branch will not continue. postjob

We can now test our Endpoint from Postman to see that data would be created in the backend Maria DB System.

maria db

As we can see in the phpMyAdmin console our data is visible in the database table.

MyAdmin

Step 7: Repeat the Above Steps for the Employee API

We would have to repeat the above steps for the getEmployee and postEmployee respectively. Once complete, we will continue in the next blog where we will integrate the AWS API Gateway with the Dell Boomi processes. You can find the blog in Build an API using AWS API Gateway and Dell Boomi - Step 2.

Thank you for going through my blog and please feel free to let me know what you think about this blog.

Topics:
api, api contract, integration, open ap, yaml

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}