Skip to content

Add data source to the wizard

Ruben Fricke edited this page Apr 21, 2021 · 2 revisions

Add a data source to the wizard

The wizard is a crucial part of DeX. Our users can use this system to automatically import projects from external data sources. It's important that we should be able to add new data sources when we realize there is a need to add a new data source. So, how do we achieve this?

By following this guide, you will be able to add easily a new data source to the system, so the users can immediately start using this without having to update anything else.

Guide

  1. It's important to start doing research on the existing external API. Make sure you validate what flow this API supports (Oauth and/or public). The Oauth flow is whenever you have to log in and with the public flow you do not have to log in, but you can't retrieve any private projects.
  2. Create a new data source adaptee interface and class in the service layer. The class should the interface and the interface should inherit the IPublicDataSourceAdaptee and/or the IAuthDataSourceAdaptee. You have to add the first adaptee interface if the public flow is supported and you should add the second adaptee interface if the Oauth flow is supported.
  3. Create resource results in the service layer for the external API you call. Every API will return their specific data. This data should get mapped to an object so we can use this data in the created adaptee.
  4. Create the API calls in the adaptee. Every API call should be in its own method and this method should be in the interface from your adaptee. So for example, I would like to create an API call to the Github API to retrieve a repository. I have to make a method to make this call and I have to add this method to the IGithubDataSourceAdaptee interface. The other methods that come from the IPublicDataSourceAdaptee interface and IAuthDataSourceAdaptee manage what API calls should be called. So, for example, to retrieve a project, sometimes multiple API calls should be made. This method should call multiple methods and combine the data to return a full project.
  5. If your data source supports the OauthFlow, you should also update the app settings. In this file, the client id and client secret are stored. Make sure you retrieve these keys and store them (temporary) in this file. Make sure you don't push these keys to Github.