Working in WSO2 Cloud Team was capable of putting me through events which I wondered what should I do now ? Specially while in Cloud Support. Once there was an issue (L1) we got reported that API Statistics are not visible on WSO2 API Manager. Oh great by this time I was not much of an expert in this area and I was like HOW ?
WSO2 API Cloud uses WSO2 APIM 1.10 and DAS 3.0.1 by that time was and I knew that DAS is working in a cluster which has two receivers, analyzers and indexers. It wasn't hard to realize that DAS analyzers aren't having required raw data stored for the time being. HOw to check whether API Gateway is publishing data to das analyzers ? Here is what was suggested to me from a DAS team member to check whether data is getting published to das receiver node. Here what I used was a adding an Output logger event adapter [1] to the Input stream that I wanted to check whether the data is getting published to DAS receiver nodes.
1. Login to DAS management console
2. Go to Main -> Event -> Publishers -> Add event publisher
3. On the Create a New Event Publisher add the Event Publisher Name and select the Event stream which needs to be logged from Event Source
4. Then from Output Event Adapter Type select logger as the value and click Add Event Publisher.
5. You will see a message Event publisher added successfully and the added Event publisher will be visible on Available Event Publishers.
6. Start publishing to the stream and you will see logs getting printed on <DAS-HOME>/repository/logs/wso2carbon.log
[1] https://docs.wso2.com/display/CEP300/Output+logger+Event+Adapter
Showing posts with label WSO2. Show all posts
Showing posts with label WSO2. Show all posts
Friday, June 17, 2016
Saturday, June 11, 2016
Deleting Admin users from your organization in WSO2 Cloud
Currently in WSO2 Cloud the Organization owners can add multiple Admin users to his organization. It is a common scenario that some people leave the organizations and if he is an admin of your organization you should remove the Admin from the organization.
In current implementation of WSO2 Cloud you are not able to delete an Admin through the Members page. As you can notice on the below image the users with Admin Role doesn't have the check box in front of them. Therefore we are not able to edit or delete the specific Admin from the organization directly.
In order to delete them the Organization owner (The creator of the organization on WSO2 Cloud) should revoke the Amin role from the user. This is not provided through WSO2 Cloud UI directly. Here is how you can achieve this.
1. You can log in to WSO2 Cloud management console using the steps described in
https://docs.wso2.com/display/APICloud/FAQ#FAQ-HowcanIlogintotheCloud'sManagementConsole?
2. On the left menu of management console go to Main -> User and Roles -> List -> Users. This will list out the Users in your organization.
3. Select the preferred user with Admin role and select View Roles and remove the admin role from that user privileges from that user and update.
4. Afterwards log out of the management console and re login through cloud ui and go to members page. You will see the check box in front of the particular user will be enabled and you will be able to delete the user (Due to caching on server side it will take some time for the changes to be depicted on UI).
* Note that you must not delete the user through management console since there are records which are not getting deleted for the user which is explicitly used in for WSO2 Cloud data in the front end. Therefore you should delete the user through UI after removing the role.
In current implementation of WSO2 Cloud you are not able to delete an Admin through the Members page. As you can notice on the below image the users with Admin Role doesn't have the check box in front of them. Therefore we are not able to edit or delete the specific Admin from the organization directly.
In order to delete them the Organization owner (The creator of the organization on WSO2 Cloud) should revoke the Amin role from the user. This is not provided through WSO2 Cloud UI directly. Here is how you can achieve this.
1. You can log in to WSO2 Cloud management console using the steps described in
https://docs.wso2.com/display/APICloud/FAQ#FAQ-HowcanIlogintotheCloud'sManagementConsole?
2. On the left menu of management console go to Main -> User and Roles -> List -> Users. This will list out the Users in your organization.
3. Select the preferred user with Admin role and select View Roles and remove the admin role from that user privileges from that user and update.
4. Afterwards log out of the management console and re login through cloud ui and go to members page. You will see the check box in front of the particular user will be enabled and you will be able to delete the user (Due to caching on server side it will take some time for the changes to be depicted on UI).
* Note that you must not delete the user through management console since there are records which are not getting deleted for the user which is explicitly used in for WSO2 Cloud data in the front end. Therefore you should delete the user through UI after removing the role.
Saturday, January 2, 2016
WSO2 API Manager Using custom headers via swagger ui
Due to various reasons most of the back end APIs are expecting headers which are not allowed by the default CORS Handler used in WSO2 API Manager. Due to the restrictions by CORS Handler while invoking APIs with custom headers fail if we use the swagger UI. This is due to the OPTION call sent to API gateway from publisher to get the allowed header types (if we are using curl or other api clients this doesn't fail because we don't us the OPTION call in it).
List down below is how to add a custom header on WSO2 API Manager and make it usable via swagger UI.
1. Start creating an API according to [1]
2. Click on EDIT Source in the step 3 provided in the tutorial
add the following swagger file to the swagger file and save
paths:
/weather:
post:
x-auth-type: "Application & Application User"
x-throttling-tier: Unlimited
parameters:
- schema:
type: object
description: Request Body
name: Payload
required: false
in: body
- name: ActionHeader
description: The Header
type: string
required: false
in: header
- name: q
type: string
required: false
in: query
- name: appId
type: string
required: false
in: query
responses:
"200": {}
get:
x-auth-type: "Application & Application User"
x-throttling-tier: Unlimited
parameters:
- name: ActionHeader
description: The Header
type: string
required: false
in: header
- name: q
type: string
required: false
in: query
- name: appId
type: string
required: false
in: query
responses:
"200": {}
swagger: "2.0"
info:
title: HeaderTutorial
version: v1
Note that following block adds the ActionHeader as a header parameter to the resource.
- name: ActionHeader
description: The custom Header
type: string
required: false
in: header
3. Then continue with the step 5 in tutorial.
4. After successfuly publishing the API you can subscribe to it through API store and invoke the API. When API is invoked you can find that below type of error message is vibile on the swagger console.
5. The above happens because the ActionHeader is not allowed in the CORS Configuration. In order to allow it first stop the running API Manager Instance
6. Open <APIM HOME>/repository/conf/api-manager.xml
7. Add the ActionHeader value to <Access-Control-Allow-Headers> under <CORSConfiguration>tag as follows
After the adding the value the Access-Control-Allow-Headers should like following
<Access-Control-Allow-Headers>authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction,Authorization,ActionHeader</Access-Control-Allow-Headers>
8. Save the file and restart API Manager
9. Invoke the api using the swagger UI you will find the API getting successfully invoked now.
The below video tutorial show the steps of how to achieve this
[1] https://docs.wso2.com/display/AM191/Create+and+Publish+an+API
List down below is how to add a custom header on WSO2 API Manager and make it usable via swagger UI.
1. Start creating an API according to [1]
2. Click on EDIT Source in the step 3 provided in the tutorial
add the following swagger file to the swagger file and save
paths:
/weather:
post:
x-auth-type: "Application & Application User"
x-throttling-tier: Unlimited
parameters:
- schema:
type: object
description: Request Body
name: Payload
required: false
in: body
- name: ActionHeader
description: The Header
type: string
required: false
in: header
- name: q
type: string
required: false
in: query
- name: appId
type: string
required: false
in: query
responses:
"200": {}
get:
x-auth-type: "Application & Application User"
x-throttling-tier: Unlimited
parameters:
- name: ActionHeader
description: The Header
type: string
required: false
in: header
- name: q
type: string
required: false
in: query
- name: appId
type: string
required: false
in: query
responses:
"200": {}
swagger: "2.0"
info:
title: HeaderTutorial
version: v1
Note that following block adds the ActionHeader as a header parameter to the resource.
- name: ActionHeader
description: The custom Header
type: string
required: false
in: header
3. Then continue with the step 5 in tutorial.
4. After successfuly publishing the API you can subscribe to it through API store and invoke the API. When API is invoked you can find that below type of error message is vibile on the swagger console.
5. The above happens because the ActionHeader is not allowed in the CORS Configuration. In order to allow it first stop the running API Manager Instance
6. Open <APIM HOME>/repository/conf/api-manager.xml
7. Add the ActionHeader value to <Access-Control-Allow-Headers> under <CORSConfiguration>tag as follows
After the adding the value the Access-Control-Allow-Headers should like following
<Access-Control-Allow-Headers>authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction,Authorization,ActionHeader</Access-Control-Allow-Headers>
8. Save the file and restart API Manager
9. Invoke the api using the swagger UI you will find the API getting successfully invoked now.
The below video tutorial show the steps of how to achieve this
[1] https://docs.wso2.com/display/AM191/Create+and+Publish+an+API
Adding a Tenant Specific Custom Handler WSO2 API Manager
Writing a Handler for WSO2 API Manager is pretty straight forward and you can find it in [1]. When it comes to multi tenancy there might be instances that this particular handler should be applied only to a specific tenant or a set of tenants. In doing so we have to edit the /repository/resources/api_templates/velocity_template.xml to include the handler to only a specific tenant. This is the template file used in WSO2 API Manager to create synapse file required to create the api. Here we have to write a simple velocity logic to add the handler only for the specific tenants. If this logic is not added the handler will be applied to all the tenant hence resulting in a performance tradeoff.
You can add the below logic right after the handlers tag in the velocity_template.xml
#if ( $apiContext.contains("/abc.com/") )
<handler class="package.path.to.class" />
#end
This will add the handler to the abc.com tenant only. You can also extend this to multiple tenant with having a logical OR "||" operator for the contains check.
Just write and save the file and will be added to the template.
[1] https://docs.wso2.com/display/AM191/Writing+Custom+Handlers
You can add the below logic right after the handlers tag in the velocity_template.xml
#if ( $apiContext.contains("/abc.com/") )
<handler class="package.path.to.class" />
#end
This will add the handler to the abc.com tenant only. You can also extend this to multiple tenant with having a logical OR "||" operator for the contains check.
Just write and save the file and will be added to the template.
[1] https://docs.wso2.com/display/AM191/Writing+Custom+Handlers
Subscribe to:
Posts (Atom)