Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to access Product Quota in ApigeeX?

Hello All,

               How do I access the  Product Quota in ApigeeX as before?

The document says "The Product Quota is superseded by more specific quota limits set on operations that you define on the API product." --> This works as expected .

 But if I don't have these specific ones and have only the Product level quota then those values are not getting reflected in the Quota Policy.

 
Am using the following variables to access them:
 
verifyapikey.{policy_name}.apiproduct.developer.quota.limit
verifyapikey.{policy_name}.apiproduct.developer.quota.interval
verifyapikey.{policy_name}.apiproduct.developer.quota.timeunit

Please let me know if am missing anything ...

Thanks

 

Solved Solved
0 2 770
1 ACCEPTED SOLUTION

yes, I apologize about that. This is a problem in the existing Apigee X UI. The internal bug reference is b/205148816 .

We have prioritized a fix and hope to issue it soon. The diagnosis is: The Apigee UI incorrectly invokes the Apigee API to set the quota information on API products.

The good news is: there's a workaround. Because it's a UI problem, if you directly invoke the Apigee API, you can set the appropriate values. The call looks like this:

 

# set quota on specific api product
PUT https://apigee.googleapis.com/v1/organizations/:org/apiproducts/productname1
Authorization: Bearer :token
content-type: application/json

{
  "name": "productname1",
  "displayName": "productname1",
  "approvalType": "auto",
  "attributes": [
    {
      "name": "access",
      "value": "public"
    }
  ],
  "environments": [
    "env1"
  ],
  "quota": "25",
  "quotaInterval": "1",
  "quotaTimeUnit": "minute",
  "operationGroup": {
    "operationConfigs": [
      {
        "apiSource": "inventory",
        "operations": [
          {
            "resource": "/*",
            "methods": [
              "POST",
              "GET"
            ]
          }
        ]
      },
      {
        "apiSource": "proxy2",
        "operations": [
          {
            "resource": "/path1",
            "methods": [
              "GET"
            ]
          }
        ]
      }
    ],
    "operationConfigType": "proxy"
  }
}

 

The key is to omit the "quota" property within the operationGroup that should have no quota information.

Things to keep in mind :

  • the quota settings can be at the operation group, or the product. The latter settings should hold only when no quota is set at the operation group.
  • You need to specify the right Quota policy, referencing the right variables. Or use the new "UseQuotaConfigInAPIProduct" element. If you use the old-style Quota config, there may be "hard coded" values that would apply if you don't specify the right variable references.
  • The MP caches API Product information, including Quota, for a few minutes. I don't think it's documented but in my experience it's 3 minutes. So after you make the above API call, you may need to go have a coffee, before returning to retest the Quota behavior.

To help diagnose whether the quota is working in the way I expect, I insert a policy that injects response headers to hold the "used" and "available" count on the quota. Insert this in the response flow. It might look like this:

 

<AssignMessage name="AM-QuotaInformation">
    <Set>
        <Headers>
            <Header name="quota-used">{ratelimit.Quota-1.used.count}</Header>
            <Header name="quota-available">{ratelimit.Quota-1.available.count}</Header>
        </Headers>
    </Set>
</AssignMessage>

 

View solution in original post

2 REPLIES 2

yes, I apologize about that. This is a problem in the existing Apigee X UI. The internal bug reference is b/205148816 .

We have prioritized a fix and hope to issue it soon. The diagnosis is: The Apigee UI incorrectly invokes the Apigee API to set the quota information on API products.

The good news is: there's a workaround. Because it's a UI problem, if you directly invoke the Apigee API, you can set the appropriate values. The call looks like this:

 

# set quota on specific api product
PUT https://apigee.googleapis.com/v1/organizations/:org/apiproducts/productname1
Authorization: Bearer :token
content-type: application/json

{
  "name": "productname1",
  "displayName": "productname1",
  "approvalType": "auto",
  "attributes": [
    {
      "name": "access",
      "value": "public"
    }
  ],
  "environments": [
    "env1"
  ],
  "quota": "25",
  "quotaInterval": "1",
  "quotaTimeUnit": "minute",
  "operationGroup": {
    "operationConfigs": [
      {
        "apiSource": "inventory",
        "operations": [
          {
            "resource": "/*",
            "methods": [
              "POST",
              "GET"
            ]
          }
        ]
      },
      {
        "apiSource": "proxy2",
        "operations": [
          {
            "resource": "/path1",
            "methods": [
              "GET"
            ]
          }
        ]
      }
    ],
    "operationConfigType": "proxy"
  }
}

 

The key is to omit the "quota" property within the operationGroup that should have no quota information.

Things to keep in mind :

  • the quota settings can be at the operation group, or the product. The latter settings should hold only when no quota is set at the operation group.
  • You need to specify the right Quota policy, referencing the right variables. Or use the new "UseQuotaConfigInAPIProduct" element. If you use the old-style Quota config, there may be "hard coded" values that would apply if you don't specify the right variable references.
  • The MP caches API Product information, including Quota, for a few minutes. I don't think it's documented but in my experience it's 3 minutes. So after you make the above API call, you may need to go have a coffee, before returning to retest the Quota behavior.

To help diagnose whether the quota is working in the way I expect, I insert a policy that injects response headers to hold the "used" and "available" count on the quota. Insert this in the response flow. It might look like this:

 

<AssignMessage name="AM-QuotaInformation">
    <Set>
        <Headers>
            <Header name="quota-used">{ratelimit.Quota-1.used.count}</Header>
            <Header name="quota-available">{ratelimit.Quota-1.available.count}</Header>
        </Headers>
    </Set>
</AssignMessage>

 

Thanks for your response ..

Your workaround works fine and am able to access the Product Quotas..👍

Thanks for your time..