Skip to content

Commit

Permalink
Merge with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilliwiddit committed Jan 3, 2025
2 parents 81bf319 + e9197c0 commit 897309e
Show file tree
Hide file tree
Showing 499 changed files with 55,203 additions and 3,315 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# See: https://help.github.com/articles/about-codeowners/

# These owners will be the default owners for everything in the repo.
* @tharindu1st @AnuGayan @chamilaadhi @Arshardh @dushaniw @tgtshanika
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
permissions:
contents: read # to fetch code (actions/checkout)
concurrency:
group: ${{ github.event.number }}
group: ${{ github.event.number || github.run_id }}
cancel-in-progress: true
jobs:
build-carbon:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11.0.16+8
java-version: 11.0.24
distribution: 'temurin'
- uses: actions/setup-node@v3
with:
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
run: mv product-apim/modules/integration/tests-integration/tests-backend/target/surefire-reports/TEST-TestSuite.xml TEST-TestSuite_${{ matrix.id }}.xml
- name: Archive testng report
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: TEST-TestSuite_${{ matrix.id }}
path: |
Expand Down Expand Up @@ -170,4 +170,4 @@ jobs:
fetch-depth: '10'
path: product-apim
- name: Build product-apim with tests
run: mvn clean install -Dcarbon.apimgt.version=$(cat ../CARBON_APIMGT_VERSION_FILE) -fae --file product-apim/pom.xml -DskipIntegrationTests
run: mvn clean install -Dcarbon.apimgt.version=$(cat ../CARBON_APIMGT_VERSION_FILE) -fae --file product-apim/pom.xml -DskipIntegrationTests
20 changes: 13 additions & 7 deletions .github/workflows/sonar-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,31 @@ jobs:
with:
java-version: 11.0.16+8
distribution: 'temurin'
- uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2
restore-keys: ${{ runner.os }}-m2

- name: Build carbon-apimgt with Tests, skipping AspectJ
run: mvn clean install --file pom.xml -Dskip.aspectj=true -Dmaven.test.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'temurin'
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build carbon-apimgt with Tests, skipping AspectJ
run: mvn clean install sonar:sonar --file pom.xml -Dskip.aspectj=true -Dmaven.test.skip=true
- name: run sonar scan
run: mvn sonar:sonar --file pom.xml -Dskip.aspectj=true -Dmaven.test.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
6 changes: 5 additions & 1 deletion components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.135</version>
<version>9.30.95-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand All @@ -21,6 +21,10 @@
<name>WSO2 Carbon - API Management API</name>

