How to access custom swagger vendor extensions in WSO2 API Manager - wso2

WSO2 Api Manager supports swagger vendor extensions (x- prefix). They are used internally to support throttling. How to access own vendor extensions from code (in Handlers or Mediators)? I couldn't find any vendor extensions registry, or they are not present in MessageContext.
{
"paths": {
"/": {
"post": {
"x-auth-type": "Application & Application User",
"x-throttling-tier": "Unlimited",
"x-mycustom-extension": "someValue", <-- How to get access to this?
"produces": [
"application/json"
],
"parameters": [
This is a fragment of swagger 2.0 spec (supported by WSO2 Api Manager). X-auth-type and x-throttling-tier are there already, but there is no way I can use my "x-mycustom-extension".

Related

The endpoint reference (EPR) for the Operation not found in WSO2 EI 6.6

I Created a DSS and exposed as a REST resource and it's working fine in Management Console try this service option, but while trying from the postman I get the following The endpoint reference (EPR) for the Operation not found error please help me to sort this out.
Postman Error
You are not setting a SOAPAction or Action header which is required. You can determine that header either based on the WSDL of the DSS, or from the example call that you make with Try This Service from the management console.
In default configuration, the DSS REST endpoint is exposed with address like:
http://{EI_ADDRESS}/services/{YOUR_DSS_SERVICE_NAME}.HTTPEndpoint/{REST_RESOURCE_PATH}
So your url doesn't point to REST resource.
Also sending data in POST to that DSS REST endpoint should be "wraped" in value object like:
{
"payload": {
"id": "10"
}
}

Amazon AWS IoT Core: sending an MQTT message via WebSocket from the browser

I'm building a webapp which should send and receive MQTT messages to and from IoT Core.
I read that Amazon AWS IoT Core does support MQTT over WebSocket so I created a test "thing", created an IAM user and attached a policy with full access to the IoT functions (connect, subscribe, send etc..).
The documentation says that the AWS SDK for JavaScript can be used in a browser environment:
So I created my webpp and imported the library
var awsIot = require('aws-iot-device-sdk');
But I get some errors:
Can't resolve 'path
Can't resolve 'fs'
Can't resolve 'tls
After searching online it seems that these libraries are only supported by node.js and not the browser.
It has to do with the fact that webpack has removed polyfills in their new version. You have to add code below to your webpack.config.js fallback location and install them of course.
Or you can switch into webpack v4.
module.exports = {
...
resolve: {
fallback: {
"fs": false,
"path":false,
"tls":false
},
}
}

How to get UUID for VMware VM in vSphere 6.5 Python vCenter API?

I'm trying to get UUID for the VMware VM using Python vCenter API.
I'm reading GET VM API doc here. which says It should be there in the response but when I run get API I don't get identity in the response. Anyone has any idea why it's not returning identity in the response payload?
"identity": {
"bios_uuid": "string",
"instance_uuid": "string",
"name": "string"
}
API I'm using https://{api_host}/rest/vcenter/vm/{vm}
The full name of that set of properties is "guest identity" which will also mean that VMware Tools are installed and running at the time of the call.

Moving .Net Core Web-API to AWS Web Api Gateway

I have a Web-API developed with .Net Core.It has few end points ( GET / POST ). The requirement is to move that to AWS API-Gateway. That Web-API is built using layered architecture, it has a business layer that talks to Db layer that got some entity framework repositories ( backend database Postgres). Now i have re-created my solution as a AWS Serverless solution ( using one of the template projects that comes with AWS Toolkit for visual studio).
The question is how to make my web api methods AWS API Gatway enabled ? I tried publishing my web-api to AWS as it is but its creating a blank api in api gateway ( Visual studio says successfully published), that means for some reasons, Api-Gateway cannot recognize my endpoint within my solution, and i think the reason is i don't know how to configure them properly and make them AWS-API Gateway enabled ...
The second question is
How the model binding will work in AWS API-GATEWAY. Should i use mapping template to implement model bindings or the built in .net core web api model binding will work and its sufficient ?
Following is an example Web API that is developed and needs to be deployed to AWS-API-Gateway
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace TestApi
{
[Route("api/testapi")]
public class TestApiController : Controller
{
private ITestApiManager testApiManager;
public TestApiController(ITestApiManager testApiManager)
{
this.testApiManager = testApiManager;
}
// GET: api/testapi/data/D-001
[HttpGet]
[Route("data/{param}")]
public IActionResult SomeMethod(string param)
{
// This method access busines layer which calls data access layer to get the data from postgress database using entity framework
}
// There are some more similar GET and POST methods in this api as well
}
}
ok i am answering my own question just incase if someone else is looking for same information. The reason my endpoints were not avaiable on API Gateway, my lambda handler was not fully qualified and i had to configure Proxy+ section in serverless.template file.
for your serverless.template file, check the Resources > AspNetCoreFunction > Handler property. It should have this format
"Handler": "<your-web-api-project-name>::<namespace-for-your-lambda>.<lambda-class-name>::FunctionHandlerAsync"
I also had to add these to make my API work on AWS Gateway into serverless.template
"Events": {
"ProxyResource": {
"Type": "Api",
"Properties": {
"Path": "/{proxy+}",
"Method": "ANY"
}
},
"RootResource": {
"Type": "Api",
"Properties": {
"Path": "/",
"Method": "ANY"
}
}
You can use API Gateway to proxy your requests, then use AspNetCoreServer to transform API Gateway requests into ASP.NET Core requests and transform outgoing responses so that API Gateway will understand them. I wrote a detailed article on how to achieve this and deploy using AWS CDK.

WSO2 ESB how to securize a proxy by default when deploy

I have a lot of proxies in WSO2 ESB that I have to securize. I need them to be securized using Username Token when deploy, instead of browsing to the dashboard and enabling it one by one.
Any help?
I guess currently, you need to use management console and do it. From the UI, it is calling a backend web service. You can automate process by automating this backend web service. This web service is exposed by following component [1]. You can use soapui or some client program to automate this web service.
[1] http://svn.wso2.org/repos/wso2/carbon/platform/trunk/components/security/org.wso2.carbon.security.mgt/
I had similar requirement, here is how I solved it
Apply Role security to WSO2 ESB Proxy using Java API
Also you can find the test case here on how to use the methods
http://svn.wso2.org/repos/wso2/tags/carbon/3.2.3/products/bps/2.1.1/modules/integration/org.wso2.bps.management.test/src/test/java/org/wso2/bps/management/SecurityTest.java
Well here how the code snippet goes to secure any proxy service with default security scenarios of WSO2 ESB. In WSO2 ESB "scenario1" signifies Usernametoken based security. Now if you wish to secure your proxy with scenario1 follow the below code snippet:
public void applySecurityOnService(String serviceName, String policyId,
String[] userGroups, String[] trustedKeyStoreArray,
String privateStore)
throws SecurityAdminServiceSecurityConfigExceptionException,
RemoteException {
ApplySecurity applySecurity;
applySecurity = new ApplySecurity();
applySecurity.setServiceName(serviceName);
applySecurity.setPolicyId("scenario" + policyId); //scenario1 i.e. for Usernametoken security policyId should be 1
applySecurity.setTrustedStores(trustedKeyStoreArray);
applySecurity.setPrivateStore(privateStore);
applySecurity.setUserGroupNames(userGroups);
stub.applySecurity(applySecurity);
_logger.info("Security Applied Successfully");
}
Here is how you may call this method from your client class:
applySecurityOnService("MyProxy", "1", new String[]{"TestRole"}, new String[]{"wso2carbon.jks"}, "wso2carbon.jks");