Skip to content

Commit

Permalink
Merge pull request #13493 from Chanuka-ChandraYapa/feature-throttle-p…
Browse files Browse the repository at this point in the history
…olicy-reset

Integration Tests for Throttle Policy Reset Support Feature
  • Loading branch information
rmsamitha authored May 22, 2024
2 parents 5c0a78e + 621e93f commit f9e0982
Show file tree
Hide file tree
Showing 11 changed files with 800 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b0032ad4fd9a2bc3c6aa1c1388ea751b0dcae3bde72935174af004ec4fcc05be
b238de2bfe4a4407554a1b438bc5dc2854ff5aaeb86d65993f32287fd7021c67
101 changes: 101 additions & 0 deletions modules/integration/tests-common/clients/store/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5781,6 +5781,99 @@ paths:
- lang: Curl
source: curl -k "https://localhost:9443/api/am/devportal/v2/throttling-policies/application/10PerMin"
x-accepts: application/json
/applications/{applicationId}/reset-throttle-policy:
post:
description: |
This operation can be used to reset the application-level throttle policy for a specific user.
parameters:
- description: |
Application Identifier consisting of the UUID of the Application.
explode: false
in: path
name: applicationId
required: true
schema:
type: string
style: simple
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ApplicationThrottleReset'
description: |
Payload for which the application-level throttle policy needs to be reset
required: true
responses:
"200":
content: {}
description: OK. Application-level throttle policy reset successfully
"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.
"401":
content:
application/json:
example:
code: 401
message: Unauthorized
description: The user is not authorized
moreInfo: ""
error: []
schema:
$ref: '#/components/schemas/Error'
description: Unauthorized. The user is not authorized.
"403":
content: {}
description: |
Forbidden.
The request must be conditional but no condition has been specified.
"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:app_manage
- apim:subscribe
summary: Reset Application-Level Throttle Policy
tags:
- Applications
x-code-samples:
- lang: Curl
source: 'curl -k \ -H "Authorization: Bearer 80249337-fe7c-3c66-bde6-ed431c144372"
\ -H "Content-Type: application/json" -X POST \ -d @payload.json \ "https://localhost:9443/api/am/devportal/v3/application/37dd21cc-631e-4c73-bf73-c59cc7087a63/reset-throttle-policy"'
x-contentType: application/json
x-accepts: application/json
/tags:
get:
description: |
Expand Down Expand Up @@ -8807,6 +8900,14 @@ components:
type: object
title: API Key generation request object
type: object
ApplicationThrottleReset:
properties:
userName:
description: The username for which the throttle policy needs to be reset
example: admin
type: string
title: Reset application level throttling
type: object
APIKeyRevokeRequest:
properties:
apikey:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


