Skip to content

Commit

Permalink
Added test for change subscription business plan forcefully
Browse files Browse the repository at this point in the history
  • Loading branch information
thisaltennakoon committed Jul 21, 2024
1 parent 140fe57 commit dcdbd5b
Show file tree
Hide file tree
Showing 9 changed files with 750 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7842,6 +7842,105 @@ paths:
source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8"
"https://127.0.0.1:9443/api/am/publisher/v4/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809"'
x-accepts: application/json
/subscriptions/change-business-plan:
post:
description: |
This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.
operationId: changeSubscriptionBusinessPlan
parameters:
- description: |
Subscription Id
explode: true
in: query
name: subscriptionId
required: true
schema:
type: string
style: form
- description: |
The business plan to be assigned to the subscription.
explode: true
in: query
name: businessPlan
required: true
schema:
type: string
style: form
- description: |
Validator for conditional requests; based on ETag.
explode: false
in: header
name: If-Match
required: false
schema:
type: string
style: simple
responses:
"200":
description: |
OK.
Subscription business plan was changed 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.
"403":
content:
application/json:
example:
code: 403
message: Forbidden
description: The request must be conditional but no condition has
been specified
moreInfo: ""
error: []
schema:
$ref: '#/components/schemas/Error'
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.
"409":
content:
application/json:
example:
code: 409
message: Conflict
description: Specified resource already exists
moreInfo: ""
error: []
schema:
$ref: '#/components/schemas/Error'
description: Conflict. Specified resource already exists.
security:
- OAuth2Security:
- apim:subscription_manage
summary: Change subscription business plan
tags:
- Subscriptions
x-code-samples:
- lang: Curl
source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8"
-X POST "https://127.0.0.1:9443/api/am/publisher/v4/subscriptions/change-business-plan?subscriptionId=92c50632-012f-4739-b37d-baa23008c813&businessPlan=Silver"'
x-accepts: application/json
/throttling-policies/{policyLevel}:
get:
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4*
Method | HTTP request | Description
------------- | ------------- | -------------
[**blockSubscription**](SubscriptionsApi.md#blockSubscription) | **POST** /subscriptions/block-subscription | Block a Subscription
[**changeSubscriptionBusinessPlan**](SubscriptionsApi.md#changeSubscriptionBusinessPlan) | **POST** /subscriptions/change-business-plan | Change subscription business plan
[**getSubscriptions**](SubscriptionsApi.md#getSubscriptions) | **GET** /subscriptions | Get all Subscriptions
[**unBlockSubscription**](SubscriptionsApi.md#unBlockSubscription) | **POST** /subscriptions/unblock-subscription | Unblock a Subscription

Expand Down Expand Up @@ -82,6 +83,80 @@ null (empty response body)
**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="changeSubscriptionBusinessPlan"></a>
# **changeSubscriptionBusinessPlan**
> changeSubscriptionBusinessPlan(subscriptionId, businessPlan, ifMatch)
Change subscription business plan

This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.

### 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.SubscriptionsApi;

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");

SubscriptionsApi apiInstance = new SubscriptionsApi(defaultClient);
String subscriptionId = "subscriptionId_example"; // String | Subscription Id
String businessPlan = "businessPlan_example"; // String | The business plan to be assigned to the subscription.
String ifMatch = "ifMatch_example"; // String | Validator for conditional requests; based on ETag.
try {
apiInstance.changeSubscriptionBusinessPlan(subscriptionId, businessPlan, ifMatch);
} catch (ApiException e) {
System.err.println("Exception when calling SubscriptionsApi#changeSubscriptionBusinessPlan");
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
------------- | ------------- | ------------- | -------------
**subscriptionId** | **String**| Subscription Id |
**businessPlan** | **String**| The business plan to be assigned to the subscription. |
**ifMatch** | **String**| Validator for conditional requests; based on ETag. | [optional]

### 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. Subscription business plan was changed successfully. | - |
**400** | Bad Request. Invalid request or validation error. | - |
**403** | Forbidden. The request must be conditional but no condition has been specified. | - |
**404** | Not Found. The specified resource does not exist. | - |
**409** | Conflict. Specified resource already exists. | - |

<a name="getSubscriptions"></a>
# **getSubscriptions**
> SubscriptionListDTO getSubscriptions(apiId, limit, offset, ifNoneMatch, query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,153 @@ public okhttp3.Call blockSubscriptionAsync(String subscriptionId, String blockSt
localVarApiClient.executeAsync(localVarCall, _callback);
return localVarCall;
}
/**
* Build call for changeSubscriptionBusinessPlan
* @param subscriptionId Subscription Id (required)
* @param businessPlan The business plan to be assigned to the subscription. (required)
* @param ifMatch Validator for conditional requests; based on ETag. (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
<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. Subscription business plan was changed successfully. </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </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> 409 </td><td> Conflict. Specified resource already exists. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call changeSubscriptionBusinessPlanCall(String subscriptionId, String businessPlan, String ifMatch, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;

// create path and map variables
String localVarPath = "/subscriptions/change-business-plan";

List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
if (subscriptionId != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("subscriptionId", subscriptionId));
}

if (businessPlan != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("businessPlan", businessPlan));
}

Map<String, String> localVarHeaderParams = new HashMap<String, String>();
if (ifMatch != null) {
localVarHeaderParams.put("If-Match", localVarApiClient.parameterToString(ifMatch));
}

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 = {

};
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 changeSubscriptionBusinessPlanValidateBeforeCall(String subscriptionId, String businessPlan, String ifMatch, final ApiCallback _callback) throws ApiException {

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

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


okhttp3.Call localVarCall = changeSubscriptionBusinessPlanCall(subscriptionId, businessPlan, ifMatch, _callback);
return localVarCall;

}

/**
* Change subscription business plan
* This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.
* @param subscriptionId Subscription Id (required)
* @param businessPlan The business plan to be assigned to the subscription. (required)
* @param ifMatch Validator for conditional requests; based on ETag. (optional)
* @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. Subscription business plan was changed successfully. </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </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> 409 </td><td> Conflict. Specified resource already exists. </td><td> - </td></tr>
</table>
*/
public void changeSubscriptionBusinessPlan(String subscriptionId, String businessPlan, String ifMatch) throws ApiException {
changeSubscriptionBusinessPlanWithHttpInfo(subscriptionId, businessPlan, ifMatch);
}

/**
* Change subscription business plan
* This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.
* @param subscriptionId Subscription Id (required)
* @param businessPlan The business plan to be assigned to the subscription. (required)
* @param ifMatch Validator for conditional requests; based on ETag. (optional)
* @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. Subscription business plan was changed successfully. </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </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> 409 </td><td> Conflict. Specified resource already exists. </td><td> - </td></tr>
</table>
*/
public ApiResponse<Void> changeSubscriptionBusinessPlanWithHttpInfo(String subscriptionId, String businessPlan, String ifMatch) throws ApiException {
okhttp3.Call localVarCall = changeSubscriptionBusinessPlanValidateBeforeCall(subscriptionId, businessPlan, ifMatch, null);
return localVarApiClient.execute(localVarCall);
}

/**
* Change subscription business plan (asynchronously)
* This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.
* @param subscriptionId Subscription Id (required)
* @param businessPlan The business plan to be assigned to the subscription. (required)
* @param ifMatch Validator for conditional requests; based on ETag. (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
<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. Subscription business plan was changed successfully. </td><td> - </td></tr>
<tr><td> 400 </td><td> Bad Request. Invalid request or validation error. </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> 409 </td><td> Conflict. Specified resource already exists. </td><td> - </td></tr>
</table>
*/
public okhttp3.Call changeSubscriptionBusinessPlanAsync(String subscriptionId, String businessPlan, String ifMatch, final ApiCallback<Void> _callback) throws ApiException {

okhttp3.Call localVarCall = changeSubscriptionBusinessPlanValidateBeforeCall(subscriptionId, businessPlan, ifMatch, _callback);
localVarApiClient.executeAsync(localVarCall, _callback);
return localVarCall;
}
/**
* Build call for getSubscriptions
* @param apiId **API ID** consisting of the **UUID** of the API. The combination of the provider of the API, name of the API and the version is also accepted as a valid API I. Should be formatted as **provider-name-version**. (optional)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4390,6 +4390,44 @@ paths:
"https://127.0.0.1:9443/api/am/publisher/v4/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809"'
operationId: unBlockSubscription

/subscriptions/change-business-plan:
post:
tags:
- Subscriptions
summary: Change subscription business plan
description: |
This operation can be used to change the business plan of a subscription specifying the subscription Id and the business plan.
parameters:
- $ref: '#/components/parameters/subscriptionId-Q'
- name: businessPlan
in: query
description: |
The business plan to be assigned to the subscription.
required: true
schema:
type: string
- $ref: '#/components/parameters/If-Match'
responses:
200:
description: |
OK.
Subscription business plan was changed successfully.
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Forbidden'
404:
$ref: '#/components/responses/NotFound'
409:
$ref: '#/components/responses/Conflict'
security:
- OAuth2Security:
- apim:subscription_manage
x-code-samples:
- lang: Curl
source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" -X POST
"https://127.0.0.1:9443/api/am/publisher/v4/subscriptions/change-business-plan?subscriptionId=92c50632-012f-4739-b37d-baa23008c813&businessPlan=Silver"'
operationId: changeSubscriptionBusinessPlan

######################################################
# The "Thorttling Tier Collection" resource APIs
Expand Down
Loading

0 comments on commit dcdbd5b

Please sign in to comment.