Para isso precisamos seguir 3 passos:
- Acesse o 3scale Admin Portal e crie o seu primeiro serviço
- Customize o Developer Portal
- Integre a sua API com o 3Scale usando o API Gateway
Antes de provisionar o API gateway on-premise, você deverá verificar o seguinte na sua conta 3Scale.
- 3scale Domain
-
Você precisa saber qual é o domínio da sua conta 3Scale SaaS.
-
O 3Scale domain é referenciado na URL do seu portal administrativo do 3Scale SaaS, ex: ie: https://<YOURDOMAIN>-admin.3scale.net/p/admin/dashboard.
-
-
Login no portal de administração http://<YOURDOMAIN>-admin.3scale.net
-
Caso seja a primeira vez que você acessa o portal 3scale, clique em activate da sua caixa de email, agora feche o wizard clicando no X na parte superior na direita da sua tela
-
A primeira página que você verá é a página de API. Daqui podemos criar a nossa API. Clique no link
Integration
-
Clique em
edit integration settings
para editar as configurações da API para o gateway -
Selecione a opção APIcast como opção para deploy do Gateway.
-
Mantenha API Key (user_key) Authentication
-
Clique em Update Service
-
Clique no botão add the Base URL of your API and save the configuration
-
Expanda a seção mapping rules que define os métodos (HTTP) que serão expostos por essa API
Nota: O mapeamento padrão é root ("/") of our API resources, something that we might want to avoid.
-
Clique em Metric or Method (Define)
-
Clique em New Method na seção Methods
-
Preencha as informações
Friendly name:
Get Customers
System name:
customers_all
Description:
Method to return all customers
-
Clique em Create Method
-
Optional: Adicione o método
Get Customer
caso você tenha feito as intruções para implementar a busca do customer por{id}
. Então nomeie paracustomer_get
-
Clique em Add mapping rule
-
Clique para editar este mapping rule
-
Insira
/customers
para o Pattern -
Selecione
customers_all
como Method -
Optional:: Clique no botão Add Mapping Rule para adicionar o
customer_get
como method mapping. -
Preencha as informações para acessar sua API:
Private Base URL:
http://camel-ose-springboot-xml-workshop-user-16.apps.ocp.rhbrlab.com:80
Note: Nós estamos utilizando um serviço de API interno porque estamos utilizando tudo dentro do mesmo cluster Openshift
-
Mais abaixo clique em API Test GET request
-
Informe
/api/customers
-
Clique em Update the Staging Environment para salvar as alterações e clique em Back to Integration & Configuration para voltar para página das integrações
-
Clique no botão Promote v.1 to Production para promover suas configurações de homologação para produção
-
Pronto! Agora a sua camada de gerenciamento de API só irá permitir que chamadas autenticadas cheguem até o seu backend de APIs (Fuse).
The focal point of your developers’ experience is the API developer portal, and the level of effort you put into it will determine the level of decreased support costs and increased developer engagement. 3scale provides a built-in, state-of-the-art CMS portal, making it very easy to create your own branded hub with a custom domain to manage developer interactions and increase API adoption.
You can customize the look and feel of the entire Developer Portal to match your own branding. You have complete control over every element of the portal, so you can make it as easy as possible for developers to learn how to use your API.
The Developer Portal's CMS consists of a few elements:
- Horizontal menu in the Admin Portal with access to content, redirects, and changes
- The main area containing details of the sections above
- CMS mode, accessible through the preview option
Liquid is a simple programming language used for displaying and processing most of the data from the 3scale system available for API providers. In the 3scale platform, it is used to expose server-side data to your API developers, greatly extending the usefulness of the CMS while maintaining a high level of security.
-
Click on the
Developer Portal
tab to access the developer portal settings. -
Click on the
Visit Developer Portal
to take a look of how your developer portal looks like.You can see there is a default portal with information of your API and how to signup. Unfortunately the API information is incorrect.
Note: We will edit our portal to update it with the correct information and to add the shadowman cool logo.
-
Go back to your admin portal browser tab and search the content sub-sections for the
Layouts
and select the</> Main layout
-
First look for the
navbar
section of the main HTML. Replace the{{ provider.name }}
for the shadowman image link:<img src="https://www.redhat.com/profiles/rh/themes/redhatdotcom/img/logo.png" alt="{{ provider.name }}">
-
Click on
Publish
button at the bottom of the editor to save the changes and made them available in the site. -
Go back to browse the top of the content sub-sections and find the
Homepage
section. -
Change all the code
Echo
references in the homepage code forCustomer
. -
Update the API call examples to reflect your real Fuse API calls.
Note: Use your production base url and add your defined methods. Dont worry if you don't have the "real" output, it won't affect the rest of the lab.
-
Refresh your Developer Portal's browser tab to check the changes. Your Developer Portal should look like this:
-
Take the place of one of your developers and signup for the Basic plan.
-
Fill in your information and your email to register as a developer. Click on the
Sign up
button.Note: Use an email address you can actually access.
-
Check your email and click on the
activate
link. -
As your portal is not currently public, you will need your portal code to finish the registration. You can get the code in your admin portal navigating to:
Settings > Developer Portal > Domains & Access
. -
Type your portal code to finish the account activation.
-
Now that your developer account is active, sign in the portal.
-
You will land in the developers homepage, where you will be able to check your developers settings and retrieve your
User Key
.Note: Copy down this key as it is used to authenticate yourself to the managed API.
Agora teste as chamadas para sua api através do API Management.