Create Operation for External REST in Visual Builder Cloud Service
Oracle Visual Builder Cloud Service allows users to expose external REST services as custom business objects through Business Object Provider(BOP) templates, which enable users to manage the VBCS interactions with external data using REST CRUD operations.
In a previous blog my colleague Shay Shmeltzer detailed how to configure BOP to read repository data from GitHub REST APIs in VBCS. This blog will serve as an extension to the earlier blog and highlight the process to configure create operation in VBCS in order to create new repositories in GitHub using the Create Repository REST API https://api.github.com/user/repos
For the purpose of the blog the GitHub BOP was been configured to read name and description of repositories and subsequently allows to users to create new repository by giving a name and a description on a Create page. This BOP uses reduced set of properties owing to the fact these are the minimal set of attributes required to create a new repository in GitHub. The EntityProvider snapshot highlights the configuration of Repository Entity with fields- name, which acts as a key, and description.
Now modify the Operations Provider to configure Read and Create operations for the Repository Entity as shown in the code
Notice that we have added the bop/js/api/operation/OperationInput api reference in the define block for the POST implementation.
The postUri variable corresponds to the GitHub Repository Create API
this._postUri = “https://api.github.com/user/repos";
The user has to create a Resource in order to add the API to the whitelist resources associated with the BOP at server side.
this._resources.push(
Resource.create({
id: ‘2’,
template: self._postUri,
entity: RESTOperationProvider.USER_ENTITY_ID
})
);
Just as the OperationBuilder required an Operation of Type READ , so the OperationBuilder requires the Operation of type CREATE
type: Operation.Type.CREATE
The implementation of the REST call is done through Operation.perform(..) method, and the REST call leverages the BOPAuthenticator in order to use the built in authentication mechanism provided by VBCS.
After configuring the BOP, click on Save Change and follow the steps given in the video below to verify the BOP and to visualize the Create operation in VBCS by creating a Business Object.
With this we have successfully configured a sample Business Object Provider with a Read and a Create Operation for repositories in GitHub.
To know more about Oracle Visual Builder Cloud Service visit the link https://cloud.oracle.com/ApplicationBuilder
The views expressed in this post are my own and do not necessarily reflect the views of Oracle.