<dependencies>
<dependency>
<groupId>org.wso2.orbit.com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.wso2.carbon.apimgt.api.model.Application;
import org.wso2.carbon.apimgt.api.model.ApplicationInfo;
import org.wso2.carbon.apimgt.api.model.Environment;
import org.wso2.carbon.apimgt.api.model.LLMProvider;
import org.wso2.carbon.apimgt.api.model.Monetization;
import org.wso2.carbon.apimgt.api.model.MonetizationUsagePublishInfo;
import org.wso2.carbon.apimgt.api.model.Workflow;
Expand Down Expand Up @@ -540,4 +541,57 @@ List<KeyManagerConfigurationDTO> getGlobalKeyManagerConfigurations(String organi
* @throws APIManagementException
*/
void deleteGlobalKeyManagerConfigurationById(String id) throws APIManagementException;

/**
* Adds a new LLM Provider for the given organization.
*
* @param organization the organization name to filter
* @param provider The LLM Provider to add.
* @return The added LLM Provider.
* @throws APIManagementException If adding fails.
*/
LLMProvider addLLMProvider(String organization, LLMProvider provider) throws APIManagementException;

/**
* Retrieves a list of LLM providers based on the given filters.
*
* @param organization the organization name to filter
* @param name the provider name to filter
* @param apiVersion the API version to filter
* @param builtInSupport whether to filter
* @return a list of LLM providers matching the specified filters
* @throws APIManagementException if an error occurs while retrieving the providers
*/
List<LLMProvider> getLLMProviders(String organization, String name, String apiVersion, Boolean builtInSupport) throws APIManagementException;

/**
* Deletes an LLM Provider by ID for the given organization.
*
* @param organization The organization name.
* @param provider LLM Provider.
* @param builtIn Whether the provider is built-in.
* @return Deleted LLM Provider UUID.
* @throws APIManagementException If deletion fails.
*/
String deleteLLMProvider(String organization, LLMProvider provider, boolean builtIn) throws APIManagementException;

/**
* Updates an LLM Provider for the given organization.
*
* @param organization The organization name.
* @param provider The LLM Provider with updated data.
* @return Updated LLM Provider.
* @throws APIManagementException If update fails.
*/
LLMProvider updateLLMProvider(String organization, LLMProvider provider) throws APIManagementException;

/**
* Retrieves an LLM Provider by ID for the given organization.
*
* @param organization The organization name.
* @param llmProviderId The ID of the LLM Provider.
* @return The LLM Provider.
* @throws APIManagementException If retrieval fails.
*/
LLMProvider getLLMProvider(String organization, String llmProviderId) throws APIManagementException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.wso2.carbon.apimgt.api;

import java.io.File;

/**
* This class contains common constants for APIs.
*/
Expand All @@ -44,4 +46,55 @@ public class APIConstants {
public static final String ENDPOINT_SECURITY_PRODUCTION = "production";
public static final String ENDPOINT_SECURITY_SANDBOX = "sandbox";
public static final String ENDPOINT_CONFIG_SESSION_TIMEOUT = "sessionTimeOut";

public static class AIAPIConstants {
public static final String LLM_PROVIDERS = "llmProviders";
public static final String LLM_PROVIDER_ID = "llmProviderId";
public static final String API_KEY_IDENTIFIER_TYPE_HEADER = "HEADER";
public static final String API_KEY_IDENTIFIER_TYPE_QUERY_PARAMETER = "QUERY_PARAMETER";
public static final String AI_API_REQUEST_METADATA = "AI_API_REQUEST_METADATA";
public static final String AI_API_RESPONSE_METADATA = "AI_API_RESPONSE_METADATA";
public static final String INPUT_SOURCE_PAYLOAD = "payload";
public static final String CONNECTOR_TYPE = "connectorType";
public static final String ID = "id";
public static final String NAME = "name";
public static final String API_VERSION = "apiVersion";
public static final String LLM_PROVIDER_CONFIGURATIONS = "configurations";
public static final String LLM_CONFIGS_ENDPOINT = "/llm-providers";
public static final String CONFIGURATIONS = "configurations";
public static final String AI_API_DEFINITION_FILE_PATH = File.separator + "repository" + File.separator +
"resources" + File.separator + "api_definitions" + File.separator;
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_NAME = "AzureOpenAI";
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_VERSION = "1.0.0";
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_CONNECTOR = "azureOpenAi_1.0.0";
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_KEY = "api-key";
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_API_DEFINITION_FILE_NAME = "azure_api.yaml";
public static final String LLM_PROVIDER_SERVICE_AZURE_OPENAI_DESCRIPTION = "Azure OpenAI service";
public static final String LLM_PROVIDER_SERVICE_OPENAI_NAME = "OpenAI";
public static final String LLM_PROVIDER_SERVICE_OPENAI_VERSION = "1.0.0";
public static final String LLM_PROVIDER_SERVICE_OPENAI_CONNECTOR = "openAi_1.0.0";
public static final String LLM_PROVIDER_SERVICE_OPENAI_KEY = "Authorization";
public static final String LLM_PROVIDER_SERVICE_OPENAI_API_DEFINITION_FILE_NAME = "openai_api.yaml";
public static final String LLM_PROVIDER_SERVICE_OPENAI_DESCRIPTION = "OpenAI service";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_NAME = "MistralAI";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_VERSION = "1.0.0";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_CONNECTOR = "mistralAi_1.0.0";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_KEY = "Authorization";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_API_DEFINITION_FILE_NAME = "mistral_api.yaml";
public static final String LLM_PROVIDER_SERVICE_MISTRALAI_DESCRIPTION = "Mistral AI service";
public static final String LLM_PROVIDER_SERVICE_METADATA_MODEL = "model";
public static final String LLM_PROVIDER_SERVICE_METADATA_PROMPT_TOKEN_COUNT = "promptTokenCount";
public static final String LLM_PROVIDER_SERVICE_METADATA_COMPLETION_TOKEN_COUNT = "completionTokenCount";
public static final String LLM_PROVIDER_SERVICE_METADATA_TOTAL_TOKEN_COUNT = "totalTokenCount";
public static final String LLM_PROVIDER_SERVICE_METADATA_IDENTIFIER_MODEL = "$.model";
public static final String LLM_PROVIDER_SERVICE_METADATA_IDENTIFIER_PROMPT_TOKEN_COUNT = "$.usage" +
".prompt_tokens";
public static final String LLM_PROVIDER_SERVICE_METADATA_IDENTIFIER_COMPLETION_TOKEN_COUNT = "$.usage" +
".completion_tokens";
public static final String LLM_PROVIDER_SERVICE_METADATA_IDENTIFIER_TOTAL_TOKEN_COUNT = "$.usage.total_tokens";
public static final String LLM_PROVIDER_SERVICE_DEFAULT = "default";
public static final String NULL = "null";
public static final String LLM_PROVIDER = "LLM_PROVIDER";
public static final String LLM_PROVIDER_TENANT_ALL = "ALL";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ Set<SubscribedAPI> getSubscribedIdentifiers(Subscriber subscriber,
String getOpenAPIDefinitionForEnvironment(API api, String environmentName)
throws APIManagementException;

/**
* Returns the swagger definition of the API for the given gateway environment and key manager as a string
*
* @param api
* @param environmentName API Gateway environment name
* @param kmId Key Manager UUID
* @return swagger string
* @throws APIManagementException if error occurred while obtaining the swagger definition
*/
String getOpenAPIDefinitionForEnvironmentByKm(API api, String environmentName, String kmId)
throws APIManagementException;

/**
* Revokes the oldAccessToken generating a new one.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ public abstract String populateCustomManagementInfo(String oasDefinition, Swagge
* @param api API
* @param oasDefinition OAS definition
* @param hostsWithSchemes host addresses with protocol mapping
* @param kmId UUID of the Key Manager
* @return updated OAS definition
* @throws APIManagementException throws if an error occurred
*/
public abstract String getOASDefinitionForStore(API api, String oasDefinition, Map<String, String> hostsWithSchemes)
public abstract String getOASDefinitionForStore(API api, String oasDefinition, Map<String, String> hostsWithSchemes,
String kmId)
throws APIManagementException;

/**
Expand All @@ -176,11 +178,12 @@ public abstract String getOASDefinitionForStore(API api, String oasDefinition, M
* @param product APIProduct
* @param oasDefinition OAS definition
* @param hostsWithSchemes host addresses with protocol mapping
* @param kmId UUID of the Key Manager
* @return updated OAS definition
* @throws APIManagementException throws if an error occurred
*/
public abstract String getOASDefinitionForStore(APIProduct product, String oasDefinition,
Map<String, String> hostsWithSchemes) throws APIManagementException;
Map<String, String> hostsWithSchemes, String kmId) throws APIManagementException;

/**
* Update OAS definition for API Publisher
Expand Down
Loading

0 comments on commit 897309e

Please sign in to comment.