Skip to content

Commit

Permalink
Merge pull request #13545 from wso2/ai_api_gateway
Browse files Browse the repository at this point in the history
Add support for AI API Gateway
  • Loading branch information
RakhithaRR authored Sep 27, 2024
2 parents cf02393 + 046c4dd commit 1c202a4
Show file tree
Hide file tree
Showing 10 changed files with 4,538 additions and 13 deletions.
20 changes: 20 additions & 0 deletions modules/distribution/product/src/main/assembly/bin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,26 @@
<include>**/**.xml</include>
</includes>
</fileSet>

<fileSet>
<directory>
../../p2-profile/product/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/api_definitions
</directory>
<outputDirectory>wso2am-${pom.version}/repository/resources/api_definitions</outputDirectory>
<includes>
<include>**/**.yaml</include>
</includes>
</fileSet>

<fileSet>
<directory>
../../p2-profile/product/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/api_definitions
</directory>
<outputDirectory>wso2am-${pom.version}/repository/resources/api_definitions</outputDirectory>
<includes>
<include>**/**.yaml</include>
</includes>
</fileSet>
<fileSet>
<directory>src/main/conf/governance</directory>
<outputDirectory>wso2am-${pom.version}/repository/resources</outputDirectory>
Expand Down
40 changes: 36 additions & 4 deletions modules/integration/tests-common/clients/admin/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8139,14 +8139,15 @@ components:
ThrottleLimit:
properties:
type:
description: |
Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT".
Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in
Definitions section.
description: "Type of the throttling limit. Allowed values are \"REQUESTCOUNTLIMIT\"\
, \"BANDWIDTHLIMIT\", \"EVENTCOUNTLIMIT\"\nand \"AIAPIQUOTALIMIT\".\n\
Please see schemas of \"RequestCountLimit\", \"BandwidthLimit\", \"EventCountLimit\"\
\ and \"AIAPIQuotaLimit\" \nthrottling limit types in Definitions section.\n"
enum:
- REQUESTCOUNTLIMIT
- BANDWIDTHLIMIT
- EVENTCOUNTLIMIT
- AIAPIQUOTALIMIT
example: REQUESTCOUNTLIMIT
type: string
requestCount:
Expand All @@ -8155,6 +8156,8 @@ components:
$ref: '#/components/schemas/BandwidthLimit'
eventCount:
$ref: '#/components/schemas/EventCountLimit'
aiApiQuota:
$ref: '#/components/schemas/AIAPIQuotaLimit'
required:
- type
title: Throttle Limit
Expand Down Expand Up @@ -8200,6 +8203,11 @@ components:
- $ref: '#/components/schemas/ThrottleLimitBase'
- $ref: '#/components/schemas/RequestCountLimit_allOf'
title: Request Count Limit object
AIAPIQuotaLimit:
allOf:
- $ref: '#/components/schemas/ThrottleLimitBase'
- $ref: '#/components/schemas/AIAPIQuotaLimit_allOf'
title: AI API Quota Limit object
EventCountLimit:
allOf:
- $ref: '#/components/schemas/ThrottleLimitBase'
Expand Down Expand Up @@ -10025,6 +10033,30 @@ components:
type: integer
required:
- requestCount
AIAPIQuotaLimit_allOf:
properties:
requestCount:
description: Maximum number of requests allowed
example: 300
format: int64
type: integer
totalTokenCount:
description: Maximum number of total tokens allowed
example: 800
format: int64
type: integer
promptTokenCount:
description: Maximum number of prompt tokens allowed
example: 400
format: int64
type: integer
completionTokenCount:
description: Maximum number of completion tokens allowed
example: 500
format: int64
type: integer
required:
- requestCount
EventCountLimit_allOf:
properties:
eventCount:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.AIAPIQuotaLimitDTO;
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;
Expand All @@ -33,15 +34,17 @@

public class ThrottleLimitDTO {
/**
* Type of the throttling limit. Allowed values are \&quot;REQUESTCOUNTLIMIT\&quot; and \&quot;BANDWIDTHLIMIT\&quot;. Please see schemas of \&quot;RequestCountLimit\&quot; and \&quot;BandwidthLimit\&quot; throttling limit types in Definitions section.
* Type of the throttling limit. Allowed values are \&quot;REQUESTCOUNTLIMIT\&quot;, \&quot;BANDWIDTHLIMIT\&quot;, \&quot;EVENTCOUNTLIMIT\&quot; and \&quot;AIAPIQUOTALIMIT\&quot;. Please see schemas of \&quot;RequestCountLimit\&quot;, \&quot;BandwidthLimit\&quot;, \&quot;EventCountLimit\&quot; and \&quot;AIAPIQuotaLimit\&quot; throttling limit types in Definitions section.
*/
@JsonAdapter(TypeEnum.Adapter.class)
public enum TypeEnum {
REQUESTCOUNTLIMIT("REQUESTCOUNTLIMIT"),

BANDWIDTHLIMIT("BANDWIDTHLIMIT"),

EVENTCOUNTLIMIT("EVENTCOUNTLIMIT");
EVENTCOUNTLIMIT("EVENTCOUNTLIMIT"),

AIAPIQUOTALIMIT("AIAPIQUOTALIMIT");

private String value;

Expand Down Expand Up @@ -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_API_QUOTA = "aiApiQuota";
@SerializedName(SERIALIZED_NAME_AI_API_QUOTA)
private AIAPIQuotaLimitDTO aiApiQuota = null;


public ThrottleLimitDTO type(TypeEnum type) {

Expand All @@ -105,10 +112,10 @@ public ThrottleLimitDTO type(TypeEnum type) {
}

/**
* Type of the throttling limit. Allowed values are \&quot;REQUESTCOUNTLIMIT\&quot; and \&quot;BANDWIDTHLIMIT\&quot;. Please see schemas of \&quot;RequestCountLimit\&quot; and \&quot;BandwidthLimit\&quot; throttling limit types in Definitions section.
* Type of the throttling limit. Allowed values are \&quot;REQUESTCOUNTLIMIT\&quot;, \&quot;BANDWIDTHLIMIT\&quot;, \&quot;EVENTCOUNTLIMIT\&quot; and \&quot;AIAPIQUOTALIMIT\&quot;. Please see schemas of \&quot;RequestCountLimit\&quot;, \&quot;BandwidthLimit\&quot;, \&quot;EventCountLimit\&quot; and \&quot;AIAPIQuotaLimit\&quot; throttling limit types in Definitions section.
* @return type
**/
@ApiModelProperty(example = "REQUESTCOUNTLIMIT", required = true, value = "Type of the throttling limit. Allowed values are \"REQUESTCOUNTLIMIT\" and \"BANDWIDTHLIMIT\". Please see schemas of \"RequestCountLimit\" and \"BandwidthLimit\" throttling limit types in Definitions section. ")
@ApiModelProperty(example = "REQUESTCOUNTLIMIT", required = true, value = "Type of the throttling limit. Allowed values are \"REQUESTCOUNTLIMIT\", \"BANDWIDTHLIMIT\", \"EVENTCOUNTLIMIT\" and \"AIAPIQUOTALIMIT\". Please see schemas of \"RequestCountLimit\", \"BandwidthLimit\", \"EventCountLimit\" and \"AIAPIQuotaLimit\" throttling limit types in Definitions section. ")

public TypeEnum getType() {
return type;
Expand Down Expand Up @@ -189,6 +196,29 @@ public void setEventCount(EventCountLimitDTO eventCount) {
}


public ThrottleLimitDTO aiApiQuota(AIAPIQuotaLimitDTO aiApiQuota) {

this.aiApiQuota = aiApiQuota;
return this;
}

/**
* Get aiApiQuota
* @return aiApiQuota
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "")

public AIAPIQuotaLimitDTO getAiApiQuota() {
return aiApiQuota;
}


public void setAiApiQuota(AIAPIQuotaLimitDTO aiApiQuota) {
this.aiApiQuota = aiApiQuota;
}


@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -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.aiApiQuota, throttleLimit.aiApiQuota);
}

@Override
public int hashCode() {
return Objects.hash(type, requestCount, bandwidth, eventCount);
return Objects.hash(type, requestCount, bandwidth, eventCount, aiApiQuota);
}


Expand All @@ -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(" aiApiQuota: ").append(toIndentedString(aiApiQuota)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4886,20 +4886,24 @@ components:
type:
type: string
description: |
Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT".
Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in
Definitions section.
Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT", "BANDWIDTHLIMIT", "EVENTCOUNTLIMIT"
and "AIAPIQUOTALIMIT".
Please see schemas of "RequestCountLimit", "BandwidthLimit", "EventCountLimit" and "AIAPIQuotaLimit"
throttling limit types in Definitions section.
example: REQUESTCOUNTLIMIT
enum:
- REQUESTCOUNTLIMIT
- BANDWIDTHLIMIT
- EVENTCOUNTLIMIT
- AIAPIQUOTALIMIT
requestCount:
$ref: '#/components/schemas/RequestCountLimit'
bandwidth:
$ref: '#/components/schemas/BandwidthLimit'
eventCount:
$ref: '#/components/schemas/EventCountLimit'
aiApiQuota:
$ref: '#/components/schemas/AIAPIQuotaLimit'
BurstLimit:
title: Burst Limit object
type: object
Expand Down Expand Up @@ -4963,6 +4967,34 @@ components:
description: Maximum number of requests allowed
format: int64
example: 30
AIAPIQuotaLimit:
title: AI API 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: 300
totalTokenCount:
type: integer
description: Maximum number of total tokens allowed
format: int64
example: 800
promptTokenCount:
type: integer
description: Maximum number of prompt tokens allowed
format: int64
example: 400
completionTokenCount:
type: integer
description: Maximum number of completion tokens allowed
format: int64
example: 500
EventCountLimit:
title: Event Count Limit object
allOf:
Expand Down
Loading

0 comments on commit 1c202a4

Please sign in to comment.