Skip to content

Commit

Permalink
Adding integration test cases for APIProduct Versioning (#13286)
Browse files Browse the repository at this point in the history
  • Loading branch information
HiranyaKavishani authored Dec 28, 2023
1 parent abd515e commit 8d0732d
Show file tree
Hide file tree
Showing 18 changed files with 668 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e8e65082ff752153ae78c9fa8bbb657df3d59b3273fb70c9dcac53fc4f8915b3
98955626332fa43085771a8f446ec2195a5b9335f93b89baf64b29bafcafbedd
100 changes: 100 additions & 0 deletions modules/integration/tests-common/clients/publisher/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11899,6 +11899,95 @@ paths:
source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8"
"https://127.0.0.1:9443/api/am/publisher/v4/api-products/890a4f4d-09eb-4877-a323-57f6ce2ed79b/restore-revision?revisionId=e0824883-3e86-403a-aec1-22bbc454eb7c"'
x-accepts: application/json
/api-products/copy-api-products:
post:
description: |
This operation can be used to create a new version of an existing API Products. The new version is specified as `newVersion` query parameter. New API Product will be in `CREATED` state.
operationId: createNewAPIProductVersion
parameters:
- description: Version of the new API Product.
explode: true
in: query
name: newVersion
required: true
schema:
maxLength: 30
type: string
style: form
- description: Specifies whether new API Product should be added as default
version.
explode: true
in: query
name: defaultVersion
required: false
schema:
default: false
type: boolean
style: form
- description: |
**API Product ID** consisting of the **UUID** of the API Product.
The combination of the provider, name and the version of the API Product is also accepted as a valid API Product ID.
Should be formatted as **provider-name-version**.
explode: true
in: query
name: apiProductId
required: true
schema:
type: string
style: form
responses:
"201":
content:
application/json:
schema:
$ref: '#/components/schemas/APIProduct'
description: |
Created.
Successful response with the newly created API Product as entity in the body. Location header contains URL of newly created API Product.
headers:
Location:
description: |
The URL of the newly created API Product.
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.
security:
- OAuth2Security:
- apim:api_publish
- apim:api_manage
summary: Create a New API Product Version
tags:
- API Products
x-code-samples:
- lang: Curl
source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8"
"https://127.0.0.1:9443/api/am/publisher/v4/api-products/copy-api-products?newVersion=2.0&defaultVersion=false&apiproductId=2fd14eb8-b828-4013-b448-0739d2e76bf7"'
x-accepts: application/json
/api-products/export:
get:
description: |
Expand Down Expand Up @@ -17082,12 +17171,14 @@ components:
transport:
- http
- https
version: 1.0.0
tags:
- pizza
- food
revisionId: 1
visibleTenants: []
cacheTimeout: 300
isDefaultVersion: false
apis:
- name: PizzaShackAPI
apiId: 01234567-0123-0123-0123-012345678901
Expand Down Expand Up @@ -17139,6 +17230,12 @@ components:
maxLength: 60
minLength: 1
type: string
version:
example: 1.0.0
maxLength: 30
minLength: 1
pattern: ^[^~!@#;:%^*()+={}|\\<>"',&/$\[\]\s+\/]+$
type: string
description:
description: A brief description about the API
example: This is a simple API for Pizza Shack online pizza delivery store
Expand All @@ -17160,6 +17257,9 @@ components:
enableSchemaValidation:
example: false
type: boolean
isDefaultVersion:
example: false
type: boolean
isRevision:
example: false
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Name | Type | Description | Notes
**policies** | **List&lt;String&gt;** | | [optional]
**apiThrottlingPolicy** | **String** | The API level throttling policy selected for the particular API | [optional]
**authorizationHeader** | **String** | Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified in tenant or system level will be used. | [optional]
**apiKeyHeader** | **String** | Name of the API key header used for invoking the API. If it is not set, default value &#x60;apiKey&#x60; will be used. | [optional]
**securityScheme** | **List&lt;String&gt;** | Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If it is not set OAuth2 will be set as the security for the current API. | [optional]
**maxTps** | [**APIMaxTpsDTO**](APIMaxTpsDTO.md) | | [optional]
**visibility** | [**VisibilityEnum**](#VisibilityEnum) | The visibility level of the API. Accepts one of the following. PUBLIC, PRIVATE, RESTRICTED. | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Name | Type | Description | Notes
**id** | **String** | UUID of the api product | [optional] [readonly]
**name** | **String** | Name of the API Product |
**context** | **String** | | [optional]
**version** | **String** | | [optional]
**description** | **String** | A brief description about the API | [optional]
**provider** | **String** | If the provider value is not given, the user invoking the API will be used as the provider. | [optional]
**hasThumbnail** | **Boolean** | | [optional]
**state** | **String** | State of the API product. Only published api products are visible on the Developer Portal | [optional]
**enableSchemaValidation** | **Boolean** | | [optional]
**isDefaultVersion** | **Boolean** | | [optional]
**isRevision** | **Boolean** | | [optional]
**revisionedApiProductId** | **String** | UUID of the api product registry artifact | [optional] [readonly]
**revisionId** | **Integer** | | [optional]
Expand All @@ -30,6 +32,7 @@ Name | Type | Description | Notes
**policies** | **List&lt;String&gt;** | | [optional]
**apiThrottlingPolicy** | **String** | The API level throttling policy selected for the particular API Product | [optional]
**authorizationHeader** | **String** | Name of the Authorization header used for invoking the API. If it is not set, Authorization header name specified in tenant or system level will be used. | [optional]
**apiKeyHeader** | **String** | Name of the API key header used for invoking the API. If it is not set, default value &#x60;apiKey&#x60; will be used. | [optional]
**securityScheme** | **List&lt;String&gt;** | Types of API security, the current API secured with. It can be either OAuth2 or mutual SSL or both. If it is not set OAuth2 will be set as the security for the current API. | [optional]
**subscriptionAvailability** | [**SubscriptionAvailabilityEnum**](#SubscriptionAvailabilityEnum) | The subscription availability. Accepts one of the following. CURRENT_TENANT, ALL_TENANTS or SPECIFIC_TENANTS. | [optional]
**subscriptionAvailableTenants** | **List&lt;String&gt;** | | [optional]
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
------------- | ------------- | -------------
[**createAPIProduct**](ApiProductsApi.md#createAPIProduct) | **POST** /api-products | Create a New API Product
[**createNewAPIProductVersion**](ApiProductsApi.md#createNewAPIProductVersion) | **POST** /api-products/copy-api-products | Create a New API Product Version
[**deleteAPIProduct**](ApiProductsApi.md#deleteAPIProduct) | **DELETE** /api-products/{apiProductId} | Delete an API Product
[**getAPIProduct**](ApiProductsApi.md#getAPIProduct) | **GET** /api-products/{apiProductId} | Get Details of an API Product
[**getAPIProductSwagger**](ApiProductsApi.md#getAPIProductSwagger) | **GET** /api-products/{apiProductId}/swagger | Get Swagger Definition
Expand Down Expand Up @@ -84,6 +85,79 @@ Name | Type | Description | Notes
**400** | Bad Request. Invalid request or validation error. | - |
**415** | Unsupported Media Type. The entity of the request was not in a supported format. | - |

<a name="createNewAPIProductVersion"></a>
# **createNewAPIProductVersion**
> APIProductDTO createNewAPIProductVersion(newVersion, apiProductId, defaultVersion)
Create a New API Product Version

This operation can be used to create a new version of an existing API Products. The new version is specified as &#x60;newVersion&#x60; query parameter. New API Product will be in &#x60;CREATED&#x60; state.

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

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

ApiProductsApi apiInstance = new ApiProductsApi(defaultClient);
String newVersion = "newVersion_example"; // String | Version of the new API Product.
String apiProductId = "apiProductId_example"; // String | **API Product ID** consisting of the **UUID** of the API Product. The combination of the provider, name and the version of the API Product is also accepted as a valid API Product ID. Should be formatted as **provider-name-version**.
Boolean defaultVersion = false; // Boolean | Specifies whether new API Product should be added as default version.
try {
APIProductDTO result = apiInstance.createNewAPIProductVersion(newVersion, apiProductId, defaultVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ApiProductsApi#createNewAPIProductVersion");
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
------------- | ------------- | ------------- | -------------
**newVersion** | **String**| Version of the new API Product. |
**apiProductId** | **String**| **API Product ID** consisting of the **UUID** of the API Product. The combination of the provider, name and the version of the API Product is also accepted as a valid API Product ID. Should be formatted as **provider-name-version**. |
**defaultVersion** | **Boolean**| Specifies whether new API Product should be added as default version. | [optional] [default to false]

### Return type

[**APIProductDTO**](APIProductDTO.md)

### Authorization

[OAuth2Security](../README.md#OAuth2Security)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: application/json

### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**201** | Created. Successful response with the newly created API Product as entity in the body. Location header contains URL of newly created API Product. | * Location - The URL of the newly created API Product. <br> |
**400** | Bad Request. Invalid request or validation error. | - |
**404** | Not Found. The specified resource does not exist. | - |

<a name="deleteAPIProduct"></a>
# **deleteAPIProduct**
> deleteAPIProduct(apiProductId, ifMatch)
Expand Down
Loading

0 comments on commit 8d0732d

Please sign in to comment.