[Apiman-user] Transfer Quota Policy

Ashish Patel ashish.patel at futuregroup.in
Thu Apr 5 10:06:29 EDT 2018


Super. Thanks Eric.

Thanks & Regards,
Ashish Patel

From: Eric Wittmann [mailto:eric.wittmann at redhat.com]
Sent: Thursday, April 05, 2018 19:32
To: Ashish Patel
Cc: Jakub Čecháček; apiman-user at lists.jboss.org
Subject: Re: [Apiman-user] Transfer Quota Policy

The documentation for creating plugins is pretty good.  You can find it here:

http://www.apiman.io/latest/developer-guide.html#_plugins

Section 4.1 describes what an Apiman plugin looks like (how to create one).  Section 4.2 describes a **Policy** plugin (there are other kinds, but you want a Policy Plugin).  And sections 4.3 and 4.4 describe testing and using the policy plugin you create.  You can skip section 4.5 - it's not relevant for what you want to do.

    Note: Pay special attention to the section about "IDataPolicy" since that will be important for this policy (you'll need to count bytes as they are sent so you can fail the request when it exceeds your limit).

You can find examples of plugins here:

https://github.com/apiman/apiman-plugins

Each sub-module is an example of a real Apiman plugin.

You will need to have some standard Java development experience to create your own custom policy plugin.  But it's actually quite easy!

-Eric




On Thu, Apr 5, 2018 at 9:04 AM, Ashish Patel <ashish.patel at futuregroup.in<mailto:ashish.patel at futuregroup.in>> wrote:
I am trying to achieve the first one “limit every request to a certain size limit” per API. Thought can use Transfer Quota policy for the same with below values.

However, I see your point “6000 Bytes” of “upload” data per “API” per “Month” / “Year” will not help as it will give issues after combined requests crosses 6000 bytes.

Can you please suggest pointer to write the custom policy plugin to achieve the request size limiter ? (Upload is what we are targeting).

Thanks & Regards,
Ashish Patel

From: Eric Wittmann [mailto:eric.wittmann at redhat.com<mailto:eric.wittmann at redhat.com>]
Sent: Thursday, April 05, 2018 18:04
To: Ashish Patel
Cc: Jakub Čecháček; apiman-user at lists.jboss.org<mailto:apiman-user at lists.jboss.org>

Subject: Re: [Apiman-user] Transfer Quota Policy

I'm not sure I understand exactly.  Are you trying to limit every request to a certain size limit?  Or are you trying to limit the total number of bytes for all requests by a user to an API over a given amount of time.

The Quota policy performs the latter function:  it allows you to limit the total # of bytes that a user can upload over a given time window (e.g. they can only upload 1GB per month).

If what you want is a request size limiter, then you might need to create a custom policy plugin.

-Eric

On Thu, Apr 5, 2018 at 1:59 AM, Ashish Patel <ashish.patel at futuregroup.in<mailto:ashish.patel at futuregroup.in>> wrote:
Thanks very much Jakub, for explaining it in detail – I understand that – will do more testing.

Our main requirement is to restrict consumers with Transfer Quota (say 6000 bytes), for all the requests (meaning reset never happens) – believe this we can achieve with “6000 Bytes” of “upload” data per “API” per “Month” / “Year”.  In my below test, it was getting reset every second and I was not getting desired result.

Thanks & Regards,
Ashish Patel


From: Jakub Čecháček [mailto:jcechace at gmail.com<mailto:jcechace at gmail.com>]
Sent: Saturday, March 31, 2018 22:48
To: Ashish Patel
Cc: apiman-user at lists.jboss.org<mailto:apiman-user at lists.jboss.org>; Marc Savy
Subject: Re: [Apiman-user] Transfer Quota Policy

Hello Ashish,

if I understand correctly you are confused why the request passes the first time while it gets denied the second time?
Simply the way this policy works is that it blocks all consecutive requests after the one which went over the quota util reset. Meaning we don't terminate requests in the middle.

Worst case this can means that with a limit of 1000 bytes you can do a first request with 999 bytes and still send a second one with 1000 bytes -- next one is guaranteed to be blocked though.


Regards,
Jakub.

On Thu, Mar 29, 2018 at 6:46 AM, Ashish Patel <ashish.patel at futuregroup.in<mailto:ashish.patel at futuregroup.in>> wrote:
Hi Marc,

Sorry for sending direct mail, can you please help release below mail sent to group to all the audience ?

Thanks & Regards,
Ashish Patel


From: Ashish Patel
Sent: Friday, March 23, 2018 16:47
To: apiman-user at lists.jboss.org<mailto:apiman-user at lists.jboss.org>
Subject: Transfer Quota Policy

Hi,

I need small help understanding Transfer Quota policy.

Have applied transfer quota policy with below config – attached with one API , set up one client and tested with Rest Client.

“6000 Bytes” of “upload” data per “API” per “Second”.


1.       Sent single request which has request payload (upload) > 6000 bytes – Instead of blocking it, it allowed the request and sent the response – However, Apiman is aware of the overshot transfer – can be seen from the Headers.

x-transferquota-limit →6000
x-transferquota-remaining →-4019
x-transferquota-reset →0



2.       Sent back to back multiple request (same payload as above) and at times it failed with failure code : 10013, "Transfer quota exceeded.". This means it is applying the policy but after some requests , not sure how many.

x-policy-failure-code →10013
x-policy-failure-message →Transfer quota exceeded.
x-policy-failure-type →Other
x-powered-by →Undertow/1
x-transferquota-limit →6000
x-transferquota-remaining →-4019
x-transferquota-reset →0


Any idea, why it’s not failing in #1 scenario – Ideally it must fail in all requests as payload size is greater than defined.

Thanks & Regards,
Ashish Patel


_______________________________________________
Apiman-user mailing list
Apiman-user at lists.jboss.org<mailto:Apiman-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/apiman-user


_______________________________________________
Apiman-user mailing list
Apiman-user at lists.jboss.org<mailto:Apiman-user at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/apiman-user


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/apiman-user/attachments/20180405/302941ad/attachment-0001.html 


More information about the Apiman-user mailing list