diff --git a/all-in-one-apim/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 b/all-in-one-apim/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 index de945afc31..bcffd25be5 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/.openapi-generator/admin-api.yaml.sha256 @@ -1 +1 @@ -66cc36eeddca21e01c5c0d08e5c35d9bba03ef6f8182792364653c50f7fe0897 \ No newline at end of file +dfd237eb3969ec36da358049eaf936f6a3bd5a46e5093aae2d06218f6c6b03f1 \ No newline at end of file diff --git a/all-in-one-apim/modules/integration/tests-common/clients/admin/api/openapi.yaml b/all-in-one-apim/modules/integration/tests-common/clients/admin/api/openapi.yaml index a88cc8d802..76acf74f2f 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/admin/api/openapi.yaml +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/api/openapi.yaml @@ -4840,6 +4840,227 @@ paths: -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/admin/v4/labels/d7cf8523-9180-4255-84fa-6cb171c1f779"' x-contentType: application/json x-accepts: application/json + /ai-service-providers: + get: + description: | + Get all AI Service providers + operationId: getAIServiceProviders + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderSummaryResponseList' + description: | + OK. + AI Service providers returned + security: + - OAuth2Security: + - apim:admin + summary: Get all AI Service providers + tags: + - AIServiceProviders + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers"' + x-accepts: application/json + post: + description: | + Add a new AI Service provider + operationId: addAIServiceProvider + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/AIServiceProviderRequest' + description: | + AI Service provider object that should to be added + required: true + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + description: | + Created. + Successful response with the newly created AI Service provider as entity in the body. + "400": + content: + application/json: + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Bad Request. Invalid request or validation error. + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + summary: Add a AI Service provider + tags: + - AIServiceProviders + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer " -H "Content-Type: + multipart/form-data" -F "name=AIServiceProviderName" -F "apiVersion=v1" + -F "configurations={\"key\":\"value\"}" -F "apiDefinition=@api_definition_file.json" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers"' + x-contentType: multipart/form-data + x-accepts: application/json + /ai-service-providers/{aiServiceProviderId}: + delete: + description: | + Delete a AI Service Provider by aiServiceProviderId + operationId: deleteAIServiceProvider + parameters: + - description: | + AI Service Provider UUID + explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: {} + description: | + OK. + AI Service provider successfully deleted. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + summary: Delete a AI Service Provider + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + x-accepts: application/json + get: + description: | + Get a AI Service Provider + operationId: getAIServiceProvider + parameters: + - description: | + AI Service Provider UUID + explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + description: | + OK. + OpenAPI specification + security: + - OAuth2Security: + - apim:admin + summary: Get AI Service Provider + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + x-accepts: application/json + put: + description: | + Update a AI Service provider by AIServiceProviderId + operationId: updateAIServiceProvider + parameters: + - description: | + AI Service Provider UUID + explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + requestBody: + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/AIServiceProviderRequest' + description: | + AI Service Provider object with updated information + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + description: | + OK. + AI Service Provider updated. + "400": + content: + application/json: + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Bad Request. Invalid request or validation error. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + summary: Update an AI Service provider + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + \ -F "name=UpdatedProviderName" \ -F "apiVersion=v2" \ -F "configurations={\"key\":\"value\"}" + \ -F "apiDefinition=@api_definition.json" \ "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/{aiServiceProviderId}"' + x-contentType: multipart/form-data + x-accepts: application/json /llm-providers: get: description: | @@ -7860,6 +8081,16 @@ components: schema: type: string style: simple + aiServiceProviderId: + description: | + AI Service Provider UUID + explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple policyId: description: | Thorttle policy UUID @@ -9314,6 +9545,185 @@ components: type: array title: Organization List type: object + AIServiceProviderRequest: + properties: + name: + example: OpenAI + maxLength: 255 + minLength: 1 + type: string + apiVersion: + example: 1.0.0 + maxLength: 255 + minLength: 1 + type: string + description: + example: OpenAI LLM + maxLength: 1023 + type: string + multipleModelProviderSupport: + default: "false" + description: | + Indicates whether the AI Service Provider supports multiple model providers. + If true, the AI Service Provider can support multiple model providers. + If false, the AI Service Provider supports only one model provider. + type: string + configurations: + description: LLM Provider configurations + type: string + apiDefinition: + description: OpenAPI specification + format: binary + type: string + modelProviders: + type: string + required: + - apiDefinition + - apiVersion + - configurations + - name + title: AIServiceProvider + type: object + ModelProvider: + example: + models: + - gpt-4o + - gpt-4o + name: OpenAI + properties: + models: + items: + example: gpt-4o + type: string + type: array + name: + example: OpenAI + type: string + required: + - models + - name + title: Model Provider + type: object + AIServiceProviderResponse: + example: + modelProviders: + - models: + - gpt-4o + - gpt-4o + name: OpenAI + - models: + - gpt-4o + - gpt-4o + name: OpenAI + apiVersion: 1.0.0 + multipleModelProviderSupport: true + builtInSupport: true + configurations: configurations + name: OpenAI + description: OpenAI LLM + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + apiDefinition: apiDefinition + properties: + id: + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + readOnly: true + type: string + name: + example: OpenAI + maxLength: 255 + minLength: 1 + type: string + apiVersion: + example: 1.0.0 + maxLength: 255 + minLength: 1 + type: string + builtInSupport: + description: Is built-in support + type: boolean + multipleModelProviderSupport: + description: | + Indicates whether the AI Service Provider supports multiple model providers. + If true, the AI Service Provider can support multiple model providers. + If false, the AI Service Provider supports only one model provider. + type: boolean + description: + example: OpenAI LLM + maxLength: 1023 + type: string + configurations: + description: LLM Provider configurations + type: string + apiDefinition: + description: OpenAPI specification + type: string + modelProviders: + description: List of model providers supported by the AI Service Provider + items: + $ref: '#/components/schemas/ModelProvider' + type: array + title: AIServiceProviderResponse + type: object + AIServiceProviderSummaryResponse: + example: + apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + properties: + id: + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + readOnly: true + type: string + name: + example: open-ai + maxLength: 255 + minLength: 1 + type: string + apiVersion: + example: 1.0.0 + maxLength: 255 + minLength: 1 + type: string + builtInSupport: + description: Is built-in support + type: boolean + description: + example: OpenAI LLM Provider + maxLength: 1023 + type: string + required: + - apiVersion + - name + title: AIServiceProviderSummaryResponse + type: object + AIServiceProviderSummaryResponseList: + example: + count: 1 + list: + - apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + - apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + properties: + count: + description: | + Number of LLM Providers returned. + example: 1 + type: integer + list: + items: + $ref: '#/components/schemas/AIServiceProviderSummaryResponse' + type: array + title: AIServiceProviderSummaryResponseList + type: object LLMProviderRequest: properties: name: diff --git a/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProviderApi.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProviderApi.java new file mode 100644 index 0000000000..ef2c0f96af --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProviderApi.java @@ -0,0 +1,476 @@ +/* + * 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; + +import org.wso2.am.integration.clients.admin.ApiCallback; +import org.wso2.am.integration.clients.admin.ApiClient; +import org.wso2.am.integration.clients.admin.ApiException; +import org.wso2.am.integration.clients.admin.ApiResponse; +import org.wso2.am.integration.clients.admin.Configuration; +import org.wso2.am.integration.clients.admin.Pair; +import org.wso2.am.integration.clients.admin.ProgressRequestBody; +import org.wso2.am.integration.clients.admin.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderResponseDTO; +import org.wso2.am.integration.clients.admin.api.dto.ErrorDTO; +import java.io.File; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AiServiceProviderApi { + private ApiClient localVarApiClient; + + public AiServiceProviderApi() { + this(Configuration.getDefaultApiClient()); + } + + public AiServiceProviderApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for deleteAIServiceProvider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + +
Status Code Description Response Headers
200 OK. AI Service provider successfully deleted. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call deleteAIServiceProviderCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteAIServiceProviderValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling deleteAIServiceProvider(Async)"); + } + + + okhttp3.Call localVarCall = deleteAIServiceProviderCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Delete a AI Service Provider + * Delete a AI Service Provider by aiServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
200 OK. AI Service provider successfully deleted. -
404 Not Found. The specified resource does not exist. -
+ */ + public void deleteAIServiceProvider(String aiServiceProviderId) throws ApiException { + deleteAIServiceProviderWithHttpInfo(aiServiceProviderId); + } + + /** + * Delete a AI Service Provider + * Delete a AI Service Provider by aiServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
200 OK. AI Service provider successfully deleted. -
404 Not Found. The specified resource does not exist. -
+ */ + public ApiResponse deleteAIServiceProviderWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = deleteAIServiceProviderValidateBeforeCall(aiServiceProviderId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete a AI Service Provider (asynchronously) + * Delete a AI Service Provider by aiServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + +
Status Code Description Response Headers
200 OK. AI Service provider successfully deleted. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call deleteAIServiceProviderAsync(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteAIServiceProviderValidateBeforeCall(aiServiceProviderId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for getAIServiceProvider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. OpenAPI specification -
+ */ + public okhttp3.Call getAIServiceProviderCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProviderValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling getAIServiceProvider(Async)"); + } + + + okhttp3.Call localVarCall = getAIServiceProviderCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Get AI Service Provider + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @return AIServiceProviderResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. OpenAPI specification -
+ */ + public AIServiceProviderResponseDTO getAIServiceProvider(String aiServiceProviderId) throws ApiException { + ApiResponse localVarResp = getAIServiceProviderWithHttpInfo(aiServiceProviderId); + return localVarResp.getData(); + } + + /** + * Get AI Service Provider + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @return ApiResponse<AIServiceProviderResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. OpenAPI specification -
+ */ + public ApiResponse getAIServiceProviderWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = getAIServiceProviderValidateBeforeCall(aiServiceProviderId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI Service Provider (asynchronously) + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. OpenAPI specification -
+ */ + public okhttp3.Call getAIServiceProviderAsync(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProviderValidateBeforeCall(aiServiceProviderId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for updateAIServiceProvider + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. AI Service Provider updated. -
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call updateAIServiceProviderCall(String aiServiceProviderId, String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + if (name != null) { + localVarFormParams.put("name", name); + } + + if (apiVersion != null) { + localVarFormParams.put("apiVersion", apiVersion); + } + + if (description != null) { + localVarFormParams.put("description", description); + } + + if (multipleModelProviderSupport != null) { + localVarFormParams.put("multipleModelProviderSupport", multipleModelProviderSupport); + } + + if (configurations != null) { + localVarFormParams.put("configurations", configurations); + } + + if (apiDefinition != null) { + localVarFormParams.put("apiDefinition", apiDefinition); + } + + if (modelProviders != null) { + localVarFormParams.put("modelProviders", modelProviders); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateAIServiceProviderValidateBeforeCall(String aiServiceProviderId, String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling updateAIServiceProvider(Async)"); + } + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling updateAIServiceProvider(Async)"); + } + + // verify the required parameter 'apiVersion' is set + if (apiVersion == null) { + throw new ApiException("Missing the required parameter 'apiVersion' when calling updateAIServiceProvider(Async)"); + } + + // verify the required parameter 'configurations' is set + if (configurations == null) { + throw new ApiException("Missing the required parameter 'configurations' when calling updateAIServiceProvider(Async)"); + } + + // verify the required parameter 'apiDefinition' is set + if (apiDefinition == null) { + throw new ApiException("Missing the required parameter 'apiDefinition' when calling updateAIServiceProvider(Async)"); + } + + + okhttp3.Call localVarCall = updateAIServiceProviderCall(aiServiceProviderId, name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, _callback); + return localVarCall; + + } + + /** + * Update an AI Service provider + * Update a AI Service provider by AIServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @return AIServiceProviderResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. AI Service Provider updated. -
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
+ */ + public AIServiceProviderResponseDTO updateAIServiceProvider(String aiServiceProviderId, String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders) throws ApiException { + ApiResponse localVarResp = updateAIServiceProviderWithHttpInfo(aiServiceProviderId, name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders); + return localVarResp.getData(); + } + + /** + * Update an AI Service provider + * Update a AI Service provider by AIServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @return ApiResponse<AIServiceProviderResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. AI Service Provider updated. -
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
+ */ + public ApiResponse updateAIServiceProviderWithHttpInfo(String aiServiceProviderId, String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders) throws ApiException { + okhttp3.Call localVarCall = updateAIServiceProviderValidateBeforeCall(aiServiceProviderId, name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update an AI Service provider (asynchronously) + * Update a AI Service provider by AIServiceProviderId + * @param aiServiceProviderId AI Service Provider UUID (required) + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. AI Service Provider updated. -
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call updateAIServiceProviderAsync(String aiServiceProviderId, String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateAIServiceProviderValidateBeforeCall(aiServiceProviderId, name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProvidersApi.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProvidersApi.java new file mode 100644 index 0000000000..f0183fcba3 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/AiServiceProvidersApi.java @@ -0,0 +1,342 @@ +/* + * 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; + +import org.wso2.am.integration.clients.admin.ApiCallback; +import org.wso2.am.integration.clients.admin.ApiClient; +import org.wso2.am.integration.clients.admin.ApiException; +import org.wso2.am.integration.clients.admin.ApiResponse; +import org.wso2.am.integration.clients.admin.Configuration; +import org.wso2.am.integration.clients.admin.Pair; +import org.wso2.am.integration.clients.admin.ProgressRequestBody; +import org.wso2.am.integration.clients.admin.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderResponseDTO; +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderSummaryResponseListDTO; +import org.wso2.am.integration.clients.admin.api.dto.ErrorDTO; +import java.io.File; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AiServiceProvidersApi { + private ApiClient localVarApiClient; + + public AiServiceProvidersApi() { + this(Configuration.getDefaultApiClient()); + } + + public AiServiceProvidersApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for addAIServiceProvider + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created AI Service provider as entity in the body. -
400 Bad Request. Invalid request or validation error. -
+ */ + public okhttp3.Call addAIServiceProviderCall(String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + if (name != null) { + localVarFormParams.put("name", name); + } + + if (apiVersion != null) { + localVarFormParams.put("apiVersion", apiVersion); + } + + if (description != null) { + localVarFormParams.put("description", description); + } + + if (multipleModelProviderSupport != null) { + localVarFormParams.put("multipleModelProviderSupport", multipleModelProviderSupport); + } + + if (configurations != null) { + localVarFormParams.put("configurations", configurations); + } + + if (apiDefinition != null) { + localVarFormParams.put("apiDefinition", apiDefinition); + } + + if (modelProviders != null) { + localVarFormParams.put("modelProviders", modelProviders); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "multipart/form-data" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addAIServiceProviderValidateBeforeCall(String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException("Missing the required parameter 'name' when calling addAIServiceProvider(Async)"); + } + + // verify the required parameter 'apiVersion' is set + if (apiVersion == null) { + throw new ApiException("Missing the required parameter 'apiVersion' when calling addAIServiceProvider(Async)"); + } + + // verify the required parameter 'configurations' is set + if (configurations == null) { + throw new ApiException("Missing the required parameter 'configurations' when calling addAIServiceProvider(Async)"); + } + + // verify the required parameter 'apiDefinition' is set + if (apiDefinition == null) { + throw new ApiException("Missing the required parameter 'apiDefinition' when calling addAIServiceProvider(Async)"); + } + + + okhttp3.Call localVarCall = addAIServiceProviderCall(name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, _callback); + return localVarCall; + + } + + /** + * Add a AI Service provider + * Add a new AI Service provider + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @return AIServiceProviderResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created AI Service provider as entity in the body. -
400 Bad Request. Invalid request or validation error. -
+ */ + public AIServiceProviderResponseDTO addAIServiceProvider(String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders) throws ApiException { + ApiResponse localVarResp = addAIServiceProviderWithHttpInfo(name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders); + return localVarResp.getData(); + } + + /** + * Add a AI Service provider + * Add a new AI Service provider + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @return ApiResponse<AIServiceProviderResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created AI Service provider as entity in the body. -
400 Bad Request. Invalid request or validation error. -
+ */ + public ApiResponse addAIServiceProviderWithHttpInfo(String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders) throws ApiException { + okhttp3.Call localVarCall = addAIServiceProviderValidateBeforeCall(name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Add a AI Service provider (asynchronously) + * Add a new AI Service provider + * @param name (required) + * @param apiVersion (required) + * @param configurations LLM Provider configurations (required) + * @param apiDefinition OpenAPI specification (required) + * @param description (optional) + * @param multipleModelProviderSupport Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. (optional, default to "false") + * @param modelProviders (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created AI Service provider as entity in the body. -
400 Bad Request. Invalid request or validation error. -
+ */ + public okhttp3.Call addAIServiceProviderAsync(String name, String apiVersion, String configurations, File apiDefinition, String description, String multipleModelProviderSupport, String modelProviders, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addAIServiceProviderValidateBeforeCall(name, apiVersion, configurations, apiDefinition, description, multipleModelProviderSupport, modelProviders, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAIServiceProviders + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service providers returned -
+ */ + public okhttp3.Call getAIServiceProvidersCall(final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProvidersValidateBeforeCall(final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getAIServiceProvidersCall(_callback); + return localVarCall; + + } + + /** + * Get all AI Service providers + * Get all AI Service providers + * @return AIServiceProviderSummaryResponseListDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service providers returned -
+ */ + public AIServiceProviderSummaryResponseListDTO getAIServiceProviders() throws ApiException { + ApiResponse localVarResp = getAIServiceProvidersWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Get all AI Service providers + * Get all AI Service providers + * @return ApiResponse<AIServiceProviderSummaryResponseListDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service providers returned -
+ */ + public ApiResponse getAIServiceProvidersWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = getAIServiceProvidersValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get all AI Service providers (asynchronously) + * Get all AI Service providers + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service providers returned -
+ */ + public okhttp3.Call getAIServiceProvidersAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProvidersValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderRequestDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderRequestDTO.java new file mode 100644 index 0000000000..c601a57d8a --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderRequestDTO.java @@ -0,0 +1,270 @@ +/* + * 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.File; +import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIServiceProviderRequestDTO +*/ + +public class AIServiceProviderRequestDTO { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MULTIPLE_MODEL_PROVIDER_SUPPORT = "multipleModelProviderSupport"; + @SerializedName(SERIALIZED_NAME_MULTIPLE_MODEL_PROVIDER_SUPPORT) + private String multipleModelProviderSupport = "false"; + + public static final String SERIALIZED_NAME_CONFIGURATIONS = "configurations"; + @SerializedName(SERIALIZED_NAME_CONFIGURATIONS) + private String configurations; + + public static final String SERIALIZED_NAME_API_DEFINITION = "apiDefinition"; + @SerializedName(SERIALIZED_NAME_API_DEFINITION) + private File apiDefinition; + + public static final String SERIALIZED_NAME_MODEL_PROVIDERS = "modelProviders"; + @SerializedName(SERIALIZED_NAME_MODEL_PROVIDERS) + private String modelProviders; + + + public AIServiceProviderRequestDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "OpenAI", required = true, value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public AIServiceProviderRequestDTO apiVersion(String apiVersion) { + + this.apiVersion = apiVersion; + return this; + } + + /** + * Get apiVersion + * @return apiVersion + **/ + @ApiModelProperty(example = "1.0.0", required = true, value = "") + + public String getApiVersion() { + return apiVersion; + } + + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + + public AIServiceProviderRequestDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI LLM", value = "") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public AIServiceProviderRequestDTO multipleModelProviderSupport(String multipleModelProviderSupport) { + + this.multipleModelProviderSupport = multipleModelProviderSupport; + return this; + } + + /** + * Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. + * @return multipleModelProviderSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. ") + + public String getMultipleModelProviderSupport() { + return multipleModelProviderSupport; + } + + + public void setMultipleModelProviderSupport(String multipleModelProviderSupport) { + this.multipleModelProviderSupport = multipleModelProviderSupport; + } + + + public AIServiceProviderRequestDTO configurations(String configurations) { + + this.configurations = configurations; + return this; + } + + /** + * LLM Provider configurations + * @return configurations + **/ + @ApiModelProperty(required = true, value = "LLM Provider configurations") + + public String getConfigurations() { + return configurations; + } + + + public void setConfigurations(String configurations) { + this.configurations = configurations; + } + + + public AIServiceProviderRequestDTO apiDefinition(File apiDefinition) { + + this.apiDefinition = apiDefinition; + return this; + } + + /** + * OpenAPI specification + * @return apiDefinition + **/ + @ApiModelProperty(required = true, value = "OpenAPI specification") + + public File getApiDefinition() { + return apiDefinition; + } + + + public void setApiDefinition(File apiDefinition) { + this.apiDefinition = apiDefinition; + } + + + public AIServiceProviderRequestDTO modelProviders(String modelProviders) { + + this.modelProviders = modelProviders; + return this; + } + + /** + * Get modelProviders + * @return modelProviders + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getModelProviders() { + return modelProviders; + } + + + public void setModelProviders(String modelProviders) { + this.modelProviders = modelProviders; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderRequestDTO aiServiceProviderRequest = (AIServiceProviderRequestDTO) o; + return Objects.equals(this.name, aiServiceProviderRequest.name) && + Objects.equals(this.apiVersion, aiServiceProviderRequest.apiVersion) && + Objects.equals(this.description, aiServiceProviderRequest.description) && + Objects.equals(this.multipleModelProviderSupport, aiServiceProviderRequest.multipleModelProviderSupport) && + Objects.equals(this.configurations, aiServiceProviderRequest.configurations) && + Objects.equals(this.apiDefinition, aiServiceProviderRequest.apiDefinition) && + Objects.equals(this.modelProviders, aiServiceProviderRequest.modelProviders); + } + + @Override + public int hashCode() { + return Objects.hash(name, apiVersion, description, multipleModelProviderSupport, configurations, apiDefinition, modelProviders); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderRequestDTO {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" multipleModelProviderSupport: ").append(toIndentedString(multipleModelProviderSupport)).append("\n"); + sb.append(" configurations: ").append(toIndentedString(configurations)).append("\n"); + sb.append(" apiDefinition: ").append(toIndentedString(apiDefinition)).append("\n"); + sb.append(" modelProviders: ").append(toIndentedString(modelProviders)).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/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderResponseDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderResponseDTO.java new file mode 100644 index 0000000000..6094774244 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderResponseDTO.java @@ -0,0 +1,334 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; +import org.wso2.am.integration.clients.admin.api.dto.ModelProviderDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIServiceProviderResponseDTO +*/ + +public class AIServiceProviderResponseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_BUILT_IN_SUPPORT = "builtInSupport"; + @SerializedName(SERIALIZED_NAME_BUILT_IN_SUPPORT) + private Boolean builtInSupport; + + public static final String SERIALIZED_NAME_MULTIPLE_MODEL_PROVIDER_SUPPORT = "multipleModelProviderSupport"; + @SerializedName(SERIALIZED_NAME_MULTIPLE_MODEL_PROVIDER_SUPPORT) + private Boolean multipleModelProviderSupport; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_CONFIGURATIONS = "configurations"; + @SerializedName(SERIALIZED_NAME_CONFIGURATIONS) + private String configurations; + + public static final String SERIALIZED_NAME_API_DEFINITION = "apiDefinition"; + @SerializedName(SERIALIZED_NAME_API_DEFINITION) + private String apiDefinition; + + public static final String SERIALIZED_NAME_MODEL_PROVIDERS = "modelProviders"; + @SerializedName(SERIALIZED_NAME_MODEL_PROVIDERS) + private List modelProviders = null; + + + public AIServiceProviderResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "ece92bdc-e1e6-325c-b6f4-656208a041e9", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public AIServiceProviderResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI", value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public AIServiceProviderResponseDTO apiVersion(String apiVersion) { + + this.apiVersion = apiVersion; + return this; + } + + /** + * Get apiVersion + * @return apiVersion + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1.0.0", value = "") + + public String getApiVersion() { + return apiVersion; + } + + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + + public AIServiceProviderResponseDTO builtInSupport(Boolean builtInSupport) { + + this.builtInSupport = builtInSupport; + return this; + } + + /** + * Is built-in support + * @return builtInSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Is built-in support") + + public Boolean isBuiltInSupport() { + return builtInSupport; + } + + + public void setBuiltInSupport(Boolean builtInSupport) { + this.builtInSupport = builtInSupport; + } + + + public AIServiceProviderResponseDTO multipleModelProviderSupport(Boolean multipleModelProviderSupport) { + + this.multipleModelProviderSupport = multipleModelProviderSupport; + return this; + } + + /** + * Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. + * @return multipleModelProviderSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Indicates whether the AI Service Provider supports multiple model providers. If true, the AI Service Provider can support multiple model providers. If false, the AI Service Provider supports only one model provider. ") + + public Boolean isMultipleModelProviderSupport() { + return multipleModelProviderSupport; + } + + + public void setMultipleModelProviderSupport(Boolean multipleModelProviderSupport) { + this.multipleModelProviderSupport = multipleModelProviderSupport; + } + + + public AIServiceProviderResponseDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI LLM", value = "") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public AIServiceProviderResponseDTO configurations(String configurations) { + + this.configurations = configurations; + return this; + } + + /** + * LLM Provider configurations + * @return configurations + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "LLM Provider configurations") + + public String getConfigurations() { + return configurations; + } + + + public void setConfigurations(String configurations) { + this.configurations = configurations; + } + + + public AIServiceProviderResponseDTO apiDefinition(String apiDefinition) { + + this.apiDefinition = apiDefinition; + return this; + } + + /** + * OpenAPI specification + * @return apiDefinition + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "OpenAPI specification") + + public String getApiDefinition() { + return apiDefinition; + } + + + public void setApiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + } + + + public AIServiceProviderResponseDTO modelProviders(List modelProviders) { + + this.modelProviders = modelProviders; + return this; + } + + /** + * List of model providers supported by the AI Service Provider + * @return modelProviders + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of model providers supported by the AI Service Provider") + + public List getModelProviders() { + return modelProviders; + } + + + public void setModelProviders(List modelProviders) { + this.modelProviders = modelProviders; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderResponseDTO aiServiceProviderResponse = (AIServiceProviderResponseDTO) o; + return Objects.equals(this.id, aiServiceProviderResponse.id) && + Objects.equals(this.name, aiServiceProviderResponse.name) && + Objects.equals(this.apiVersion, aiServiceProviderResponse.apiVersion) && + Objects.equals(this.builtInSupport, aiServiceProviderResponse.builtInSupport) && + Objects.equals(this.multipleModelProviderSupport, aiServiceProviderResponse.multipleModelProviderSupport) && + Objects.equals(this.description, aiServiceProviderResponse.description) && + Objects.equals(this.configurations, aiServiceProviderResponse.configurations) && + Objects.equals(this.apiDefinition, aiServiceProviderResponse.apiDefinition) && + Objects.equals(this.modelProviders, aiServiceProviderResponse.modelProviders); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, apiVersion, builtInSupport, multipleModelProviderSupport, description, configurations, apiDefinition, modelProviders); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderResponseDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" builtInSupport: ").append(toIndentedString(builtInSupport)).append("\n"); + sb.append(" multipleModelProviderSupport: ").append(toIndentedString(multipleModelProviderSupport)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" configurations: ").append(toIndentedString(configurations)).append("\n"); + sb.append(" apiDefinition: ").append(toIndentedString(apiDefinition)).append("\n"); + sb.append(" modelProviders: ").append(toIndentedString(modelProviders)).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/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseDTO.java new file mode 100644 index 0000000000..2cc7e86681 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseDTO.java @@ -0,0 +1,213 @@ +/* + * 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; +/** +* AIServiceProviderSummaryResponseDTO +*/ + +public class AIServiceProviderSummaryResponseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_BUILT_IN_SUPPORT = "builtInSupport"; + @SerializedName(SERIALIZED_NAME_BUILT_IN_SUPPORT) + private Boolean builtInSupport; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + + public AIServiceProviderSummaryResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "ece92bdc-e1e6-325c-b6f4-656208a041e9", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public AIServiceProviderSummaryResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "open-ai", required = true, value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public AIServiceProviderSummaryResponseDTO apiVersion(String apiVersion) { + + this.apiVersion = apiVersion; + return this; + } + + /** + * Get apiVersion + * @return apiVersion + **/ + @ApiModelProperty(example = "1.0.0", required = true, value = "") + + public String getApiVersion() { + return apiVersion; + } + + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + + public AIServiceProviderSummaryResponseDTO builtInSupport(Boolean builtInSupport) { + + this.builtInSupport = builtInSupport; + return this; + } + + /** + * Is built-in support + * @return builtInSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Is built-in support") + + public Boolean isBuiltInSupport() { + return builtInSupport; + } + + + public void setBuiltInSupport(Boolean builtInSupport) { + this.builtInSupport = builtInSupport; + } + + + public AIServiceProviderSummaryResponseDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI LLM Provider", value = "") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderSummaryResponseDTO aiServiceProviderSummaryResponse = (AIServiceProviderSummaryResponseDTO) o; + return Objects.equals(this.id, aiServiceProviderSummaryResponse.id) && + Objects.equals(this.name, aiServiceProviderSummaryResponse.name) && + Objects.equals(this.apiVersion, aiServiceProviderSummaryResponse.apiVersion) && + Objects.equals(this.builtInSupport, aiServiceProviderSummaryResponse.builtInSupport) && + Objects.equals(this.description, aiServiceProviderSummaryResponse.description); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, apiVersion, builtInSupport, description); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderSummaryResponseDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" builtInSupport: ").append(toIndentedString(builtInSupport)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).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/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseListDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseListDTO.java new file mode 100644 index 0000000000..26e421b54b --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/AIServiceProviderSummaryResponseListDTO.java @@ -0,0 +1,131 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderSummaryResponseDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIServiceProviderSummaryResponseListDTO +*/ + +public class AIServiceProviderSummaryResponseListDTO { + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public static final String SERIALIZED_NAME_LIST = "list"; + @SerializedName(SERIALIZED_NAME_LIST) + private List list = null; + + + public AIServiceProviderSummaryResponseListDTO count(Integer count) { + + this.count = count; + return this; + } + + /** + * Number of LLM Providers returned. + * @return count + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1", value = "Number of LLM Providers returned. ") + + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + public AIServiceProviderSummaryResponseListDTO list(List list) { + + this.list = list; + return this; + } + + /** + * Get list + * @return list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getList() { + return list; + } + + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderSummaryResponseListDTO aiServiceProviderSummaryResponseList = (AIServiceProviderSummaryResponseListDTO) o; + return Objects.equals(this.count, aiServiceProviderSummaryResponseList.count) && + Objects.equals(this.list, aiServiceProviderSummaryResponseList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, list); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderSummaryResponseListDTO {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).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/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ModelProviderDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ModelProviderDTO.java new file mode 100644 index 0000000000..24819e6be5 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/gen/java/org/wso2/am/integration/clients/admin/api/dto/ModelProviderDTO.java @@ -0,0 +1,128 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* ModelProviderDTO +*/ + +public class ModelProviderDTO { + public static final String SERIALIZED_NAME_MODELS = "models"; + @SerializedName(SERIALIZED_NAME_MODELS) + private List models = new ArrayList(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + public ModelProviderDTO models(List models) { + + this.models = models; + return this; + } + + /** + * Get models + * @return models + **/ + @ApiModelProperty(required = true, value = "") + + public List getModels() { + return models; + } + + + public void setModels(List models) { + this.models = models; + } + + + public ModelProviderDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "OpenAI", required = true, value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelProviderDTO modelProvider = (ModelProviderDTO) o; + return Objects.equals(this.models, modelProvider.models) && + Objects.equals(this.name, modelProvider.name); + } + + @Override + public int hashCode() { + return Objects.hash(models, name); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class ModelProviderDTO {\n"); + sb.append(" models: ").append(toIndentedString(models)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/all-in-one-apim/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml index c56448e463..2887ee5a3f 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml +++ b/all-in-one-apim/modules/integration/tests-common/clients/admin/src/main/resources/admin-api.yaml @@ -2782,6 +2782,170 @@ paths: source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://127.0.0.1:9443/api/am/admin/v4/labels/d7cf8523-9180-4255-84fa-6cb171c1f779"' + ###################################################### + # AI Service Providers resource APIs + ###################################################### + /ai-service-providers: + get: + tags: + - AIServiceProviders + summary: Get all AI Service providers + description: | + Get all AI Service providers + responses: + 200: + description: | + OK. + AI Service providers returned + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderSummaryResponseList' + security: + - OAuth2Security: + - apim:admin + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers"' + operationId: getAIServiceProviders + + post: + tags: + - AIServiceProviders + summary: Add a AI Service provider + description: | + Add a new AI Service provider + requestBody: + description: | + AI Service provider object that should to be added + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/AIServiceProviderRequest' + required: true + responses: + 201: + description: | + Created. + Successful response with the newly created AI Service provider as entity in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + 400: + $ref: '#/components/responses/BadRequest' + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer " -H "Content-Type: multipart/form-data" + -F "name=AIServiceProviderName" -F "apiVersion=v1" -F "configurations={\"key\":\"value\"}" + -F "apiDefinition=@api_definition_file.json" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers"' + operationId: addAIServiceProvider + + ###################################################### + # The "Individual AI Service Provider" resource APIs + ###################################################### + /ai-service-providers/{aiServiceProviderId}: + put: + tags: + - AIServiceProvider + summary: Update an AI Service provider + description: | + Update a AI Service provider by AIServiceProviderId + parameters: + - $ref: '#/components/parameters/aiServiceProviderId' + requestBody: + description: | + AI Service Provider object with updated information + content: + multipart/form-data: + schema: + $ref: '#/components/schemas/AIServiceProviderRequest' + required: true + responses: + 200: + description: | + OK. + AI Service Provider updated. + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" \ + -F "name=UpdatedProviderName" \ + -F "apiVersion=v2" \ + -F "configurations={\"key\":\"value\"}" \ + -F "apiDefinition=@api_definition.json" \ + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/{aiServiceProviderId}"' + operationId: updateAIServiceProvider + + delete: + tags: + - AIServiceProvider + summary: Delete a AI Service Provider + description: | + Delete a AI Service Provider by aiServiceProviderId + parameters: + - $ref: '#/components/parameters/aiServiceProviderId' + responses: + 200: + description: | + OK. + AI Service provider successfully deleted. + content: { } + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:admin + - apim:llm_provider_manage + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + operationId: deleteAIServiceProvider + + get: + tags: + - AIServiceProvider + summary: Get AI Service Provider + description: | + Get a AI Service Provider + parameters: + - $ref: '#/components/parameters/aiServiceProviderId' + responses: + 200: + description: | + OK. + OpenAPI specification + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + security: + - OAuth2Security: + - apim:admin + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/admin/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + operationId: getAIServiceProvider + ###################################################### # LLM Providers resource APIs ###################################################### @@ -5745,6 +5909,143 @@ components: type: array items: $ref: '#/components/schemas/Organization' + AIServiceProviderRequest: + title: AIServiceProvider + required: + - name + - apiVersion + - configurations + - apiDefinition + type: object + properties: + name: + maxLength: 255 + minLength: 1 + type: string + example: OpenAI + apiVersion: + maxLength: 255 + minLength: 1 + type: string + example: 1.0.0 + description: + maxLength: 1023 + type: string + example: OpenAI LLM + multipleModelProviderSupport: + type: string + description: | + Indicates whether the AI Service Provider supports multiple model providers. + If true, the AI Service Provider can support multiple model providers. + If false, the AI Service Provider supports only one model provider. + default: "false" + configurations: + type: string + description: LLM Provider configurations + apiDefinition: + type: string + description: OpenAPI specification + format: binary + modelProviders: + type: string + ModelProvider: + title: Model Provider + type: object + required: + - name + - models + properties: + models: + type: array + items: + type: string + example: "gpt-4o" + name: + type: string + example: OpenAI + AIServiceProviderResponse: + title: AIServiceProviderResponse + type: object + properties: + id: + type: string + readOnly: true + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + name: + maxLength: 255 + minLength: 1 + type: string + example: OpenAI + apiVersion: + maxLength: 255 + minLength: 1 + type: string + example: 1.0.0 + builtInSupport: + type: boolean + description: Is built-in support + multipleModelProviderSupport: + type: boolean + description: | + Indicates whether the AI Service Provider supports multiple model providers. + If true, the AI Service Provider can support multiple model providers. + If false, the AI Service Provider supports only one model provider. + description: + maxLength: 1023 + type: string + example: OpenAI LLM + configurations: + type: string + description: LLM Provider configurations + apiDefinition: + type: string + description: OpenAPI specification + modelProviders: + type: array + description: List of model providers supported by the AI Service Provider + items: + $ref: '#/components/schemas/ModelProvider' + AIServiceProviderSummaryResponse: + title: AIServiceProviderSummaryResponse + type: object + required: + - name + - apiVersion + properties: + id: + type: string + readOnly: true + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + name: + maxLength: 255 + minLength: 1 + type: string + example: open-ai + apiVersion: + maxLength: 255 + minLength: 1 + type: string + example: 1.0.0 + builtInSupport: + type: boolean + description: Is built-in support + description: + maxLength: 1023 + type: string + example: OpenAI LLM Provider + AIServiceProviderSummaryResponseList: + title: AIServiceProviderSummaryResponseList + type: object + properties: + count: + type: integer + description: | + Number of LLM Providers returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/AIServiceProviderSummaryResponse' LLMProviderRequest: title: LLMProvider type: object @@ -6880,6 +7181,14 @@ components: required: true schema: type: string + aiServiceProviderId: + name: aiServiceProviderId + in: path + description: | + AI Service Provider UUID + required: true + schema: + type: string policyId: name: policyId in: path diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 b/all-in-one-apim/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 index 7cfe53b16e..7a1796b0d3 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 @@ -1 +1 @@ -5c7554b2fa756ce1039fa5d021f7ec32dd0a3e47c25c29aeb003e622bfacf248 \ No newline at end of file +36c5a264d30c86cb3b84eb92636d8a05dcdcee1cee17d5a3bac0df4fe78fa21c \ No newline at end of file diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/api/openapi.yaml b/all-in-one-apim/modules/integration/tests-common/clients/publisher/api/openapi.yaml index 210fc6e663..fe8e4dafc8 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/api/openapi.yaml +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/api/openapi.yaml @@ -15851,6 +15851,633 @@ paths: source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://127.0.0.1:9443/api/am/publisher/v2/operation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' x-accepts: application/json + /apis/{apiId}/endpoints: + get: + description: | + This operation can be used to get all the available endpoints of an API. + operationId: getApiEndpoints + parameters: + - description: | + **API ID** consisting of the **UUID** of the API. + explode: false + in: path + name: apiId + required: true + schema: + type: string + style: simple + - description: | + Maximum size of resource array to return. + explode: true + in: query + name: limit + required: false + schema: + default: 25 + type: integer + style: form + - description: | + Starting point within the complete list of items qualified. + explode: true + in: query + name: offset + required: false + schema: + default: 0 + type: integer + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpointList' + description: | + OK. + List of API endpoints. + headers: + Content-Type: + description: | + The content type of the body. + explode: false + schema: + type: string + style: simple + "400": + content: + application/json: + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Bad Request. Invalid request or validation error. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + "500": + content: + application/json: + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error. + security: + - OAuth2Security: + - apim:api_view + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + summary: Get all API Endpoints + tags: + - API Endpoints + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints?limit=10&offset=0"' + x-accepts: application/json + post: + description: | + This operation can be used to add an endpoint to an API. + operationId: addApiEndpoint + parameters: + - description: | + **API ID** consisting of the **UUID** of the API. + explode: false + in: path + name: apiId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + description: Endpoint object that needs to be added + required: true + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + description: | + Created. + Successful response with the newly created API Endpoint object in the body. + "400": + content: + application/json: + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Bad Request. Invalid request or validation error. + "415": + content: + application/json: + example: + code: 415 + message: Unsupported media type + description: The entity of the request was not in a supported format + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Unsupported Media Type. The entity of the request was not in + a supported format. + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + summary: Add an Endpoint + tags: + - API Endpoints + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints"' + x-contentType: application/json + x-accepts: application/json + /apis/{apiId}/endpoints/{endpointId}: + delete: + description: | + This operation can be used to delete a API endpoint. + operationId: deleteApiEndpoint + parameters: + - description: | + **API ID** consisting of the **UUID** of the API. + explode: false + in: path + name: apiId + required: true + schema: + type: string + style: simple + - description: | + **Endpoint ID** consisting of the **UUID** of the Endpoint**. + explode: false + in: path + name: endpointId + required: true + schema: + type: string + style: simple + responses: + "200": + content: {} + description: | + OK. + Endpoint deleted successfully. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + "500": + content: + application/json: + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error. + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + summary: Delete an Endpoint + tags: + - API Endpoints + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + x-accepts: application/json + get: + description: | + This operation can be used to get an endpoint of an API by UUID. + operationId: getApiEndpoint + parameters: + - description: | + **API ID** consisting of the **UUID** of the API. + explode: false + in: path + name: apiId + required: true + schema: + type: string + style: simple + - description: | + **Endpoint ID** consisting of the **UUID** of the Endpoint**. + explode: false + in: path + name: endpointId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + description: | + OK. + API Endpoint object is returned. + headers: + Content-Type: + description: | + The content type of the body. + explode: false + schema: + type: string + style: simple + "500": + content: + application/json: + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + security: + - OAuth2Security: + - apim:api_view + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + summary: Get an Endpoint + tags: + - API Endpoints + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + x-accepts: application/json + put: + description: | + This operation can be used to update a API endpoint. + operationId: updateApiEndpoint + parameters: + - description: | + **API ID** consisting of the **UUID** of the API. + explode: false + in: path + name: apiId + required: true + schema: + type: string + style: simple + - description: | + **Endpoint ID** consisting of the **UUID** of the Endpoint**. + explode: false + in: path + name: endpointId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + description: API Endpoint object with updated details + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + description: | + OK. + Updated API Endpoint is returned. + headers: + Content-Type: + description: | + The content type of the body. + explode: false + schema: + type: string + style: simple + "400": + content: + application/json: + example: + code: 400 + message: Bad Request + description: Invalid request or validation error + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Bad Request. Invalid request or validation error. + "404": + content: + application/json: + example: + code: 404 + message: Not Found + description: The specified resource does not exist + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Found. The specified resource does not exist. + "415": + content: + application/json: + example: + code: 415 + message: Unsupported media type + description: The entity of the request was not in a supported format + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Unsupported Media Type. The entity of the request was not in + a supported format. + "500": + content: + application/json: + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error. + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + summary: Update an Endpoint + tags: + - API Endpoints + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + x-contentType: application/json + x-accepts: application/json + /ai-service-providers: + get: + description: | + Get all AI Service providers + operationId: getAIServiceProviders + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderSummaryResponseList' + description: | + OK. + List of AI Service providers. + headers: + Content-Type: + description: The content type of the body. + explode: false + schema: + type: string + style: simple + "406": + content: + application/json: + example: + code: 406 + message: Not Acceptable + description: The requested media type is not supported + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Not Acceptable. The requested media type is not supported. + "500": + content: + application/json: + example: + code: 500 + message: Internal Server Error + description: The server encountered an internal error. Please contact + administrator. + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error. + security: + - OAuth2Security: + - apim:llm_provider_read + summary: Get all AI Service providers + tags: + - AIServiceProviders + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers"' + x-accepts: application/json + /ai-service-providers/{aiServiceProviderId}/api-definition: + get: + description: | + Get AI Service Provider's API Definition + operationId: getAIServiceProviderApiDefinition + parameters: + - explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + type: string + description: | + OK. + API Definition + security: + - OAuth2Security: + - apim:llm_provider_read + summary: Get AI Service Provider's API Definition + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/api-definition"' + x-accepts: application/json + /ai-service-providers/{aiServiceProviderId}/endpoint-configuration: + get: + description: | + Get AI Service Provider's endpoint security configurations + operationId: getAIServiceProviderEndpointConfiguration + parameters: + - explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderEndpointConfiguration' + description: | + OK. + API Definition + security: + - OAuth2Security: + - apim:llm_provider_read + summary: Get AI Service Provider's security configurations + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/endpoint-configuration"' + x-accepts: application/json + /ai-service-providers/{aiServiceProviderId}/models: + get: + description: | + Get AI Service Provider's model list + operationId: getAIServiceProviderModels + parameters: + - explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/ModelProvider' + type: array + description: | + OK. + List of supported model families grouped by vendor + security: + - OAuth2Security: + - apim:llm_provider_read + summary: Get AI Service Provider's model list + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/models"' + x-accepts: application/json + /ai-service-providers/{aiServiceProviderId}: + get: + description: | + Get a AI Service Provider + operationId: getAIServiceProvider + parameters: + - description: | + AI Service Provider ID + explode: false + in: path + name: aiServiceProviderId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + description: | + OK. + AI Service Provider + security: + - OAuth2Security: + - apim:llm_provider_read + summary: Get AI Service Provider + tags: + - AIServiceProvider + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + x-accepts: application/json /gateway-policies: get: description: | @@ -17631,6 +18258,7 @@ components: type: HTTP version: 1.0.0 provider: admin + subtype: AIAPI gatewayVendor: wso2 securityScheme: - securityScheme @@ -17664,6 +18292,7 @@ components: type: HTTP version: 1.0.0 provider: admin + subtype: AIAPI gatewayVendor: wso2 securityScheme: - securityScheme @@ -17747,6 +18376,7 @@ components: type: HTTP version: 1.0.0 provider: admin + subtype: AIAPI gatewayVendor: wso2 securityScheme: - securityScheme @@ -17804,6 +18434,12 @@ components: type: example: HTTP type: string + subtype: + default: DEFAULT + description: Subtype of the API. + example: AIAPI + readOnly: true + type: string audience: description: The audience of the API. Accepted values are PUBLIC, SINGLE enum: @@ -17916,6 +18552,7 @@ components: type: object API: example: + primarySandboxEndpointId: 13092607-ed01-4fa1-bc64-5da0e2abe92c endpointImplementationType: INLINE workflowStatus: APPROVED isRevision: false @@ -18097,6 +18734,7 @@ components: - http - https revisionId: 1 + primaryProductionEndpointId: 13092607-ed01-4fa1-bc64-5da0e2abe92c businessInformation: "" securityScheme: - oauth2 @@ -18526,6 +19164,12 @@ components: url: https://localhost:9443/am/sample/pizzashack/v1/api/ properties: {} type: object + primaryProductionEndpointId: + example: 13092607-ed01-4fa1-bc64-5da0e2abe92c + type: string + primarySandboxEndpointId: + example: 13092607-ed01-4fa1-bc64-5da0e2abe92c + type: string endpointImplementationType: default: ENDPOINT enum: @@ -20307,6 +20951,224 @@ components: type: array title: Environment List type: object + APIEndpoint: + example: + deploymentStage: PRODUCTION or SANDBOX + endpointConfig: '{}' + name: Endpoint1 + id: 57a380b7-d852-4f56-bb23-db172722e9d4 + properties: + id: + example: 57a380b7-d852-4f56-bb23-db172722e9d4 + type: string + name: + example: Endpoint1 + type: string + deploymentStage: + example: PRODUCTION or SANDBOX + type: string + endpointConfig: + description: | + Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. + properties: {} + type: object + required: + - name + title: Endpoint + type: object + APIEndpointList: + example: + pagination: + next: next + total: 10 + offset: 0 + previous: previous + limit: 1 + count: 1 + list: + - deploymentStage: PRODUCTION or SANDBOX + endpointConfig: '{}' + name: Endpoint1 + id: 57a380b7-d852-4f56-bb23-db172722e9d4 + - deploymentStage: PRODUCTION or SANDBOX + endpointConfig: '{}' + name: Endpoint1 + id: 57a380b7-d852-4f56-bb23-db172722e9d4 + properties: + count: + description: | + Number of Endpoints returned. + example: 1 + type: integer + list: + items: + $ref: '#/components/schemas/APIEndpoint' + type: array + pagination: + $ref: '#/components/schemas/Pagination' + title: Endpoints List + type: object + ModelProvider: + example: + models: + - gpt-4o + - gpt-4o + name: OpenAI + properties: + models: + items: + example: gpt-4o + type: string + type: array + name: + example: OpenAI + type: string + title: Model Provider + type: object + AIServiceProviderResponse: + example: + apiVersion: 1.0.0 + builtInSupport: true + configurations: configurations + name: OpenAI + description: OpenAI LLM + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + apiDefinition: apiDefinition + properties: + id: + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + readOnly: true + type: string + name: + example: OpenAI + maxLength: 255 + minLength: 1 + type: string + apiVersion: + example: 1.0.0 + maxLength: 255 + minLength: 1 + type: string + builtInSupport: + description: Is built-in support + type: boolean + description: + example: OpenAI LLM + maxLength: 1023 + type: string + configurations: + description: LLM Provider configurations + type: string + apiDefinition: + description: OpenAPI specification + type: string + title: AIServiceProviderResponse + type: object + AIServiceProviderSummaryResponse: + example: + apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + properties: + id: + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + readOnly: true + type: string + name: + example: open-ai + maxLength: 255 + minLength: 1 + type: string + apiVersion: + example: 1.0.0 + maxLength: 255 + minLength: 1 + type: string + builtInSupport: + description: Is built-in support + type: boolean + description: + example: OpenAI LLM Provider + maxLength: 1023 + type: string + title: AIServiceProviderSummaryResponse + type: object + AIServiceProviderSummaryResponseList: + example: + count: 1 + list: + - apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + - apiVersion: 1.0.0 + builtInSupport: true + name: open-ai + description: OpenAI LLM Provider + id: ece92bdc-e1e6-325c-b6f4-656208a041e9 + properties: + count: + description: | + Number of LLM Providers returned. + example: 1 + type: integer + list: + items: + $ref: '#/components/schemas/AIServiceProviderSummaryResponse' + type: array + title: AIServiceProviderSummaryResponseList + type: object + AIServiceProviderEndpointConfiguration: + example: + authHeader: Authorization + authQueryParameter: ApiKey + authenticationConfiguration: + type: apiKey + parameters: + headerEnabled: true + headerName: Authorization + enabled: false + properties: + authenticationConfiguration: + $ref: '#/components/schemas/AIServiceProviderEndpointAuthenticationConfiguration' + authHeader: + deprecated: true + example: Authorization + type: string + authQueryParameter: + deprecated: true + example: ApiKey + type: string + title: AIServiceProviderEndpointConfiguration + type: object + AIServiceProviderEndpointAuthenticationConfiguration: + example: + type: apiKey + parameters: + headerEnabled: true + headerName: Authorization + enabled: false + properties: + enabled: + default: false + description: Whether the authentication configuration is enabled or not + type: boolean + type: + description: Type of the authentication configuration + example: apiKey + type: string + parameters: + description: | + Parameters required for the authentication configuration. The parameters are different based on the type of the authentication configuration. + example: + headerEnabled: true + headerName: Authorization + type: object + title: AIServiceProviderEndpointAuthenticationConfiguration + type: object AdditionalProperty: example: value: wso2 @@ -23457,6 +24319,7 @@ components: apim:api_list_view: View, Retrieve API list apim:api_definition_view: View, Retrieve API definition apim:policies_import_export: Export and import policies related operations + apim:llm_provider_read: Read LLM Providers apim:publisher_organization_read: Read organization tokenUrl: https://localhost:9443/oauth2/token type: oauth2 diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointAuthenticationConfigurationDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointAuthenticationConfigurationDTO.md new file mode 100644 index 0000000000..1697145db8 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointAuthenticationConfigurationDTO.md @@ -0,0 +1,14 @@ + + +# AIServiceProviderEndpointAuthenticationConfigurationDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**enabled** | **Boolean** | Whether the authentication configuration is enabled or not | [optional] +**type** | **String** | Type of the authentication configuration | [optional] +**parameters** | [**Object**](.md) | Parameters required for the authentication configuration. The parameters are different based on the type of the authentication configuration. | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointConfigurationDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointConfigurationDTO.md new file mode 100644 index 0000000000..fde129c251 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderEndpointConfigurationDTO.md @@ -0,0 +1,14 @@ + + +# AIServiceProviderEndpointConfigurationDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**authenticationConfiguration** | [**AIServiceProviderEndpointAuthenticationConfigurationDTO**](AIServiceProviderEndpointAuthenticationConfigurationDTO.md) | | [optional] +**authHeader** | **String** | | [optional] +**authQueryParameter** | **String** | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderResponseDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderResponseDTO.md new file mode 100644 index 0000000000..c4f7e0194c --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderResponseDTO.md @@ -0,0 +1,18 @@ + + +# AIServiceProviderResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] [readonly] +**name** | **String** | | [optional] +**apiVersion** | **String** | | [optional] +**builtInSupport** | **Boolean** | Is built-in support | [optional] +**description** | **String** | | [optional] +**configurations** | **String** | LLM Provider configurations | [optional] +**apiDefinition** | **String** | OpenAPI specification | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseDTO.md new file mode 100644 index 0000000000..5d204567b9 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseDTO.md @@ -0,0 +1,16 @@ + + +# AIServiceProviderSummaryResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] [readonly] +**name** | **String** | | [optional] +**apiVersion** | **String** | | [optional] +**builtInSupport** | **Boolean** | Is built-in support | [optional] +**description** | **String** | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseListDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseListDTO.md new file mode 100644 index 0000000000..23a57f3743 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AIServiceProviderSummaryResponseListDTO.md @@ -0,0 +1,13 @@ + + +# AIServiceProviderSummaryResponseListDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **Integer** | Number of LLM Providers returned. | [optional] +**list** | [**List<AIServiceProviderSummaryResponseDTO>**](AIServiceProviderSummaryResponseDTO.md) | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIDTO.md index fb8b8d4be6..a16aff3b05 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIDTO.md +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIDTO.md @@ -58,6 +58,8 @@ Name | Type | Description | Notes **lastUpdatedTimestamp** | **String** | | [optional] **lastUpdatedTime** | **String** | | [optional] **endpointConfig** | [**Object**](.md) | Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. `Simple REST Endpoint` { \"endpoint_type\": \"http\", \"sandbox_endpoints\": { \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/\" }, \"production_endpoints\": { \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/\" } } `Loadbalanced Endpoint` { \"endpoint_type\": \"load_balance\", \"algoCombo\": \"org.apache.synapse.endpoints.algorithms.RoundRobin\", \"sessionManagement\": \"\", \"sandbox_endpoints\": [ { \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/1\" }, { \"endpoint_type\": \"http\", \"template_not_supported\": false, \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/2\" } ], \"production_endpoints\": [ { \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/3\" }, { \"endpoint_type\": \"http\", \"template_not_supported\": false, \"url\": \"https://localhost:9443/am/sample/pizzashack/v1/api/4\" } ], \"sessionTimeOut\": \"\", \"algoClassName\": \"org.apache.synapse.endpoints.algorithms.RoundRobin\" } `Failover Endpoint` { \"production_failovers\":[ { \"endpoint_type\":\"http\", \"template_not_supported\":false, \"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/1\" } ], \"endpoint_type\":\"failover\", \"sandbox_endpoints\":{ \"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/2\" }, \"production_endpoints\":{ \"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/3\" }, \"sandbox_failovers\":[ { \"endpoint_type\":\"http\", \"template_not_supported\":false, \"url\":\"https://localhost:9443/am/sample/pizzashack/v1/api/4\" } ] } `Default Endpoint` { \"endpoint_type\":\"default\", \"sandbox_endpoints\":{ \"url\":\"default\" }, \"production_endpoints\":{ \"url\":\"default\" } } `Endpoint from Endpoint Registry` { \"endpoint_type\": \"Registry\", \"endpoint_id\": \"{registry-name:entry-name:version}\", } | [optional] +**primaryProductionEndpointId** | **String** | | [optional] +**primarySandboxEndpointId** | **String** | | [optional] **endpointImplementationType** | [**EndpointImplementationTypeEnum**](#EndpointImplementationTypeEnum) | | [optional] **scopes** | [**List<APIScopeDTO>**](APIScopeDTO.md) | | [optional] **operations** | [**List<APIOperationsDTO>**](APIOperationsDTO.md) | | [optional] diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointDTO.md new file mode 100644 index 0000000000..e4b80b5f38 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointDTO.md @@ -0,0 +1,15 @@ + + +# APIEndpointDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**name** | **String** | | +**deploymentStage** | **String** | | [optional] +**endpointConfig** | [**Object**](.md) | Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointListDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointListDTO.md new file mode 100644 index 0000000000..9ec78200b6 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIEndpointListDTO.md @@ -0,0 +1,14 @@ + + +# APIEndpointListDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **Integer** | Number of Endpoints returned. | [optional] +**list** | [**List<APIEndpointDTO>**](APIEndpointDTO.md) | | [optional] +**pagination** | [**PaginationDTO**](PaginationDTO.md) | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIInfoDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIInfoDTO.md index e6f4157270..b7071c6c90 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIInfoDTO.md +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/APIInfoDTO.md @@ -15,6 +15,7 @@ Name | Type | Description | Notes **version** | **String** | | [optional] **provider** | **String** | If the provider value is not given, the user invoking the API will be used as the provider. | [optional] **type** | **String** | | [optional] +**subtype** | **String** | Subtype of the API. | [optional] [readonly] **audience** | [**AudienceEnum**](#AudienceEnum) | The audience of the API. Accepted values are PUBLIC, SINGLE | [optional] **audiences** | **List<String>** | The audiences of the API for jwt validation. Accepted values are any String values | [optional] **lifeCycleStatus** | **String** | | [optional] diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProviderApi.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProviderApi.md new file mode 100644 index 0000000000..fc0d5d3795 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProviderApi.md @@ -0,0 +1,280 @@ +# AiServiceProviderApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getAIServiceProvider**](AiServiceProviderApi.md#getAIServiceProvider) | **GET** /ai-service-providers/{aiServiceProviderId} | Get AI Service Provider +[**getAIServiceProviderApiDefinition**](AiServiceProviderApi.md#getAIServiceProviderApiDefinition) | **GET** /ai-service-providers/{aiServiceProviderId}/api-definition | Get AI Service Provider's API Definition +[**getAIServiceProviderEndpointConfiguration**](AiServiceProviderApi.md#getAIServiceProviderEndpointConfiguration) | **GET** /ai-service-providers/{aiServiceProviderId}/endpoint-configuration | Get AI Service Provider's security configurations +[**getAIServiceProviderModels**](AiServiceProviderApi.md#getAIServiceProviderModels) | **GET** /ai-service-providers/{aiServiceProviderId}/models | Get AI Service Provider's model list + + + +# **getAIServiceProvider** +> AIServiceProviderResponseDTO getAIServiceProvider(aiServiceProviderId) + +Get AI Service Provider + +Get a AI Service Provider + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + AiServiceProviderApi apiInstance = new AiServiceProviderApi(defaultClient); + String aiServiceProviderId = "aiServiceProviderId_example"; // String | AI Service Provider ID + try { + AIServiceProviderResponseDTO result = apiInstance.getAIServiceProvider(aiServiceProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiServiceProviderApi#getAIServiceProvider"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **aiServiceProviderId** | **String**| AI Service Provider ID | + +### Return type + +[**AIServiceProviderResponseDTO**](AIServiceProviderResponseDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. AI Service Provider | - | + + +# **getAIServiceProviderApiDefinition** +> String getAIServiceProviderApiDefinition(aiServiceProviderId) + +Get AI Service Provider's API Definition + +Get AI Service Provider's API Definition + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + AiServiceProviderApi apiInstance = new AiServiceProviderApi(defaultClient); + String aiServiceProviderId = "aiServiceProviderId_example"; // String | + try { + String result = apiInstance.getAIServiceProviderApiDefinition(aiServiceProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiServiceProviderApi#getAIServiceProviderApiDefinition"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **aiServiceProviderId** | **String**| | + +### Return type + +**String** + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. API Definition | - | + + +# **getAIServiceProviderEndpointConfiguration** +> AIServiceProviderEndpointConfigurationDTO getAIServiceProviderEndpointConfiguration(aiServiceProviderId) + +Get AI Service Provider's security configurations + +Get AI Service Provider's endpoint security configurations + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + AiServiceProviderApi apiInstance = new AiServiceProviderApi(defaultClient); + String aiServiceProviderId = "aiServiceProviderId_example"; // String | + try { + AIServiceProviderEndpointConfigurationDTO result = apiInstance.getAIServiceProviderEndpointConfiguration(aiServiceProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiServiceProviderApi#getAIServiceProviderEndpointConfiguration"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **aiServiceProviderId** | **String**| | + +### Return type + +[**AIServiceProviderEndpointConfigurationDTO**](AIServiceProviderEndpointConfigurationDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. API Definition | - | + + +# **getAIServiceProviderModels** +> List<ModelProviderDTO> getAIServiceProviderModels(aiServiceProviderId) + +Get AI Service Provider's model list + +Get AI Service Provider's model list + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + AiServiceProviderApi apiInstance = new AiServiceProviderApi(defaultClient); + String aiServiceProviderId = "aiServiceProviderId_example"; // String | + try { + List result = apiInstance.getAIServiceProviderModels(aiServiceProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiServiceProviderApi#getAIServiceProviderModels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **aiServiceProviderId** | **String**| | + +### Return type + +[**List<ModelProviderDTO>**](ModelProviderDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. List of supported model families grouped by vendor | - | + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProvidersApi.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProvidersApi.md new file mode 100644 index 0000000000..b77a133ccc --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/AiServiceProvidersApi.md @@ -0,0 +1,74 @@ +# AiServiceProvidersApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getAIServiceProviders**](AiServiceProvidersApi.md#getAIServiceProviders) | **GET** /ai-service-providers | Get all AI Service providers + + + +# **getAIServiceProviders** +> AIServiceProviderSummaryResponseListDTO getAIServiceProviders() + +Get all AI Service providers + +Get all AI Service providers + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProvidersApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + AiServiceProvidersApi apiInstance = new AiServiceProvidersApi(defaultClient); + try { + AIServiceProviderSummaryResponseListDTO result = apiInstance.getAIServiceProviders(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling AiServiceProvidersApi#getAIServiceProviders"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**AIServiceProviderSummaryResponseListDTO**](AIServiceProviderSummaryResponseListDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. List of AI Service providers. | * Content-Type - The content type of the body.
| +**406** | Not Acceptable. The requested media type is not supported. | - | +**500** | Internal Server Error. | - | + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ApiEndpointsApi.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ApiEndpointsApi.md new file mode 100644 index 0000000000..3f079d9aec --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ApiEndpointsApi.md @@ -0,0 +1,374 @@ +# ApiEndpointsApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addApiEndpoint**](ApiEndpointsApi.md#addApiEndpoint) | **POST** /apis/{apiId}/endpoints | Add an Endpoint +[**deleteApiEndpoint**](ApiEndpointsApi.md#deleteApiEndpoint) | **DELETE** /apis/{apiId}/endpoints/{endpointId} | Delete an Endpoint +[**getApiEndpoint**](ApiEndpointsApi.md#getApiEndpoint) | **GET** /apis/{apiId}/endpoints/{endpointId} | Get an Endpoint +[**getApiEndpoints**](ApiEndpointsApi.md#getApiEndpoints) | **GET** /apis/{apiId}/endpoints | Get all API Endpoints +[**updateApiEndpoint**](ApiEndpointsApi.md#updateApiEndpoint) | **PUT** /apis/{apiId}/endpoints/{endpointId} | Update an Endpoint + + + +# **addApiEndpoint** +> APIEndpointDTO addApiEndpoint(apiId, apIEndpointDTO) + +Add an Endpoint + +This operation can be used to add an endpoint to an API. + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + ApiEndpointsApi apiInstance = new ApiEndpointsApi(defaultClient); + String apiId = "apiId_example"; // String | **API ID** consisting of the **UUID** of the API. + APIEndpointDTO apIEndpointDTO = new APIEndpointDTO(); // APIEndpointDTO | Endpoint object that needs to be added + try { + APIEndpointDTO result = apiInstance.addApiEndpoint(apiId, apIEndpointDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ApiEndpointsApi#addApiEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiId** | **String**| **API ID** consisting of the **UUID** of the API. | + **apIEndpointDTO** | [**APIEndpointDTO**](APIEndpointDTO.md)| Endpoint object that needs to be added | + +### Return type + +[**APIEndpointDTO**](APIEndpointDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**201** | Created. Successful response with the newly created API Endpoint object in the body. | - | +**400** | Bad Request. Invalid request or validation error. | - | +**415** | Unsupported Media Type. The entity of the request was not in a supported format. | - | + + +# **deleteApiEndpoint** +> deleteApiEndpoint(apiId, endpointId) + +Delete an Endpoint + +This operation can be used to delete a API endpoint. + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + ApiEndpointsApi apiInstance = new ApiEndpointsApi(defaultClient); + String apiId = "apiId_example"; // String | **API ID** consisting of the **UUID** of the API. + String endpointId = "endpointId_example"; // String | **Endpoint ID** consisting of the **UUID** of the Endpoint**. + try { + apiInstance.deleteApiEndpoint(apiId, endpointId); + } catch (ApiException e) { + System.err.println("Exception when calling ApiEndpointsApi#deleteApiEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiId** | **String**| **API ID** consisting of the **UUID** of the API. | + **endpointId** | **String**| **Endpoint ID** consisting of the **UUID** of the Endpoint**. | + +### Return type + +null (empty response body) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. Endpoint deleted successfully. | - | +**404** | Not Found. The specified resource does not exist. | - | +**500** | Internal Server Error. | - | + + +# **getApiEndpoint** +> APIEndpointDTO getApiEndpoint(apiId, endpointId) + +Get an Endpoint + +This operation can be used to get an endpoint of an API by UUID. + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + ApiEndpointsApi apiInstance = new ApiEndpointsApi(defaultClient); + String apiId = "apiId_example"; // String | **API ID** consisting of the **UUID** of the API. + String endpointId = "endpointId_example"; // String | **Endpoint ID** consisting of the **UUID** of the Endpoint**. + try { + APIEndpointDTO result = apiInstance.getApiEndpoint(apiId, endpointId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ApiEndpointsApi#getApiEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiId** | **String**| **API ID** consisting of the **UUID** of the API. | + **endpointId** | **String**| **Endpoint ID** consisting of the **UUID** of the Endpoint**. | + +### Return type + +[**APIEndpointDTO**](APIEndpointDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. API Endpoint object is returned. | * Content-Type - The content type of the body.
| +**500** | Internal Server Error. | - | +**404** | Not Found. The specified resource does not exist. | - | + + +# **getApiEndpoints** +> APIEndpointListDTO getApiEndpoints(apiId, limit, offset) + +Get all API Endpoints + +This operation can be used to get all the available endpoints of an API. + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + ApiEndpointsApi apiInstance = new ApiEndpointsApi(defaultClient); + String apiId = "apiId_example"; // String | **API ID** consisting of the **UUID** of the API. + Integer limit = 25; // Integer | Maximum size of resource array to return. + Integer offset = 0; // Integer | Starting point within the complete list of items qualified. + try { + APIEndpointListDTO result = apiInstance.getApiEndpoints(apiId, limit, offset); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ApiEndpointsApi#getApiEndpoints"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiId** | **String**| **API ID** consisting of the **UUID** of the API. | + **limit** | **Integer**| Maximum size of resource array to return. | [optional] [default to 25] + **offset** | **Integer**| Starting point within the complete list of items qualified. | [optional] [default to 0] + +### Return type + +[**APIEndpointListDTO**](APIEndpointListDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. List of API endpoints. | * Content-Type - The content type of the body.
| +**400** | Bad Request. Invalid request or validation error. | - | +**404** | Not Found. The specified resource does not exist. | - | +**500** | Internal Server Error. | - | + + +# **updateApiEndpoint** +> APIEndpointDTO updateApiEndpoint(apiId, endpointId, apIEndpointDTO) + +Update an Endpoint + +This operation can be used to update a API endpoint. + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + ApiEndpointsApi apiInstance = new ApiEndpointsApi(defaultClient); + String apiId = "apiId_example"; // String | **API ID** consisting of the **UUID** of the API. + String endpointId = "endpointId_example"; // String | **Endpoint ID** consisting of the **UUID** of the Endpoint**. + APIEndpointDTO apIEndpointDTO = new APIEndpointDTO(); // APIEndpointDTO | API Endpoint object with updated details + try { + APIEndpointDTO result = apiInstance.updateApiEndpoint(apiId, endpointId, apIEndpointDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ApiEndpointsApi#updateApiEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **apiId** | **String**| **API ID** consisting of the **UUID** of the API. | + **endpointId** | **String**| **Endpoint ID** consisting of the **UUID** of the Endpoint**. | + **apIEndpointDTO** | [**APIEndpointDTO**](APIEndpointDTO.md)| API Endpoint object with updated details | [optional] + +### Return type + +[**APIEndpointDTO**](APIEndpointDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. Updated API Endpoint is returned. | * Content-Type - The content type of the body.
| +**400** | Bad Request. Invalid request or validation error. | - | +**404** | Not Found. The specified resource does not exist. | - | +**415** | Unsupported Media Type. The entity of the request was not in a supported format. | - | +**500** | Internal Server Error. | - | + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderEndpointConfigurationDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderEndpointConfigurationDTO.md new file mode 100644 index 0000000000..68c9f870fd --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderEndpointConfigurationDTO.md @@ -0,0 +1,13 @@ + + +# LLMProviderEndpointConfigurationDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**authHeader** | **String** | | [optional] +**authQueryParameter** | **String** | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderResponseDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderResponseDTO.md new file mode 100644 index 0000000000..c3cf017188 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderResponseDTO.md @@ -0,0 +1,18 @@ + + +# LLMProviderResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] [readonly] +**name** | **String** | | [optional] +**apiVersion** | **String** | | [optional] +**builtInSupport** | **Boolean** | Is built-in support | [optional] +**description** | **String** | | [optional] +**configurations** | **String** | LLM Provider configurations | [optional] +**apiDefinition** | **String** | OpenAPI specification | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseDTO.md new file mode 100644 index 0000000000..3b502e95e8 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseDTO.md @@ -0,0 +1,16 @@ + + +# LLMProviderSummaryResponseDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] [readonly] +**name** | **String** | | [optional] +**apiVersion** | **String** | | [optional] +**builtInSupport** | **Boolean** | Is built-in support | [optional] +**description** | **String** | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseListDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseListDTO.md new file mode 100644 index 0000000000..a47786886d --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LLMProviderSummaryResponseListDTO.md @@ -0,0 +1,13 @@ + + +# LLMProviderSummaryResponseListDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **Integer** | Number of LLM Providers returned. | [optional] +**list** | [**List<LLMProviderSummaryResponseDTO>**](LLMProviderSummaryResponseDTO.md) | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProviderApi.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProviderApi.md new file mode 100644 index 0000000000..52efbc5742 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProviderApi.md @@ -0,0 +1,212 @@ +# LlmProviderApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getLLMProviderApiDefinition**](LlmProviderApi.md#getLLMProviderApiDefinition) | **GET** /llm-providers/{llmProviderId}/api-definition | Get LLM Provider's API Definition +[**getLLMProviderEndpointConfiguration**](LlmProviderApi.md#getLLMProviderEndpointConfiguration) | **GET** /llm-providers/{llmProviderId}/endpoint-configuration | Get LLM provider's security configurations +[**getLLMProviderModels**](LlmProviderApi.md#getLLMProviderModels) | **GET** /llm-providers/{llmProviderId}/models | Get LLM provider's model list + + + +# **getLLMProviderApiDefinition** +> String getLLMProviderApiDefinition(llmProviderId) + +Get LLM Provider's API Definition + +Get LLM Provider's API Definition + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.LlmProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + LlmProviderApi apiInstance = new LlmProviderApi(defaultClient); + String llmProviderId = "llmProviderId_example"; // String | + try { + String result = apiInstance.getLLMProviderApiDefinition(llmProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LlmProviderApi#getLLMProviderApiDefinition"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **llmProviderId** | **String**| | + +### Return type + +**String** + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. API Definition | - | + + +# **getLLMProviderEndpointConfiguration** +> LLMProviderEndpointConfigurationDTO getLLMProviderEndpointConfiguration(llmProviderId) + +Get LLM provider's security configurations + +Get LLM provider's endpoint security configurations + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.LlmProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + LlmProviderApi apiInstance = new LlmProviderApi(defaultClient); + String llmProviderId = "llmProviderId_example"; // String | + try { + LLMProviderEndpointConfigurationDTO result = apiInstance.getLLMProviderEndpointConfiguration(llmProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LlmProviderApi#getLLMProviderEndpointConfiguration"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **llmProviderId** | **String**| | + +### Return type + +[**LLMProviderEndpointConfigurationDTO**](LLMProviderEndpointConfigurationDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. API Definition | - | + + +# **getLLMProviderModels** +> List<String> getLLMProviderModels(llmProviderId) + +Get LLM provider's model list + +Get LLM provider's model list + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.LlmProviderApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + LlmProviderApi apiInstance = new LlmProviderApi(defaultClient); + String llmProviderId = "llmProviderId_example"; // String | + try { + List result = apiInstance.getLLMProviderModels(llmProviderId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LlmProviderApi#getLLMProviderModels"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **llmProviderId** | **String**| | + +### Return type + +**List<String>** + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. List of models | - | + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProvidersApi.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProvidersApi.md new file mode 100644 index 0000000000..71293e5175 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/LlmProvidersApi.md @@ -0,0 +1,74 @@ +# LlmProvidersApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**getLLMProviders**](LlmProvidersApi.md#getLLMProviders) | **GET** /llm-providers | Get all LLM providers + + + +# **getLLMProviders** +> LLMProviderSummaryResponseListDTO getLLMProviders() + +Get all LLM providers + +Get all LLM providers + +### Example +```java +// Import classes: +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.auth.*; +import org.wso2.am.integration.clients.publisher.api.models.*; +import org.wso2.am.integration.clients.publisher.api.v1.LlmProvidersApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://apis.wso2.com/api/am/publisher/v4"); + + // Configure OAuth2 access token for authorization: OAuth2Security + OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security"); + OAuth2Security.setAccessToken("YOUR ACCESS TOKEN"); + + LlmProvidersApi apiInstance = new LlmProvidersApi(defaultClient); + try { + LLMProviderSummaryResponseListDTO result = apiInstance.getLLMProviders(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling LlmProvidersApi#getLLMProviders"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**LLMProviderSummaryResponseListDTO**](LLMProviderSummaryResponseListDTO.md) + +### Authorization + +[OAuth2Security](../README.md#OAuth2Security) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | OK. List of LLM providers. | * Content-Type - The content type of the body.
| +**406** | Not Acceptable. The requested media type is not supported. | - | +**500** | Internal Server Error. | - | + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ModelProviderDTO.md b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ModelProviderDTO.md new file mode 100644 index 0000000000..71596c0920 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/docs/ModelProviderDTO.md @@ -0,0 +1,13 @@ + + +# ModelProviderDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**models** | **List<String>** | | [optional] +**name** | **String** | | [optional] + + + diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProviderApi.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProviderApi.java new file mode 100644 index 0000000000..05bd7861e2 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProviderApi.java @@ -0,0 +1,503 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1; + +import org.wso2.am.integration.clients.publisher.api.ApiCallback; +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.ApiResponse; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.Pair; +import org.wso2.am.integration.clients.publisher.api.ProgressRequestBody; +import org.wso2.am.integration.clients.publisher.api.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.wso2.am.integration.clients.publisher.api.v1.dto.AIServiceProviderEndpointConfigurationDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.AIServiceProviderResponseDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.ModelProviderDTO; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AiServiceProviderApi { + private ApiClient localVarApiClient; + + public AiServiceProviderApi() { + this(Configuration.getDefaultApiClient()); + } + + public AiServiceProviderApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for getAIServiceProvider + * @param aiServiceProviderId AI Service Provider ID (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service Provider -
+ */ + public okhttp3.Call getAIServiceProviderCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProviderValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling getAIServiceProvider(Async)"); + } + + + okhttp3.Call localVarCall = getAIServiceProviderCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Get AI Service Provider + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider ID (required) + * @return AIServiceProviderResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service Provider -
+ */ + public AIServiceProviderResponseDTO getAIServiceProvider(String aiServiceProviderId) throws ApiException { + ApiResponse localVarResp = getAIServiceProviderWithHttpInfo(aiServiceProviderId); + return localVarResp.getData(); + } + + /** + * Get AI Service Provider + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider ID (required) + * @return ApiResponse<AIServiceProviderResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service Provider -
+ */ + public ApiResponse getAIServiceProviderWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = getAIServiceProviderValidateBeforeCall(aiServiceProviderId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI Service Provider (asynchronously) + * Get a AI Service Provider + * @param aiServiceProviderId AI Service Provider ID (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. AI Service Provider -
+ */ + public okhttp3.Call getAIServiceProviderAsync(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProviderValidateBeforeCall(aiServiceProviderId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAIServiceProviderApiDefinition + * @param aiServiceProviderId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public okhttp3.Call getAIServiceProviderApiDefinitionCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}/api-definition" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProviderApiDefinitionValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling getAIServiceProviderApiDefinition(Async)"); + } + + + okhttp3.Call localVarCall = getAIServiceProviderApiDefinitionCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Get AI Service Provider's API Definition + * Get AI Service Provider's API Definition + * @param aiServiceProviderId (required) + * @return String + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public String getAIServiceProviderApiDefinition(String aiServiceProviderId) throws ApiException { + ApiResponse localVarResp = getAIServiceProviderApiDefinitionWithHttpInfo(aiServiceProviderId); + return localVarResp.getData(); + } + + /** + * Get AI Service Provider's API Definition + * Get AI Service Provider's API Definition + * @param aiServiceProviderId (required) + * @return ApiResponse<String> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public ApiResponse getAIServiceProviderApiDefinitionWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = getAIServiceProviderApiDefinitionValidateBeforeCall(aiServiceProviderId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI Service Provider's API Definition (asynchronously) + * Get AI Service Provider's API Definition + * @param aiServiceProviderId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public okhttp3.Call getAIServiceProviderApiDefinitionAsync(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProviderApiDefinitionValidateBeforeCall(aiServiceProviderId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAIServiceProviderEndpointConfiguration + * @param aiServiceProviderId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public okhttp3.Call getAIServiceProviderEndpointConfigurationCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}/endpoint-configuration" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProviderEndpointConfigurationValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling getAIServiceProviderEndpointConfiguration(Async)"); + } + + + okhttp3.Call localVarCall = getAIServiceProviderEndpointConfigurationCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Get AI Service Provider's security configurations + * Get AI Service Provider's endpoint security configurations + * @param aiServiceProviderId (required) + * @return AIServiceProviderEndpointConfigurationDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public AIServiceProviderEndpointConfigurationDTO getAIServiceProviderEndpointConfiguration(String aiServiceProviderId) throws ApiException { + ApiResponse localVarResp = getAIServiceProviderEndpointConfigurationWithHttpInfo(aiServiceProviderId); + return localVarResp.getData(); + } + + /** + * Get AI Service Provider's security configurations + * Get AI Service Provider's endpoint security configurations + * @param aiServiceProviderId (required) + * @return ApiResponse<AIServiceProviderEndpointConfigurationDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public ApiResponse getAIServiceProviderEndpointConfigurationWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = getAIServiceProviderEndpointConfigurationValidateBeforeCall(aiServiceProviderId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI Service Provider's security configurations (asynchronously) + * Get AI Service Provider's endpoint security configurations + * @param aiServiceProviderId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. API Definition -
+ */ + public okhttp3.Call getAIServiceProviderEndpointConfigurationAsync(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProviderEndpointConfigurationValidateBeforeCall(aiServiceProviderId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAIServiceProviderModels + * @param aiServiceProviderId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. List of supported model families grouped by vendor -
+ */ + public okhttp3.Call getAIServiceProviderModelsCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers/{aiServiceProviderId}/models" + .replaceAll("\\{" + "aiServiceProviderId" + "\\}", localVarApiClient.escapeString(aiServiceProviderId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProviderModelsValidateBeforeCall(String aiServiceProviderId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'aiServiceProviderId' is set + if (aiServiceProviderId == null) { + throw new ApiException("Missing the required parameter 'aiServiceProviderId' when calling getAIServiceProviderModels(Async)"); + } + + + okhttp3.Call localVarCall = getAIServiceProviderModelsCall(aiServiceProviderId, _callback); + return localVarCall; + + } + + /** + * Get AI Service Provider's model list + * Get AI Service Provider's model list + * @param aiServiceProviderId (required) + * @return List<ModelProviderDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. List of supported model families grouped by vendor -
+ */ + public List getAIServiceProviderModels(String aiServiceProviderId) throws ApiException { + ApiResponse> localVarResp = getAIServiceProviderModelsWithHttpInfo(aiServiceProviderId); + return localVarResp.getData(); + } + + /** + * Get AI Service Provider's model list + * Get AI Service Provider's model list + * @param aiServiceProviderId (required) + * @return ApiResponse<List<ModelProviderDTO>> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. List of supported model families grouped by vendor -
+ */ + public ApiResponse> getAIServiceProviderModelsWithHttpInfo(String aiServiceProviderId) throws ApiException { + okhttp3.Call localVarCall = getAIServiceProviderModelsValidateBeforeCall(aiServiceProviderId, null); + Type localVarReturnType = new TypeToken>(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get AI Service Provider's model list (asynchronously) + * Get AI Service Provider's model list + * @param aiServiceProviderId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + +
Status Code Description Response Headers
200 OK. List of supported model families grouped by vendor -
+ */ + public okhttp3.Call getAIServiceProviderModelsAsync(String aiServiceProviderId, final ApiCallback> _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProviderModelsValidateBeforeCall(aiServiceProviderId, _callback); + Type localVarReturnType = new TypeToken>(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProvidersApi.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProvidersApi.java new file mode 100644 index 0000000000..0a99629b66 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/AiServiceProvidersApi.java @@ -0,0 +1,167 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1; + +import org.wso2.am.integration.clients.publisher.api.ApiCallback; +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.ApiResponse; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.Pair; +import org.wso2.am.integration.clients.publisher.api.ProgressRequestBody; +import org.wso2.am.integration.clients.publisher.api.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.wso2.am.integration.clients.publisher.api.v1.dto.AIServiceProviderSummaryResponseListDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.ErrorDTO; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class AiServiceProvidersApi { + private ApiClient localVarApiClient; + + public AiServiceProvidersApi() { + this(Configuration.getDefaultApiClient()); + } + + public AiServiceProvidersApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for getAIServiceProviders + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. List of AI Service providers. * Content-Type - The content type of the body.
406 Not Acceptable. The requested media type is not supported. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getAIServiceProvidersCall(final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/ai-service-providers"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getAIServiceProvidersValidateBeforeCall(final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getAIServiceProvidersCall(_callback); + return localVarCall; + + } + + /** + * Get all AI Service providers + * Get all AI Service providers + * @return AIServiceProviderSummaryResponseListDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. List of AI Service providers. * Content-Type - The content type of the body.
406 Not Acceptable. The requested media type is not supported. -
500 Internal Server Error. -
+ */ + public AIServiceProviderSummaryResponseListDTO getAIServiceProviders() throws ApiException { + ApiResponse localVarResp = getAIServiceProvidersWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * Get all AI Service providers + * Get all AI Service providers + * @return ApiResponse<AIServiceProviderSummaryResponseListDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. List of AI Service providers. * Content-Type - The content type of the body.
406 Not Acceptable. The requested media type is not supported. -
500 Internal Server Error. -
+ */ + public ApiResponse getAIServiceProvidersWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = getAIServiceProvidersValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get all AI Service providers (asynchronously) + * Get all AI Service providers + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. List of AI Service providers. * Content-Type - The content type of the body.
406 Not Acceptable. The requested media type is not supported. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getAIServiceProvidersAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAIServiceProvidersValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/ApiEndpointsApi.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/ApiEndpointsApi.java new file mode 100644 index 0000000000..70e033b986 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/ApiEndpointsApi.java @@ -0,0 +1,721 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1; + +import org.wso2.am.integration.clients.publisher.api.ApiCallback; +import org.wso2.am.integration.clients.publisher.api.ApiClient; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.ApiResponse; +import org.wso2.am.integration.clients.publisher.api.Configuration; +import org.wso2.am.integration.clients.publisher.api.Pair; +import org.wso2.am.integration.clients.publisher.api.ProgressRequestBody; +import org.wso2.am.integration.clients.publisher.api.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIEndpointDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIEndpointListDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.ErrorDTO; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ApiEndpointsApi { + private ApiClient localVarApiClient; + + public ApiEndpointsApi() { + this(Configuration.getDefaultApiClient()); + } + + public ApiEndpointsApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for addApiEndpoint + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param apIEndpointDTO Endpoint object that needs to be added (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created API Endpoint object in the body. -
400 Bad Request. Invalid request or validation error. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
+ */ + public okhttp3.Call addApiEndpointCall(String apiId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = apIEndpointDTO; + + // create path and map variables + String localVarPath = "/apis/{apiId}/endpoints" + .replaceAll("\\{" + "apiId" + "\\}", localVarApiClient.escapeString(apiId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call addApiEndpointValidateBeforeCall(String apiId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'apiId' is set + if (apiId == null) { + throw new ApiException("Missing the required parameter 'apiId' when calling addApiEndpoint(Async)"); + } + + // verify the required parameter 'apIEndpointDTO' is set + if (apIEndpointDTO == null) { + throw new ApiException("Missing the required parameter 'apIEndpointDTO' when calling addApiEndpoint(Async)"); + } + + + okhttp3.Call localVarCall = addApiEndpointCall(apiId, apIEndpointDTO, _callback); + return localVarCall; + + } + + /** + * Add an Endpoint + * This operation can be used to add an endpoint to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param apIEndpointDTO Endpoint object that needs to be added (required) + * @return APIEndpointDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created API Endpoint object in the body. -
400 Bad Request. Invalid request or validation error. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
+ */ + public APIEndpointDTO addApiEndpoint(String apiId, APIEndpointDTO apIEndpointDTO) throws ApiException { + ApiResponse localVarResp = addApiEndpointWithHttpInfo(apiId, apIEndpointDTO); + return localVarResp.getData(); + } + + /** + * Add an Endpoint + * This operation can be used to add an endpoint to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param apIEndpointDTO Endpoint object that needs to be added (required) + * @return ApiResponse<APIEndpointDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created API Endpoint object in the body. -
400 Bad Request. Invalid request or validation error. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
+ */ + public ApiResponse addApiEndpointWithHttpInfo(String apiId, APIEndpointDTO apIEndpointDTO) throws ApiException { + okhttp3.Call localVarCall = addApiEndpointValidateBeforeCall(apiId, apIEndpointDTO, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Add an Endpoint (asynchronously) + * This operation can be used to add an endpoint to an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param apIEndpointDTO Endpoint object that needs to be added (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created. Successful response with the newly created API Endpoint object in the body. -
400 Bad Request. Invalid request or validation error. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
+ */ + public okhttp3.Call addApiEndpointAsync(String apiId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addApiEndpointValidateBeforeCall(apiId, apIEndpointDTO, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteApiEndpoint + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. Endpoint deleted successfully. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call deleteApiEndpointCall(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/apis/{apiId}/endpoints/{endpointId}" + .replaceAll("\\{" + "apiId" + "\\}", localVarApiClient.escapeString(apiId.toString())) + .replaceAll("\\{" + "endpointId" + "\\}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteApiEndpointValidateBeforeCall(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'apiId' is set + if (apiId == null) { + throw new ApiException("Missing the required parameter 'apiId' when calling deleteApiEndpoint(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling deleteApiEndpoint(Async)"); + } + + + okhttp3.Call localVarCall = deleteApiEndpointCall(apiId, endpointId, _callback); + return localVarCall; + + } + + /** + * Delete an Endpoint + * This operation can be used to delete a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. Endpoint deleted successfully. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public void deleteApiEndpoint(String apiId, String endpointId) throws ApiException { + deleteApiEndpointWithHttpInfo(apiId, endpointId); + } + + /** + * Delete an Endpoint + * This operation can be used to delete a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. Endpoint deleted successfully. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public ApiResponse deleteApiEndpointWithHttpInfo(String apiId, String endpointId) throws ApiException { + okhttp3.Call localVarCall = deleteApiEndpointValidateBeforeCall(apiId, endpointId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete an Endpoint (asynchronously) + * This operation can be used to delete a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. Endpoint deleted successfully. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call deleteApiEndpointAsync(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteApiEndpointValidateBeforeCall(apiId, endpointId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for getApiEndpoint + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. API Endpoint object is returned. * Content-Type - The content type of the body.
500 Internal Server Error. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call getApiEndpointCall(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/apis/{apiId}/endpoints/{endpointId}" + .replaceAll("\\{" + "apiId" + "\\}", localVarApiClient.escapeString(apiId.toString())) + .replaceAll("\\{" + "endpointId" + "\\}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getApiEndpointValidateBeforeCall(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'apiId' is set + if (apiId == null) { + throw new ApiException("Missing the required parameter 'apiId' when calling getApiEndpoint(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling getApiEndpoint(Async)"); + } + + + okhttp3.Call localVarCall = getApiEndpointCall(apiId, endpointId, _callback); + return localVarCall; + + } + + /** + * Get an Endpoint + * This operation can be used to get an endpoint of an API by UUID. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @return APIEndpointDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. API Endpoint object is returned. * Content-Type - The content type of the body.
500 Internal Server Error. -
404 Not Found. The specified resource does not exist. -
+ */ + public APIEndpointDTO getApiEndpoint(String apiId, String endpointId) throws ApiException { + ApiResponse localVarResp = getApiEndpointWithHttpInfo(apiId, endpointId); + return localVarResp.getData(); + } + + /** + * Get an Endpoint + * This operation can be used to get an endpoint of an API by UUID. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @return ApiResponse<APIEndpointDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. API Endpoint object is returned. * Content-Type - The content type of the body.
500 Internal Server Error. -
404 Not Found. The specified resource does not exist. -
+ */ + public ApiResponse getApiEndpointWithHttpInfo(String apiId, String endpointId) throws ApiException { + okhttp3.Call localVarCall = getApiEndpointValidateBeforeCall(apiId, endpointId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get an Endpoint (asynchronously) + * This operation can be used to get an endpoint of an API by UUID. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Status Code Description Response Headers
200 OK. API Endpoint object is returned. * Content-Type - The content type of the body.
500 Internal Server Error. -
404 Not Found. The specified resource does not exist. -
+ */ + public okhttp3.Call getApiEndpointAsync(String apiId, String endpointId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getApiEndpointValidateBeforeCall(apiId, endpointId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getApiEndpoints + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 OK. List of API endpoints. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getApiEndpointsCall(String apiId, Integer limit, Integer offset, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/apis/{apiId}/endpoints" + .replaceAll("\\{" + "apiId" + "\\}", localVarApiClient.escapeString(apiId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (offset != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset)); + } + + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getApiEndpointsValidateBeforeCall(String apiId, Integer limit, Integer offset, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'apiId' is set + if (apiId == null) { + throw new ApiException("Missing the required parameter 'apiId' when calling getApiEndpoints(Async)"); + } + + + okhttp3.Call localVarCall = getApiEndpointsCall(apiId, limit, offset, _callback); + return localVarCall; + + } + + /** + * Get all API Endpoints + * This operation can be used to get all the available endpoints of an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @return APIEndpointListDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 OK. List of API endpoints. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public APIEndpointListDTO getApiEndpoints(String apiId, Integer limit, Integer offset) throws ApiException { + ApiResponse localVarResp = getApiEndpointsWithHttpInfo(apiId, limit, offset); + return localVarResp.getData(); + } + + /** + * Get all API Endpoints + * This operation can be used to get all the available endpoints of an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @return ApiResponse<APIEndpointListDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 OK. List of API endpoints. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public ApiResponse getApiEndpointsWithHttpInfo(String apiId, Integer limit, Integer offset) throws ApiException { + okhttp3.Call localVarCall = getApiEndpointsValidateBeforeCall(apiId, limit, offset, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get all API Endpoints (asynchronously) + * This operation can be used to get all the available endpoints of an API. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param limit Maximum size of resource array to return. (optional, default to 25) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 OK. List of API endpoints. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getApiEndpointsAsync(String apiId, Integer limit, Integer offset, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getApiEndpointsValidateBeforeCall(apiId, limit, offset, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for updateApiEndpoint + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param apIEndpointDTO API Endpoint object with updated details (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK. Updated API Endpoint is returned. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
500 Internal Server Error. -
+ */ + public okhttp3.Call updateApiEndpointCall(String apiId, String endpointId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = apIEndpointDTO; + + // create path and map variables + String localVarPath = "/apis/{apiId}/endpoints/{endpointId}" + .replaceAll("\\{" + "apiId" + "\\}", localVarApiClient.escapeString(apiId.toString())) + .replaceAll("\\{" + "endpointId" + "\\}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "OAuth2Security" }; + return localVarApiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateApiEndpointValidateBeforeCall(String apiId, String endpointId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'apiId' is set + if (apiId == null) { + throw new ApiException("Missing the required parameter 'apiId' when calling updateApiEndpoint(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling updateApiEndpoint(Async)"); + } + + + okhttp3.Call localVarCall = updateApiEndpointCall(apiId, endpointId, apIEndpointDTO, _callback); + return localVarCall; + + } + + /** + * Update an Endpoint + * This operation can be used to update a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param apIEndpointDTO API Endpoint object with updated details (optional) + * @return APIEndpointDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK. Updated API Endpoint is returned. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
500 Internal Server Error. -
+ */ + public APIEndpointDTO updateApiEndpoint(String apiId, String endpointId, APIEndpointDTO apIEndpointDTO) throws ApiException { + ApiResponse localVarResp = updateApiEndpointWithHttpInfo(apiId, endpointId, apIEndpointDTO); + return localVarResp.getData(); + } + + /** + * Update an Endpoint + * This operation can be used to update a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param apIEndpointDTO API Endpoint object with updated details (optional) + * @return ApiResponse<APIEndpointDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK. Updated API Endpoint is returned. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
500 Internal Server Error. -
+ */ + public ApiResponse updateApiEndpointWithHttpInfo(String apiId, String endpointId, APIEndpointDTO apIEndpointDTO) throws ApiException { + okhttp3.Call localVarCall = updateApiEndpointValidateBeforeCall(apiId, endpointId, apIEndpointDTO, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update an Endpoint (asynchronously) + * This operation can be used to update a API endpoint. + * @param apiId **API ID** consisting of the **UUID** of the API. (required) + * @param endpointId **Endpoint ID** consisting of the **UUID** of the Endpoint**. (required) + * @param apIEndpointDTO API Endpoint object with updated details (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 OK. Updated API Endpoint is returned. * Content-Type - The content type of the body.
400 Bad Request. Invalid request or validation error. -
404 Not Found. The specified resource does not exist. -
415 Unsupported Media Type. The entity of the request was not in a supported format. -
500 Internal Server Error. -
+ */ + public okhttp3.Call updateApiEndpointAsync(String apiId, String endpointId, APIEndpointDTO apIEndpointDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateApiEndpointValidateBeforeCall(apiId, endpointId, apIEndpointDTO, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointAuthenticationConfigurationDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointAuthenticationConfigurationDTO.java new file mode 100644 index 0000000000..f129b718ef --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointAuthenticationConfigurationDTO.java @@ -0,0 +1,157 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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; +/** +* AIServiceProviderEndpointAuthenticationConfigurationDTO +*/ + +public class AIServiceProviderEndpointAuthenticationConfigurationDTO { + public static final String SERIALIZED_NAME_ENABLED = "enabled"; + @SerializedName(SERIALIZED_NAME_ENABLED) + private Boolean enabled = false; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; + + public static final String SERIALIZED_NAME_PARAMETERS = "parameters"; + @SerializedName(SERIALIZED_NAME_PARAMETERS) + private Object parameters; + + + public AIServiceProviderEndpointAuthenticationConfigurationDTO enabled(Boolean enabled) { + + this.enabled = enabled; + return this; + } + + /** + * Whether the authentication configuration is enabled or not + * @return enabled + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether the authentication configuration is enabled or not") + + public Boolean isEnabled() { + return enabled; + } + + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + + public AIServiceProviderEndpointAuthenticationConfigurationDTO type(String type) { + + this.type = type; + return this; + } + + /** + * Type of the authentication configuration + * @return type + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "apiKey", value = "Type of the authentication configuration") + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + public AIServiceProviderEndpointAuthenticationConfigurationDTO parameters(Object parameters) { + + this.parameters = parameters; + return this; + } + + /** + * Parameters required for the authentication configuration. The parameters are different based on the type of the authentication configuration. + * @return parameters + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "{\"headerEnabled\":true,\"headerName\":\"Authorization\"}", value = "Parameters required for the authentication configuration. The parameters are different based on the type of the authentication configuration. ") + + public Object getParameters() { + return parameters; + } + + + public void setParameters(Object parameters) { + this.parameters = parameters; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderEndpointAuthenticationConfigurationDTO aiServiceProviderEndpointAuthenticationConfiguration = (AIServiceProviderEndpointAuthenticationConfigurationDTO) o; + return Objects.equals(this.enabled, aiServiceProviderEndpointAuthenticationConfiguration.enabled) && + Objects.equals(this.type, aiServiceProviderEndpointAuthenticationConfiguration.type) && + Objects.equals(this.parameters, aiServiceProviderEndpointAuthenticationConfiguration.parameters); + } + + @Override + public int hashCode() { + return Objects.hash(enabled, type, parameters); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderEndpointAuthenticationConfigurationDTO {\n"); + sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointConfigurationDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointConfigurationDTO.java new file mode 100644 index 0000000000..4156e5c0e1 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderEndpointConfigurationDTO.java @@ -0,0 +1,158 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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.publisher.api.v1.dto.AIServiceProviderEndpointAuthenticationConfigurationDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIServiceProviderEndpointConfigurationDTO +*/ + +public class AIServiceProviderEndpointConfigurationDTO { + public static final String SERIALIZED_NAME_AUTHENTICATION_CONFIGURATION = "authenticationConfiguration"; + @SerializedName(SERIALIZED_NAME_AUTHENTICATION_CONFIGURATION) + private AIServiceProviderEndpointAuthenticationConfigurationDTO authenticationConfiguration; + + public static final String SERIALIZED_NAME_AUTH_HEADER = "authHeader"; + @SerializedName(SERIALIZED_NAME_AUTH_HEADER) + private String authHeader; + + public static final String SERIALIZED_NAME_AUTH_QUERY_PARAMETER = "authQueryParameter"; + @SerializedName(SERIALIZED_NAME_AUTH_QUERY_PARAMETER) + private String authQueryParameter; + + + public AIServiceProviderEndpointConfigurationDTO authenticationConfiguration(AIServiceProviderEndpointAuthenticationConfigurationDTO authenticationConfiguration) { + + this.authenticationConfiguration = authenticationConfiguration; + return this; + } + + /** + * Get authenticationConfiguration + * @return authenticationConfiguration + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public AIServiceProviderEndpointAuthenticationConfigurationDTO getAuthenticationConfiguration() { + return authenticationConfiguration; + } + + + public void setAuthenticationConfiguration(AIServiceProviderEndpointAuthenticationConfigurationDTO authenticationConfiguration) { + this.authenticationConfiguration = authenticationConfiguration; + } + + + public AIServiceProviderEndpointConfigurationDTO authHeader(String authHeader) { + + this.authHeader = authHeader; + return this; + } + + /** + * Get authHeader + * @return authHeader + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Authorization", value = "") + + public String getAuthHeader() { + return authHeader; + } + + + public void setAuthHeader(String authHeader) { + this.authHeader = authHeader; + } + + + public AIServiceProviderEndpointConfigurationDTO authQueryParameter(String authQueryParameter) { + + this.authQueryParameter = authQueryParameter; + return this; + } + + /** + * Get authQueryParameter + * @return authQueryParameter + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "ApiKey", value = "") + + public String getAuthQueryParameter() { + return authQueryParameter; + } + + + public void setAuthQueryParameter(String authQueryParameter) { + this.authQueryParameter = authQueryParameter; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderEndpointConfigurationDTO aiServiceProviderEndpointConfiguration = (AIServiceProviderEndpointConfigurationDTO) o; + return Objects.equals(this.authenticationConfiguration, aiServiceProviderEndpointConfiguration.authenticationConfiguration) && + Objects.equals(this.authHeader, aiServiceProviderEndpointConfiguration.authHeader) && + Objects.equals(this.authQueryParameter, aiServiceProviderEndpointConfiguration.authQueryParameter); + } + + @Override + public int hashCode() { + return Objects.hash(authenticationConfiguration, authHeader, authQueryParameter); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderEndpointConfigurationDTO {\n"); + sb.append(" authenticationConfiguration: ").append(toIndentedString(authenticationConfiguration)).append("\n"); + sb.append(" authHeader: ").append(toIndentedString(authHeader)).append("\n"); + sb.append(" authQueryParameter: ").append(toIndentedString(authQueryParameter)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderResponseDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderResponseDTO.java new file mode 100644 index 0000000000..e8496eaecd --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderResponseDTO.java @@ -0,0 +1,273 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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; +/** +* AIServiceProviderResponseDTO +*/ + +public class AIServiceProviderResponseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_BUILT_IN_SUPPORT = "builtInSupport"; + @SerializedName(SERIALIZED_NAME_BUILT_IN_SUPPORT) + private Boolean builtInSupport; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_CONFIGURATIONS = "configurations"; + @SerializedName(SERIALIZED_NAME_CONFIGURATIONS) + private String configurations; + + public static final String SERIALIZED_NAME_API_DEFINITION = "apiDefinition"; + @SerializedName(SERIALIZED_NAME_API_DEFINITION) + private String apiDefinition; + + + public AIServiceProviderResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "ece92bdc-e1e6-325c-b6f4-656208a041e9", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public AIServiceProviderResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI", value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public AIServiceProviderResponseDTO apiVersion(String apiVersion) { + + this.apiVersion = apiVersion; + return this; + } + + /** + * Get apiVersion + * @return apiVersion + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1.0.0", value = "") + + public String getApiVersion() { + return apiVersion; + } + + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + + public AIServiceProviderResponseDTO builtInSupport(Boolean builtInSupport) { + + this.builtInSupport = builtInSupport; + return this; + } + + /** + * Is built-in support + * @return builtInSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Is built-in support") + + public Boolean isBuiltInSupport() { + return builtInSupport; + } + + + public void setBuiltInSupport(Boolean builtInSupport) { + this.builtInSupport = builtInSupport; + } + + + public AIServiceProviderResponseDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI LLM", value = "") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public AIServiceProviderResponseDTO configurations(String configurations) { + + this.configurations = configurations; + return this; + } + + /** + * LLM Provider configurations + * @return configurations + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "LLM Provider configurations") + + public String getConfigurations() { + return configurations; + } + + + public void setConfigurations(String configurations) { + this.configurations = configurations; + } + + + public AIServiceProviderResponseDTO apiDefinition(String apiDefinition) { + + this.apiDefinition = apiDefinition; + return this; + } + + /** + * OpenAPI specification + * @return apiDefinition + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "OpenAPI specification") + + public String getApiDefinition() { + return apiDefinition; + } + + + public void setApiDefinition(String apiDefinition) { + this.apiDefinition = apiDefinition; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderResponseDTO aiServiceProviderResponse = (AIServiceProviderResponseDTO) o; + return Objects.equals(this.id, aiServiceProviderResponse.id) && + Objects.equals(this.name, aiServiceProviderResponse.name) && + Objects.equals(this.apiVersion, aiServiceProviderResponse.apiVersion) && + Objects.equals(this.builtInSupport, aiServiceProviderResponse.builtInSupport) && + Objects.equals(this.description, aiServiceProviderResponse.description) && + Objects.equals(this.configurations, aiServiceProviderResponse.configurations) && + Objects.equals(this.apiDefinition, aiServiceProviderResponse.apiDefinition); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, apiVersion, builtInSupport, description, configurations, apiDefinition); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderResponseDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" builtInSupport: ").append(toIndentedString(builtInSupport)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" configurations: ").append(toIndentedString(configurations)).append("\n"); + sb.append(" apiDefinition: ").append(toIndentedString(apiDefinition)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseDTO.java new file mode 100644 index 0000000000..c9cf4ae907 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseDTO.java @@ -0,0 +1,215 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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; +/** +* AIServiceProviderSummaryResponseDTO +*/ + +public class AIServiceProviderSummaryResponseDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_API_VERSION = "apiVersion"; + @SerializedName(SERIALIZED_NAME_API_VERSION) + private String apiVersion; + + public static final String SERIALIZED_NAME_BUILT_IN_SUPPORT = "builtInSupport"; + @SerializedName(SERIALIZED_NAME_BUILT_IN_SUPPORT) + private Boolean builtInSupport; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + + public AIServiceProviderSummaryResponseDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "ece92bdc-e1e6-325c-b6f4-656208a041e9", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public AIServiceProviderSummaryResponseDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "open-ai", value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public AIServiceProviderSummaryResponseDTO apiVersion(String apiVersion) { + + this.apiVersion = apiVersion; + return this; + } + + /** + * Get apiVersion + * @return apiVersion + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1.0.0", value = "") + + public String getApiVersion() { + return apiVersion; + } + + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + + public AIServiceProviderSummaryResponseDTO builtInSupport(Boolean builtInSupport) { + + this.builtInSupport = builtInSupport; + return this; + } + + /** + * Is built-in support + * @return builtInSupport + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Is built-in support") + + public Boolean isBuiltInSupport() { + return builtInSupport; + } + + + public void setBuiltInSupport(Boolean builtInSupport) { + this.builtInSupport = builtInSupport; + } + + + public AIServiceProviderSummaryResponseDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI LLM Provider", value = "") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderSummaryResponseDTO aiServiceProviderSummaryResponse = (AIServiceProviderSummaryResponseDTO) o; + return Objects.equals(this.id, aiServiceProviderSummaryResponse.id) && + Objects.equals(this.name, aiServiceProviderSummaryResponse.name) && + Objects.equals(this.apiVersion, aiServiceProviderSummaryResponse.apiVersion) && + Objects.equals(this.builtInSupport, aiServiceProviderSummaryResponse.builtInSupport) && + Objects.equals(this.description, aiServiceProviderSummaryResponse.description); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, apiVersion, builtInSupport, description); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderSummaryResponseDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" apiVersion: ").append(toIndentedString(apiVersion)).append("\n"); + sb.append(" builtInSupport: ").append(toIndentedString(builtInSupport)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseListDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseListDTO.java new file mode 100644 index 0000000000..1bb42a1c67 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/AIServiceProviderSummaryResponseListDTO.java @@ -0,0 +1,131 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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 java.util.ArrayList; +import java.util.List; +import org.wso2.am.integration.clients.publisher.api.v1.dto.AIServiceProviderSummaryResponseDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* AIServiceProviderSummaryResponseListDTO +*/ + +public class AIServiceProviderSummaryResponseListDTO { + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public static final String SERIALIZED_NAME_LIST = "list"; + @SerializedName(SERIALIZED_NAME_LIST) + private List list = null; + + + public AIServiceProviderSummaryResponseListDTO count(Integer count) { + + this.count = count; + return this; + } + + /** + * Number of LLM Providers returned. + * @return count + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1", value = "Number of LLM Providers returned. ") + + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + public AIServiceProviderSummaryResponseListDTO list(List list) { + + this.list = list; + return this; + } + + /** + * Get list + * @return list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getList() { + return list; + } + + + public void setList(List list) { + this.list = list; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AIServiceProviderSummaryResponseListDTO aiServiceProviderSummaryResponseList = (AIServiceProviderSummaryResponseListDTO) o; + return Objects.equals(this.count, aiServiceProviderSummaryResponseList.count) && + Objects.equals(this.list, aiServiceProviderSummaryResponseList.list); + } + + @Override + public int hashCode() { + return Objects.hash(count, list); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class AIServiceProviderSummaryResponseListDTO {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIDTO.java index ded621b7eb..65e0ee11ce 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIDTO.java +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIDTO.java @@ -510,6 +510,14 @@ public AccessControlEnum read(final JsonReader jsonReader) throws IOException { @SerializedName(SERIALIZED_NAME_ENDPOINT_CONFIG) private Object endpointConfig; + public static final String SERIALIZED_NAME_PRIMARY_PRODUCTION_ENDPOINT_ID = "primaryProductionEndpointId"; + @SerializedName(SERIALIZED_NAME_PRIMARY_PRODUCTION_ENDPOINT_ID) + private String primaryProductionEndpointId; + + public static final String SERIALIZED_NAME_PRIMARY_SANDBOX_ENDPOINT_ID = "primarySandboxEndpointId"; + @SerializedName(SERIALIZED_NAME_PRIMARY_SANDBOX_ENDPOINT_ID) + private String primarySandboxEndpointId; + /** * Gets or Sets endpointImplementationType */ @@ -1801,6 +1809,52 @@ public void setEndpointConfig(Object endpointConfig) { } + public APIDTO primaryProductionEndpointId(String primaryProductionEndpointId) { + + this.primaryProductionEndpointId = primaryProductionEndpointId; + return this; + } + + /** + * Get primaryProductionEndpointId + * @return primaryProductionEndpointId + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "13092607-ed01-4fa1-bc64-5da0e2abe92c", value = "") + + public String getPrimaryProductionEndpointId() { + return primaryProductionEndpointId; + } + + + public void setPrimaryProductionEndpointId(String primaryProductionEndpointId) { + this.primaryProductionEndpointId = primaryProductionEndpointId; + } + + + public APIDTO primarySandboxEndpointId(String primarySandboxEndpointId) { + + this.primarySandboxEndpointId = primarySandboxEndpointId; + return this; + } + + /** + * Get primarySandboxEndpointId + * @return primarySandboxEndpointId + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "13092607-ed01-4fa1-bc64-5da0e2abe92c", value = "") + + public String getPrimarySandboxEndpointId() { + return primarySandboxEndpointId; + } + + + public void setPrimarySandboxEndpointId(String primarySandboxEndpointId) { + this.primarySandboxEndpointId = primarySandboxEndpointId; + } + + public APIDTO endpointImplementationType(EndpointImplementationTypeEnum endpointImplementationType) { this.endpointImplementationType = endpointImplementationType; @@ -2138,6 +2192,8 @@ public boolean equals(Object o) { Objects.equals(this.lastUpdatedTimestamp, API.lastUpdatedTimestamp) && Objects.equals(this.lastUpdatedTime, API.lastUpdatedTime) && Objects.equals(this.endpointConfig, API.endpointConfig) && + Objects.equals(this.primaryProductionEndpointId, API.primaryProductionEndpointId) && + Objects.equals(this.primarySandboxEndpointId, API.primarySandboxEndpointId) && Objects.equals(this.endpointImplementationType, API.endpointImplementationType) && Objects.equals(this.scopes, API.scopes) && Objects.equals(this.operations, API.operations) && @@ -2154,7 +2210,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, name, displayName, description, context, version, provider, lifeCycleStatus, wsdlInfo, wsdlUrl, responseCachingEnabled, cacheTimeout, hasThumbnail, isDefaultVersion, isRevision, revisionedApiId, revisionId, enableSchemaValidation, enableSubscriberVerification, type, audience, audiences, transport, tags, policies, organizationPolicies, apiThrottlingPolicy, authorizationHeader, apiKeyHeader, securityScheme, maxTps, visibility, visibleRoles, visibleTenants, visibleOrganizations, mediationPolicies, apiPolicies, subscriptionAvailability, subscriptionAvailableTenants, additionalProperties, additionalPropertiesMap, monetization, accessControl, accessControlRoles, businessInformation, corsConfiguration, websubSubscriptionConfiguration, workflowStatus, createdTime, lastUpdatedTimestamp, lastUpdatedTime, endpointConfig, endpointImplementationType, scopes, operations, threatProtectionPolicies, categories, keyManagers, serviceInfo, advertiseInfo, gatewayVendor, gatewayType, asyncTransportProtocols, initiatedFromGateway); + return Objects.hash(id, name, displayName, description, context, version, provider, lifeCycleStatus, wsdlInfo, wsdlUrl, responseCachingEnabled, cacheTimeout, hasThumbnail, isDefaultVersion, isRevision, revisionedApiId, revisionId, enableSchemaValidation, enableSubscriberVerification, type, audience, audiences, transport, tags, policies, organizationPolicies, apiThrottlingPolicy, authorizationHeader, apiKeyHeader, securityScheme, maxTps, visibility, visibleRoles, visibleTenants, visibleOrganizations, mediationPolicies, apiPolicies, subscriptionAvailability, subscriptionAvailableTenants, additionalProperties, additionalPropertiesMap, monetization, accessControl, accessControlRoles, businessInformation, corsConfiguration, websubSubscriptionConfiguration, workflowStatus, createdTime, lastUpdatedTimestamp, lastUpdatedTime, endpointConfig, primaryProductionEndpointId, primarySandboxEndpointId, endpointImplementationType, scopes, operations, threatProtectionPolicies, categories, keyManagers, serviceInfo, advertiseInfo, gatewayVendor, gatewayType, asyncTransportProtocols, initiatedFromGateway); } @@ -2214,6 +2270,8 @@ public String toString() { sb.append(" lastUpdatedTimestamp: ").append(toIndentedString(lastUpdatedTimestamp)).append("\n"); sb.append(" lastUpdatedTime: ").append(toIndentedString(lastUpdatedTime)).append("\n"); sb.append(" endpointConfig: ").append(toIndentedString(endpointConfig)).append("\n"); + sb.append(" primaryProductionEndpointId: ").append(toIndentedString(primaryProductionEndpointId)).append("\n"); + sb.append(" primarySandboxEndpointId: ").append(toIndentedString(primarySandboxEndpointId)).append("\n"); sb.append(" endpointImplementationType: ").append(toIndentedString(endpointImplementationType)).append("\n"); sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); sb.append(" operations: ").append(toIndentedString(operations)).append("\n"); diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointDTO.java new file mode 100644 index 0000000000..c1c966f542 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointDTO.java @@ -0,0 +1,185 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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; +/** +* APIEndpointDTO +*/ + +public class APIEndpointDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_DEPLOYMENT_STAGE = "deploymentStage"; + @SerializedName(SERIALIZED_NAME_DEPLOYMENT_STAGE) + private String deploymentStage; + + public static final String SERIALIZED_NAME_ENDPOINT_CONFIG = "endpointConfig"; + @SerializedName(SERIALIZED_NAME_ENDPOINT_CONFIG) + private Object endpointConfig; + + + public APIEndpointDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "57a380b7-d852-4f56-bb23-db172722e9d4", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public APIEndpointDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @ApiModelProperty(example = "Endpoint1", required = true, value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public APIEndpointDTO deploymentStage(String deploymentStage) { + + this.deploymentStage = deploymentStage; + return this; + } + + /** + * Get deploymentStage + * @return deploymentStage + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "PRODUCTION or SANDBOX", value = "") + + public String getDeploymentStage() { + return deploymentStage; + } + + + public void setDeploymentStage(String deploymentStage) { + this.deploymentStage = deploymentStage; + } + + + public APIEndpointDTO endpointConfig(Object endpointConfig) { + + this.endpointConfig = endpointConfig; + return this; + } + + /** + * Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. + * @return endpointConfig + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. ") + + public Object getEndpointConfig() { + return endpointConfig; + } + + + public void setEndpointConfig(Object endpointConfig) { + this.endpointConfig = endpointConfig; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIEndpointDTO apIEndpoint = (APIEndpointDTO) o; + return Objects.equals(this.id, apIEndpoint.id) && + Objects.equals(this.name, apIEndpoint.name) && + Objects.equals(this.deploymentStage, apIEndpoint.deploymentStage) && + Objects.equals(this.endpointConfig, apIEndpoint.endpointConfig); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, deploymentStage, endpointConfig); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class APIEndpointDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" deploymentStage: ").append(toIndentedString(deploymentStage)).append("\n"); + sb.append(" endpointConfig: ").append(toIndentedString(endpointConfig)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointListDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointListDTO.java new file mode 100644 index 0000000000..04d2a351af --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIEndpointListDTO.java @@ -0,0 +1,161 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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 java.util.ArrayList; +import java.util.List; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIEndpointDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.PaginationDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* APIEndpointListDTO +*/ + +public class APIEndpointListDTO { + public static final String SERIALIZED_NAME_COUNT = "count"; + @SerializedName(SERIALIZED_NAME_COUNT) + private Integer count; + + public static final String SERIALIZED_NAME_LIST = "list"; + @SerializedName(SERIALIZED_NAME_LIST) + private List list = null; + + public static final String SERIALIZED_NAME_PAGINATION = "pagination"; + @SerializedName(SERIALIZED_NAME_PAGINATION) + private PaginationDTO pagination; + + + public APIEndpointListDTO count(Integer count) { + + this.count = count; + return this; + } + + /** + * Number of Endpoints returned. + * @return count + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1", value = "Number of Endpoints returned. ") + + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + public APIEndpointListDTO list(List list) { + + this.list = list; + return this; + } + + /** + * Get list + * @return list + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getList() { + return list; + } + + + public void setList(List list) { + this.list = list; + } + + + public APIEndpointListDTO pagination(PaginationDTO pagination) { + + this.pagination = pagination; + return this; + } + + /** + * Get pagination + * @return pagination + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public PaginationDTO getPagination() { + return pagination; + } + + + public void setPagination(PaginationDTO pagination) { + this.pagination = pagination; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + APIEndpointListDTO apIEndpointList = (APIEndpointListDTO) o; + return Objects.equals(this.count, apIEndpointList.count) && + Objects.equals(this.list, apIEndpointList.list) && + Objects.equals(this.pagination, apIEndpointList.pagination); + } + + @Override + public int hashCode() { + return Objects.hash(count, list, pagination); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class APIEndpointListDTO {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" list: ").append(toIndentedString(list)).append("\n"); + sb.append(" pagination: ").append(toIndentedString(pagination)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIInfoDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIInfoDTO.java index 9f18f75838..3a5c7b2c97 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIInfoDTO.java +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/APIInfoDTO.java @@ -71,6 +71,10 @@ public class APIInfoDTO { @SerializedName(SERIALIZED_NAME_TYPE) private String type; + public static final String SERIALIZED_NAME_SUBTYPE = "subtype"; + @SerializedName(SERIALIZED_NAME_SUBTYPE) + private String subtype = "DEFAULT"; + /** * The audience of the API. Accepted values are PUBLIC, SINGLE */ @@ -366,6 +370,29 @@ public void setType(String type) { } + public APIInfoDTO subtype(String subtype) { + + this.subtype = subtype; + return this; + } + + /** + * Subtype of the API. + * @return subtype + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "AIAPI", value = "Subtype of the API.") + + public String getSubtype() { + return subtype; + } + + + public void setSubtype(String subtype) { + this.subtype = subtype; + } + + public APIInfoDTO audience(AudienceEnum audience) { this.audience = audience; @@ -614,6 +641,7 @@ public boolean equals(Object o) { Objects.equals(this.version, apIInfo.version) && Objects.equals(this.provider, apIInfo.provider) && Objects.equals(this.type, apIInfo.type) && + Objects.equals(this.subtype, apIInfo.subtype) && Objects.equals(this.audience, apIInfo.audience) && Objects.equals(this.audiences, apIInfo.audiences) && Objects.equals(this.lifeCycleStatus, apIInfo.lifeCycleStatus) && @@ -628,7 +656,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(id, name, description, context, additionalProperties, additionalPropertiesMap, version, provider, type, audience, audiences, lifeCycleStatus, workflowStatus, hasThumbnail, securityScheme, createdTime, updatedTime, gatewayVendor, advertiseOnly); + return Objects.hash(id, name, description, context, additionalProperties, additionalPropertiesMap, version, provider, type, subtype, audience, audiences, lifeCycleStatus, workflowStatus, hasThumbnail, securityScheme, createdTime, updatedTime, gatewayVendor, advertiseOnly); } @@ -645,6 +673,7 @@ public String toString() { sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" subtype: ").append(toIndentedString(subtype)).append("\n"); sb.append(" audience: ").append(toIndentedString(audience)).append("\n"); sb.append(" audiences: ").append(toIndentedString(audiences)).append("\n"); sb.append(" lifeCycleStatus: ").append(toIndentedString(lifeCycleStatus)).append("\n"); diff --git a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/ModelProviderDTO.java b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/ModelProviderDTO.java new file mode 100644 index 0000000000..18a81a0f28 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/ModelProviderDTO.java @@ -0,0 +1,130 @@ +/* + * WSO2 API Manager - Publisher API + * This document specifies a **RESTful API** for WSO2 **API Manager** - **Publisher**. # Authentication The Publisher REST API is 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_publisher\", \"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_publisher\", \"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_api123\\\"}\", \"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 publisher REST API can be viewed in **OAuth2 Security** section of this document and scope for each resource is given in **authorization** 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=\" \\ -H \"Authorization: Basic base64(cliet_id:client_secret)\" \\ https://:/oauth2/token ``` **Sample request** ``` curl https://localhost:9443/oauth2/token -k \\ -H \"Authorization: Basic Zk9DaTR2Tko1OVBwSHVjQzJDQVlmWXVBRGRNYTphNEZ3SGxxMGlDSUtWczJNUElJRG5lcFpuWU1h\" \\ -d \"grant_type=password&username=admin&password=admin&scope=apim:api_view apim:api_create\" ``` 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:api_create apim:api_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/a09044034b5c3c1b01a9) + * + * 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.publisher.api.v1.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 java.util.ArrayList; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* ModelProviderDTO +*/ + +public class ModelProviderDTO { + public static final String SERIALIZED_NAME_MODELS = "models"; + @SerializedName(SERIALIZED_NAME_MODELS) + private List models = null; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + public ModelProviderDTO models(List models) { + + this.models = models; + return this; + } + + /** + * Get models + * @return models + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getModels() { + return models; + } + + + public void setModels(List models) { + this.models = models; + } + + + public ModelProviderDTO name(String name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "OpenAI", value = "") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelProviderDTO modelProvider = (ModelProviderDTO) o; + return Objects.equals(this.models, modelProvider.models) && + Objects.equals(this.name, modelProvider.name); + } + + @Override + public int hashCode() { + return Objects.hash(models, name); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class ModelProviderDTO {\n"); + sb.append(" models: ").append(toIndentedString(models)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml index 8e31169bd7..34affd15f2 100644 --- a/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml +++ b/all-in-one-apim/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml @@ -8831,6 +8831,387 @@ paths: source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://127.0.0.1:9443/api/am/publisher/v2/operation-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a/content"' + ###################################################### + # The "API Endpoint Collection" resource APIs + ###################################################### + /apis/{apiId}/endpoints: + get: + tags: + - API Endpoints + summary: Get all API Endpoints + description: | + This operation can be used to get all the available endpoints of an API. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/offset' + responses: + 200: + description: | + OK. + List of API endpoints. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpointList' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_view + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints?limit=10&offset=0"' + operationId: getApiEndpoints + + post: + tags: + - API Endpoints + summary: Add an Endpoint + description: | + This operation can be used to add an endpoint to an API. + parameters: + - $ref: '#/components/parameters/apiId' + requestBody: + description: Endpoint object that needs to be added + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + required: true + responses: + 201: + description: | + Created. + Successful response with the newly created API Endpoint object in the body. + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + 400: + $ref: '#/components/responses/BadRequest' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints"' + operationId: addApiEndpoint + + /apis/{apiId}/endpoints/{endpointId}: + get: + tags: + - API Endpoints + summary: Get an Endpoint + description: | + This operation can be used to get an endpoint of an API by UUID. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/endpointId' + responses: + 200: + description: | + OK. + API Endpoint object is returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + 500: + $ref: '#/components/responses/InternalServerError' + 404: + $ref: '#/components/responses/NotFound' + security: + - OAuth2Security: + - apim:api_view + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + operationId: getApiEndpoint + + put: + tags: + - API Endpoints + summary: Update an Endpoint + description: | + This operation can be used to update a API endpoint. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/endpointId' + requestBody: + description: API Endpoint object with updated details + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + responses: + 200: + description: | + OK. + Updated API Endpoint is returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/APIEndpoint' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 415: + $ref: '#/components/responses/UnsupportedMediaType' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + operationId: updateApiEndpoint + + delete: + tags: + - API Endpoints + summary: Delete an Endpoint + description: | + This operation can be used to delete a API endpoint. + parameters: + - $ref: '#/components/parameters/apiId' + - $ref: '#/components/parameters/endpointId' + responses: + 200: + description: | + OK. + Endpoint deleted successfully. + content: {} + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:api_create + - apim:api_manage + - apim:api_publish + - apim:api_import_export + x-code-samples: + - lang: Curl + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/apis/96077508-fd01-4fae-bc64-5de0e2baf43c/endpoints/13092607-ed01-4fa1-bc64-5da0e2abe92c"' + operationId: deleteApiEndpoint + + ###################################################### + # AI Service Providers resource APIs + ###################################################### + /ai-service-providers: + get: + tags: + - AIServiceProviders + summary: Get all AI Service providers + description: | + Get all AI Service providers + responses: + 200: + description: | + OK. + List of AI Service providers. + headers: + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderSummaryResponseList' + 406: + $ref: '#/components/responses/NotAcceptable' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:llm_provider_read + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers"' + operationId: getAIServiceProviders + + /ai-service-providers/{aiServiceProviderId}/api-definition: + get: + tags: + - AIServiceProvider + summary: Get AI Service Provider's API Definition + description: | + Get AI Service Provider's API Definition + parameters: + - name: aiServiceProviderId + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + API Definition + content: + application/json: + schema: + type: string + security: + - OAuth2Security: + - apim:llm_provider_read + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/api-definition"' + operationId: getAIServiceProviderApiDefinition + + /ai-service-providers/{aiServiceProviderId}/endpoint-configuration: + get: + tags: + - AIServiceProvider + summary: Get AI Service Provider's security configurations + description: | + Get AI Service Provider's endpoint security configurations + parameters: + - name: aiServiceProviderId + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + API Definition + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderEndpointConfiguration' + security: + - OAuth2Security: + - apim:llm_provider_read + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/endpoint-configuration"' + operationId: getAIServiceProviderEndpointConfiguration + + /ai-service-providers/{aiServiceProviderId}/models: + get: + tags: + - AIServiceProvider + summary: Get AI Service Provider's model list + description: | + Get AI Service Provider's model list + parameters: + - name: aiServiceProviderId + in: path + required: true + schema: + type: string + responses: + 200: + description: | + OK. + List of supported model families grouped by vendor + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ModelProvider' + security: + - OAuth2Security: + - apim:llm_provider_read + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f/models"' + operationId: getAIServiceProviderModels + + ###################################################### + # The "Individual AI Service Provider" resource APIs + ###################################################### + /ai-service-providers/{aiServiceProviderId}: + get: + tags: + - AIServiceProvider + summary: Get AI Service Provider + description: | + Get a AI Service Provider + parameters: + - name: aiServiceProviderId + in: path + description: | + AI Service Provider ID + required: true + schema: + type: string + responses: + 200: + description: | + OK. + AI Service Provider + content: + application/json: + schema: + $ref: '#/components/schemas/AIServiceProviderResponse' + security: + - OAuth2Security: + - apim:llm_provider_read + x-code-samples: + - lang: Curl + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://127.0.0.1:9443/api/am/publisher/v4/ai-service-providers/a2f1e643-9b2a-4f58-bd7a-8c2d3f1e9d6f"' + operationId: getAIServiceProvider + ###################################################### # The Gateway Policies API ###################################################### @@ -9466,6 +9847,12 @@ components: type: type: string example: HTTP + subtype: + type: string + description: Subtype of the API. + default: DEFAULT + example: AIAPI + readOnly: true audience: type: string description: The audience of the API. Accepted values are PUBLIC, SINGLE @@ -9983,6 +10370,12 @@ components: url: https://localhost:9443/am/sample/pizzashack/v1/api/ production_endpoints: url: https://localhost:9443/am/sample/pizzashack/v1/api/ + primaryProductionEndpointId: + type: string + example: "13092607-ed01-4fa1-bc64-5da0e2abe92c" + primarySandboxEndpointId: + type: string + example: "13092607-ed01-4fa1-bc64-5da0e2abe92c" endpointImplementationType: type: string example: INLINE @@ -11405,6 +11798,153 @@ components: type: array items: $ref: '#/components/schemas/Environment' + APIEndpoint: + title: Endpoint + type: object + required: + - name + properties: + id: + type: string + example: "57a380b7-d852-4f56-bb23-db172722e9d4" + name: + type: string + example: "Endpoint1" + deploymentStage: + type: string + example: "PRODUCTION or SANDBOX" + endpointConfig: + type: object + properties: {} + description: | + Endpoint configuration of the API. This can be used to provide different types of endpoints including Simple REST Endpoints, Loadbalanced and Failover. + APIEndpointList: + title: Endpoints List + type: object + properties: + count: + type: integer + description: | + Number of Endpoints returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/APIEndpoint' + pagination: + $ref: '#/components/schemas/Pagination' + ModelProvider: + title: Model Provider + type: object + properties: + models: + type: array + items: + type: string + example: "gpt-4o" + name: + type: string + example: OpenAI + AIServiceProviderResponse: + title: AIServiceProviderResponse + type: object + properties: + id: + type: string + readOnly: true + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + name: + maxLength: 255 + minLength: 1 + type: string + example: OpenAI + apiVersion: + maxLength: 255 + minLength: 1 + type: string + example: 1.0.0 + builtInSupport: + type: boolean + description: Is built-in support + description: + maxLength: 1023 + type: string + example: OpenAI LLM + configurations: + type: string + description: LLM Provider configurations + apiDefinition: + type: string + description: OpenAPI specification + AIServiceProviderSummaryResponse: + title: AIServiceProviderSummaryResponse + type: object + properties: + id: + type: string + readOnly: true + example: ece92bdc-e1e6-325c-b6f4-656208a041e9 + name: + maxLength: 255 + minLength: 1 + type: string + example: open-ai + apiVersion: + maxLength: 255 + minLength: 1 + type: string + example: 1.0.0 + builtInSupport: + type: boolean + description: Is built-in support + description: + maxLength: 1023 + type: string + example: OpenAI LLM Provider + AIServiceProviderSummaryResponseList: + title: AIServiceProviderSummaryResponseList + type: object + properties: + count: + type: integer + description: | + Number of LLM Providers returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/AIServiceProviderSummaryResponse' + AIServiceProviderEndpointConfiguration: + title: AIServiceProviderEndpointConfiguration + type: object + properties: + authenticationConfiguration: + $ref: '#/components/schemas/AIServiceProviderEndpointAuthenticationConfiguration' + authHeader: + type: string + example: Authorization + deprecated: true + authQueryParameter: + type: string + example: ApiKey + deprecated: true + AIServiceProviderEndpointAuthenticationConfiguration: + title: AIServiceProviderEndpointAuthenticationConfiguration + type: object + properties: + enabled: + type: boolean + description: Whether the authentication configuration is enabled or not + default: false + type: + type: string + description: Type of the authentication configuration + example: apiKey + parameters: + type: object + description: | + Parameters required for the authentication configuration. The parameters are different based on the type of the authentication configuration. + example: { "headerEnabled": true, "headerName": "Authorization" } AdditionalProperty: title: Additional Gateway Properties type: object @@ -13717,4 +14257,5 @@ components: apim:api_list_view: View, Retrieve API list apim:api_definition_view: View, Retrieve API definition apim:policies_import_export: Export and import policies related operations + apim:llm_provider_read: Read LLM Providers apim:publisher_organization_read: Read organization diff --git a/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIAdminImpl.java b/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIAdminImpl.java index 7ed97222db..34a1c77bd9 100644 --- a/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIAdminImpl.java +++ b/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIAdminImpl.java @@ -65,6 +65,8 @@ public class RestAPIAdminImpl { private EnvironmentApi environmentApi = new EnvironmentApi(); private LlmProviderApi llmProviderApi = new LlmProviderApi(); private LlmProvidersApi llmProvidersApi = new LlmProvidersApi(); + private AiServiceProviderApi aiServiceProviderApi = new AiServiceProviderApi(); + private AiServiceProvidersApi aiServiceProvidersApi = new AiServiceProvidersApi(); private EnvironmentCollectionApi environmentCollectionApi = new EnvironmentCollectionApi(); private TenantConfigApi tenantConfigApi = new TenantConfigApi(); private TenantConfigSchemaApi tenantConfigSchemaApi = new TenantConfigSchemaApi(); @@ -115,7 +117,8 @@ public RestAPIAdminImpl(String username, String password, String tenantDomain, S "apim:api_category " + "apim:admin_tier_view " + "apim:admin_tier_manage " + - "apim:scope_manage"; + "apim:scope_manage " + + "apim:llm_provider_manage "; String accessToken = ClientAuthenticator .getAccessToken(scopeList, @@ -150,6 +153,8 @@ public RestAPIAdminImpl(String username, String password, String tenantDomain, S environmentApi.setApiClient(apiAdminClient); llmProviderApi.setApiClient(apiAdminClient); llmProvidersApi.setApiClient(apiAdminClient); + aiServiceProviderApi.setApiClient(apiAdminClient); + aiServiceProvidersApi.setApiClient(apiAdminClient); environmentCollectionApi.setApiClient(apiAdminClient); workflowCollectionApi.setApiClient(apiAdminClient); workflowsIndividualApi.setApiClient(apiAdminClient); @@ -321,6 +326,78 @@ public ApiResponse deleteLLMProvider(String llmProviderId) throws ApiExcep return llmProviderApi.llmProvidersLlmProviderIdDeleteWithHttpInfo(llmProviderId); } + /** + * Retrieves a list of AI Service Providers. + * + * @return ApiResponse containing a list of AIServiceProviderSummaryResponseListDTO with details about available AI service providers. + * @throws ApiException if there is an error during the API call. + */ + public ApiResponse getAIServiceProviders() throws ApiException { + return aiServiceProvidersApi.getAIServiceProvidersWithHttpInfo(); + } + + /** + * Retrieves details of a specific AI Service Provider by its ID. + * + * @param aiServiceProviderId The unique identifier of the AI service provider. + * @return ApiResponse containing AIServiceProviderResponseDTO with details of the specified AI service provider. + * @throws ApiException if there is an error during the API call. + */ + public ApiResponse getAIServiceProvider(String aiServiceProviderId) throws ApiException { + return aiServiceProviderApi.getAIServiceProviderWithHttpInfo(aiServiceProviderId); + } + + /** + * Add the details of a specific AI Service Provider. + * + * @param name The new name of the AI service provider. + * @param apiVersion The API version of the AI service provider. + * @param description A brief description of the AI service provider. + * @param multipleModelProviderSupport Whether the provider supports multiple model providers. + * @param configurations Configuration details for the AI service provider. + * @param apiDefinition The API definition file for the AI service provider. + * @param modelProviders The list of model providers for the AI service provider. + * @return ApiResponse containing AIServiceProviderResponseDTO with the created details of the AI service provider. + * @throws ApiException if there is an error during the API call. + */ + public ApiResponse addAIServiceProvider(String name, String apiVersion, String description, + Boolean multipleModelProviderSupport, String configurations, File apiDefinition, String modelProviders) throws ApiException { + + return aiServiceProvidersApi.addAIServiceProviderWithHttpInfo(name, apiVersion, configurations, + apiDefinition, description, multipleModelProviderSupport.toString(), modelProviders); + } + + /** + * Updates the details of a specific AI Service Provider by its ID. + * + * @param aiServiceProviderId The unique identifier of the AI service provider. + * @param name The new name of the AI service provider. + * @param apiVersion The API version of the AI service provider. + * @param description A brief description of the AI service provider. + * @param multipleModelProviderSupport Whether the provider supports multiple model providers. + * @param configurations Configuration details for the AI service provider. + * @param apiDefinition The API definition file for the AI service provider. + * @param modelProviders The list of model providers for the AI service provider. + * @return ApiResponse containing AIServiceProviderResponseDTO with the updated details of the AI service provider. + * @throws ApiException if there is an error during the API call. + */ + public ApiResponse updateAIServiceProvider(String aiServiceProviderId, String name, String apiVersion, + String description, Boolean multipleModelProviderSupport, String configurations, File apiDefinition, String modelProviders) throws ApiException { + return aiServiceProviderApi.updateAIServiceProviderWithHttpInfo(aiServiceProviderId, name, apiVersion, + configurations, apiDefinition, description, multipleModelProviderSupport.toString(), modelProviders); + } + + /** + * Deletes a specific AI Service Provider by its ID. + * + * @param aiServiceProviderId The unique identifier of the AI service provider to be deleted. + * @return ApiResponse containing void, indicating successful deletion of the AI service provider. + * @throws ApiException if there is an error during the API call. + */ + public ApiResponse deleteAIServiceProvider(String aiServiceProviderId) throws ApiException { + return aiServiceProviderApi.deleteAIServiceProviderWithHttpInfo(aiServiceProviderId); + } + /*** * This method is used to put an system scopes mapping. * diff --git a/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java b/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java index 1944cebee7..e7e152bb58 100644 --- a/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java +++ b/all-in-one-apim/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java @@ -31,9 +31,11 @@ import org.wso2.am.integration.clients.publisher.api.ApiClient; import org.wso2.am.integration.clients.publisher.api.ApiException; import org.wso2.am.integration.clients.publisher.api.ApiResponse; +import org.wso2.am.integration.clients.publisher.api.v1.AiServiceProviderApi; import org.wso2.am.integration.clients.publisher.api.v1.ApIsApi; import org.wso2.am.integration.clients.publisher.api.v1.ApiAuditApi; import org.wso2.am.integration.clients.publisher.api.v1.ApiDocumentsApi; +import org.wso2.am.integration.clients.publisher.api.v1.ApiEndpointsApi; import org.wso2.am.integration.clients.publisher.api.v1.ApiLifecycleApi; import org.wso2.am.integration.clients.publisher.api.v1.ApiOperationPoliciesApi; import org.wso2.am.integration.clients.publisher.api.v1.ApiProductLifecycleApi; @@ -60,6 +62,8 @@ import org.wso2.am.integration.clients.publisher.api.v1.ValidationApi; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIBusinessInformationDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.APICorsConfigurationDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIEndpointDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIEndpointListDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIKeyDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIListDTO; @@ -91,6 +95,7 @@ import org.wso2.am.integration.clients.publisher.api.v1.dto.LifecycleHistoryDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.LifecycleStateDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.MockResponsePayloadListDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.ModelProviderDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.OpenAPIDefinitionValidationResponseDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.OperationPolicyDataDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.OperationPolicyDataListDTO; @@ -166,7 +171,8 @@ public class RestAPIPublisherImpl { private ApiOperationPoliciesApi apisOperationPoliciesApi = new ApiOperationPoliciesApi(); private OperationPoliciesApi operationPoliciesApi = new OperationPoliciesApi(); private GatewayPoliciesApi gatewayPoliciesApi = new GatewayPoliciesApi(); - + private ApiEndpointsApi apiEndpointsApi = new ApiEndpointsApi(); + private AiServiceProviderApi aiServiceProviderApi = new AiServiceProviderApi(); private ImportExportApi importExportApi = new ImportExportApi(); private LinterCustomRulesApi linterCustomRulesApi = new LinterCustomRulesApi(); @@ -193,7 +199,8 @@ public RestAPIPublisherImpl(String username, String password, String tenantDomai "apim:ep_certificates_add apim:ep_certificates_update apim:publisher_settings " + "apim:pub_alert_manage apim:shared_scope_manage apim:api_generate_key apim:comment_view " + "apim:comment_write apim:common_operation_policy_view apim:common_operation_policy_manage " + - "apim:policies_import_export apim:gateway_policy_view apim:gateway_policy_manage apim:subscription_manage", + "apim:policies_import_export apim:gateway_policy_view apim:gateway_policy_manage " + + "apim:subscription_manage apim:llm_provider_read", appName, callBackURL, tokenScope, appOwner, grantType, dcrURL, username, password, tenantDomain, tokenURL); apiPublisherClient.addDefaultHeader("Authorization", "Bearer " + accessToken); @@ -229,6 +236,8 @@ public RestAPIPublisherImpl(String username, String password, String tenantDomai importExportApi.setApiClient(apiPublisherClient); linterCustomRulesApi.setApiClient(apiPublisherClient); gatewayPoliciesApi.setApiClient(apiPublisherClient); + apiEndpointsApi.setApiClient(apiPublisherClient); + aiServiceProviderApi.setApiClient(apiPublisherClient); this.tenantDomain = tenantDomain; this.restAPIGateway = new RestAPIGatewayImpl(this.username, this.password, tenantDomain); } @@ -1817,8 +1826,6 @@ private void waitForDeployAPI(String apiUUID, String revisionUUID, String apiTyp if (context.startsWith("/{version}")) { Assert.assertEquals(apiInfo.getContext(), context.replace("{version}", version)); } else { - log.info("AAAAAAAAAA********************************************AAAAAAAAAA"); - log.info("context: " + context + " version: " + version); Assert.assertEquals(apiInfo.getContext(), context.concat("/").concat(version)); } Assert.assertEquals(apiInfo.getName(), name); @@ -2830,4 +2837,146 @@ public SettingsDTO getSettings() throws ApiException { public void changeSubscriptionBusinessPlan(String subscriptionId, String businessPlan, String ifMatch) throws ApiException { subscriptionsApi.changeSubscriptionBusinessPlan(subscriptionId, businessPlan, ifMatch); } + + /** + * This method is used to add an API Endpoint. + * + * @param apiId API UUID + * @param name API endpoint name + * @param deploymentStage Deployment stage: Production or Sandbox + * @param endpointConfig Endpoint configuration object + * @return HttpResponse + * @throws ApiException throws if an error occurred when creating the API Endpoint + */ + public HttpResponse addApiEndpoint(String apiId, String name, String deploymentStage, Object endpointConfig) + throws ApiException { + + APIEndpointDTO apiEndpointDTO = new APIEndpointDTO(); + apiEndpointDTO.setName(name); + apiEndpointDTO.setDeploymentStage(deploymentStage); + apiEndpointDTO.setEndpointConfig(endpointConfig); + Gson gson = new Gson(); + try { + ApiResponse addedApiEndpoint = apiEndpointsApi.addApiEndpointWithHttpInfo(apiId, + apiEndpointDTO); + apiEndpointDTO = addedApiEndpoint.getData(); + } catch (ApiException e) { + throw new ApiException(e); + } + HttpResponse response = null; + if (apiEndpointDTO != null && StringUtils.isNotEmpty(apiEndpointDTO.getId())) { + response = new HttpResponse(gson.toJson(apiEndpointDTO), HttpStatus.SC_CREATED); + } + return response; + } + /** + * Update an API endpoint with name and deployment stage + * + * @param apiId API ID + * @param endpointId API endpoint ID + * @param name Endpoint name + * @param deploymentStage Deployment stage + * @param endpointConfig API endpoint configuration + * @return HttpResponse + * @throws ApiException throws if an error occurred when updating the API endpoint + */ + public HttpResponse updateApiEndpoint(String apiId, String endpointId, String name, String deploymentStage, Object endpointConfig) throws ApiException { + APIEndpointDTO apiEndpointDTO = new APIEndpointDTO(); + apiEndpointDTO.setName(name); + apiEndpointDTO.setDeploymentStage(deploymentStage); + apiEndpointDTO.setEndpointConfig(endpointConfig); + Gson gson = new Gson(); + try { + ApiResponse updatedApiEndpoint = apiEndpointsApi.updateApiEndpointWithHttpInfo(apiId, endpointId, apiEndpointDTO); + apiEndpointDTO = updatedApiEndpoint.getData(); + } catch (ApiException e) { + throw new ApiException(e); + } + HttpResponse response = null; + if (apiEndpointDTO != null && StringUtils.isNotEmpty(apiEndpointDTO.getId())) { + response = new HttpResponse(gson.toJson(apiEndpointDTO), HttpStatus.SC_OK); + } + return response; + } + + /** + * Delete an API endpoint + * + * @param apiId API ID + * @param endpointId API endpoint ID + * @return HttpResponse + * @throws ApiException throws if an error occurred when deleting the API endpoint + */ + public HttpResponse deleteApiEndpoint(String apiId, String endpointId) throws ApiException { + try { + apiEndpointsApi.deleteApiEndpointWithHttpInfo(apiId, endpointId); + } catch (ApiException e) { + throw new ApiException(e); + } + return new HttpResponse("API endpoint deleted successfully", HttpStatus.SC_OK); + } + + /** + * Get API endpoints for a given API UUID. + * + * @param apiId API UUID + * @return HttpResponse + * @throws ApiException throws if an error occurred when retrieving the API endpoints + */ + public HttpResponse getApiEndpoints(String apiId) { + APIEndpointListDTO apiEndpointListDTO; + HttpResponse response = null; + Gson gson = new Gson(); + try { + ApiResponse apiResponse = apiEndpointsApi.getApiEndpointsWithHttpInfo(apiId, null, 0); + apiEndpointListDTO = apiResponse.getData(); + } catch (ApiException e) { + return new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + if (apiEndpointListDTO.getCount() > 0) { + response = new HttpResponse(gson.toJson(apiEndpointListDTO), HttpStatus.SC_OK); + } + return response; + } + + /** + * Get a specific API endpoint by endpoint ID. + * + * @param apiId API UUID + * @param endpointId API endpoint ID + * @return HttpResponse + * @throws ApiException throws if an error occurred when retrieving the API endpoint + */ + public HttpResponse getApiEndpoint(String apiId, String endpointId) throws ApiException { + APIEndpointDTO apiEndpointDTO; + HttpResponse response = null; + Gson gson = new Gson(); + try { + ApiResponse apiResponse = apiEndpointsApi.getApiEndpointWithHttpInfo(apiId, endpointId); + apiEndpointDTO = apiResponse.getData(); + } catch (ApiException e) { + return new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + if (apiEndpointDTO != null && StringUtils.isNotEmpty(apiEndpointDTO.getId())) { + response = new HttpResponse(gson.toJson(apiEndpointDTO), HttpStatus.SC_OK); + } + return response; + } + + /** + * Get AI Service Provider's model list + * + * @param aiServiceProviderId AI service provider ID + * @return HttpResponse + */ + public HttpResponse getAIServiceProviderModels(String aiServiceProviderId) { + Gson gson = new Gson(); + try { + ApiResponse> modelListResponse = aiServiceProviderApi.getAIServiceProviderModelsWithHttpInfo( + aiServiceProviderId); + return new HttpResponse(gson.toJson(modelListResponse.getData()), modelListResponse.getStatusCode()); + } catch (ApiException e) { + return new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + } } diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/aiapi/AIAPITestCase.java b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/aiapi/AIAPITestCase.java index 6dfc961c58..5b489a2cbc 100644 --- a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/aiapi/AIAPITestCase.java +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/aiapi/AIAPITestCase.java @@ -20,9 +20,13 @@ import com.github.tomakehurst.wiremock.WireMockServer; import com.github.tomakehurst.wiremock.client.WireMock; +import com.github.tomakehurst.wiremock.extension.responsetemplating.ResponseTemplateTransformer; +import com.google.gson.Gson; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.jetbrains.annotations.NotNull; +import org.json.JSONException; import org.json.JSONObject; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -31,10 +35,12 @@ import org.testng.annotations.Factory; import org.testng.annotations.Test; import org.wso2.am.integration.clients.admin.ApiResponse; -import org.wso2.am.integration.clients.admin.api.dto.LLMProviderResponseDTO; -import org.wso2.am.integration.clients.admin.api.dto.LLMProviderSummaryResponseDTO; -import org.wso2.am.integration.clients.admin.api.dto.LLMProviderSummaryResponseListDTO; +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderResponseDTO; +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderSummaryResponseDTO; +import org.wso2.am.integration.clients.admin.api.dto.AIServiceProviderSummaryResponseListDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIOperationPoliciesDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.OperationPolicyDTO; import org.wso2.am.integration.clients.store.api.v1.dto.APIKeyDTO; import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO; import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyGenerateRequestDTO; @@ -43,6 +49,7 @@ import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants; import org.wso2.am.integration.test.utils.bean.APIThrottlingTier; import org.wso2.am.integration.test.utils.http.HTTPSClientUtils; +import org.wso2.am.integration.test.utils.MockServerUtils; import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; import org.wso2.carbon.automation.engine.annotations.SetEnvironment; import org.wso2.carbon.automation.engine.context.TestUserMode; @@ -54,17 +61,21 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; -import java.net.Socket; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; /** * AI API Test Case @@ -74,58 +85,82 @@ public class AIAPITestCase extends APIMIntegrationBaseTest { private static final Log log = LogFactory.getLog(AIAPITestCase.class); - // Variables related to mistral AI API - private static final String mistralAPIName = "mistralAPI"; - private static final String mistralAPIVersion = "1.0.0"; - private static final String mistralAPIContext = "mistralAPI"; - private static final String mistralAPIEndpoint = "/mistral"; - private static final String mistralAPIResource = "/v1/chat/completions"; - private String mistralAPIId; - private String mistralResponse; - - // Application and API related common details - private static final String apiProvider = "admin"; - private static final String applicationName = "AI-API-Application"; + // API Configuration Constants + private static final String MISTRAL_API_NAME = "mistralAPI"; + private static final String UNSECURED_API_NAME = "mistralNoAuthAPI"; + private static final String API_VERSION_1_0_0 = "1.0.0"; + private static final String API_VERSION_2_0_0 = "2.0.0"; + private static final String MISTRAL_API_CONTEXT = "mistralAPI"; + private static final String UNSECURED_API_CONTEXT = "mistralNoAuthAPI"; + private static final String MISTRAL_API_ENDPOINT = "/mistral"; + private static final String MISTRAL_API_ENDPOINT_UPDATED = "/mistral-updated"; + private static final String NO_AUTH_API_ENDPOINT = "/no-auth"; + private static final String MISTRAL_API_RESOURCE = "/v1/chat/completions"; + // API Instance Variables + private String mistralApiId; + private String unsecuredApiId; + private String mistralPayload; + private String model1Response; + private String model2Response; + private String model3Response; + + // Application Configuration Constants + private static final String API_PROVIDER = "admin"; + private static final String APPLICATION_NAME = "AI-API-Application"; + + // Application Instance Variables private String applicationId; + private String apiKey; - // Other variables + // WireMock Configuration + private static final String ENDPOINT_HOST = "http://localhost"; + + // WireMock Instance Variables private String resourcePath; private WireMockServer wireMockServer; private int endpointPort; - private String endpointHost = "http://localhost"; - private int lowerPortLimit = 9950; - private int upperPortLimit = 9999; - - private String llmProviderId; - private final String llmProviderName = "TestAIService"; - private final String llmProviderApiVersion = "1.0.0"; - - private final String llmProviderDescription = "This is a copy of MistralAI service"; - private final String modelList = "[\"model-1\", \"model-2\"]"; - - private final String incorrectLlmProviderConfigurations = "{\"connectorType\":\"mistralAi_1.0.0\"," + - "\"metadata\":[{\"attributeName\":\"model\"," + - "\"inputSource\":\"payload\",\"attributeIdentifier\":\"$.usage.model\"}," + - "{\"attributeName\":\"promptTokenCount\",\"inputSource\":\"payload\",\"attributeIdentifier\":\"$" + - ".usage.prompt_tokens\"},{\"attributeName\":\"completionTokenCount\",\"inputSource\":\"payload\"," + - "\"attributeIdentifier\":\"$.usage.completion_tokens\"},{\"attributeName\":\"totalTokenCount\"," + - "\"inputSource\":\"payload\",\"attributeIdentifier\":\"$.usage.total_tokens\"}]," + - "\"authHeader\":\"Authorization\"}"; - - private final String correctLlmProviderConfigurations = "{\"connectorType\":\"mistralAi_1.0.0\"," + - "\"metadata\":[{\"attributeName\":\"model\"," + - "\"inputSource\":\"payload\",\"attributeIdentifier\":\"$.usage.model\"}," + - "{\"attributeName\":\"promptTokenCount\",\"inputSource\":\"payload\",\"attributeIdentifier\":\"$" + - ".usage.prompt_tokens\"},{\"attributeName\":\"completionTokenCount\",\"inputSource\":\"payload\"," + - "\"attributeIdentifier\":\"$.usage.completion_tokens\"},{\"attributeName\":\"totalTokenCount\"," + - "\"inputSource\":\"payload\",\"attributeIdentifier\":\"$.usage.total_tokens\"}]," + - "\"authHeader\":\"Authorization\"}"; - - private List defaultLlmProviders = new ArrayList<>(); - - private final String apiDefinitionFileName = "mistral-def.json"; - - private final String mistralResponseFileName = "mistral-response.json"; + + // AI Service Provider Configuration Constants + private static final String AI_SERVICE_PROVIDER_NAME = "TestAIService"; + private static final String AI_SERVICE_PROVIDER_API_VERSION = "1.0.0"; + private static final String AI_SERVICE_PROVIDER_DESCRIPTION = "This is a copy of MistralAI service"; + private static final String MODEL_SMALL = "mistral-small-latest"; + private static final String MODEL_MEDIUM = "mistral-medium-latest"; + private static final String MODEL_LARGE = "mistral-large-latest"; + + // AI Service Provider Instance Variables + private String aiServiceProviderId; + private String modelProviders; + // Endpoint Configuration Constants + private static final String PRODUCTION_ENDPOINT_NAME = "Prod Endpoint"; + private static final String SANDBOX_ENDPOINT_NAME = "Sandbox Endpoint"; + private static final String PRODUCTION_DEPLOYMENT_STAGE = "PRODUCTION"; + private static final String SANDBOX_DEPLOYMENT_STAGE = "SANDBOX"; + private static final String DEFAULT_PRODUCTION_ENDPOINT_ID = "default_production_endpoint"; + private static final String DEFAULT_PRODUCTION_ENDPOINT_NAME = "Default Production Endpoint"; + private static final String FAILOVER_ENDPOINT_URL = "/failover-endpoint"; + private static final String FAILOVER_ENDPOINT_NAME = "Failover Endpoint"; + // Endpoint Instance Variables + private String productionEndpointId; + private String sandboxEndpointId; + private String newVersionApiId; + private final List endpointsList = new ArrayList<>(); + private Map policyMap; + + // AI Service Provider Configuration Variables (loaded from JSON files) + private String customAiServiceProviderConfigurations; + private String updatedCustomAiServiceProviderConfigurations; + + // File Configuration Constants + private static final String API_DEFINITION_FILE_NAME = "mistral-def.json"; + private static final String MISTRAL_RESPONSE_FILE_NAME = "mistral-response.json"; + private static final String MISTRAL_PAYLOAD_FILE_NAME = "mistral-payload.json"; + private static final String AI_SERVICE_PROVIDER_CONFIG_NO_AUTH_FILE = "ai-service-provider-config-no-auth.json"; + private static final String AI_SERVICE_PROVIDER_CONFIG_WITH_AUTH_FILE = "ai-service-provider-config-with-auth.json"; + private static final String ENDPOINT_CONFIG_TEMPLATE_FILE = "endpoint-config-template.json"; + + // Default AI Service Providers + private final List defaultAiServiceProviders = new ArrayList<>(); @Factory(dataProvider = "userModeDataProvider") public AIAPITestCase(TestUserMode userMode) { @@ -143,276 +178,967 @@ public static Object[][] userModeDataProvider() { @BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { - super.init(userMode); - defaultLlmProviders.add("MistralAI"); - defaultLlmProviders.add("OpenAI"); - defaultLlmProviders.add("AzureOpenAI"); - - // Add application - ApplicationDTO applicationDTO = restAPIStore.addApplication(applicationName, - APIThrottlingTier.UNLIMITED.getState(), "", "this-is-test"); - applicationId = applicationDTO.getApplicationId(); - Assert.assertNotNull(applicationId); - - resourcePath = TestConfigurationProvider.getResourceLocation() + "ai-api" + File.separator; - mistralResponse = readFile(resourcePath + mistralResponseFileName); - - // Start WireMock server + initializeDefaultAiServiceProviders(); + initializeModelConfigurations(); + policyMap = restAPIPublisher.getAllCommonOperationPolicies(); + applicationId = createTestApplication(); + initializeTestData(); startWiremockServer(); } /** - * Tests the retrieval of predefined LLM providers and verifies all are present. - * Ensures that all predefined LLM providers are retrieved successfully. + * Tests the retrieval of predefined AI service providers and validates against expected providers. + * Verifies that all expected built-in AI service providers are present and have correct properties. */ - @Test(groups = {"wso2.am"}, description = "Test retrieve LLM Providers") - public void testPredefinedLLMProviders() throws Exception { - - List copyDefaultLlmProviders = new ArrayList<>(defaultLlmProviders); - ApiResponse llmProviders = restAPIAdmin.getLLMProviders(); - assertEquals(Response.Status.OK.getStatusCode(), - llmProviders.getStatusCode(), "Failed to retrieve LLM providers"); - for (LLMProviderSummaryResponseDTO provider : llmProviders.getData().getList()) { - if (defaultLlmProviders.contains(provider.getName())) { - copyDefaultLlmProviders.remove(provider.getName()); + @Test(groups = {"wso2.am"}, description = "Test retrieve AI Service Providers") + public void testPredefinedAiServiceProviders() throws Exception { + ApiResponse aiServiceProviders = restAPIAdmin.getAIServiceProviders(); + assertEquals(Response.Status.OK.getStatusCode(), aiServiceProviders.getStatusCode(), + "Failed to retrieve AI service providers"); + + List providerList = aiServiceProviders.getData().getList(); + assertNotNull(providerList, "AI service providers list should not be null"); + assertTrue(providerList.size() >= defaultAiServiceProviders.size(), + "Expected at least " + defaultAiServiceProviders.size() + " providers, but found: " + providerList.size()); + + // Create a map of retrieved providers for easier lookup + Map retrievedProviders = new HashMap<>(); + for (AIServiceProviderSummaryResponseDTO provider : providerList) { + retrievedProviders.put(provider.getName(), provider); + } + + // Validate each expected provider is present and has correct properties + List missingProviders = new ArrayList<>(); + for (String expectedProvider : defaultAiServiceProviders) { + AIServiceProviderSummaryResponseDTO provider = retrievedProviders.get(expectedProvider); + if (provider == null) { + missingProviders.add(expectedProvider); + } else { + // Validate provider properties + assertNotNull(provider.getId(), "Provider ID should not be null for: " + expectedProvider); + assertEquals(expectedProvider, provider.getName(), "Provider name mismatch"); + assertNotNull(provider.getApiVersion(), "API version should not be null for: " + expectedProvider); + assertTrue(provider.isBuiltInSupport(), "Provider should have built-in support: " + expectedProvider); + assertNotNull(provider.getDescription(), "Description should not be null for: " + expectedProvider); + + log.info( + "Validated AI service provider: " + expectedProvider + " (ID: " + provider.getId() + ", Version: " + provider.getApiVersion() + ")"); } } - assertEquals(0, - copyDefaultLlmProviders.size(), "Failed to retrieve all predefined LLM providers"); + + assertTrue(missingProviders.isEmpty(), "Missing expected AI service providers: " + missingProviders); + + log.info("Successfully validated " + defaultAiServiceProviders.size() + " predefined AI service providers"); } /** - * Adds a custom LLM provider and verifies successful creation. + * Adds a custom AI service provider with no auth and verifies successful creation. * Ensures the provider is created with the given details and retrieves its ID. */ - @Test(groups = {"wso2.am"}, description = "Add LLM Provider", - dependsOnMethods = "testPredefinedLLMProviders") - public void addCustomLLMProvider() throws Exception { - - String originalDefinition = readFile(resourcePath + apiDefinitionFileName); + @Test(groups = {"wso2.am"}, description = "Add AI Service Provider") + public void addCustomAiServiceProviderWithNoAuth() throws Exception { + String originalDefinition = readFile(resourcePath + API_DEFINITION_FILE_NAME); File file = getTempFileWithContent(originalDefinition); - ApiResponse createProviderResponse = restAPIAdmin.addLLMProvider(llmProviderName, - llmProviderApiVersion, llmProviderDescription, incorrectLlmProviderConfigurations, file, modelList); + ApiResponse createProviderResponse = restAPIAdmin.addAIServiceProvider( + AI_SERVICE_PROVIDER_NAME, AI_SERVICE_PROVIDER_API_VERSION, AI_SERVICE_PROVIDER_DESCRIPTION, false, + customAiServiceProviderConfigurations, file, modelProviders); - assertEquals(Response.Status.CREATED.getStatusCode(), - createProviderResponse.getStatusCode(), "Failed to add a LLM provider"); - llmProviderId = createProviderResponse.getData().getId(); + assertEquals(createProviderResponse.getStatusCode(), Response.Status.CREATED.getStatusCode(), + "Failed to add an AI service provider"); + aiServiceProviderId = createProviderResponse.getData().getId(); + assertNotNull(aiServiceProviderId, "AI Service Provider ID should not be null"); } /** - * Retrieves a specified LLM provider and verifies the provider's details. + * Retrieves a specified AI service provider and verifies the provider's details. * Ensures the provider is retrieved successfully and the name and API version match. */ - @Test(groups = {"wso2.am"}, description = "Get LLM Provider", - dependsOnMethods = "addCustomLLMProvider") - public void retrieveCustomLLMProvider() throws Exception { - - ApiResponse getProviderResponse = restAPIAdmin.getLLMProvider(llmProviderId); - assertEquals(Response.Status.OK.getStatusCode(), - getProviderResponse.getStatusCode(), "Failed to retrieve LLM provider"); - assertEquals(getProviderResponse.getData().getName(), llmProviderName, "LLM provider name does not " + - "match"); - assertEquals(getProviderResponse.getData().getApiVersion(), - llmProviderApiVersion, "LLM provider API version does not match"); + @Test(groups = {"wso2.am"}, description = "Get AI Service Provider", + dependsOnMethods = "addCustomAiServiceProviderWithNoAuth") + public void retrieveCustomAiServiceProvider() throws Exception { + ApiResponse getProviderResponse = restAPIAdmin.getAIServiceProvider( + aiServiceProviderId); + assertEquals(getProviderResponse.getStatusCode(), Response.Status.OK.getStatusCode(), + "Failed to retrieve AI service provider"); + assertEquals(getProviderResponse.getData().getName(), AI_SERVICE_PROVIDER_NAME, + "AI service provider name does not match"); + assertEquals(getProviderResponse.getData().getApiVersion(), AI_SERVICE_PROVIDER_API_VERSION, + "AI service provider API version does not match"); } /** - * Updates a specified LLM provider with new configurations and verifies the update. - * Ensures the updated provider is retrieved successfully and the configurations are correct. + * Test AI API with unsecured AI service provider. Verify creation, deployment, and publishing */ - @Test(groups = {"wso2.am"}, description = "Update LLM Provider", - dependsOnMethods = "addCustomLLMProvider") - public void updateCustomLLMProvider() throws Exception { + @Test(groups = {"wso2.am"}, description = "Test Unsecured AI API creation, deployment and publishing", + dependsOnMethods = "addCustomAiServiceProviderWithNoAuth") + public void testUnsecuredAiApiCreationAndPublish() throws Exception { + unsecuredApiId = createAndPublishAiApi(NO_AUTH_API_ENDPOINT, "mistral-no-auth-add-props.json"); + } + + /** + * Test Unsecured AI API invocation + */ + @Test(groups = {"wso2.am"}, description = "Test AI API invocation", + dependsOnMethods = "testUnsecuredAiApiCreationAndPublish") + public void testUnsecuredAiApiInvocation() throws Exception { + apiKey = subscribeToApiAndGenerateKey(unsecuredApiId); - String originalDefinition = readFile(resourcePath + apiDefinitionFileName); + // Invoke API + Map requestHeaders = new HashMap<>(); + requestHeaders.put("ApiKey", apiKey); + requestHeaders.put("Content-Type", "application/json"); + String invokeURL = getAPIInvocationURLHttp(UNSECURED_API_CONTEXT, API_VERSION_1_0_0) + MISTRAL_API_RESOURCE; + HttpResponse serviceResponse = HTTPSClientUtils.doPost(invokeURL, requestHeaders, mistralPayload); + + assertEquals(serviceResponse.getResponseCode(), HttpStatus.SC_OK, "Unsecured AI API invocation failed"); + assertEquals(serviceResponse.getData(), model1Response, "Unsecured AI API response mismatch"); + } + + /** + * Updates the created AI service provider with apikey auth configurations and verifies the update. + * Ensures the updated provider is retrieved successfully and the configurations are correct. + */ + @Test(groups = {"wso2.am"}, description = "Update AI Service Provider", + dependsOnMethods = "testUnsecuredAiApiInvocation") + public void updateCustomAiServiceProvider() throws Exception { + String originalDefinition = readFile(resourcePath + API_DEFINITION_FILE_NAME); File file = getTempFileWithContent(originalDefinition); - ApiResponse updateProviderResponse = restAPIAdmin.updateLLMProvider(llmProviderId, - llmProviderName, llmProviderApiVersion, llmProviderDescription, - correctLlmProviderConfigurations, file, modelList); + ApiResponse updateProviderResponse = restAPIAdmin.updateAIServiceProvider( + aiServiceProviderId, AI_SERVICE_PROVIDER_NAME, AI_SERVICE_PROVIDER_API_VERSION, + AI_SERVICE_PROVIDER_DESCRIPTION, false, updatedCustomAiServiceProviderConfigurations, file, + modelProviders); - assertEquals(Response.Status.OK.getStatusCode(), - updateProviderResponse.getStatusCode(), "Failed to update LLM provider"); + assertEquals(updateProviderResponse.getStatusCode(), Response.Status.OK.getStatusCode(), + "Failed to update AI service provider"); - ApiResponse getProviderResponse = restAPIAdmin.getLLMProvider(llmProviderId); - assertEquals(Response.Status.OK.getStatusCode(), - getProviderResponse.getStatusCode(), "Failed to retrieve LLM provider"); - assertEquals(getProviderResponse.getData().getConfigurations(), - correctLlmProviderConfigurations, "Failed to update LLM provider configurations"); + ApiResponse getProviderResponse = restAPIAdmin.getAIServiceProvider( + aiServiceProviderId); + assertEquals(getProviderResponse.getStatusCode(), Response.Status.OK.getStatusCode(), + "Failed to retrieve AI service provider"); + assertEquals(getProviderResponse.getData().getConfigurations(), updatedCustomAiServiceProviderConfigurations, + "Failed to update AI service provider configurations"); } /** - * Test Mistral AI API creation, deployment, and publishing + * Test AI API creation, deployment, and publishing */ @Test(groups = {"wso2.am"}, description = "Test Mistral AI API creation, deployment and publishing", - dependsOnMethods = "updateCustomLLMProvider") - public void testMistralAIAPICreationAndPublish() throws Exception { + dependsOnMethods = "updateCustomAiServiceProvider") + public void testSecuredAiApiCreationAndPublish() throws Exception { + mistralApiId = createAndPublishAiApi(MISTRAL_API_ENDPOINT, "mistral-add-props.json"); + } - String originalDefinition = readFile(resourcePath + apiDefinitionFileName); - String additionalProperties = readFile(resourcePath + "mistral-add-props.json"); - JSONObject additionalPropertiesObj = new JSONObject(additionalProperties); + /** + * Test Mistral AI API invocation + */ + @Test(groups = {"wso2.am"}, description = "Test AI API invocation", + dependsOnMethods = "testSecuredAiApiCreationAndPublish") + public void testSecuredAiApiInvocation() throws Exception { + // Note: Use existing API key from previous test to avoid regeneration + if (apiKey == null) { + apiKey = subscribeToApiAndGenerateKey(mistralApiId); + } else { + // Just subscribe the existing application + SubscriptionDTO subscriptionDTO = restAPIStore.subscribeToAPI(mistralApiId, applicationId, + APIMIntegrationConstants.API_TIER.UNLIMITED); + assertNotNull(subscriptionDTO, "AI API subscription failed"); + } - // Update production endpoint - JSONObject endpointConfig = additionalPropertiesObj.getJSONObject("endpointConfig"); + // Invoke API + Map requestHeaders = new HashMap<>(); + requestHeaders.put("ApiKey", apiKey); + requestHeaders.put("Content-Type", "application/json"); + String invokeURL = getAPIInvocationURLHttp(MISTRAL_API_CONTEXT, API_VERSION_1_0_0) + MISTRAL_API_RESOURCE; + HttpResponse serviceResponse = HTTPSClientUtils.doPost(invokeURL, requestHeaders, mistralPayload); + + assertEquals(serviceResponse.getResponseCode(), HttpStatus.SC_OK, "AI API invocation failed"); + assertEquals(serviceResponse.getData(), model1Response, "AI API response mismatch"); + } + + /** + * Test endpoint addition to Mistral AI API - handles multiple endpoints (production and sandbox) + */ + @Test(groups = {"wso2.am"}, description = "Test multiple endpoint addition to AI API", + dependsOnMethods = "testSecuredAiApiInvocation") + public void testAddAiApiEndpoint() throws Exception { + // Add production endpoint + String endpointConfig = readFile(resourcePath + ENDPOINT_CONFIG_TEMPLATE_FILE); + JSONObject prodEndpointConfigObj = new JSONObject(endpointConfig); JSONObject productionEndpoints = new JSONObject(); - productionEndpoints.put("url", endpointHost + ":" + endpointPort + mistralAPIEndpoint); - endpointConfig.put("production_endpoints", productionEndpoints); - additionalPropertiesObj.put("endpointConfig", endpointConfig); + productionEndpoints.put("url", ENDPOINT_HOST + ":" + endpointPort + MISTRAL_API_ENDPOINT); + prodEndpointConfigObj.put("production_endpoints", productionEndpoints); + + // Remove sandbox section from endpoint_security for production endpoint + JSONObject endpointSecurity = prodEndpointConfigObj.getJSONObject("endpoint_security"); + endpointSecurity.remove("sandbox"); + prodEndpointConfigObj.put("endpoint_security", endpointSecurity); + + Map prodEndpointConfigMap = new Gson().fromJson(prodEndpointConfigObj.toString(), Map.class); + HttpResponse addProdEndpointResponse = restAPIPublisher.addApiEndpoint(mistralApiId, PRODUCTION_ENDPOINT_NAME, + PRODUCTION_DEPLOYMENT_STAGE, prodEndpointConfigMap); + assertEquals(addProdEndpointResponse.getResponseCode(), HttpStatus.SC_CREATED, + "Failed to add production endpoint to API: " + mistralApiId); + + // Extract endpoint ID from response for later use + JSONObject prodEndpointResponse = new JSONObject(addProdEndpointResponse.getData()); + productionEndpointId = prodEndpointResponse.getString("id"); + assertNotNull(productionEndpointId, "Production endpoint ID should not be null"); + + // Add sandbox endpoint using the same template + JSONObject sandboxEndpointConfigObj = new JSONObject(endpointConfig); + JSONObject sandboxEndpoints = new JSONObject(); + sandboxEndpoints.put("url", ENDPOINT_HOST + ":" + endpointPort + MISTRAL_API_ENDPOINT + "/sandbox"); + sandboxEndpointConfigObj.put("sandbox_endpoints", sandboxEndpoints); + + // Remove production section from endpoint_security for sandbox endpoint + JSONObject sandboxEndpointSecurity = sandboxEndpointConfigObj.getJSONObject("endpoint_security"); + sandboxEndpointSecurity.remove("production"); + sandboxEndpointConfigObj.put("endpoint_security", sandboxEndpointSecurity); + + Map sandboxEndpointConfigMap = new Gson().fromJson(sandboxEndpointConfigObj.toString(), + Map.class); + HttpResponse addSandboxEndpointResponse = restAPIPublisher.addApiEndpoint(mistralApiId, SANDBOX_ENDPOINT_NAME, + SANDBOX_DEPLOYMENT_STAGE, sandboxEndpointConfigMap); + assertEquals(addSandboxEndpointResponse.getResponseCode(), HttpStatus.SC_CREATED, + "Failed to add sandbox endpoint to API: " + mistralApiId); + + // Extract endpoint ID from response for later use + JSONObject sandboxEndpointResponse = new JSONObject(addSandboxEndpointResponse.getData()); + sandboxEndpointId = sandboxEndpointResponse.getString("id"); + assertNotNull(sandboxEndpointId, "Sandbox endpoint ID should not be null"); + } - // Create API - File file = getTempFileWithContent(originalDefinition); - APIDTO apidto = restAPIPublisher.importOASDefinition(file, additionalPropertiesObj.toString()); - mistralAPIId = apidto.getId(); + /** + * Test retrieving all endpoints for an API + */ + @Test(groups = {"wso2.am"}, description = "Test retrieving all API endpoints", + dependsOnMethods = "testAddAiApiEndpoint") + public void testGetApiEndpoints() throws Exception { + HttpResponse getEndpointsResponse = restAPIPublisher.getApiEndpoints(mistralApiId); + assertEquals(getEndpointsResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve endpoints for API: " + mistralApiId); + + // Parse response to verify endpoints exist + JSONObject endpointsResponse = new JSONObject(getEndpointsResponse.getData()); + assertTrue(endpointsResponse.has("list"), "Response should contain 'list' field"); + + // Update the endpoints list with the current API response + ArrayList retrievedEndpointsList = new ArrayList<>(); + for (int i = 0; i < endpointsResponse.getJSONArray("list").length(); i++) { + retrievedEndpointsList.add(endpointsResponse.getJSONArray("list").getJSONObject(i)); + } + + // Verify that we have at least 2 endpoints (production and sandbox) + int endpointCount = retrievedEndpointsList.size(); + assertTrue(endpointCount >= 2, "Should have 2 endpoints, but found: " + endpointCount); + + // Verify that our created endpoints are in the list + boolean foundProductionEndpoint = false; + boolean foundSandboxEndpoint = false; + + for (JSONObject endpoint : retrievedEndpointsList) { + String endpointId = endpoint.getString("id"); + String endpointName = endpoint.getString("name"); + + if (productionEndpointId.equals(endpointId) && PRODUCTION_ENDPOINT_NAME.equals(endpointName)) { + foundProductionEndpoint = true; + } + if (sandboxEndpointId.equals(endpointId) && SANDBOX_ENDPOINT_NAME.equals(endpointName)) { + foundSandboxEndpoint = true; + } + } + + assertTrue(foundProductionEndpoint, "Production endpoint not found in the list"); + assertTrue(foundSandboxEndpoint, "Sandbox endpoint not found in the list"); + } - HttpResponse createdApiResponse = restAPIPublisher.getAPI(mistralAPIId); - assertEquals(Response.Status.OK.getStatusCode(), - createdApiResponse.getResponseCode(), mistralAPIId + " AI API creation failed"); + /** + * Test retrieving a specific endpoint by ID + */ + @Test(groups = {"wso2.am"}, description = "Test retrieving a specific API endpoint", + dependsOnMethods = "testAddAiApiEndpoint") + public void testGetApiEndpoint() throws Exception { + // Test retrieving production endpoint + HttpResponse getProdEndpointResponse = restAPIPublisher.getApiEndpoint(mistralApiId, productionEndpointId); + assertEquals(getProdEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve production endpoint for API: " + mistralApiId); + + // Parse and verify production endpoint details + JSONObject prodEndpoint = new JSONObject(getProdEndpointResponse.getData()); + assertEquals(prodEndpoint.getString("id"), productionEndpointId, + "Retrieved endpoint ID does not match expected production endpoint ID"); + assertEquals(prodEndpoint.getString("name"), PRODUCTION_ENDPOINT_NAME, + "Retrieved endpoint name does not match expected production endpoint name"); + assertEquals(prodEndpoint.getString("deploymentStage"), PRODUCTION_DEPLOYMENT_STAGE, + "Retrieved endpoint deployment stage does not match expected production stage"); + + // Test retrieving sandbox endpoint + HttpResponse getSandboxEndpointResponse = restAPIPublisher.getApiEndpoint(mistralApiId, sandboxEndpointId); + assertEquals(getSandboxEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve sandbox endpoint for API: " + mistralApiId); + + // Parse and verify sandbox endpoint details + JSONObject sandboxEndpoint = new JSONObject(getSandboxEndpointResponse.getData()); + assertEquals(sandboxEndpoint.getString("id"), sandboxEndpointId, + "Retrieved endpoint ID does not match expected sandbox endpoint ID"); + assertEquals(sandboxEndpoint.getString("name"), SANDBOX_ENDPOINT_NAME, + "Retrieved endpoint name does not match expected sandbox endpoint name"); + assertEquals(sandboxEndpoint.getString("deploymentStage"), SANDBOX_DEPLOYMENT_STAGE, + "Retrieved endpoint deployment stage does not match expected sandbox stage"); + } - // Deploy API - String revisionUUID = createAPIRevisionAndDeployUsingRest(mistralAPIId, restAPIPublisher); - Assert.assertNotNull(revisionUUID); + /** + * Test updating an existing endpoint + */ + @Test(groups = {"wso2.am"}, description = "Test updating an API endpoint", + dependsOnMethods = "testGetApiEndpoint") + public void testUpdateApiEndpoint() throws Exception { + // Create updated endpoint configuration for production endpoint + String baseEndpointConfig = readFile(resourcePath + ENDPOINT_CONFIG_TEMPLATE_FILE); + JSONObject updatedProdEndpointConfigObj = updateBaseEndpointConfig(baseEndpointConfig); + + // Convert JSONObject to Map to avoid "map" wrapper in serialization + Map updatedProdEndpointConfigMap = new Gson().fromJson(updatedProdEndpointConfigObj.toString(), Map.class); + // Update the production endpoint + HttpResponse updateProdEndpointResponse = restAPIPublisher.updateApiEndpoint(mistralApiId, + productionEndpointId, PRODUCTION_ENDPOINT_NAME, PRODUCTION_DEPLOYMENT_STAGE, updatedProdEndpointConfigMap); + assertEquals(updateProdEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to update production endpoint for API: " + mistralApiId); + + // Verify the update by retrieving the endpoint + HttpResponse getUpdatedProdEndpointResponse = restAPIPublisher.getApiEndpoint(mistralApiId, productionEndpointId); + assertEquals(getUpdatedProdEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve updated production endpoint"); + + JSONObject updatedProdEndpoint = new JSONObject(getUpdatedProdEndpointResponse.getData()); + JSONObject endpointConfig = new JSONObject(updatedProdEndpoint.getString("endpointConfig")); + JSONObject prodEndpoints = endpointConfig.getJSONObject("production_endpoints"); + String updatedUrl = prodEndpoints.getString("url"); + assertTrue(updatedUrl.contains(MISTRAL_API_ENDPOINT_UPDATED), + "Updated endpoint URL should contain '/mistral-updated' but was: " + updatedUrl); + } - // Publish API - HttpResponse lifecycleResponse = restAPIPublisher - .changeAPILifeCycleStatusToPublish(mistralAPIId, false); - assertEquals(lifecycleResponse.getResponseCode(), HttpStatus.SC_OK); + @NotNull + private JSONObject updateBaseEndpointConfig(String updatedProdEndpointConfig) throws JSONException { + JSONObject updatedProdEndpointConfigObj = new JSONObject(updatedProdEndpointConfig); + JSONObject updatedProductionEndpoints = new JSONObject(); + // Update the URL to a different endpoint + updatedProductionEndpoints.put("url", ENDPOINT_HOST + ":" + endpointPort + MISTRAL_API_ENDPOINT_UPDATED); + updatedProdEndpointConfigObj.put("production_endpoints", updatedProductionEndpoints); + + // Update the endpoint security configuration + JSONObject endpointSecurity = updatedProdEndpointConfigObj.getJSONObject("endpoint_security"); + JSONObject productionSecurity = endpointSecurity.getJSONObject("production"); + productionSecurity.put("apiKeyValue", "Bearer 456"); // Change the API key value + endpointSecurity.put("production", productionSecurity); + + // Remove sandbox section from endpoint_security for production endpoint update + endpointSecurity.remove("sandbox"); + updatedProdEndpointConfigObj.put("endpoint_security", endpointSecurity); + return updatedProdEndpointConfigObj; + } - waitForAPIDeploymentSync(apidto.getProvider(), - apidto.getName(), apidto.getVersion(), APIMIntegrationConstants.IS_API_EXISTS); + /** + * Test deleting an API endpoint + */ + @Test(groups = {"wso2.am"}, description = "Test deleting an API endpoint", + dependsOnMethods = "testUpdateApiEndpoint") + public void testDeleteApiEndpoint() throws Exception { + // First verify that the sandbox endpoint exists + HttpResponse getSandboxEndpointResponse = restAPIPublisher.getApiEndpoint(mistralApiId, sandboxEndpointId); + assertEquals(getSandboxEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Sandbox endpoint should exist before deletion"); + + // Delete the sandbox endpoint + HttpResponse deleteSandboxEndpointResponse = restAPIPublisher.deleteApiEndpoint(mistralApiId, + sandboxEndpointId); + assertEquals(deleteSandboxEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to delete sandbox endpoint for API: " + mistralApiId); + + // Verify that the production endpoint still exists + HttpResponse getProdEndpointResponse = restAPIPublisher.getApiEndpoint(mistralApiId, productionEndpointId); + assertEquals(getProdEndpointResponse.getResponseCode(), HttpStatus.SC_OK, + "Production endpoint should still exist after deleting sandbox endpoint"); + + // Verify the endpoint count in the list has decreased + HttpResponse getEndpointsResponse = restAPIPublisher.getApiEndpoints(mistralApiId); + assertEquals(getEndpointsResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve endpoints list after deletion"); + + // Parse the response and verify endpoint count + JSONObject endpointsResponse = new JSONObject(getEndpointsResponse.getData()); + int endpointCount = endpointsResponse.getJSONArray("list").length(); + assertTrue(endpointCount >= 1, "Should have at least 1 endpoint remaining, but found: " + endpointCount); + + // Verify that the sandbox endpoint is not in the list anymore + boolean foundSandboxEndpoint = false; + for (int i = 0; i < endpointCount; i++) { + JSONObject endpoint = endpointsResponse.getJSONArray("list").getJSONObject(i); + String endpointId = endpoint.getString("id"); + if (sandboxEndpointId.equals(endpointId)) { + foundSandboxEndpoint = true; + break; + } + } + assertFalse(foundSandboxEndpoint, "Deleted sandbox endpoint should not be in the endpoints list"); } /** - * Test Mistral AI API invocation + * Test final retrieval of all endpoints to verify the complete endpoint lifecycle */ - @Test(groups = {"wso2.am"}, description = "Test AI API invocation", - dependsOnMethods = "testMistralAIAPICreationAndPublish") - public void testMistralAIApiInvocation() throws Exception { + @Test(groups = {"wso2.am"}, description = "Test final retrieval of all API endpoints", + dependsOnMethods = "testDeleteApiEndpoint") + public void testGetAllEndpoints() throws Exception { + // Get all endpoints one final time + HttpResponse getEndpointsResponse = restAPIPublisher.getApiEndpoints(mistralApiId); + assertEquals(getEndpointsResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve final endpoints list for API: " + mistralApiId); + + // Update the endpoints list with the final API response + JSONObject endpointsResponse = new JSONObject(getEndpointsResponse.getData()); + for (int i = 0; i < endpointsResponse.getJSONArray("list").length(); i++) { + endpointsList.add(endpointsResponse.getJSONArray("list").getJSONObject(i)); + } + + // Verify that we have at least 1 endpoint remaining (production endpoint) + assertFalse(endpointsList.isEmpty(), + "Should have at least 1 endpoint remaining, but found: " + endpointsList.size()); + + // Verify that the production endpoint still exists + boolean foundProductionEndpoint = false; + for (JSONObject endpoint : endpointsList) { + if (productionEndpointId.equals(endpoint.getString("id"))) { + foundProductionEndpoint = true; + break; + } + } + assertTrue(foundProductionEndpoint, "Production endpoint should still exist in the final list"); + + // Verify that the sandbox endpoint is completely removed + boolean foundSandboxEndpoint = false; + for (JSONObject endpoint : endpointsList) { + if (sandboxEndpointId.equals(endpoint.getString("id"))) { + foundSandboxEndpoint = true; + break; + } + } + assertFalse(foundSandboxEndpoint, "Sandbox endpoint should be completely removed from the final list"); + } - // Subscribe to API - SubscriptionDTO subscriptionDTO = restAPIStore. - subscribeToAPI(mistralAPIId, applicationId, APIMIntegrationConstants.API_TIER.UNLIMITED); - assertNotNull(subscriptionDTO, "Mistral AI API Subscription failed"); + /** + * Test retrieving AI service provider models from the publisher portal + */ + @Test(groups = {"wso2.am"}, description = "Test retrieving AI service provider models", + dependsOnMethods = "testGetAllEndpoints") + public void testGetServiceProviderModels() { + // Retrieve model list + HttpResponse getModelListResponse = restAPIPublisher.getAIServiceProviderModels(aiServiceProviderId); + assertEquals(getModelListResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve model list of AI Service Provider: " + aiServiceProviderId); + + // Parse the model provider response to extract the models list + List> modelProviderList = new Gson().fromJson(getModelListResponse.getData(), List.class); + List modelList = new ArrayList<>(); + + if (!modelProviderList.isEmpty()) { + Map firstProvider = modelProviderList.get(0); + if (firstProvider.containsKey("models")) { + List models = (List) firstProvider.get("models"); + modelList.addAll(models); + } + } - // Get API Key - APIKeyDTO apiKeyDTO = restAPIStore. - generateAPIKeys(applicationId, ApplicationKeyGenerateRequestDTO.KeyTypeEnum.PRODUCTION.toString(), - -1, null, null); - assertNotNull(apiKeyDTO, "Mistral AI API Key generation failed"); - String apiKey = apiKeyDTO.getApikey(); + // Verify that the retrieved model list contains the expected 3 models + assertNotNull(modelList, "Model list should not be null"); + assertEquals(modelList.size(), 3, "Expected 3 models but found: " + modelList.size()); + + // Verify presence of specific models + assertTrue(modelList.contains(MODEL_SMALL), "Model list should contain " + MODEL_SMALL); + assertTrue(modelList.contains(MODEL_MEDIUM), "Model list should contain " + MODEL_MEDIUM); + assertTrue(modelList.contains(MODEL_LARGE), "Model list should contain " + MODEL_LARGE); + } + + /** + * Test Mistral AI API invocation after adding model round-robin policy + */ + @Test(groups = {"wso2.am"}, description = "Test AI API invocation after adding model round-robin policy", + dependsOnMethods = "testGetServiceProviderModels") + public void testApiInvocationWithRoundRobinPolicy() throws Exception { + + HttpResponse getAPIResponse = restAPIPublisher.getAPI(mistralApiId); + APIDTO apidto = new Gson().fromJson(getAPIResponse.getData(), APIDTO.class); + + // Add weighted round-robin policy + String policyName = "modelWeightedRoundRobin"; + Assert.assertNotNull(policyMap.get(policyName), "Unable to find a common policy with name " + policyName); + + Map attributeMap = new HashMap<>(); + JSONObject weightedRoundRobinConfigs = new JSONObject(); + List productionModelList = new ArrayList<>(); + + // Use specific models for the round-robin configuration + String firstModel = MODEL_MEDIUM; + String secondModel = MODEL_LARGE; + + JSONObject model1Obj = new JSONObject(); + model1Obj.put("vendor", ""); + model1Obj.put("model", firstModel); + model1Obj.put("endpointId", productionEndpointId); + model1Obj.put("endpointName", PRODUCTION_ENDPOINT_NAME); + model1Obj.put("weight", 80); + + JSONObject model2Obj = new JSONObject(); + model2Obj.put("vendor", ""); + model2Obj.put("model", secondModel); + model2Obj.put("endpointId", DEFAULT_PRODUCTION_ENDPOINT_ID); + model2Obj.put("endpointName", DEFAULT_PRODUCTION_ENDPOINT_NAME); + model2Obj.put("weight", 20); + + productionModelList.add(model1Obj); + productionModelList.add(model2Obj); + weightedRoundRobinConfigs.put("production", productionModelList); + weightedRoundRobinConfigs.put("sandbox", new ArrayList<>()); // No sandbox models configured + weightedRoundRobinConfigs.put("suspendDuration", "5"); + + String configString = weightedRoundRobinConfigs.toString().replace("\"", "'"); + attributeMap.put("weightedRoundRobinConfigs", configString); + + List requestPolicyList = new ArrayList<>(); + OperationPolicyDTO roundRobinPolicyDTO = new OperationPolicyDTO(); + roundRobinPolicyDTO.setPolicyName(policyName); + roundRobinPolicyDTO.setPolicyType("common"); + roundRobinPolicyDTO.setPolicyId(policyMap.get(policyName)); + roundRobinPolicyDTO.setParameters(attributeMap); + requestPolicyList.add(roundRobinPolicyDTO); + + APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO(); + apiOperationPoliciesDTO.setRequest(requestPolicyList); + apiOperationPoliciesDTO.setResponse(new ArrayList<>()); + apiOperationPoliciesDTO.setFault(new ArrayList<>()); + apidto.setApiPolicies(apiOperationPoliciesDTO); + restAPIPublisher.updateAPI(apidto); + + // Create Revision and Deploy to Gateway + createAPIRevisionAndDeployUsingRest(mistralApiId, restAPIPublisher); + waitForAPIDeployment(); // Invoke API Map requestHeaders = new HashMap<>(); requestHeaders.put("ApiKey", apiKey); - String invokeURL = getAPIInvocationURLHttp(mistralAPIContext, mistralAPIVersion) + - mistralAPIResource; - String mistralPayload = readFile(resourcePath + "mistral-payload.json"); - HttpResponse serviceResponse = HTTPSClientUtils. - doPost(invokeURL, requestHeaders, mistralPayload); + requestHeaders.put("Content-Type", "application/json"); + String invokeURL = getAPIInvocationURLHttp(MISTRAL_API_CONTEXT, API_VERSION_1_0_0) + MISTRAL_API_RESOURCE; + HttpResponse serviceResponse = HTTPSClientUtils.doPost(invokeURL, requestHeaders, mistralPayload); assertEquals(serviceResponse.getResponseCode(), HttpStatus.SC_OK, "Failed to invoke Mistral AI API"); - assertEquals(mistralResponse, serviceResponse.getData(), "Mistral AI API response mismatch"); + + // Verify that the response matches one of the configured models (model2 or model3) + String actualResponse = serviceResponse.getData(); + boolean isFirstModelResponse = model2Response.equals(actualResponse); + boolean isSecondModelResponse = model3Response.equals(actualResponse); + + assertTrue(isFirstModelResponse || isSecondModelResponse, + "Response should match either " + firstModel + " or " + secondModel + " response. " + + "Actual response: " + actualResponse + + ", Expected " + firstModel + " response: " + model2Response + + ", Expected " + secondModel + " response: " + model3Response); + } + + /** + * Test creating a new API version with failover policy + */ + @Test(groups = { "wso2.am" }, description = "Test creating new API version with failover policy", + dependsOnMethods = "testApiInvocationWithRoundRobinPolicy") + public void testCreateApiVersionWithFailover() throws Exception { + // Create new version of the API + HttpResponse copyApiResponse = restAPIPublisher.copyAPI(API_VERSION_2_0_0, mistralApiId, false); + assertEquals(copyApiResponse.getResponseCode(), HttpStatus.SC_OK, "Failed to create new version of API"); + + newVersionApiId = copyApiResponse.getData(); + assertNotNull(newVersionApiId, "New version API ID should not be null"); + + // Get the new version API + HttpResponse getNewVersionApiResponse = restAPIPublisher.getAPI(newVersionApiId); + assertEquals(getNewVersionApiResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to retrieve new version API"); + + APIDTO newVersionApiDto = new Gson().fromJson(getNewVersionApiResponse.getData(), APIDTO.class); + assertEquals(newVersionApiDto.getVersion(), API_VERSION_2_0_0, "API version should match"); + + // Add a new endpoint with failover URL for the new version + String baseEndpointConfig = readFile(resourcePath + ENDPOINT_CONFIG_TEMPLATE_FILE); + JSONObject failoverEndpointConfigObj = new JSONObject(baseEndpointConfig); + JSONObject productionEndpoints = new JSONObject(); + productionEndpoints.put("url", ENDPOINT_HOST + ":" + endpointPort + FAILOVER_ENDPOINT_URL); + failoverEndpointConfigObj.put("production_endpoints", productionEndpoints); + + // Remove sandbox section from endpoint_security for failover production endpoint + JSONObject failoverEndpointSecurity = failoverEndpointConfigObj.getJSONObject("endpoint_security"); + failoverEndpointSecurity.remove("sandbox"); + failoverEndpointConfigObj.put("endpoint_security", failoverEndpointSecurity); + + Map failoverEndpointConfigMap = new Gson().fromJson(failoverEndpointConfigObj.toString(), + Map.class); + HttpResponse addFailoverEndpointResponse = restAPIPublisher.addApiEndpoint(newVersionApiId, + FAILOVER_ENDPOINT_NAME, PRODUCTION_DEPLOYMENT_STAGE, failoverEndpointConfigMap); + assertEquals(addFailoverEndpointResponse.getResponseCode(), HttpStatus.SC_CREATED, + "Failed to add failover endpoint to new version API"); + + // Extract failover endpoint ID from response + JSONObject failoverEndpointResponse = new JSONObject(addFailoverEndpointResponse.getData()); + String failoverEndpointId = failoverEndpointResponse.getString("id"); + assertNotNull(failoverEndpointId, "Failover endpoint ID should not be null"); + + // Update the API to set the new endpoint as primary production endpoint + newVersionApiDto.setPrimaryProductionEndpointId(failoverEndpointId); + + // Remove the round-robin policy and add failover policy + String failoverPolicyName = "modelFailover"; + Assert.assertNotNull(policyMap.get(failoverPolicyName), + "Unable to find a common policy with name " + failoverPolicyName); + + Map failoverAttributeMap = new HashMap<>(); + JSONObject failoverConfigs = new JSONObject(); + + // Configure production failover + JSONObject productionConfig = getProductionFailoverProdConfig(failoverEndpointId); + + // Configure sandbox failover (empty in this case) + JSONObject sandboxConfig = new JSONObject(); + sandboxConfig.put("targetModel", new JSONObject()); + sandboxConfig.put("fallbackModels", new ArrayList()); + + failoverConfigs.put("production", productionConfig); + failoverConfigs.put("sandbox", sandboxConfig); + failoverConfigs.put("requestTimeout", "120"); + failoverConfigs.put("suspendDuration", "0"); + + String configString = failoverConfigs.toString().replace("\"", "'"); + failoverAttributeMap.put("failoverConfigs", configString); + + // Create failover policy + List requestPolicyList = new ArrayList<>(); + OperationPolicyDTO failoverPolicyDTO = new OperationPolicyDTO(); + failoverPolicyDTO.setPolicyName(failoverPolicyName); + failoverPolicyDTO.setPolicyType("common"); + failoverPolicyDTO.setPolicyId(policyMap.get(failoverPolicyName)); + failoverPolicyDTO.setParameters(failoverAttributeMap); + requestPolicyList.add(failoverPolicyDTO); + + APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO(); + apiOperationPoliciesDTO.setRequest(requestPolicyList); + newVersionApiDto.setApiPolicies(apiOperationPoliciesDTO); + + // Update the new version API with failover policy + HttpResponse updateResponse = restAPIPublisher.updateAPIWithHttpInfo(newVersionApiDto); + assertEquals(updateResponse.getResponseCode(), HttpStatus.SC_OK, + "Failed to update new version API with failover policy and updated primary production endpoint"); + + // Create revision and deploy the new version + String revisionUUID = createAPIRevisionAndDeployUsingRest(newVersionApiId, restAPIPublisher); + assertNotNull(revisionUUID, "Failed to create and deploy revision for new version API"); + + // Publish the new version API + HttpResponse lifecycleResponse = restAPIPublisher.changeAPILifeCycleStatusToPublish(newVersionApiId, false); + assertEquals(lifecycleResponse.getResponseCode(), HttpStatus.SC_OK, "Failed to publish new version API"); + + // Wait for API deployment + waitForAPIDeploymentSync(newVersionApiDto.getProvider(), newVersionApiDto.getName(), + newVersionApiDto.getVersion(), APIMIntegrationConstants.IS_API_EXISTS); + + // Invoke the new version API to test failover + Map requestHeaders = new HashMap<>(); + requestHeaders.put("ApiKey", apiKey); + requestHeaders.put("Content-Type", "application/json"); + String invokeURL = getAPIInvocationURLHttp(MISTRAL_API_CONTEXT, API_VERSION_2_0_0) + MISTRAL_API_RESOURCE; + HttpResponse serviceResponse = HTTPSClientUtils.doPost(invokeURL, requestHeaders, mistralPayload); + + // Verify that the API call succeeded (failover should have worked) + assertEquals(serviceResponse.getResponseCode(), HttpStatus.SC_OK, + "API invocation should succeed due to failover"); + + // Verify that the response matches the fallback model (model3) + String actualResponse = serviceResponse.getData(); + String expectedFallbackResponse = model3Response; + assertEquals(actualResponse, expectedFallbackResponse, + "Response should match fallback model (model3) after failover"); } /** - * Deletes a specified LLM provider after removing API subscriptions and applications. - * Verifies that the provider is successfully deleted and no longer listed. + * Helper method to create production failover configuration */ - @Test(groups = {"wso2.am"}, description = "Delete LLM Provider", - dependsOnMethods = "testMistralAIApiInvocation") - public void deleteLLMProvider() throws Exception { + @NotNull + private JSONObject getProductionFailoverProdConfig(String failoverEndpointId) throws JSONException { + JSONObject productionConfig = new JSONObject(); + JSONObject targetModel = new JSONObject(); + targetModel.put("model", MODEL_SMALL); + targetModel.put("endpointId", failoverEndpointId); + targetModel.put("endpointName", FAILOVER_ENDPOINT_NAME); + productionConfig.put("targetModel", targetModel); + + List fallbackModels = new ArrayList<>(); + JSONObject fallbackModel = new JSONObject(); + fallbackModel.put("model", MODEL_LARGE); + fallbackModel.put("endpointId", DEFAULT_PRODUCTION_ENDPOINT_ID); + fallbackModel.put("endpointName", DEFAULT_PRODUCTION_ENDPOINT_NAME); + fallbackModels.add(fallbackModel); + productionConfig.put("fallbackModels", fallbackModels); + return productionConfig; + } + + @AfterClass(alwaysRun = true) + public void cleanUpArtifacts() throws Exception { - restAPIStore.removeAPISubscriptionByName(mistralAPIName, mistralAPIVersion, apiProvider, applicationName); restAPIStore.deleteApplication(applicationId); - restAPIPublisher.deleteAPI(mistralAPIId); - - ApiResponse deleteProviderResponse = restAPIAdmin.deleteLLMProvider(llmProviderId); - assertEquals(Response.Status.OK.getStatusCode(), - deleteProviderResponse.getStatusCode(), "Failed to delete LLM provider"); - - ApiResponse llmProviders = restAPIAdmin.getLLMProviders(); - assertEquals(Response.Status.OK.getStatusCode(), - llmProviders.getStatusCode(), "Failed to retrieve LLM providers"); - for (LLMProviderSummaryResponseDTO provider : llmProviders.getData().getList()) { - if (provider.getName().equals(llmProviderName)) { - Assert.fail("LLM Provider " + llmProviderName + " has not deleted correctly"); + undeployAndDeleteAPIRevisionsUsingRest(unsecuredApiId, restAPIPublisher); + undeployAndDeleteAPIRevisionsUsingRest(mistralApiId, restAPIPublisher); + undeployAndDeleteAPIRevisionsUsingRest(newVersionApiId, restAPIPublisher); + restAPIPublisher.deleteAPI(unsecuredApiId); + restAPIPublisher.deleteAPI(mistralApiId); + restAPIPublisher.deleteAPI(newVersionApiId); + + // Clean up AI service provider + if (aiServiceProviderId != null) { + try { + ApiResponse deleteProviderResponse = restAPIAdmin.deleteAIServiceProvider(aiServiceProviderId); + assertEquals(deleteProviderResponse.getStatusCode(), Response.Status.OK.getStatusCode(), + "Failed to delete AI service provider"); + + // Verify the AI service provider is no longer listed + ApiResponse aiServiceProviders = restAPIAdmin.getAIServiceProviders(); + assertEquals(aiServiceProviders.getStatusCode(), Response.Status.OK.getStatusCode(), + "Failed to retrieve AI service providers after deletion"); + assertNotNull(aiServiceProviders.getData().getList(), "AI service providers list should not be null"); + + // Ensure the deleted provider is not in the list + for (AIServiceProviderSummaryResponseDTO provider : aiServiceProviders.getData().getList()) { + if (provider.getName().equals(AI_SERVICE_PROVIDER_NAME)) { + Assert.fail("AI Service Provider " + AI_SERVICE_PROVIDER_NAME + " has not been deleted correctly"); + } + } + } catch (Exception e) { + log.warn("Failed to delete AI service provider: " + e.getMessage()); + } + } + + // Stop WireMock server + if (wireMockServer != null) { + try { + wireMockServer.stop(); + } catch (Exception e) { + log.warn("Error stopping WireMock server: " + e.getMessage()); } } } - @AfterClass(alwaysRun = true) - public void destroyAPIs() throws Exception { + /** + * Initialize default AI service providers list + */ + private void initializeDefaultAiServiceProviders() { + defaultAiServiceProviders.add("MistralAI"); + defaultAiServiceProviders.add("OpenAI"); + defaultAiServiceProviders.add("AzureOpenAI"); + defaultAiServiceProviders.add("AWSBedrock"); + defaultAiServiceProviders.add("Anthropic"); + defaultAiServiceProviders.add("Gemini"); + defaultAiServiceProviders.add("AzureAIFoundry"); + } - if (wireMockServer != null) { - wireMockServer.stop(); - } + /** + * Initialize model configurations + */ + private void initializeModelConfigurations() { + String modelList = String.format("[\"%s\", \"%s\", \"%s\"]", MODEL_SMALL, MODEL_MEDIUM, MODEL_LARGE); + modelProviders = String.format("[{\"models\": %s, \"name\": \"%s\"}]", modelList, AI_SERVICE_PROVIDER_NAME); } - private File getTempFileWithContent(String content) throws IOException { + /** + * Create test application for API subscriptions + * + * @return application ID + * @throws Exception if application creation fails + */ + private String createTestApplication() throws Exception { + ApplicationDTO applicationDTO = restAPIStore.addApplication(APPLICATION_NAME, + APIThrottlingTier.UNLIMITED.getState(), "", "this-is-test"); + String appId = applicationDTO.getApplicationId(); + Assert.assertNotNull(appId, "Application ID should not be null"); + return appId; + } - File temp = File.createTempFile("swagger", ".json"); - try (BufferedWriter out = new BufferedWriter(new FileWriter(temp))) { - out.write(content); - } - temp.deleteOnExit(); - return temp; + /** + * Initialize test data including response templates and payloads + * + * @throws Exception if file reading fails + */ + private void initializeTestData() throws Exception { + resourcePath = TestConfigurationProvider.getResourceLocation() + "ai-api" + File.separator; + String mistralResponse = readFile(resourcePath + MISTRAL_RESPONSE_FILE_NAME); + model1Response = mistralResponse.replace("{{jsonPath request.body '$.model'}}", MODEL_SMALL); + model2Response = mistralResponse.replace("{{jsonPath request.body '$.model'}}", MODEL_MEDIUM); + model3Response = mistralResponse.replace("{{jsonPath request.body '$.model'}}", MODEL_LARGE); + mistralPayload = readFile(resourcePath + MISTRAL_PAYLOAD_FILE_NAME); + + // Load AI service provider configurations from JSON files + customAiServiceProviderConfigurations = readFile(resourcePath + AI_SERVICE_PROVIDER_CONFIG_NO_AUTH_FILE); + updatedCustomAiServiceProviderConfigurations = readFile( + resourcePath + AI_SERVICE_PROVIDER_CONFIG_WITH_AUTH_FILE); } - private void startWiremockServer() throws Exception { + /** + * Create and publish an AI API with given configurations + * + * @param endpoint endpoint URL + * @param additionalPropsFileName additional properties file name + * @return API ID of the created API + * @throws Exception if API creation fails + */ + private String createAndPublishAiApi(String endpoint, String additionalPropsFileName) throws Exception { + String apiDefinition = readFile(resourcePath + API_DEFINITION_FILE_NAME); + String additionalProperties = readFile(resourcePath + additionalPropsFileName); + JSONObject additionalPropertiesObj = new JSONObject(additionalProperties); + + // Update endpoint configuration + JSONObject endpointConfig = additionalPropertiesObj.getJSONObject("endpointConfig"); + JSONObject productionEndpoints = new JSONObject(); + productionEndpoints.put("url", ENDPOINT_HOST + ":" + endpointPort + endpoint); + endpointConfig.put("production_endpoints", productionEndpoints); + additionalPropertiesObj.put("endpointConfig", endpointConfig); + + // Create API + File file = getTempFileWithContent(apiDefinition); + APIDTO apidto = restAPIPublisher.importOASDefinition(file, additionalPropertiesObj.toString()); + String apiId = apidto.getId(); + + // Verify API creation + HttpResponse createdApiResponse = restAPIPublisher.getAPI(apiId); + assertEquals(createdApiResponse.getResponseCode(), Response.Status.OK.getStatusCode(), + "Failed to create AI API using the custom AI Service Provider"); - endpointPort = getAvailablePort(); - wireMockServer = new WireMockServer(options().port(endpointPort)); + // Deploy and publish API + String revisionUUID = createAPIRevisionAndDeployUsingRest(apiId, restAPIPublisher); + Assert.assertNotNull(revisionUUID, "Revision UUID should not be null"); - wireMockServer.stubFor(WireMock.post(urlEqualTo(mistralAPIEndpoint + mistralAPIResource)) - .willReturn(aResponse().withStatus(200). - withHeader("Content-Type", "application/json").withBody(mistralResponse))); + HttpResponse lifecycleResponse = restAPIPublisher.changeAPILifeCycleStatusToPublish(apiId, false); + assertEquals(lifecycleResponse.getResponseCode(), HttpStatus.SC_OK, "Failed to publish API"); - wireMockServer.start(); - log.info("Wiremock server started on port " + endpointPort); + waitForAPIDeploymentSync(apidto.getProvider(), apidto.getName(), apidto.getVersion(), + APIMIntegrationConstants.IS_API_EXISTS); + return apiId; } /** - * Find a free port to start backend WebSocket server in given port range + * Subscribe to API and generate API key * - * @return Available Port Number + * @param apiId API ID to subscribe to + * @return API key + * @throws Exception if subscription or key generation fails */ - private int getAvailablePort() { - - while (lowerPortLimit < upperPortLimit) { - if (isPortFree(lowerPortLimit)) { - return lowerPortLimit; - } - lowerPortLimit++; - } - return -1; + private String subscribeToApiAndGenerateKey(String apiId) throws Exception { + // Subscribe to API + SubscriptionDTO subscriptionDTO = restAPIStore.subscribeToAPI(apiId, applicationId, + APIMIntegrationConstants.API_TIER.UNLIMITED); + assertNotNull(subscriptionDTO, "API subscription should not be null"); + + // Generate API Key + APIKeyDTO apiKeyDTO = restAPIStore.generateAPIKeys(applicationId, + ApplicationKeyGenerateRequestDTO.KeyTypeEnum.PRODUCTION.toString(), -1, null, null); + assertNotNull(apiKeyDTO, "API Key should not be null"); + return apiKeyDTO.getApikey(); } /** - * Check whether give port is available + * Create a temporary file with the given content * - * @param port Port Number - * @return status + * @param content Content to write to the file + * @return Temporary file + * @throws IOException if file creation fails */ - private boolean isPortFree(int port) { + private File getTempFileWithContent(String content) throws IOException { + + File temp = File.createTempFile("swagger", ".json"); + temp.deleteOnExit(); + BufferedWriter out = new BufferedWriter(new FileWriter(temp)); + out.write(content); + out.close(); + return temp; + } + + private void startWiremockServer() { + + endpointPort = MockServerUtils.getAvailablePort(MockServerUtils.LOCALHOST, true); + assertNotEquals(endpointPort, -1, + "No available port in the range " + MockServerUtils.httpsPortLowerRange + "-" + + MockServerUtils.httpsPortUpperRange + " was found"); + wireMockServer = new WireMockServer(options() + .port(endpointPort) + .extensions(new ResponseTemplateTransformer(true))); + + // Stub for secured AI API (with Authorization header value of Bearer 123) + wireMockServer.stubFor(WireMock.post(urlEqualTo(MISTRAL_API_ENDPOINT + MISTRAL_API_RESOURCE)) + .withHeader("Authorization", WireMock.matching("Bearer 123")) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_SMALL))) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(model1Response))); + + // Stub for round-robin policy: model1 request routed to model2 (80% weight) + // Using more flexible matching with containsString to handle potential JSON formatting issues + wireMockServer.stubFor(WireMock.post(urlEqualTo(MISTRAL_API_ENDPOINT_UPDATED + MISTRAL_API_RESOURCE)) + .withHeader("Authorization", WireMock.matching("Bearer 456")) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_MEDIUM))) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(model2Response))); + + // Stub for round-robin policy: model1 request routed to model3 (20% weight) + wireMockServer.stubFor(WireMock.post(urlEqualTo(MISTRAL_API_ENDPOINT_UPDATED + MISTRAL_API_RESOURCE)) + .withHeader("Authorization", WireMock.matching("Bearer 456")) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_LARGE))) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(model3Response))); + + // Stub for /mistral endpoint with Bearer 123 and model3 + // Using flexible matching to handle JSON formatting issues + wireMockServer.stubFor(WireMock.post(urlEqualTo(MISTRAL_API_ENDPOINT + MISTRAL_API_RESOURCE)) + .withHeader("Authorization", WireMock.matching("Bearer 123")) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_LARGE))) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(model3Response))); + + // Stub for failover endpoint that returns 500 (to trigger failover) + wireMockServer.stubFor(WireMock.post(urlEqualTo(FAILOVER_ENDPOINT_URL + MISTRAL_API_RESOURCE)) + .withHeader("Authorization", WireMock.matching("Bearer 123")) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_SMALL))) + .willReturn(aResponse() + .withStatus(429) + .withHeader("Content-Type", "application/json") + .withBody("{\"error\": \"Rate limit exceeded\"}"))); + + // Stub for unsecured AI API (no Authorization header) + wireMockServer.stubFor(WireMock.post(urlEqualTo(NO_AUTH_API_ENDPOINT + MISTRAL_API_RESOURCE)) + .withRequestBody(matchingJsonPath("$.model", equalTo(MODEL_SMALL))) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "application/json") + .withBody(model1Response))); - Socket s = null; try { - s = new Socket(endpointHost, port); - // something is using the port and has responded. - return false; - } catch (IOException e) { - // port available - return true; - } finally { - if (s != null) { - try { - s.close(); - } catch (IOException e) { - throw new RuntimeException("Unable to close connection ", e); - } - } + wireMockServer.start(); + log.info("WireMock server started successfully on port " + endpointPort); + } catch (Exception e) { + log.error("Failed to start WireMock server on port " + endpointPort + ": " + e.getMessage(), e); + throw e; } } + } diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java index 34fe16879b..18f331a973 100644 --- a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/workflow/WorkflowApprovalExecutorTest.java @@ -95,6 +95,7 @@ public class WorkflowApprovalExecutorTest extends APIManagerLifecycleBaseTest { private APIIdentifier apiIdentifier; private AdminDashboardRestClient adminDashboardRestClient; private String apiId; + private String apiId2; private String applicationID; private String subscriptionId; private ApiProductTestHelper apiProductTestHelper; @@ -1324,12 +1325,12 @@ public void testAPIRevisionDeploymentWorkflowProcess() throws Exception { apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED); apiRequest.setProvider(USER_SMITH); HttpResponse apiResponse = restAPIPublisher.addAPI(apiRequest); - apiId = apiResponse.getData(); + apiId2 = apiResponse.getData(); assertEquals(apiResponse.getResponseCode(), 201, "API creation failed in Revision Deployment Workflow Executor"); // Create revision and send deploy request - String firstRevisionUUID = createAPIRevisionAndDeployUsingRest(apiId, restAPIPublisher); + String firstRevisionUUID = createAPIRevisionAndDeployUsingRest(apiId2, restAPIPublisher); String firstExternalWorkflowRef = getExternalRef(apiName); @@ -1342,14 +1343,14 @@ public void testAPIRevisionDeploymentWorkflowProcess() throws Exception { // Reject workflow and check whether the revision is not deployed response = restAPIAdmin.rejectWorkflowStatus(firstExternalWorkflowRef); assertEquals(response.getResponseCode(), 200, "First Workflow request reject failed for user admin"); - HttpResponse apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + HttpResponse apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); JSONObject apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); assertEquals(apiRevisionsGetResponseObj.getJSONArray("list").length(), 0, "First Revision is deployed"); - deployAPIRevisionWithWorkflow(apiId, firstRevisionUUID, firstExternalWorkflowRef); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + deployAPIRevisionWithWorkflow(apiId2, firstRevisionUUID, firstExternalWorkflowRef); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); @@ -1364,18 +1365,18 @@ public void testAPIRevisionDeploymentWorkflowProcess() throws Exception { } // Undeploy revision and check whether it is undeployed - undeployAPIRevisionWithWorkflow(apiId, firstRevisionUUID, firstExternalWorkflowRef); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + undeployAPIRevisionWithWorkflow(apiId2, firstRevisionUUID, firstExternalWorkflowRef); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); assertEquals(apiRevisionsGetResponseObj.getJSONArray("list").length(), 0, "First Revision is deployed"); // Deploy a revision then send another request and check whether the second request is not deployed - deployAPIRevisionWithWorkflow(apiId, firstRevisionUUID, firstExternalWorkflowRef); + deployAPIRevisionWithWorkflow(apiId2, firstRevisionUUID, firstExternalWorkflowRef); // Create Second Revision and send deploy request - String secondRevisionUUID = createAPIRevisionAndDeployUsingRest(apiId, restAPIPublisher); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + String secondRevisionUUID = createAPIRevisionAndDeployUsingRest(apiId2, restAPIPublisher); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); @@ -1390,14 +1391,14 @@ public void testAPIRevisionDeploymentWorkflowProcess() throws Exception { } String secondExternalWorkflowRef = getExternalRef(apiName); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); // Reject the second workflow request and check whether the second revision is not deployed response = restAPIAdmin.rejectWorkflowStatus(secondExternalWorkflowRef); assertEquals(response.getResponseCode(), 200, "Workflow request update failed for user admin"); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); @@ -1412,8 +1413,8 @@ public void testAPIRevisionDeploymentWorkflowProcess() throws Exception { } // Deploy the second revision and check whether the first revision is undeployed - deployAPIRevisionWithWorkflow(apiId, secondRevisionUUID, secondExternalWorkflowRef); - apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId, "deployed:true"); + deployAPIRevisionWithWorkflow(apiId2, secondRevisionUUID, secondExternalWorkflowRef); + apiRevisionsGetResponse = restAPIPublisher.getAPIRevisions(apiId2, "deployed:true"); assertEquals(apiRevisionsGetResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Unable to retrieve deployed revisions" + apiRevisionsGetResponse.getData()); apiRevisionsGetResponseObj = new JSONObject(apiRevisionsGetResponse.getData()); @@ -1524,6 +1525,7 @@ public void destroy() throws Exception { removeDeletePendingApplication(applicationName); undeployAndDeleteAPIRevisionsUsingRest(apiId, restAPIPublisher); restAPIPublisher.deleteAPI(apiId); + restAPIPublisher.deleteAPI(apiId2); userManagementClient.deleteUser(USER_SMITH); userManagementClient.deleteUser(USER_ADMIN); userManagementClient.deleteUser("JaneDoe"); diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-no-auth.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-no-auth.json new file mode 100644 index 0000000000..748b1b3536 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-no-auth.json @@ -0,0 +1,46 @@ +{ + "connectorType": "mistralAi_1.0.0", + "authenticationConfiguration": { + "enabled": false, + "type": "none", + "parameters": {} + }, + "metadata": [ + { + "attributeName": "requestModel", + "inputSource": "payload", + "attributeIdentifier": "$.model", + "required": false + }, + { + "attributeName": "responseModel", + "inputSource": "payload", + "attributeIdentifier": "$.model", + "required": true + }, + { + "attributeName": "promptTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.prompt_tokens", + "required": true + }, + { + "attributeName": "completionTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.completion_tokens", + "required": true + }, + { + "attributeName": "totalTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.total_tokens", + "required": true + }, + { + "attributeName": "remainingTokenCount", + "inputSource": "header", + "attributeIdentifier": "x-ratelimit-remaining-tokens", + "required": false + } + ] +} diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-with-auth.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-with-auth.json new file mode 100644 index 0000000000..a07fbce8d5 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/ai-service-provider-config-with-auth.json @@ -0,0 +1,50 @@ +{ + "connectorType": "mistralAi_1.0.0", + "authenticationConfiguration": { + "enabled": true, + "type": "apikey", + "parameters": { + "headerEnabled": true, + "queryParameterEnabled": false, + "headerName": "Authorization" + } + }, + "metadata": [ + { + "attributeName": "requestModel", + "inputSource": "payload", + "attributeIdentifier": "$.model", + "required": false + }, + { + "attributeName": "responseModel", + "inputSource": "payload", + "attributeIdentifier": "$.model", + "required": true + }, + { + "attributeName": "promptTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.prompt_tokens", + "required": true + }, + { + "attributeName": "completionTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.completion_tokens", + "required": true + }, + { + "attributeName": "totalTokenCount", + "inputSource": "payload", + "attributeIdentifier": "$.usage.total_tokens", + "required": true + }, + { + "attributeName": "remainingTokenCount", + "inputSource": "header", + "attributeIdentifier": "x-ratelimit-remaining-tokens", + "required": false + } + ] +} diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/endpoint-config-template.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/endpoint-config-template.json new file mode 100644 index 0000000000..98c8662a35 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/endpoint-config-template.json @@ -0,0 +1,31 @@ +{ + "endpoint_type": "http", + "endpoint_security": { + "production": { + "enabled": true, + "type": "apikey", + "apiKeyIdentifier": "Authorization", + "apiKeyValue": "Bearer 123", + "apiKeyIdentifierType": "HEADER", + "username": "", + "password": null, + "grantType": "", + "tokenUrl": "", + "clientId": null, + "clientSecret": null + }, + "sandbox": { + "enabled": true, + "type": "apikey", + "apiKeyIdentifier": "Authorization", + "apiKeyValue": "Bearer 456", + "apiKeyIdentifierType": "HEADER", + "username": "", + "password": null, + "grantType": "", + "tokenUrl": "", + "clientId": null, + "clientSecret": null + } + } +} diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-add-props.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-add-props.json index f750df0299..2644a2dc9b 100644 --- a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-add-props.json +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-add-props.json @@ -20,20 +20,6 @@ "clientId": null, "clientSecret": null, "customParameters": "{}" - }, - "sandbox": { - "enabled": true, - "type": "apikey", - "apiKeyIdentifier": "Authorization", - "apiKeyValue": "123", - "apiKeyIdentifierType": "HEADER", - "username": "", - "password": null, - "grantType": "", - "tokenUrl": "", - "clientId": null, - "clientSecret": null, - "customParameters": "{}" } } }, diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-no-auth-add-props.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-no-auth-add-props.json new file mode 100644 index 0000000000..b95f19aa38 --- /dev/null +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-no-auth-add-props.json @@ -0,0 +1,34 @@ +{ + "name": "mistralNoAuthAPI", + "version": "1.0.0", + "context": "mistralNoAuthAPI", + "gatewayType": "wso2/synapse", + "policies": ["Unlimited"], + "endpointConfig": { + "endpoint_type": "http" + }, + "subtypeConfiguration": { + "subtype": "AIAPI", + "configuration": { + "llmProviderName": "TestAIService", + "llmProviderApiVersion": "1.0.0" + } + }, + "maxTps": { + "production": 1000, + "sandbox": 1000, + "productionTimeUnit": "MINUTE", + "sandboxTimeUnit": "MINUTE", + "tokenBasedThrottlingConfiguration": { + "productionMaxPromptTokenCount": 1234, + "productionMaxCompletionTokenCount": 2345, + "productionMaxTotalTokenCount": 3456, + "sandboxMaxPromptTokenCount": 4567, + "sandboxMaxCompletionTokenCount": 5678, + "sandboxMaxTotalTokenCount": 6789, + "isTokenBasedThrottlingEnabled": true + } + }, + "securityScheme":["api_key"], + "egress":true +} diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-payload.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-payload.json index 8b68988e59..a0310d7d3f 100644 --- a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-payload.json +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-payload.json @@ -1,4 +1,4 @@ { - "model": "mistral-large-latest", + "model": "mistral-small-latest", "messages": [{"role": "user", "content": "Who is the most renowned French painter?"}] -} \ No newline at end of file +} diff --git a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-response.json b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-response.json index 24dfac720f..eaf684b0ae 100644 --- a/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-response.json +++ b/all-in-one-apim/modules/integration/tests-integration/tests-backend/src/test/resources/ai-api/mistral-response.json @@ -2,7 +2,7 @@ "id": "f821a1dd4df2492382ec9676b59ddcd3", "object": "chat.completion", "created": 1727259070, - "model": "mistral-large-latest", + "model": "{{jsonPath request.body '$.model'}}", "choices": [ { "index": 0, @@ -20,4 +20,4 @@ "total_tokens": 358, "completion_tokens": 346 } -} \ No newline at end of file +} diff --git a/all-in-one-apim/pom.xml b/all-in-one-apim/pom.xml index 8dec887411..7780471ccc 100644 --- a/all-in-one-apim/pom.xml +++ b/all-in-one-apim/pom.xml @@ -1310,7 +1310,6 @@ 9.3.49 - 9.32.75 [9.0.0, 10.0.0) diff --git a/api-control-plane/pom.xml b/api-control-plane/pom.xml index 5db84acf5f..18403cdcee 100644 --- a/api-control-plane/pom.xml +++ b/api-control-plane/pom.xml @@ -1289,7 +1289,6 @@ 9.3.49 - 9.32.75 [9.0.0, 10.0.0) diff --git a/gateway/pom.xml b/gateway/pom.xml index d87e6e4c16..6a44c02e8a 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -1289,7 +1289,6 @@ 9.3.49 - 9.32.75 [9.0.0, 10.0.0) diff --git a/traffic-manager/pom.xml b/traffic-manager/pom.xml index 55563ea770..1788376920 100644 --- a/traffic-manager/pom.xml +++ b/traffic-manager/pom.xml @@ -1289,7 +1289,6 @@ 9.3.49 - 9.32.75 [9.0.0, 10.0.0)