From 7ddd6953edbeace14a16afd129d2378d946de2f2 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Tue, 3 Sep 2024 15:07:56 +0530 Subject: [PATCH] Update API definitions for AI subscription policies Update admin and internal API definitions to include AI subscription policies related DTOs --- .../.openapi-generator/admin-api.yaml.sha256 | 2 +- .../clients/admin/api/openapi.yaml | 32 +++ .../admin/api/dto/AIQuotaLimitAllOfDTO.java | 185 +++++++++++++ .../admin/api/dto/AIQuotaLimitDTO.java | 243 ++++++++++++++++++ .../admin/api/dto/ThrottleLimitDTO.java | 38 ++- .../admin/src/main/resources/admin-api.yaml | 31 +++ .../internal/api/dto/AIQuotaLimitDTO.java | 210 +++++++++++++++ .../internal/api/dto/ThrottleLimitDTO.java | 28 +- .../internal-api/src/main/resources/api.yaml | 32 +++ 9 files changed, 795 insertions(+), 6 deletions(-) create mode 100644 modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitAllOfDTO.java create mode 100644 modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitDTO.java create mode 100644 modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/AIQuotaLimitDTO.java diff --git a/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 b/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 index 219bbf22ef..4f5ee33907 100644 --- a/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 +++ b/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 @@ -1 +1 @@ -cca415b078e76654cef5d2b0ec616e8e322a3b7607e6a4a14b545c200ad7ec97 \ No newline at end of file +107551f176df23e9935ec5689c024391825a72c2eaf11e3879bdf11d77401eeb \ No newline at end of file diff --git a/modules/integration/tests-common/clients/admin/api/openapi.yaml b/modules/integration/tests-common/clients/admin/api/openapi.yaml index 47ea98940a..b273d59b5d 100644 --- a/modules/integration/tests-common/clients/admin/api/openapi.yaml +++ b/modules/integration/tests-common/clients/admin/api/openapi.yaml @@ -8147,6 +8147,7 @@ components: - REQUESTCOUNTLIMIT - BANDWIDTHLIMIT - EVENTCOUNTLIMIT + - AIQUOTALIMIT example: REQUESTCOUNTLIMIT type: string requestCount: @@ -8155,6 +8156,8 @@ components: $ref: '#/components/schemas/BandwidthLimit' eventCount: $ref: '#/components/schemas/EventCountLimit' + aiQuota: + $ref: '#/components/schemas/AIQuotaLimit' required: - type title: Throttle Limit @@ -8200,6 +8203,11 @@ components: - $ref: '#/components/schemas/ThrottleLimitBase' - $ref: '#/components/schemas/RequestCountLimit_allOf' title: Request Count Limit object + AIQuotaLimit: + allOf: + - $ref: '#/components/schemas/ThrottleLimitBase' + - $ref: '#/components/schemas/AIQuotaLimit_allOf' + title: AI Quota Limit object EventCountLimit: allOf: - $ref: '#/components/schemas/ThrottleLimitBase' @@ -10025,6 +10033,30 @@ components: type: integer required: - requestCount + AIQuotaLimit_allOf: + properties: + requestCount: + description: Maximum number of requests allowed + example: 30 + format: int64 + type: integer + totalTokenCount: + description: Maximum number of total tokens allowed + example: 1000 + format: int64 + type: integer + requestTokenCount: + description: Maximum number of request tokens allowed + example: 300 + format: int64 + type: integer + responseTokenCount: + description: Maximum number of response tokens allowed + example: 300 + format: int64 + type: integer + required: + - requestCount EventCountLimit_allOf: properties: eventCount: diff --git a/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitAllOfDTO.java b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitAllOfDTO.java new file mode 100644 index 0000000000..6fa6a151f7 --- /dev/null +++ b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitAllOfDTO.java @@ -0,0 +1,185 @@ +/* + * WSO2 API Manager - Admin + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Admin Portal**. Please see [full OpenAPI Specification](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.7.206/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml) of the API which is written using [OAS 3.0](http://swagger.io/) specification. # Authentication Our REST APIs are protected using OAuth2 and access control is achieved through scopes. Before you start invoking the the API you need to obtain an access token with the required scopes. This guide will walk you through the steps that you will need to follow to obtain an access token. First you need to obtain the consumer key/secret key pair by calling the dynamic client registration (DCR) endpoint. You can add your preferred grant types in the payload. A sample payload is shown below. ``` { \"callbackUrl\":\"www.google.lk\", \"clientName\":\"rest_api_admin\", \"owner\":\"admin\", \"grantType\":\"client_credentials password refresh_token\", \"saasApp\":true } ``` Create a file (payload.json) with the above sample payload, and use the cURL shown bellow to invoke the DCR endpoint. Authorization header of this should contain the base64 encoded admin username and password. **Format of the request** ``` curl -X POST -H \"Authorization: Basic Base64(admin_username:admin_password)\" -H \"Content-Type: application/json\" \\ -d @payload.json https://:/client-registration/v0.17/register ``` **Sample request** ``` curl -X POST -H \"Authorization: Basic YWRtaW46YWRtaW4=\" -H \"Content-Type: application/json\" \\ -d @payload.json https://localhost:9443/client-registration/v0.17/register ``` Following is a sample response after invoking the above curl. ``` { \"clientId\": \"fOCi4vNJ59PpHucC2CAYfYuADdMa\", \"clientName\": \"rest_api_admin\", \"callBackURL\": \"www.google.lk\", \"clientSecret\": \"a4FwHlq0iCIKVs2MPIIDnepZnYMa\", \"isSaasApplication\": true, \"appOwner\": \"admin\", \"jsonString\": \"{\\\"grant_types\\\":\\\"client_credentials password refresh_token\\\",\\\"redirect_uris\\\":\\\"www.google.lk\\\",\\\"client_name\\\":\\\"rest_api_admin\\\"}\", \"jsonAppAttribute\": \"{}\", \"tokenType\": null } ``` Next you must use the above client id and secret to obtain the access token. We will be using the password grant type for this, you can use any grant type you desire. You also need to add the proper **scope** when getting the access token. All possible scopes for Admin REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorizations** section of resource documentation. Following is the format of the request if you are using the password grant type. ``` curl -k -d \"grant_type=password&username=&password=&scope=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/token ``` **Sample request** ``` curl https://localhost:8243/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:admin apim:tier_view\" ``` Shown below is a sample response to the above request. ``` { \"access_token\": \"e79bda48-3406-3178-acce-f6e4dbdcbb12\", \"refresh_token\": \"a757795d-e69f-38b8-bd85-9aded677a97c\", \"scope\": \"apim:admin apim:tier_view\", \"token_type\": \"Bearer\", \"expires_in\": 3600 } ``` Now you have a valid access token, which you can use to invoke an API. Navigate through the API descriptions to find the required API, obtain an access token as described above and invoke the API with the authentication header. If you use a different authentication mechanism, this process may change. # Try out in Postman If you want to try-out the embedded postman collection with \"Run in Postman\" option, please follow the guidelines listed below. * All of the OAuth2 secured endpoints have been configured with an Authorization Bearer header with a parameterized access token. Before invoking any REST API resource make sure you run the `Register DCR Application` and `Generate Access Token` requests to fetch an access token with all required scopes. * Make sure you have an API Manager instance up and running. * Update the `basepath` parameter to match the hostname and port of the APIM instance. [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/f5ac2ca9fb22afef6ed6) + * + * The version of the OpenAPI document: v4 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.wso2.am.integration.clients.admin.api.dto; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIQuotaLimitAllOfDTO +*/ + +public class AIQuotaLimitAllOfDTO { + public static final String SERIALIZED_NAME_REQUEST_COUNT = "requestCount"; + @SerializedName(SERIALIZED_NAME_REQUEST_COUNT) + private Long requestCount; + + public static final String SERIALIZED_NAME_TOTAL_TOKEN_COUNT = "totalTokenCount"; + @SerializedName(SERIALIZED_NAME_TOTAL_TOKEN_COUNT) + private Long totalTokenCount; + + public static final String SERIALIZED_NAME_REQUEST_TOKEN_COUNT = "requestTokenCount"; + @SerializedName(SERIALIZED_NAME_REQUEST_TOKEN_COUNT) + private Long requestTokenCount; + + public static final String SERIALIZED_NAME_RESPONSE_TOKEN_COUNT = "responseTokenCount"; + @SerializedName(SERIALIZED_NAME_RESPONSE_TOKEN_COUNT) + private Long responseTokenCount; + + + public AIQuotaLimitAllOfDTO requestCount(Long requestCount) { + + this.requestCount = requestCount; + return this; + } + + /** + * Maximum number of requests allowed + * @return requestCount + **/ + @ApiModelProperty(example = "30", required = true, value = "Maximum number of requests allowed") + + public Long getRequestCount() { + return requestCount; + } + + + public void setRequestCount(Long requestCount) { + this.requestCount = requestCount; + } + + + public AIQuotaLimitAllOfDTO totalTokenCount(Long totalTokenCount) { + + this.totalTokenCount = totalTokenCount; + return this; + } + + /** + * Maximum number of total tokens allowed + * @return totalTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1000", value = "Maximum number of total tokens allowed") + + public Long getTotalTokenCount() { + return totalTokenCount; + } + + + public void setTotalTokenCount(Long totalTokenCount) { + this.totalTokenCount = totalTokenCount; + } + + + public AIQuotaLimitAllOfDTO requestTokenCount(Long requestTokenCount) { + + this.requestTokenCount = requestTokenCount; + return this; + } + + /** + * Maximum number of request tokens allowed + * @return requestTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "300", value = "Maximum number of request tokens allowed") + + public Long getRequestTokenCount() { + return requestTokenCount; + } + + + public void setRequestTokenCount(Long requestTokenCount) { + this.requestTokenCount = requestTokenCount; + } + + + public AIQuotaLimitAllOfDTO responseTokenCount(Long responseTokenCount) { + + this.responseTokenCount = responseTokenCount; + return this; + } + + /** + * Maximum number of response tokens allowed + * @return responseTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "300", value = "Maximum number of response tokens allowed") + + public Long getResponseTokenCount() { + return responseTokenCount; + } + + + public void setResponseTokenCount(Long responseTokenCount) { + this.responseTokenCount = responseTokenCount; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIQuotaLimitAllOfDTO aiQuotaLimitAllOf = (AIQuotaLimitAllOfDTO) o; + return Objects.equals(this.requestCount, aiQuotaLimitAllOf.requestCount) && + Objects.equals(this.totalTokenCount, aiQuotaLimitAllOf.totalTokenCount) && + Objects.equals(this.requestTokenCount, aiQuotaLimitAllOf.requestTokenCount) && + Objects.equals(this.responseTokenCount, aiQuotaLimitAllOf.responseTokenCount); + } + + @Override + public int hashCode() { + return Objects.hash(requestCount, totalTokenCount, requestTokenCount, responseTokenCount); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIQuotaLimitAllOfDTO {\n"); + sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); + sb.append(" totalTokenCount: ").append(toIndentedString(totalTokenCount)).append("\n"); + sb.append(" requestTokenCount: ").append(toIndentedString(requestTokenCount)).append("\n"); + sb.append(" responseTokenCount: ").append(toIndentedString(responseTokenCount)).append("\n"); +sb.append("}"); +return sb.toString(); +} + +/** +* Convert the given object to string with each line indented by 4 spaces +* (except the first line). +*/ +private String toIndentedString(Object o) { +if (o == null) { +return "null"; +} +return o.toString().replace("\n", "\n "); +} + +} + diff --git a/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitDTO.java b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitDTO.java new file mode 100644 index 0000000000..3978023d0a --- /dev/null +++ b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIQuotaLimitDTO.java @@ -0,0 +1,243 @@ +/* + * WSO2 API Manager - Admin + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Admin Portal**. Please see [full OpenAPI Specification](https://raw.githubusercontent.com/wso2/carbon-apimgt/v6.7.206/components/apimgt/org.wso2.carbon.apimgt.rest.api.admin.v1/src/main/resources/admin-api.yaml) of the API which is written using [OAS 3.0](http://swagger.io/) specification. # Authentication Our REST APIs are protected using OAuth2 and access control is achieved through scopes. Before you start invoking the the API you need to obtain an access token with the required scopes. This guide will walk you through the steps that you will need to follow to obtain an access token. First you need to obtain the consumer key/secret key pair by calling the dynamic client registration (DCR) endpoint. You can add your preferred grant types in the payload. A sample payload is shown below. ``` { \"callbackUrl\":\"www.google.lk\", \"clientName\":\"rest_api_admin\", \"owner\":\"admin\", \"grantType\":\"client_credentials password refresh_token\", \"saasApp\":true } ``` Create a file (payload.json) with the above sample payload, and use the cURL shown bellow to invoke the DCR endpoint. Authorization header of this should contain the base64 encoded admin username and password. **Format of the request** ``` curl -X POST -H \"Authorization: Basic Base64(admin_username:admin_password)\" -H \"Content-Type: application/json\" \\ -d @payload.json https://:/client-registration/v0.17/register ``` **Sample request** ``` curl -X POST -H \"Authorization: Basic YWRtaW46YWRtaW4=\" -H \"Content-Type: application/json\" \\ -d @payload.json https://localhost:9443/client-registration/v0.17/register ``` Following is a sample response after invoking the above curl. ``` { \"clientId\": \"fOCi4vNJ59PpHucC2CAYfYuADdMa\", \"clientName\": \"rest_api_admin\", \"callBackURL\": \"www.google.lk\", \"clientSecret\": \"a4FwHlq0iCIKVs2MPIIDnepZnYMa\", \"isSaasApplication\": true, \"appOwner\": \"admin\", \"jsonString\": \"{\\\"grant_types\\\":\\\"client_credentials password refresh_token\\\",\\\"redirect_uris\\\":\\\"www.google.lk\\\",\\\"client_name\\\":\\\"rest_api_admin\\\"}\", \"jsonAppAttribute\": \"{}\", \"tokenType\": null } ``` Next you must use the above client id and secret to obtain the access token. We will be using the password grant type for this, you can use any grant type you desire. You also need to add the proper **scope** when getting the access token. All possible scopes for Admin REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorizations** section of resource documentation. Following is the format of the request if you are using the password grant type. ``` curl -k -d \"grant_type=password&username=&password=&scope=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/token ``` **Sample request** ``` curl https://localhost:8243/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:admin apim:tier_view\" ``` Shown below is a sample response to the above request. ``` { \"access_token\": \"e79bda48-3406-3178-acce-f6e4dbdcbb12\", \"refresh_token\": \"a757795d-e69f-38b8-bd85-9aded677a97c\", \"scope\": \"apim:admin apim:tier_view\", \"token_type\": \"Bearer\", \"expires_in\": 3600 } ``` Now you have a valid access token, which you can use to invoke an API. Navigate through the API descriptions to find the required API, obtain an access token as described above and invoke the API with the authentication header. If you use a different authentication mechanism, this process may change. # Try out in Postman If you want to try-out the embedded postman collection with \"Run in Postman\" option, please follow the guidelines listed below. * All of the OAuth2 secured endpoints have been configured with an Authorization Bearer header with a parameterized access token. Before invoking any REST API resource make sure you run the `Register DCR Application` and `Generate Access Token` requests to fetch an access token with all required scopes. * Make sure you have an API Manager instance up and running. * Update the `basepath` parameter to match the hostname and port of the APIM instance. [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/f5ac2ca9fb22afef6ed6) + * + * The version of the OpenAPI document: v4 + * Contact: architecture@wso2.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package org.wso2.am.integration.clients.admin.api.dto; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.wso2.am.integration.clients.admin.api.dto.AIQuotaLimitAllOfDTO; +import org.wso2.am.integration.clients.admin.api.dto.ThrottleLimitBaseDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIQuotaLimitDTO +*/ + +public class AIQuotaLimitDTO { + public static final String SERIALIZED_NAME_TIME_UNIT = "timeUnit"; + @SerializedName(SERIALIZED_NAME_TIME_UNIT) + private String timeUnit; + + public static final String SERIALIZED_NAME_UNIT_TIME = "unitTime"; + @SerializedName(SERIALIZED_NAME_UNIT_TIME) + private Integer unitTime; + + public static final String SERIALIZED_NAME_REQUEST_COUNT = "requestCount"; + @SerializedName(SERIALIZED_NAME_REQUEST_COUNT) + private Long requestCount; + + public static final String SERIALIZED_NAME_TOTAL_TOKEN_COUNT = "totalTokenCount"; + @SerializedName(SERIALIZED_NAME_TOTAL_TOKEN_COUNT) + private Long totalTokenCount; + + public static final String SERIALIZED_NAME_REQUEST_TOKEN_COUNT = "requestTokenCount"; + @SerializedName(SERIALIZED_NAME_REQUEST_TOKEN_COUNT) + private Long requestTokenCount; + + public static final String SERIALIZED_NAME_RESPONSE_TOKEN_COUNT = "responseTokenCount"; + @SerializedName(SERIALIZED_NAME_RESPONSE_TOKEN_COUNT) + private Long responseTokenCount; + + + public AIQuotaLimitDTO timeUnit(String timeUnit) { + + this.timeUnit = timeUnit; + return this; + } + + /** + * Unit of the time. Allowed values are \"sec\", \"min\", \"hour\", \"day\" + * @return timeUnit + **/ + @ApiModelProperty(example = "min", required = true, value = "Unit of the time. Allowed values are \"sec\", \"min\", \"hour\", \"day\"") + + public String getTimeUnit() { + return timeUnit; + } + + + public void setTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + } + + + public AIQuotaLimitDTO unitTime(Integer unitTime) { + + this.unitTime = unitTime; + return this; + } + + /** + * Time limit that the throttling limit applies. + * @return unitTime + **/ + @ApiModelProperty(example = "10", required = true, value = "Time limit that the throttling limit applies.") + + public Integer getUnitTime() { + return unitTime; + } + + + public void setUnitTime(Integer unitTime) { + this.unitTime = unitTime; + } + + + public AIQuotaLimitDTO requestCount(Long requestCount) { + + this.requestCount = requestCount; + return this; + } + + /** + * Maximum number of requests allowed + * @return requestCount + **/ + @ApiModelProperty(example = "30", required = true, value = "Maximum number of requests allowed") + + public Long getRequestCount() { + return requestCount; + } + + + public void setRequestCount(Long requestCount) { + this.requestCount = requestCount; + } + + + public AIQuotaLimitDTO totalTokenCount(Long totalTokenCount) { + + this.totalTokenCount = totalTokenCount; + return this; + } + + /** + * Maximum number of total tokens allowed + * @return totalTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1000", value = "Maximum number of total tokens allowed") + + public Long getTotalTokenCount() { + return totalTokenCount; + } + + + public void setTotalTokenCount(Long totalTokenCount) { + this.totalTokenCount = totalTokenCount; + } + + + public AIQuotaLimitDTO requestTokenCount(Long requestTokenCount) { + + this.requestTokenCount = requestTokenCount; + return this; + } + + /** + * Maximum number of request tokens allowed + * @return requestTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "300", value = "Maximum number of request tokens allowed") + + public Long getRequestTokenCount() { + return requestTokenCount; + } + + + public void setRequestTokenCount(Long requestTokenCount) { + this.requestTokenCount = requestTokenCount; + } + + + public AIQuotaLimitDTO responseTokenCount(Long responseTokenCount) { + + this.responseTokenCount = responseTokenCount; + return this; + } + + /** + * Maximum number of response tokens allowed + * @return responseTokenCount + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "300", value = "Maximum number of response tokens allowed") + + public Long getResponseTokenCount() { + return responseTokenCount; + } + + + public void setResponseTokenCount(Long responseTokenCount) { + this.responseTokenCount = responseTokenCount; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIQuotaLimitDTO aiQuotaLimit = (AIQuotaLimitDTO) o; + return Objects.equals(this.timeUnit, aiQuotaLimit.timeUnit) && + Objects.equals(this.unitTime, aiQuotaLimit.unitTime) && + Objects.equals(this.requestCount, aiQuotaLimit.requestCount) && + Objects.equals(this.totalTokenCount, aiQuotaLimit.totalTokenCount) && + Objects.equals(this.requestTokenCount, aiQuotaLimit.requestTokenCount) && + Objects.equals(this.responseTokenCount, aiQuotaLimit.responseTokenCount); + } + + @Override + public int hashCode() { + return Objects.hash(timeUnit, unitTime, requestCount, totalTokenCount, requestTokenCount, responseTokenCount); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIQuotaLimitDTO {\n"); + sb.append(" timeUnit: ").append(toIndentedString(timeUnit)).append("\n"); + sb.append(" unitTime: ").append(toIndentedString(unitTime)).append("\n"); + sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); + sb.append(" totalTokenCount: ").append(toIndentedString(totalTokenCount)).append("\n"); + sb.append(" requestTokenCount: ").append(toIndentedString(requestTokenCount)).append("\n"); + sb.append(" responseTokenCount: ").append(toIndentedString(responseTokenCount)).append("\n"); +sb.append("}"); +return sb.toString(); +} + +/** +* Convert the given object to string with each line indented by 4 spaces +* (except the first line). +*/ +private String toIndentedString(Object o) { +if (o == null) { +return "null"; +} +return o.toString().replace("\n", "\n "); +} + +} + diff --git a/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ThrottleLimitDTO.java b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ThrottleLimitDTO.java index 518b8e8085..5dcf3a8fcb 100644 --- a/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ThrottleLimitDTO.java +++ b/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ThrottleLimitDTO.java @@ -23,6 +23,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import org.wso2.am.integration.clients.admin.api.dto.AIQuotaLimitDTO; import org.wso2.am.integration.clients.admin.api.dto.BandwidthLimitDTO; import org.wso2.am.integration.clients.admin.api.dto.EventCountLimitDTO; import org.wso2.am.integration.clients.admin.api.dto.RequestCountLimitDTO; @@ -41,7 +42,9 @@ public enum TypeEnum { BANDWIDTHLIMIT("BANDWIDTHLIMIT"), - EVENTCOUNTLIMIT("EVENTCOUNTLIMIT"); + EVENTCOUNTLIMIT("EVENTCOUNTLIMIT"), + + AIQUOTALIMIT("AIQUOTALIMIT"); private String value; @@ -97,6 +100,10 @@ public TypeEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_EVENT_COUNT) private EventCountLimitDTO eventCount = null; + public static final String SERIALIZED_NAME_AI_QUOTA = "aiQuota"; + @SerializedName(SERIALIZED_NAME_AI_QUOTA) + private AIQuotaLimitDTO aiQuota = null; + public ThrottleLimitDTO type(TypeEnum type) { @@ -189,6 +196,29 @@ public void setEventCount(EventCountLimitDTO eventCount) { } + public ThrottleLimitDTO aiQuota(AIQuotaLimitDTO aiQuota) { + + this.aiQuota = aiQuota; + return this; + } + + /** + * Get aiQuota + * @return aiQuota + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public AIQuotaLimitDTO getAiQuota() { + return aiQuota; + } + + + public void setAiQuota(AIQuotaLimitDTO aiQuota) { + this.aiQuota = aiQuota; + } + + @Override public boolean equals(Object o) { if (this == o) { @@ -201,12 +231,13 @@ public boolean equals(Object o) { return Objects.equals(this.type, throttleLimit.type) && Objects.equals(this.requestCount, throttleLimit.requestCount) && Objects.equals(this.bandwidth, throttleLimit.bandwidth) && - Objects.equals(this.eventCount, throttleLimit.eventCount); + Objects.equals(this.eventCount, throttleLimit.eventCount) && + Objects.equals(this.aiQuota, throttleLimit.aiQuota); } @Override public int hashCode() { - return Objects.hash(type, requestCount, bandwidth, eventCount); + return Objects.hash(type, requestCount, bandwidth, eventCount, aiQuota); } @@ -218,6 +249,7 @@ public String toString() { sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); sb.append(" bandwidth: ").append(toIndentedString(bandwidth)).append("\n"); sb.append(" eventCount: ").append(toIndentedString(eventCount)).append("\n"); + sb.append(" aiQuota: ").append(toIndentedString(aiQuota)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml b/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml index d8466dfc96..2e743a0030 100644 --- a/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml +++ b/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml @@ -4894,12 +4894,15 @@ components: - REQUESTCOUNTLIMIT - BANDWIDTHLIMIT - EVENTCOUNTLIMIT + - AIQUOTALIMIT requestCount: $ref: '#/components/schemas/RequestCountLimit' bandwidth: $ref: '#/components/schemas/BandwidthLimit' eventCount: $ref: '#/components/schemas/EventCountLimit' + aiQuota: + $ref: '#/components/schemas/AIQuotaLimit' BurstLimit: title: Burst Limit object type: object @@ -4963,6 +4966,34 @@ components: description: Maximum number of requests allowed format: int64 example: 30 + AIQuotaLimit: + title: AI Quota Limit object + allOf: + - $ref: '#/components/schemas/ThrottleLimitBase' + - required: + - requestCount + type: object + properties: + requestCount: + type: integer + description: Maximum number of requests allowed + format: int64 + example: 30 + totalTokenCount: + type: integer + description: Maximum number of total tokens allowed + format: int64 + example: 1000 + requestTokenCount: + type: integer + description: Maximum number of request tokens allowed + format: int64 + example: 300 + responseTokenCount: + type: integer + description: Maximum number of response tokens allowed + format: int64 + example: 300 EventCountLimit: title: Event Count Limit object allOf: diff --git a/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/AIQuotaLimitDTO.java b/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/AIQuotaLimitDTO.java new file mode 100644 index 0000000000..626f93ca8c --- /dev/null +++ b/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/AIQuotaLimitDTO.java @@ -0,0 +1,210 @@ +/* + * Internal Utility API + * This API allows you to access internal data. + * + * OpenAPI spec version: 1.0.0 + * + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package org.wso2.am.integration.clients.internal.api.dto; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.wso2.am.integration.clients.internal.api.dto.ThrottleLimitBaseDTO; + +/** + * AIQuotaLimitDTO + */ + +public class AIQuotaLimitDTO { + @SerializedName("timeUnit") + private String timeUnit = null; + + @SerializedName("unitTime") + private Integer unitTime = null; + + @SerializedName("requestCount") + private Long requestCount = null; + + @SerializedName("totalTokenCount") + private Long totalTokenCount = null; + + @SerializedName("requestTokenCount") + private Long requestTokenCount = null; + + @SerializedName("responseTokenCount") + private Long responseTokenCount = null; + + public AIQuotaLimitDTO timeUnit(String timeUnit) { + this.timeUnit = timeUnit; + return this; + } + + /** + * Unit of the time. Allowed values are \"sec\", \"min\", \"hour\", \"day\" + * @return timeUnit + **/ + @ApiModelProperty(example = "min", required = true, value = "Unit of the time. Allowed values are \"sec\", \"min\", \"hour\", \"day\"") + public String getTimeUnit() { + return timeUnit; + } + + public void setTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + } + + public AIQuotaLimitDTO unitTime(Integer unitTime) { + this.unitTime = unitTime; + return this; + } + + /** + * Time limit that the throttling limit applies. + * @return unitTime + **/ + @ApiModelProperty(example = "10", required = true, value = "Time limit that the throttling limit applies.") + public Integer getUnitTime() { + return unitTime; + } + + public void setUnitTime(Integer unitTime) { + this.unitTime = unitTime; + } + + public AIQuotaLimitDTO requestCount(Long requestCount) { + this.requestCount = requestCount; + return this; + } + + /** + * Maximum number of requests allowed + * @return requestCount + **/ + @ApiModelProperty(example = "1000", required = true, value = "Maximum number of requests allowed") + public Long getRequestCount() { + return requestCount; + } + + public void setRequestCount(Long requestCount) { + this.requestCount = requestCount; + } + + public AIQuotaLimitDTO totalTokenCount(Long totalTokenCount) { + this.totalTokenCount = totalTokenCount; + return this; + } + + /** + * Maximum number of total tokens allowed + * @return totalTokenCount + **/ + @ApiModelProperty(example = "1000", value = "Maximum number of total tokens allowed") + public Long getTotalTokenCount() { + return totalTokenCount; + } + + public void setTotalTokenCount(Long totalTokenCount) { + this.totalTokenCount = totalTokenCount; + } + + public AIQuotaLimitDTO requestTokenCount(Long requestTokenCount) { + this.requestTokenCount = requestTokenCount; + return this; + } + + /** + * Maximum number of request tokens allowed + * @return requestTokenCount + **/ + @ApiModelProperty(example = "300", value = "Maximum number of request tokens allowed") + public Long getRequestTokenCount() { + return requestTokenCount; + } + + public void setRequestTokenCount(Long requestTokenCount) { + this.requestTokenCount = requestTokenCount; + } + + public AIQuotaLimitDTO responseTokenCount(Long responseTokenCount) { + this.responseTokenCount = responseTokenCount; + return this; + } + + /** + * Maximum number of response tokens allowed + * @return responseTokenCount + **/ + @ApiModelProperty(example = "300", value = "Maximum number of response tokens allowed") + public Long getResponseTokenCount() { + return responseTokenCount; + } + + public void setResponseTokenCount(Long responseTokenCount) { + this.responseTokenCount = responseTokenCount; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIQuotaLimitDTO aiQuotaLimit = (AIQuotaLimitDTO) o; + return Objects.equals(this.timeUnit, aiQuotaLimit.timeUnit) && + Objects.equals(this.unitTime, aiQuotaLimit.unitTime) && + Objects.equals(this.requestCount, aiQuotaLimit.requestCount) && + Objects.equals(this.totalTokenCount, aiQuotaLimit.totalTokenCount) && + Objects.equals(this.requestTokenCount, aiQuotaLimit.requestTokenCount) && + Objects.equals(this.responseTokenCount, aiQuotaLimit.responseTokenCount); + } + + @Override + public int hashCode() { + return Objects.hash(timeUnit, unitTime, requestCount, totalTokenCount, requestTokenCount, responseTokenCount); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AIQuotaLimitDTO {\n"); + + sb.append(" timeUnit: ").append(toIndentedString(timeUnit)).append("\n"); + sb.append(" unitTime: ").append(toIndentedString(unitTime)).append("\n"); + sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); + sb.append(" totalTokenCount: ").append(toIndentedString(totalTokenCount)).append("\n"); + sb.append(" requestTokenCount: ").append(toIndentedString(requestTokenCount)).append("\n"); + sb.append(" responseTokenCount: ").append(toIndentedString(responseTokenCount)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/ThrottleLimitDTO.java b/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/ThrottleLimitDTO.java index bf6f596d12..835f833f07 100644 --- a/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/ThrottleLimitDTO.java +++ b/modules/integration/tests-common/clients/internal-api/src/gen/java/org/wso2/am/integration/clients/internal/api/dto/ThrottleLimitDTO.java @@ -23,6 +23,7 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.IOException; +import org.wso2.am.integration.clients.internal.api.dto.AIQuotaLimitDTO; import org.wso2.am.integration.clients.internal.api.dto.BandwidthLimitDTO; import org.wso2.am.integration.clients.internal.api.dto.EventCountLimitDTO; import org.wso2.am.integration.clients.internal.api.dto.RequestCountLimitDTO; @@ -44,6 +45,9 @@ public class ThrottleLimitDTO { @SerializedName("eventCount") private EventCountLimitDTO eventCount = null; + @SerializedName("aiQuota") + private AIQuotaLimitDTO aiQuota = null; + public ThrottleLimitDTO quotaType(String quotaType) { this.quotaType = quotaType; return this; @@ -116,6 +120,24 @@ public void setEventCount(EventCountLimitDTO eventCount) { this.eventCount = eventCount; } + public ThrottleLimitDTO aiQuota(AIQuotaLimitDTO aiQuota) { + this.aiQuota = aiQuota; + return this; + } + + /** + * Get aiQuota + * @return aiQuota + **/ + @ApiModelProperty(value = "") + public AIQuotaLimitDTO getAiQuota() { + return aiQuota; + } + + public void setAiQuota(AIQuotaLimitDTO aiQuota) { + this.aiQuota = aiQuota; + } + @Override public boolean equals(java.lang.Object o) { @@ -129,12 +151,13 @@ public boolean equals(java.lang.Object o) { return Objects.equals(this.quotaType, throttleLimit.quotaType) && Objects.equals(this.requestCount, throttleLimit.requestCount) && Objects.equals(this.bandwidth, throttleLimit.bandwidth) && - Objects.equals(this.eventCount, throttleLimit.eventCount); + Objects.equals(this.eventCount, throttleLimit.eventCount) && + Objects.equals(this.aiQuota, throttleLimit.aiQuota); } @Override public int hashCode() { - return Objects.hash(quotaType, requestCount, bandwidth, eventCount); + return Objects.hash(quotaType, requestCount, bandwidth, eventCount, aiQuota); } @@ -147,6 +170,7 @@ public String toString() { sb.append(" requestCount: ").append(toIndentedString(requestCount)).append("\n"); sb.append(" bandwidth: ").append(toIndentedString(bandwidth)).append("\n"); sb.append(" eventCount: ").append(toIndentedString(eventCount)).append("\n"); + sb.append(" aiQuota: ").append(toIndentedString(aiQuota)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/modules/integration/tests-common/clients/internal-api/src/main/resources/api.yaml b/modules/integration/tests-common/clients/internal-api/src/main/resources/api.yaml index 0fd3675db6..61924cea6e 100644 --- a/modules/integration/tests-common/clients/internal-api/src/main/resources/api.yaml +++ b/modules/integration/tests-common/clients/internal-api/src/main/resources/api.yaml @@ -1373,6 +1373,8 @@ definitions: $ref: '#/definitions/BandwidthLimit' eventCount: $ref: '#/definitions/EventCountLimit' + aiQuota: + $ref: '#/definitions/AIQuotaLimit' #----------------------------------------------------- # The Throttling Bandwidth Limit resource @@ -1428,3 +1430,33 @@ definitions: format: int64 example: 3000 + #----------------------------------------------------- + # The Throttling AI Quota Limit resource + #----------------------------------------------------- + AIQuotaLimit: + title: AI Quota Limit object + allOf: + - $ref: '#/definitions/ThrottleLimitBase' + - required: + - requestCount + properties: + requestCount: + type: integer + format: int64 + description: Maximum number of requests allowed + example: 1000 + totalTokenCount: + type: integer + description: Maximum number of total tokens allowed + format: int64 + example: 1000 + requestTokenCount: + type: integer + description: Maximum number of request tokens allowed + format: int64 + example: 300 + responseTokenCount: + type: integer + description: Maximum number of response tokens allowed + format: int64 + example: 300