# ApplicationThrottleResetDTO

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**userName** | **String** | The username for which the throttle policy needs to be reset | [optional]



Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Method | HTTP request | Description
[**applicationsApplicationIdDelete**](ApplicationsApi.md#applicationsApplicationIdDelete) | **DELETE** /applications/{applicationId} | Remove an Application
[**applicationsApplicationIdGet**](ApplicationsApi.md#applicationsApplicationIdGet) | **GET** /applications/{applicationId} | Get Details of an Application
[**applicationsApplicationIdPut**](ApplicationsApi.md#applicationsApplicationIdPut) | **PUT** /applications/{applicationId} | Update an Application
[**applicationsApplicationIdResetThrottlePolicyPost**](ApplicationsApi.md#applicationsApplicationIdResetThrottlePolicyPost) | **POST** /applications/{applicationId}/reset-throttle-policy | Reset Application-Level Throttle Policy
[**applicationsGet**](ApplicationsApi.md#applicationsGet) | **GET** /applications | Retrieve/Search Applications
[**applicationsPost**](ApplicationsApi.md#applicationsPost) | **POST** /applications | Create a New Application

Expand Down Expand Up @@ -230,6 +231,79 @@ Name | Type | Description | Notes
**404** | Not Found. The specified resource does not exist. | - |
**412** | Precondition Failed. The request has not been performed because one of the preconditions is not met. | - |

<a name="applicationsApplicationIdResetThrottlePolicyPost"></a>
# **applicationsApplicationIdResetThrottlePolicyPost**
> applicationsApplicationIdResetThrottlePolicyPost(applicationId, applicationThrottleResetDTO)
Reset Application-Level Throttle Policy

This operation can be used to reset the application-level throttle policy for a specific user.

### Example
```java
// Import classes:
import org.wso2.am.integration.clients.store.api.ApiClient;
import org.wso2.am.integration.clients.store.api.ApiException;
import org.wso2.am.integration.clients.store.api.Configuration;
import org.wso2.am.integration.clients.store.api.auth.*;
import org.wso2.am.integration.clients.store.api.models.*;
import org.wso2.am.integration.clients.store.api.v1.ApplicationsApi;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://apis.wso2.com/api/am/devportal/v3");

// Configure OAuth2 access token for authorization: OAuth2Security
OAuth OAuth2Security = (OAuth) defaultClient.getAuthentication("OAuth2Security");
OAuth2Security.setAccessToken("YOUR ACCESS TOKEN");

ApplicationsApi apiInstance = new ApplicationsApi(defaultClient);
String applicationId = "applicationId_example"; // String | Application Identifier consisting of the UUID of the Application.
ApplicationThrottleResetDTO applicationThrottleResetDTO = new ApplicationThrottleResetDTO(); // ApplicationThrottleResetDTO | Payload for which the application-level throttle policy needs to be reset
try {
apiInstance.applicationsApplicationIdResetThrottlePolicyPost(applicationId, applicationThrottleResetDTO);
} catch (ApiException e) {
System.err.println("Exception when calling ApplicationsApi#applicationsApplicationIdResetThrottlePolicyPost");
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
------------- | ------------- | ------------- | -------------
**applicationId** | **String**| Application Identifier consisting of the UUID of the Application. |
**applicationThrottleResetDTO** | [**ApplicationThrottleResetDTO**](ApplicationThrottleResetDTO.md)| Payload for which the application-level throttle policy needs to be reset |

### Return type

null (empty response body)

### 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. Application-level throttle policy reset successfully | - |
**400** | Bad Request. Invalid request or validation error. | - |
**401** | Unauthorized. The user is not authorized. | - |
**403** | Forbidden. The request must be conditional but no condition has been specified. | - |
**404** | Not Found. The specified resource does not exist. | - |
**500** | Internal Server Error. | - |

<a name="applicationsGet"></a>
# **applicationsGet**
> ApplicationListDTO applicationsGet(groupId, query, sortBy, sortOrder, limit, offset, ifNoneMatch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationListDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationThrottleResetDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ErrorDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.WorkflowResponseDTO;

Expand Down Expand Up @@ -463,6 +464,142 @@ public okhttp3.Call applicationsApplicationIdPutAsync(String applicationId, Appl
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
/**
* Build call for applicationsApplicationIdResetThrottlePolicyPost
* @param applicationId Application Identifier consisting of the UUID of the Application. (required)
* @param applicationThrottleResetDTO Payload for which the application-level throttle policy needs to be reset (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
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> OK. Application-level throttle policy reset successfully </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </td><td> - </td></tr>
<tr><td> 401 </td><td> Unauthorized. The user is not authorized. </td><td> - </td></tr>
<tr><td> 403 </td><td> Forbidden. The request must be conditional but no condition has been specified. </td><td> - </td></tr>
<tr><td> 404 </td><td> Not Found. The specified resource does not exist. </td><td> - </td></tr>
<tr><td> 500 </td><td> Internal Server Error. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call applicationsApplicationIdResetThrottlePolicyPostCall(String applicationId, ApplicationThrottleResetDTO applicationThrottleResetDTO, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = applicationThrottleResetDTO;

// create path and map variables
String localVarPath = "/applications/{applicationId}/reset-throttle-policy"
.replaceAll("\\{" + "applicationId" + "\\}", localVarApiClient.escapeString(applicationId.toString()));

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
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 applicationsApplicationIdResetThrottlePolicyPostValidateBeforeCall(String applicationId, ApplicationThrottleResetDTO applicationThrottleResetDTO, final ApiCallback _callback) throws ApiException {

// verify the required parameter 'applicationId' is set
if (applicationId == null) {
throw new ApiException("Missing the required parameter 'applicationId' when calling applicationsApplicationIdResetThrottlePolicyPost(Async)");
}

// verify the required parameter 'applicationThrottleResetDTO' is set
if (applicationThrottleResetDTO == null) {
throw new ApiException("Missing the required parameter 'applicationThrottleResetDTO' when calling applicationsApplicationIdResetThrottlePolicyPost(Async)");
}


okhttp3.Call localVarCall = applicationsApplicationIdResetThrottlePolicyPostCall(applicationId, applicationThrottleResetDTO, _callback);
return localVarCall;

}

/**
* Reset Application-Level Throttle Policy
* This operation can be used to reset the application-level throttle policy for a specific user.
* @param applicationId Application Identifier consisting of the UUID of the Application. (required)
* @param applicationThrottleResetDTO Payload for which the application-level throttle policy needs to be reset (required)
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> OK. Application-level throttle policy reset successfully </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </td><td> - </td></tr>
<tr><td> 401 </td><td> Unauthorized. The user is not authorized. </td><td> - </td></tr>
<tr><td> 403 </td><td> Forbidden. The request must be conditional but no condition has been specified. </td><td> - </td></tr>
<tr><td> 404 </td><td> Not Found. The specified resource does not exist. </td><td> - </td></tr>
<tr><td> 500 </td><td> Internal Server Error. </td><td> - </td></tr>
</table>
*/
public void applicationsApplicationIdResetThrottlePolicyPost(String applicationId, ApplicationThrottleResetDTO applicationThrottleResetDTO) throws ApiException {
applicationsApplicationIdResetThrottlePolicyPostWithHttpInfo(applicationId, applicationThrottleResetDTO);
}

/**
* Reset Application-Level Throttle Policy
* This operation can be used to reset the application-level throttle policy for a specific user.
* @param applicationId Application Identifier consisting of the UUID of the Application. (required)
* @param applicationThrottleResetDTO Payload for which the application-level throttle policy needs to be reset (required)
* @return ApiResponse&lt;Void&gt;
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> OK. Application-level throttle policy reset successfully </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </td><td> - </td></tr>
<tr><td> 401 </td><td> Unauthorized. The user is not authorized. </td><td> - </td></tr>
<tr><td> 403 </td><td> Forbidden. The request must be conditional but no condition has been specified. </td><td> - </td></tr>
<tr><td> 404 </td><td> Not Found. The specified resource does not exist. </td><td> - </td></tr>
<tr><td> 500 </td><td> Internal Server Error. </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> applicationsApplicationIdResetThrottlePolicyPostWithHttpInfo(String applicationId, ApplicationThrottleResetDTO applicationThrottleResetDTO) throws ApiException {
okhttp3.Call localVarCall = applicationsApplicationIdResetThrottlePolicyPostValidateBeforeCall(applicationId, applicationThrottleResetDTO, null);
return localVarApiClient.execute(localVarCall);
}

/**
* Reset Application-Level Throttle Policy (asynchronously)
* This operation can be used to reset the application-level throttle policy for a specific user.
* @param applicationId Application Identifier consisting of the UUID of the Application. (required)
* @param applicationThrottleResetDTO Payload for which the application-level throttle policy needs to be reset (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
<table summary="Response Details" border="1">
<tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
<tr><td> 200 </td><td> OK. Application-level throttle policy reset successfully </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </td><td> - </td></tr>
<tr><td> 401 </td><td> Unauthorized. The user is not authorized. </td><td> - </td></tr>
<tr><td> 403 </td><td> Forbidden. The request must be conditional but no condition has been specified. </td><td> - </td></tr>
<tr><td> 404 </td><td> Not Found. The specified resource does not exist. </td><td> - </td></tr>
<tr><td> 500 </td><td> Internal Server Error. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call applicationsApplicationIdResetThrottlePolicyPostAsync(String applicationId, ApplicationThrottleResetDTO applicationThrottleResetDTO, final ApiCallback<Void> _callback) throws ApiException {

okhttp3.Call localVarCall = applicationsApplicationIdResetThrottlePolicyPostValidateBeforeCall(applicationId, applicationThrottleResetDTO, _callback);
localVarApiClient.executeAsync(localVarCall, _callback);
return localVarCall;
}
/**
* Build call for applicationsGet
* @param groupId Application Group Id (optional)
Expand Down
Loading

0 comments on commit f9e0982

Please sign in to comment.