From e7c48ac0c358a115e6a9cb482604aa7c3d29c972 Mon Sep 17 00:00:00 2001 From: yasasrangika Date: Sun, 7 Jan 2024 21:04:06 +0530 Subject: [PATCH 1/4] add integration tests for gateway policy feature --- .../clients/publisher/api/openapi.yaml | 683 +++++++++++++++ .../publisher/docs/GatewayPoliciesApi.md | 439 ++++++++++ .../docs/GatewayPolicyDeploymentDTO.md | 14 + .../docs/GatewayPolicyMappingDataListDTO.md | 14 + .../GatewayPolicyMappingDeploymentInfoDTO.md | 15 + .../docs/GatewayPolicyMappingInfoDTO.md | 14 + .../docs/GatewayPolicyMappingsDTO.md | 16 + .../publisher/api/v1/GatewayPoliciesApi.java | 818 ++++++++++++++++++ .../v1/dto/GatewayPolicyDeploymentDTO.java | 155 ++++ .../dto/GatewayPolicyMappingDataListDTO.java | 161 ++++ ...GatewayPolicyMappingDeploymentInfoDTO.java | 188 ++++ .../v1/dto/GatewayPolicyMappingInfoDTO.java | 157 ++++ .../api/v1/dto/GatewayPolicyMappingsDTO.java | 216 +++++ .../src/main/resources/publisher-api.yaml | 365 ++++++++ .../test/impl/RestAPIPublisherImpl.java | 97 ++- .../APIManagerLifecycleBaseTest.java | 1 + .../gatewayPolicy/GatewayPolicyTestCase.java | 314 +++++++ 17 files changed, 3665 insertions(+), 2 deletions(-) create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPolicyDeploymentDTO.md create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDataListDTO.md create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDeploymentInfoDTO.md create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingInfoDTO.md create mode 100644 modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingsDTO.md create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyDeploymentDTO.java create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDataListDTO.java create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDeploymentInfoDTO.java create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingInfoDTO.java create mode 100644 modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingsDTO.java create mode 100644 modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java diff --git a/modules/integration/tests-common/clients/publisher/api/openapi.yaml b/modules/integration/tests-common/clients/publisher/api/openapi.yaml index d47406610b..cc8b54eba4 100644 --- a/modules/integration/tests-common/clients/publisher/api/openapi.yaml +++ b/modules/integration/tests-common/clients/publisher/api/openapi.yaml @@ -14706,6 +14706,503 @@ 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 + /gateway-policies: + get: + description: | + This operation provides you a list of all gateway policies mapping information. + operationId: getAllGatewayPolicies + parameters: + - description: | + Maximum size of policy array to return. + explode: true + in: query + name: limit + required: false + schema: + 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 + - description: | + **Search condition**. + + You can search in attributes by using an **"gatewayLabel:"** modifier. + + Eg. + The entry "gatewayLabel:gateway1" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on "gateway1". + + If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. + + Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) + explode: true + in: query + name: query + required: false + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappingDataList' + description: | + OK. + List of gateway policies is returned. + headers: + Content-Type: + description: The content type of the body. + explode: false + schema: + type: string + style: simple + "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:gateway_policy_view + - apim:gateway_policy_manage + summary: | + Get all gateway policies mapping information + tags: + - Gateway Policies + 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/gateway-policies"' + x-accepts: application/json + post: + description: | + This operation can be used to apply gateway policies to the request, response, fault flows. + operationId: addGatewayPoliciesToFlows + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + description: Policy details object that needs to be added. + required: true + responses: + "201": + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappingInfo' + description: | + OK. + Policy mapping created successfully. + headers: + Location: + description: | + The URL of the created gateway policy mapping. + explode: false + schema: + type: string + style: simple + 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:gateway_policy_manage + summary: Engage gateway policies to the request, response, fault flows + tags: + - Gateway Policies + 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/gateway-policies"' + x-contentType: application/json + x-accepts: application/json + /gateway-policies/{gatewayPolicyMappingId}: + delete: + description: | + This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + operationId: deleteGatewayPolicyByPolicyId + parameters: + - description: | + Gateway policy mapping Id + explode: false + in: path + name: gatewayPolicyMappingId + required: true + schema: + type: string + style: simple + responses: + "200": + content: {} + description: | + OK. + Resource successfully deleted. + "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. + "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:gateway_policy_manage + summary: Delete a gateway policy mapping + tags: + - Gateway Policies + 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/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + x-accepts: application/json + get: + description: | + This operation can be used to retrieve information of a selected gateway policy mapping. + operationId: getGatewayPolicyMappingContentByPolicyMappingId + parameters: + - description: | + Gateway policy mapping Id + explode: false + in: path + name: gatewayPolicyMappingId + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + description: | + OK. + Gateway policy mapping information returned. + headers: + Content-Type: + description: | + The content type of the body. + explode: false + schema: + type: string + style: simple + "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:gateway_policy_view + - apim:gateway_policy_manage + summary: Retrieve information of a selected gateway policy mapping + tags: + - Gateway Policies + 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/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + x-accepts: application/json + put: + description: | + This operation can be used to update already added gateway policies to the request, response, fault flows. + operationId: updateGatewayPoliciesToFlows + parameters: + - description: | + Gateway policy mapping Id + explode: false + in: path + name: gatewayPolicyMappingId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + description: Policy details object that needs to be updated. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + description: | + OK. + Policy mapping updated successfully. + 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:gateway_policy_manage + summary: Update gateway policies added to the request, response, fault flows + tags: + - Gateway Policies + 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/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + x-contentType: application/json + x-accepts: application/json + /gateway-policies/{gatewayPolicyMappingId}/deploy: + post: + description: | + This operation can be used to engage gateway policy mapping to the gateway/s. + operationId: engageGlobalPolicy + parameters: + - description: | + Gateway policy mapping Id + explode: false + in: path + name: gatewayPolicyMappingId + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/GatewayPolicyDeployment' + type: array + description: Policy details object that needs to be added. + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyDeployment' + description: | + OK. + Gateway policy mapping engaged successfully. + 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:gateway_policy_manage + summary: Engage gateway policy mapping to the gateways + tags: + - Gateway Policies + 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/gateway-policies/deploy"' + x-contentType: application/json + x-accepts: application/json /api-products/change-lifecycle: post: description: | @@ -15320,6 +15817,16 @@ components: schema: type: string style: simple + gatewayPolicyMappingId: + description: | + Gateway policy mapping Id + explode: false + in: path + name: gatewayPolicyMappingId + required: true + schema: + type: string + style: simple revisionId: description: | Revision ID of an API @@ -20384,6 +20891,182 @@ components: $ref: '#/components/schemas/OperationPolicy' type: array title: API Operation Level Policies + GatewayPolicyMappings: + example: + policyMapping: + request: + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + response: + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + fault: + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + - policyVersion: v1 + policyId: policyId + policyName: policyName + parameters: + key: '{}' + displayName: item_type_setter + description: Set header value to the request with item type and response header + set with served server name + id: 121223q41-24141-124124124-12414 + appliedGatewayLabels: + - gatewayLabel_1 + - gatewayLabel_1 + properties: + id: + example: 121223q41-24141-124124124-12414 + type: string + policyMapping: + $ref: '#/components/schemas/APIOperationPolicies' + description: + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header + set with served server name + type: string + displayName: + description: Meaningful name to identify the policy mapping + example: item_type_setter + type: string + appliedGatewayLabels: + items: + example: gatewayLabel_1 + type: string + type: array + required: + - displayName + - policyMapping + title: Gateway Policy Mappings + type: object + GatewayPolicyMappingDeploymentInfo: + example: + displayName: item_type_setter + description: Set header value to the request with item type and response header + set with served server name + id: 121223q41-24141-124124124-12414 + appliedGatewayLabels: + - gatewayLabel_1 + - gatewayLabel_1 + properties: + id: + example: 121223q41-24141-124124124-12414 + type: string + description: + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header + set with served server name + type: string + displayName: + description: Meaningful name to identify the policy mapping + example: item_type_setter + type: string + appliedGatewayLabels: + items: + example: gatewayLabel_1 + type: string + type: array + title: Gateway Policy Mapping and Deployment Information + type: object + GatewayPolicyMappingInfo: + example: + displayName: item_type_setter + description: Set header value to the request with item type and response header + set with served server name + id: 121223q41-24141-124124124-12414 + properties: + id: + example: 121223q41-24141-124124124-12414 + type: string + description: + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header + set with served server name + type: string + displayName: + description: Meaningful name to identify the policy mapping + example: item_type_setter + type: string + title: Gateway Policy Mapping Information + type: object + GatewayPolicyDeployment: + example: + gatewayLabel: gatewayLabel_1 + mappingUUID: 01234567-0123-0123-0123-012345678901 + gatewayDeployment: true + properties: + gatewayLabel: + example: gatewayLabel_1 + type: string + gatewayDeployment: + example: true + type: boolean + mappingUUID: + example: 01234567-0123-0123-0123-012345678901 + type: string + required: + - gatewayDeployment + - gatewayLabel + title: Details to map, deploy, undeploy policy mappings to gateways + type: object + GatewayPolicyMappingDataList: + example: + pagination: + next: next + total: 10 + offset: 0 + previous: previous + limit: 1 + count: 1 + list: + - displayName: item_type_setter + description: Set header value to the request with item type and response + header set with served server name + id: 121223q41-24141-124124124-12414 + appliedGatewayLabels: + - gatewayLabel_1 + - gatewayLabel_1 + - displayName: item_type_setter + description: Set header value to the request with item type and response + header set with served server name + id: 121223q41-24141-124124124-12414 + appliedGatewayLabels: + - gatewayLabel_1 + - gatewayLabel_1 + properties: + count: + description: | + Number of gateway policy mappings returned. + example: 1 + type: integer + list: + items: + $ref: '#/components/schemas/GatewayPolicyMappingDeploymentInfo' + type: array + pagination: + $ref: '#/components/schemas/Pagination' + title: Gateway Policy Mapping List + type: object GatewayEnvironmentProtocolURI: example: protocol: default diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md new file mode 100644 index 0000000000..3c951a90dd --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md @@ -0,0 +1,439 @@ +# GatewayPoliciesApi + +All URIs are relative to *https://apis.wso2.com/api/am/publisher/v4* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addGatewayPoliciesToFlows**](GatewayPoliciesApi.md#addGatewayPoliciesToFlows) | **POST** /gateway-policies | Engage gateway policies to the request, response, fault flows +[**deleteGatewayPolicyByPolicyId**](GatewayPoliciesApi.md#deleteGatewayPolicyByPolicyId) | **DELETE** /gateway-policies/{gatewayPolicyMappingId} | Delete a gateway policy mapping +[**engageGlobalPolicy**](GatewayPoliciesApi.md#engageGlobalPolicy) | **POST** /gateway-policies/{gatewayPolicyMappingId}/deploy | Engage gateway policy mapping to the gateways +[**getAllGatewayPolicies**](GatewayPoliciesApi.md#getAllGatewayPolicies) | **GET** /gateway-policies | Get all gateway policies mapping information +[**getGatewayPolicyMappingContentByPolicyMappingId**](GatewayPoliciesApi.md#getGatewayPolicyMappingContentByPolicyMappingId) | **GET** /gateway-policies/{gatewayPolicyMappingId} | Retrieve information of a selected gateway policy mapping +[**updateGatewayPoliciesToFlows**](GatewayPoliciesApi.md#updateGatewayPoliciesToFlows) | **PUT** /gateway-policies/{gatewayPolicyMappingId} | Update gateway policies added to the request, response, fault flows + + + +# **addGatewayPoliciesToFlows** +> GatewayPolicyMappingInfoDTO addGatewayPoliciesToFlows(gatewayPolicyMappingsDTO) + +Engage gateway policies to the request, response, fault flows + +This operation can be used to apply gateway policies to the request, response, fault flows. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO = new GatewayPolicyMappingsDTO(); // GatewayPolicyMappingsDTO | Policy details object that needs to be added. + try { + GatewayPolicyMappingInfoDTO result = apiInstance.addGatewayPoliciesToFlows(gatewayPolicyMappingsDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#addGatewayPoliciesToFlows"); + 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 +------------- | ------------- | ------------- | ------------- + **gatewayPolicyMappingsDTO** | [**GatewayPolicyMappingsDTO**](GatewayPolicyMappingsDTO.md)| Policy details object that needs to be added. | + +### Return type + +[**GatewayPolicyMappingInfoDTO**](GatewayPolicyMappingInfoDTO.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** | OK. Policy mapping created successfully. | * Location - The URL of the created gateway policy mapping.
* 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. | - | + + +# **deleteGatewayPolicyByPolicyId** +> deleteGatewayPolicyByPolicyId(gatewayPolicyMappingId) + +Delete a gateway policy mapping + +This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + String gatewayPolicyMappingId = "gatewayPolicyMappingId_example"; // String | Gateway policy mapping Id + try { + apiInstance.deleteGatewayPolicyByPolicyId(gatewayPolicyMappingId); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#deleteGatewayPolicyByPolicyId"); + 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 +------------- | ------------- | ------------- | ------------- + **gatewayPolicyMappingId** | **String**| Gateway policy mapping Id | + +### 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. Resource successfully deleted. | - | +**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. | - | + + +# **engageGlobalPolicy** +> GatewayPolicyDeploymentDTO engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO) + +Engage gateway policy mapping to the gateways + +This operation can be used to engage gateway policy mapping to the gateway/s. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + String gatewayPolicyMappingId = "gatewayPolicyMappingId_example"; // String | Gateway policy mapping Id + List gatewayPolicyDeploymentDTO = Arrays.asList(); // List | Policy details object that needs to be added. + try { + GatewayPolicyDeploymentDTO result = apiInstance.engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#engageGlobalPolicy"); + 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 +------------- | ------------- | ------------- | ------------- + **gatewayPolicyMappingId** | **String**| Gateway policy mapping Id | + **gatewayPolicyDeploymentDTO** | [**List<GatewayPolicyDeploymentDTO>**](GatewayPolicyDeploymentDTO.md)| Policy details object that needs to be added. | + +### Return type + +[**GatewayPolicyDeploymentDTO**](GatewayPolicyDeploymentDTO.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. Gateway policy mapping engaged successfully. | * 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. | - | + + +# **getAllGatewayPolicies** +> GatewayPolicyMappingDataListDTO getAllGatewayPolicies(limit, offset, query) + +Get all gateway policies mapping information + +This operation provides you a list of all gateway policies mapping information. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + Integer limit = 56; // Integer | Maximum size of policy array to return. + Integer offset = 0; // Integer | Starting point within the complete list of items qualified. + String query = "query_example"; // String | **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) + try { + GatewayPolicyMappingDataListDTO result = apiInstance.getAllGatewayPolicies(limit, offset, query); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#getAllGatewayPolicies"); + 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 +------------- | ------------- | ------------- | ------------- + **limit** | **Integer**| Maximum size of policy array to return. | [optional] + **offset** | **Integer**| Starting point within the complete list of items qualified. | [optional] [default to 0] + **query** | **String**| **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) | [optional] + +### Return type + +[**GatewayPolicyMappingDataListDTO**](GatewayPolicyMappingDataListDTO.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 gateway policies is returned. | * Content-Type - The content type of the body.
| +**404** | Not Found. The specified resource does not exist. | - | +**500** | Internal Server Error. | - | + + +# **getGatewayPolicyMappingContentByPolicyMappingId** +> GatewayPolicyMappingsDTO getGatewayPolicyMappingContentByPolicyMappingId(gatewayPolicyMappingId) + +Retrieve information of a selected gateway policy mapping + +This operation can be used to retrieve information of a selected gateway policy mapping. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + String gatewayPolicyMappingId = "gatewayPolicyMappingId_example"; // String | Gateway policy mapping Id + try { + GatewayPolicyMappingsDTO result = apiInstance.getGatewayPolicyMappingContentByPolicyMappingId(gatewayPolicyMappingId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#getGatewayPolicyMappingContentByPolicyMappingId"); + 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 +------------- | ------------- | ------------- | ------------- + **gatewayPolicyMappingId** | **String**| Gateway policy mapping Id | + +### Return type + +[**GatewayPolicyMappingsDTO**](GatewayPolicyMappingsDTO.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. Gateway policy mapping information returned. | * Content-Type - The content type of the body.
| +**404** | Not Found. The specified resource does not exist. | - | +**500** | Internal Server Error. | - | + + +# **updateGatewayPoliciesToFlows** +> GatewayPolicyMappingsDTO updateGatewayPoliciesToFlows(gatewayPolicyMappingId, gatewayPolicyMappingsDTO) + +Update gateway policies added to the request, response, fault flows + +This operation can be used to update already added gateway policies to the request, response, fault flows. + +### 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.GatewayPoliciesApi; + +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"); + + GatewayPoliciesApi apiInstance = new GatewayPoliciesApi(defaultClient); + String gatewayPolicyMappingId = "gatewayPolicyMappingId_example"; // String | Gateway policy mapping Id + GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO = new GatewayPolicyMappingsDTO(); // GatewayPolicyMappingsDTO | Policy details object that needs to be updated. + try { + GatewayPolicyMappingsDTO result = apiInstance.updateGatewayPoliciesToFlows(gatewayPolicyMappingId, gatewayPolicyMappingsDTO); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling GatewayPoliciesApi#updateGatewayPoliciesToFlows"); + 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 +------------- | ------------- | ------------- | ------------- + **gatewayPolicyMappingId** | **String**| Gateway policy mapping Id | + **gatewayPolicyMappingsDTO** | [**GatewayPolicyMappingsDTO**](GatewayPolicyMappingsDTO.md)| Policy details object that needs to be updated. | + +### Return type + +[**GatewayPolicyMappingsDTO**](GatewayPolicyMappingsDTO.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. Policy mapping updated successfully. | * 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. | - | + diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyDeploymentDTO.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyDeploymentDTO.md new file mode 100644 index 0000000000..79dc0a1ffb --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyDeploymentDTO.md @@ -0,0 +1,14 @@ + + +# GatewayPolicyDeploymentDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**gatewayLabel** | **String** | | +**gatewayDeployment** | **Boolean** | | +**mappingUUID** | **String** | | [optional] + + + diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDataListDTO.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDataListDTO.md new file mode 100644 index 0000000000..7167c0748c --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDataListDTO.md @@ -0,0 +1,14 @@ + + +# GatewayPolicyMappingDataListDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **Integer** | Number of gateway policy mappings returned. | [optional] +**list** | [**List<GatewayPolicyMappingDeploymentInfoDTO>**](GatewayPolicyMappingDeploymentInfoDTO.md) | | [optional] +**pagination** | [**PaginationDTO**](PaginationDTO.md) | | [optional] + + + diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDeploymentInfoDTO.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDeploymentInfoDTO.md new file mode 100644 index 0000000000..9217bce994 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingDeploymentInfoDTO.md @@ -0,0 +1,15 @@ + + +# GatewayPolicyMappingDeploymentInfoDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**description** | **String** | A brief description about the policy mapping | [optional] +**displayName** | **String** | Meaningful name to identify the policy mapping | [optional] +**appliedGatewayLabels** | **List<String>** | | [optional] + + + diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingInfoDTO.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingInfoDTO.md new file mode 100644 index 0000000000..6c6ca00fd9 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingInfoDTO.md @@ -0,0 +1,14 @@ + + +# GatewayPolicyMappingInfoDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**description** | **String** | A brief description about the policy mapping | [optional] +**displayName** | **String** | Meaningful name to identify the policy mapping | [optional] + + + diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingsDTO.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingsDTO.md new file mode 100644 index 0000000000..8b15209635 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPolicyMappingsDTO.md @@ -0,0 +1,16 @@ + + +# GatewayPolicyMappingsDTO + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | | [optional] +**policyMapping** | [**APIOperationPoliciesDTO**](APIOperationPoliciesDTO.md) | | +**description** | **String** | A brief description about the policy mapping | [optional] +**displayName** | **String** | Meaningful name to identify the policy mapping | +**appliedGatewayLabels** | **List<String>** | | [optional] + + + diff --git a/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java new file mode 100644 index 0000000000..8d1b042ac6 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java @@ -0,0 +1,818 @@ +/* + * 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.ErrorDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyDeploymentDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingDataListDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingInfoDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingsDTO; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GatewayPoliciesApi { + private ApiClient localVarApiClient; + + public GatewayPoliciesApi() { + this(Configuration.getDefaultApiClient()); + } + + public GatewayPoliciesApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + /** + * Build call for addGatewayPoliciesToFlows + * @param gatewayPolicyMappingsDTO Policy details 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 OK. Policy mapping created successfully. * Location - The URL of the created gateway policy mapping.
* 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 addGatewayPoliciesToFlowsCall(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = gatewayPolicyMappingsDTO; + + // create path and map variables + String localVarPath = "/gateway-policies"; + + 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 addGatewayPoliciesToFlowsValidateBeforeCall(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'gatewayPolicyMappingsDTO' is set + if (gatewayPolicyMappingsDTO == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingsDTO' when calling addGatewayPoliciesToFlows(Async)"); + } + + + okhttp3.Call localVarCall = addGatewayPoliciesToFlowsCall(gatewayPolicyMappingsDTO, _callback); + return localVarCall; + + } + + /** + * Engage gateway policies to the request, response, fault flows + * This operation can be used to apply gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingsDTO Policy details object that needs to be added. (required) + * @return GatewayPolicyMappingInfoDTO + * @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 OK. Policy mapping created successfully. * Location - The URL of the created gateway policy mapping.
* 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 GatewayPolicyMappingInfoDTO addGatewayPoliciesToFlows(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + ApiResponse localVarResp = addGatewayPoliciesToFlowsWithHttpInfo(gatewayPolicyMappingsDTO); + return localVarResp.getData(); + } + + /** + * Engage gateway policies to the request, response, fault flows + * This operation can be used to apply gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingsDTO Policy details object that needs to be added. (required) + * @return ApiResponse<GatewayPolicyMappingInfoDTO> + * @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 OK. Policy mapping created successfully. * Location - The URL of the created gateway policy mapping.
* 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 addGatewayPoliciesToFlowsWithHttpInfo(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + okhttp3.Call localVarCall = addGatewayPoliciesToFlowsValidateBeforeCall(gatewayPolicyMappingsDTO, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Engage gateway policies to the request, response, fault flows (asynchronously) + * This operation can be used to apply gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingsDTO Policy details 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 OK. Policy mapping created successfully. * Location - The URL of the created gateway policy mapping.
* 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 addGatewayPoliciesToFlowsAsync(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = addGatewayPoliciesToFlowsValidateBeforeCall(gatewayPolicyMappingsDTO, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteGatewayPolicyByPolicyId + * @param gatewayPolicyMappingId Gateway policy mapping 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. Resource successfully deleted. -
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. -
+ */ + public okhttp3.Call deleteGatewayPolicyByPolicyIdCall(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/gateway-policies/{gatewayPolicyMappingId}" + .replaceAll("\\{" + "gatewayPolicyMappingId" + "\\}", localVarApiClient.escapeString(gatewayPolicyMappingId.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 deleteGatewayPolicyByPolicyIdValidateBeforeCall(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'gatewayPolicyMappingId' is set + if (gatewayPolicyMappingId == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingId' when calling deleteGatewayPolicyByPolicyId(Async)"); + } + + + okhttp3.Call localVarCall = deleteGatewayPolicyByPolicyIdCall(gatewayPolicyMappingId, _callback); + return localVarCall; + + } + + /** + * Delete a gateway policy mapping + * This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping Id (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. Resource successfully deleted. -
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. -
+ */ + public void deleteGatewayPolicyByPolicyId(String gatewayPolicyMappingId) throws ApiException { + deleteGatewayPolicyByPolicyIdWithHttpInfo(gatewayPolicyMappingId); + } + + /** + * Delete a gateway policy mapping + * This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping Id (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. Resource successfully deleted. -
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. -
+ */ + public ApiResponse deleteGatewayPolicyByPolicyIdWithHttpInfo(String gatewayPolicyMappingId) throws ApiException { + okhttp3.Call localVarCall = deleteGatewayPolicyByPolicyIdValidateBeforeCall(gatewayPolicyMappingId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete a gateway policy mapping (asynchronously) + * This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping 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. Resource successfully deleted. -
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. -
+ */ + public okhttp3.Call deleteGatewayPolicyByPolicyIdAsync(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteGatewayPolicyByPolicyIdValidateBeforeCall(gatewayPolicyMappingId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for engageGlobalPolicy + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyDeploymentDTO Policy details 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
200 OK. Gateway policy mapping engaged successfully. * 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 engageGlobalPolicyCall(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = gatewayPolicyDeploymentDTO; + + // create path and map variables + String localVarPath = "/gateway-policies/{gatewayPolicyMappingId}/deploy" + .replaceAll("\\{" + "gatewayPolicyMappingId" + "\\}", localVarApiClient.escapeString(gatewayPolicyMappingId.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 engageGlobalPolicyValidateBeforeCall(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'gatewayPolicyMappingId' is set + if (gatewayPolicyMappingId == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingId' when calling engageGlobalPolicy(Async)"); + } + + // verify the required parameter 'gatewayPolicyDeploymentDTO' is set + if (gatewayPolicyDeploymentDTO == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyDeploymentDTO' when calling engageGlobalPolicy(Async)"); + } + + + okhttp3.Call localVarCall = engageGlobalPolicyCall(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO, _callback); + return localVarCall; + + } + + /** + * Engage gateway policy mapping to the gateways + * This operation can be used to engage gateway policy mapping to the gateway/s. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyDeploymentDTO Policy details object that needs to be added. (required) + * @return GatewayPolicyDeploymentDTO + * @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. Gateway policy mapping engaged successfully. * 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 GatewayPolicyDeploymentDTO engageGlobalPolicy(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { + ApiResponse localVarResp = engageGlobalPolicyWithHttpInfo(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + return localVarResp.getData(); + } + + /** + * Engage gateway policy mapping to the gateways + * This operation can be used to engage gateway policy mapping to the gateway/s. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyDeploymentDTO Policy details object that needs to be added. (required) + * @return ApiResponse<GatewayPolicyDeploymentDTO> + * @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. Gateway policy mapping engaged successfully. * 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 engageGlobalPolicyWithHttpInfo(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { + okhttp3.Call localVarCall = engageGlobalPolicyValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Engage gateway policy mapping to the gateways (asynchronously) + * This operation can be used to engage gateway policy mapping to the gateway/s. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyDeploymentDTO Policy details 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
200 OK. Gateway policy mapping engaged successfully. * 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 engageGlobalPolicyAsync(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = engageGlobalPolicyValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getAllGatewayPolicies + * @param limit Maximum size of policy array to return. (optional) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param query **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (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. List of gateway policies is returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getAllGatewayPoliciesCall(Integer limit, Integer offset, String query, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/gateway-policies"; + + 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)); + } + + if (query != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("query", query)); + } + + 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 getAllGatewayPoliciesValidateBeforeCall(Integer limit, Integer offset, String query, final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getAllGatewayPoliciesCall(limit, offset, query, _callback); + return localVarCall; + + } + + /** + * Get all gateway policies mapping information + * This operation provides you a list of all gateway policies mapping information. + * @param limit Maximum size of policy array to return. (optional) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param query **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional) + * @return GatewayPolicyMappingDataListDTO + * @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 gateway policies is returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public GatewayPolicyMappingDataListDTO getAllGatewayPolicies(Integer limit, Integer offset, String query) throws ApiException { + ApiResponse localVarResp = getAllGatewayPoliciesWithHttpInfo(limit, offset, query); + return localVarResp.getData(); + } + + /** + * Get all gateway policies mapping information + * This operation provides you a list of all gateway policies mapping information. + * @param limit Maximum size of policy array to return. (optional) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param query **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (optional) + * @return ApiResponse<GatewayPolicyMappingDataListDTO> + * @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 gateway policies is returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public ApiResponse getAllGatewayPoliciesWithHttpInfo(Integer limit, Integer offset, String query) throws ApiException { + okhttp3.Call localVarCall = getAllGatewayPoliciesValidateBeforeCall(limit, offset, query, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get all gateway policies mapping information (asynchronously) + * This operation provides you a list of all gateway policies mapping information. + * @param limit Maximum size of policy array to return. (optional) + * @param offset Starting point within the complete list of items qualified. (optional, default to 0) + * @param query **Search condition**. You can search in attributes by using an **\"gatewayLabel:\"** modifier. Eg. The entry \"gatewayLabel:gateway1\" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on \"gateway1\". If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) (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. List of gateway policies is returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getAllGatewayPoliciesAsync(Integer limit, Integer offset, String query, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getAllGatewayPoliciesValidateBeforeCall(limit, offset, query, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getGatewayPolicyMappingContentByPolicyMappingId + * @param gatewayPolicyMappingId Gateway policy mapping 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. Gateway policy mapping information returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getGatewayPolicyMappingContentByPolicyMappingIdCall(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/gateway-policies/{gatewayPolicyMappingId}" + .replaceAll("\\{" + "gatewayPolicyMappingId" + "\\}", localVarApiClient.escapeString(gatewayPolicyMappingId.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 getGatewayPolicyMappingContentByPolicyMappingIdValidateBeforeCall(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'gatewayPolicyMappingId' is set + if (gatewayPolicyMappingId == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingId' when calling getGatewayPolicyMappingContentByPolicyMappingId(Async)"); + } + + + okhttp3.Call localVarCall = getGatewayPolicyMappingContentByPolicyMappingIdCall(gatewayPolicyMappingId, _callback); + return localVarCall; + + } + + /** + * Retrieve information of a selected gateway policy mapping + * This operation can be used to retrieve information of a selected gateway policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @return GatewayPolicyMappingsDTO + * @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. Gateway policy mapping information returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public GatewayPolicyMappingsDTO getGatewayPolicyMappingContentByPolicyMappingId(String gatewayPolicyMappingId) throws ApiException { + ApiResponse localVarResp = getGatewayPolicyMappingContentByPolicyMappingIdWithHttpInfo(gatewayPolicyMappingId); + return localVarResp.getData(); + } + + /** + * Retrieve information of a selected gateway policy mapping + * This operation can be used to retrieve information of a selected gateway policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @return ApiResponse<GatewayPolicyMappingsDTO> + * @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. Gateway policy mapping information returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public ApiResponse getGatewayPolicyMappingContentByPolicyMappingIdWithHttpInfo(String gatewayPolicyMappingId) throws ApiException { + okhttp3.Call localVarCall = getGatewayPolicyMappingContentByPolicyMappingIdValidateBeforeCall(gatewayPolicyMappingId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Retrieve information of a selected gateway policy mapping (asynchronously) + * This operation can be used to retrieve information of a selected gateway policy mapping. + * @param gatewayPolicyMappingId Gateway policy mapping 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. Gateway policy mapping information returned. * Content-Type - The content type of the body.
404 Not Found. The specified resource does not exist. -
500 Internal Server Error. -
+ */ + public okhttp3.Call getGatewayPolicyMappingContentByPolicyMappingIdAsync(String gatewayPolicyMappingId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGatewayPolicyMappingContentByPolicyMappingIdValidateBeforeCall(gatewayPolicyMappingId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for updateGatewayPoliciesToFlows + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyMappingsDTO Policy details object that needs to be updated. (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. Policy mapping updated successfully. * 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 updateGatewayPoliciesToFlowsCall(String gatewayPolicyMappingId, GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = gatewayPolicyMappingsDTO; + + // create path and map variables + String localVarPath = "/gateway-policies/{gatewayPolicyMappingId}" + .replaceAll("\\{" + "gatewayPolicyMappingId" + "\\}", localVarApiClient.escapeString(gatewayPolicyMappingId.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 updateGatewayPoliciesToFlowsValidateBeforeCall(String gatewayPolicyMappingId, GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'gatewayPolicyMappingId' is set + if (gatewayPolicyMappingId == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingId' when calling updateGatewayPoliciesToFlows(Async)"); + } + + // verify the required parameter 'gatewayPolicyMappingsDTO' is set + if (gatewayPolicyMappingsDTO == null) { + throw new ApiException("Missing the required parameter 'gatewayPolicyMappingsDTO' when calling updateGatewayPoliciesToFlows(Async)"); + } + + + okhttp3.Call localVarCall = updateGatewayPoliciesToFlowsCall(gatewayPolicyMappingId, gatewayPolicyMappingsDTO, _callback); + return localVarCall; + + } + + /** + * Update gateway policies added to the request, response, fault flows + * This operation can be used to update already added gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyMappingsDTO Policy details object that needs to be updated. (required) + * @return GatewayPolicyMappingsDTO + * @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. Policy mapping updated successfully. * 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 GatewayPolicyMappingsDTO updateGatewayPoliciesToFlows(String gatewayPolicyMappingId, GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + ApiResponse localVarResp = updateGatewayPoliciesToFlowsWithHttpInfo(gatewayPolicyMappingId, gatewayPolicyMappingsDTO); + return localVarResp.getData(); + } + + /** + * Update gateway policies added to the request, response, fault flows + * This operation can be used to update already added gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyMappingsDTO Policy details object that needs to be updated. (required) + * @return ApiResponse<GatewayPolicyMappingsDTO> + * @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. Policy mapping updated successfully. * 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 updateGatewayPoliciesToFlowsWithHttpInfo(String gatewayPolicyMappingId, GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + okhttp3.Call localVarCall = updateGatewayPoliciesToFlowsValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyMappingsDTO, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update gateway policies added to the request, response, fault flows (asynchronously) + * This operation can be used to update already added gateway policies to the request, response, fault flows. + * @param gatewayPolicyMappingId Gateway policy mapping Id (required) + * @param gatewayPolicyMappingsDTO Policy details object that needs to be updated. (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. Policy mapping updated successfully. * 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 updateGatewayPoliciesToFlowsAsync(String gatewayPolicyMappingId, GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateGatewayPoliciesToFlowsValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyMappingsDTO, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyDeploymentDTO.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyDeploymentDTO.java new file mode 100644 index 0000000000..4dd60b37c4 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyDeploymentDTO.java @@ -0,0 +1,155 @@ +/* + * 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; +/** +* GatewayPolicyDeploymentDTO +*/ + +public class GatewayPolicyDeploymentDTO { + public static final String SERIALIZED_NAME_GATEWAY_LABEL = "gatewayLabel"; + @SerializedName(SERIALIZED_NAME_GATEWAY_LABEL) + private String gatewayLabel; + + public static final String SERIALIZED_NAME_GATEWAY_DEPLOYMENT = "gatewayDeployment"; + @SerializedName(SERIALIZED_NAME_GATEWAY_DEPLOYMENT) + private Boolean gatewayDeployment; + + public static final String SERIALIZED_NAME_MAPPING_U_U_I_D = "mappingUUID"; + @SerializedName(SERIALIZED_NAME_MAPPING_U_U_I_D) + private String mappingUUID; + + + public GatewayPolicyDeploymentDTO gatewayLabel(String gatewayLabel) { + + this.gatewayLabel = gatewayLabel; + return this; + } + + /** + * Get gatewayLabel + * @return gatewayLabel + **/ + @ApiModelProperty(example = "gatewayLabel_1", required = true, value = "") + + public String getGatewayLabel() { + return gatewayLabel; + } + + + public void setGatewayLabel(String gatewayLabel) { + this.gatewayLabel = gatewayLabel; + } + + + public GatewayPolicyDeploymentDTO gatewayDeployment(Boolean gatewayDeployment) { + + this.gatewayDeployment = gatewayDeployment; + return this; + } + + /** + * Get gatewayDeployment + * @return gatewayDeployment + **/ + @ApiModelProperty(example = "true", required = true, value = "") + + public Boolean isGatewayDeployment() { + return gatewayDeployment; + } + + + public void setGatewayDeployment(Boolean gatewayDeployment) { + this.gatewayDeployment = gatewayDeployment; + } + + + public GatewayPolicyDeploymentDTO mappingUUID(String mappingUUID) { + + this.mappingUUID = mappingUUID; + return this; + } + + /** + * Get mappingUUID + * @return mappingUUID + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "01234567-0123-0123-0123-012345678901", value = "") + + public String getMappingUUID() { + return mappingUUID; + } + + + public void setMappingUUID(String mappingUUID) { + this.mappingUUID = mappingUUID; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GatewayPolicyDeploymentDTO gatewayPolicyDeployment = (GatewayPolicyDeploymentDTO) o; + return Objects.equals(this.gatewayLabel, gatewayPolicyDeployment.gatewayLabel) && + Objects.equals(this.gatewayDeployment, gatewayPolicyDeployment.gatewayDeployment) && + Objects.equals(this.mappingUUID, gatewayPolicyDeployment.mappingUUID); + } + + @Override + public int hashCode() { + return Objects.hash(gatewayLabel, gatewayDeployment, mappingUUID); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class GatewayPolicyDeploymentDTO {\n"); + sb.append(" gatewayLabel: ").append(toIndentedString(gatewayLabel)).append("\n"); + sb.append(" gatewayDeployment: ").append(toIndentedString(gatewayDeployment)).append("\n"); + sb.append(" mappingUUID: ").append(toIndentedString(mappingUUID)).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/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDataListDTO.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDataListDTO.java new file mode 100644 index 0000000000..bde8c99d82 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDataListDTO.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.GatewayPolicyMappingDeploymentInfoDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.PaginationDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* GatewayPolicyMappingDataListDTO +*/ + +public class GatewayPolicyMappingDataListDTO { + 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 GatewayPolicyMappingDataListDTO count(Integer count) { + + this.count = count; + return this; + } + + /** + * Number of gateway policy mappings returned. + * @return count + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "1", value = "Number of gateway policy mappings returned. ") + + public Integer getCount() { + return count; + } + + + public void setCount(Integer count) { + this.count = count; + } + + + public GatewayPolicyMappingDataListDTO 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 GatewayPolicyMappingDataListDTO 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; + } + GatewayPolicyMappingDataListDTO gatewayPolicyMappingDataList = (GatewayPolicyMappingDataListDTO) o; + return Objects.equals(this.count, gatewayPolicyMappingDataList.count) && + Objects.equals(this.list, gatewayPolicyMappingDataList.list) && + Objects.equals(this.pagination, gatewayPolicyMappingDataList.pagination); + } + + @Override + public int hashCode() { + return Objects.hash(count, list, pagination); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class GatewayPolicyMappingDataListDTO {\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/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDeploymentInfoDTO.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDeploymentInfoDTO.java new file mode 100644 index 0000000000..d733b45506 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingDeploymentInfoDTO.java @@ -0,0 +1,188 @@ +/* + * 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; +/** +* GatewayPolicyMappingDeploymentInfoDTO +*/ + +public class GatewayPolicyMappingDeploymentInfoDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + private String displayName; + + public static final String SERIALIZED_NAME_APPLIED_GATEWAY_LABELS = "appliedGatewayLabels"; + @SerializedName(SERIALIZED_NAME_APPLIED_GATEWAY_LABELS) + private List appliedGatewayLabels = null; + + + public GatewayPolicyMappingDeploymentInfoDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "121223q41-24141-124124124-12414", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public GatewayPolicyMappingDeploymentInfoDTO description(String description) { + + this.description = description; + return this; + } + + /** + * A brief description about the policy mapping + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Set header value to the request with item type and response header set with served server name", value = "A brief description about the policy mapping") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public GatewayPolicyMappingDeploymentInfoDTO displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + /** + * Meaningful name to identify the policy mapping + * @return displayName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "item_type_setter", value = "Meaningful name to identify the policy mapping") + + public String getDisplayName() { + return displayName; + } + + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + public GatewayPolicyMappingDeploymentInfoDTO appliedGatewayLabels(List appliedGatewayLabels) { + + this.appliedGatewayLabels = appliedGatewayLabels; + return this; + } + + /** + * Get appliedGatewayLabels + * @return appliedGatewayLabels + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getAppliedGatewayLabels() { + return appliedGatewayLabels; + } + + + public void setAppliedGatewayLabels(List appliedGatewayLabels) { + this.appliedGatewayLabels = appliedGatewayLabels; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GatewayPolicyMappingDeploymentInfoDTO gatewayPolicyMappingDeploymentInfo = (GatewayPolicyMappingDeploymentInfoDTO) o; + return Objects.equals(this.id, gatewayPolicyMappingDeploymentInfo.id) && + Objects.equals(this.description, gatewayPolicyMappingDeploymentInfo.description) && + Objects.equals(this.displayName, gatewayPolicyMappingDeploymentInfo.displayName) && + Objects.equals(this.appliedGatewayLabels, gatewayPolicyMappingDeploymentInfo.appliedGatewayLabels); + } + + @Override + public int hashCode() { + return Objects.hash(id, description, displayName, appliedGatewayLabels); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class GatewayPolicyMappingDeploymentInfoDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" appliedGatewayLabels: ").append(toIndentedString(appliedGatewayLabels)).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/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingInfoDTO.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingInfoDTO.java new file mode 100644 index 0000000000..3ee14f38af --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingInfoDTO.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; +/** +* GatewayPolicyMappingInfoDTO +*/ + +public class GatewayPolicyMappingInfoDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + private String displayName; + + + public GatewayPolicyMappingInfoDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "121223q41-24141-124124124-12414", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public GatewayPolicyMappingInfoDTO description(String description) { + + this.description = description; + return this; + } + + /** + * A brief description about the policy mapping + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Set header value to the request with item type and response header set with served server name", value = "A brief description about the policy mapping") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public GatewayPolicyMappingInfoDTO displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + /** + * Meaningful name to identify the policy mapping + * @return displayName + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "item_type_setter", value = "Meaningful name to identify the policy mapping") + + public String getDisplayName() { + return displayName; + } + + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GatewayPolicyMappingInfoDTO gatewayPolicyMappingInfo = (GatewayPolicyMappingInfoDTO) o; + return Objects.equals(this.id, gatewayPolicyMappingInfo.id) && + Objects.equals(this.description, gatewayPolicyMappingInfo.description) && + Objects.equals(this.displayName, gatewayPolicyMappingInfo.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(id, description, displayName); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class GatewayPolicyMappingInfoDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).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/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingsDTO.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingsDTO.java new file mode 100644 index 0000000000..f393583776 --- /dev/null +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/dto/GatewayPolicyMappingsDTO.java @@ -0,0 +1,216 @@ +/* + * 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.APIOperationPoliciesDTO; +import com.fasterxml.jackson.annotation.JsonCreator; +/** +* GatewayPolicyMappingsDTO +*/ + +public class GatewayPolicyMappingsDTO { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_POLICY_MAPPING = "policyMapping"; + @SerializedName(SERIALIZED_NAME_POLICY_MAPPING) + private APIOperationPoliciesDTO policyMapping; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + private String displayName; + + public static final String SERIALIZED_NAME_APPLIED_GATEWAY_LABELS = "appliedGatewayLabels"; + @SerializedName(SERIALIZED_NAME_APPLIED_GATEWAY_LABELS) + private List appliedGatewayLabels = null; + + + public GatewayPolicyMappingsDTO id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "121223q41-24141-124124124-12414", value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public GatewayPolicyMappingsDTO policyMapping(APIOperationPoliciesDTO policyMapping) { + + this.policyMapping = policyMapping; + return this; + } + + /** + * Get policyMapping + * @return policyMapping + **/ + @ApiModelProperty(required = true, value = "") + + public APIOperationPoliciesDTO getPolicyMapping() { + return policyMapping; + } + + + public void setPolicyMapping(APIOperationPoliciesDTO policyMapping) { + this.policyMapping = policyMapping; + } + + + public GatewayPolicyMappingsDTO description(String description) { + + this.description = description; + return this; + } + + /** + * A brief description about the policy mapping + * @return description + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Set header value to the request with item type and response header set with served server name", value = "A brief description about the policy mapping") + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public GatewayPolicyMappingsDTO displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + /** + * Meaningful name to identify the policy mapping + * @return displayName + **/ + @ApiModelProperty(example = "item_type_setter", required = true, value = "Meaningful name to identify the policy mapping") + + public String getDisplayName() { + return displayName; + } + + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + public GatewayPolicyMappingsDTO appliedGatewayLabels(List appliedGatewayLabels) { + + this.appliedGatewayLabels = appliedGatewayLabels; + return this; + } + + /** + * Get appliedGatewayLabels + * @return appliedGatewayLabels + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public List getAppliedGatewayLabels() { + return appliedGatewayLabels; + } + + + public void setAppliedGatewayLabels(List appliedGatewayLabels) { + this.appliedGatewayLabels = appliedGatewayLabels; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GatewayPolicyMappingsDTO gatewayPolicyMappings = (GatewayPolicyMappingsDTO) o; + return Objects.equals(this.id, gatewayPolicyMappings.id) && + Objects.equals(this.policyMapping, gatewayPolicyMappings.policyMapping) && + Objects.equals(this.description, gatewayPolicyMappings.description) && + Objects.equals(this.displayName, gatewayPolicyMappings.displayName) && + Objects.equals(this.appliedGatewayLabels, gatewayPolicyMappings.appliedGatewayLabels); + } + + @Override + public int hashCode() { + return Objects.hash(id, policyMapping, description, displayName, appliedGatewayLabels); + } + + +@Override +public String toString() { +StringBuilder sb = new StringBuilder(); +sb.append("class GatewayPolicyMappingsDTO {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" policyMapping: ").append(toIndentedString(policyMapping)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" appliedGatewayLabels: ").append(toIndentedString(appliedGatewayLabels)).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/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml b/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml index 15c9492378..066e2a3b70 100644 --- a/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml +++ b/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml @@ -8223,6 +8223,272 @@ 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 Gateway Policies API + ###################################################### + /gateway-policies: + post: + tags: + - Gateway Policies + summary: Engage gateway policies to the request, response, fault flows + description: | + This operation can be used to apply gateway policies to the request, response, fault flows. + operationId: addGatewayPoliciesToFlows + requestBody: + description: Policy details object that needs to be added. + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + required: true + responses: + 201: + description: | + OK. + Policy mapping created successfully. + headers: + Location: + description: | + The URL of the created gateway policy mapping. + schema: + type: string + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappingInfo' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_manage + 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/gateway-policies"' + + get: + tags: + - Gateway Policies + summary: | + Get all gateway policies mapping information + description: | + This operation provides you a list of all gateway policies mapping information. + operationId: getAllGatewayPolicies + parameters: + - $ref: '#/components/parameters/policyLimit' + - $ref: '#/components/parameters/offset' + - name: query + in: query + description: | + **Search condition**. + + You can search in attributes by using an **"gatewayLabel:"** modifier. + + Eg. + The entry "gatewayLabel:gateway1" will result in a match with a Gateway Policy Mapping only if the policy mapping is deployed on "gateway1". + + If query attribute is provided, this returns the Gateway policy Mapping available under the given limit. + + Please note that you need to use encoded URL (URL encoding) if you are using a client which does not support URL encoding (such as curl) + schema: + type: string + responses: + 200: + description: | + OK. + List of gateway policies is returned. + headers: + Content-Type: + description: The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappingDataList' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_view + - apim:gateway_policy_manage + 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/gateway-policies"' + + /gateway-policies/{gatewayPolicyMappingId}: + get: + tags: + - Gateway Policies + summary: Retrieve information of a selected gateway policy mapping + description: | + This operation can be used to retrieve information of a selected gateway policy mapping. + operationId: getGatewayPolicyMappingContentByPolicyMappingId + parameters: + - $ref: '#/components/parameters/gatewayPolicyMappingId' + responses: + 200: + description: | + OK. + Gateway policy mapping information returned. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_view + - apim:gateway_policy_manage + 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/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + + delete: + tags: + - Gateway Policies + summary: Delete a gateway policy mapping + description: | + This operation can be used to delete an existing gateway policy mapping by providing the Id of the policy mapping. + operationId: deleteGatewayPolicyByPolicyId + parameters: + - $ref: '#/components/parameters/gatewayPolicyMappingId' + responses: + 200: + description: | + OK. + Resource successfully deleted. + content: { } + 403: + $ref: '#/components/responses/Forbidden' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_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/publisher/v4/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + + put: + tags: + - Gateway Policies + summary: Update gateway policies added to the request, response, fault flows + description: | + This operation can be used to update already added gateway policies to the request, response, fault flows. + operationId: updateGatewayPoliciesToFlows + parameters: + - $ref: '#/components/parameters/gatewayPolicyMappingId' + requestBody: + description: Policy details object that needs to be updated. + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + required: true + responses: + 200: + description: | + OK. + Policy mapping updated successfully. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyMappings' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_manage + 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/gateway-policies/f56eb8b4-128c-45aa-ad35-9c87a546261a"' + + /gateway-policies/{gatewayPolicyMappingId}/deploy: + post: + tags: + - Gateway Policies + summary: Engage gateway policy mapping to the gateways + description: | + This operation can be used to engage gateway policy mapping to the gateway/s. + operationId: engageGlobalPolicy + parameters: + - $ref: '#/components/parameters/gatewayPolicyMappingId' + requestBody: + description: Policy details object that needs to be added. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/GatewayPolicyDeployment' + required: true + responses: + 200: + description: | + OK. + Gateway policy mapping engaged successfully. + headers: + Content-Type: + description: | + The content type of the body. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/GatewayPolicyDeployment' + 400: + $ref: '#/components/responses/BadRequest' + 404: + $ref: '#/components/responses/NotFound' + 500: + $ref: '#/components/responses/InternalServerError' + security: + - OAuth2Security: + - apim:gateway_policy_manage + 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/gateway-policies/deploy"' + + /api-products/change-lifecycle: post: tags: @@ -11854,6 +12120,97 @@ components: type: array items: $ref: '#/components/schemas/OperationPolicy' + GatewayPolicyMappings: + title: Gateway Policy Mappings + type: object + required: + - policyMapping + - displayName + properties: + id: + type: string + example: 121223q41-24141-124124124-12414 + policyMapping: + $ref: '#/components/schemas/APIOperationPolicies' + description: + type: string + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header set with served server name + displayName: + type: string + description: Meaningful name to identify the policy mapping + example: item_type_setter + appliedGatewayLabels: + type: array + items: + type: string + example: gatewayLabel_1 + GatewayPolicyMappingDeploymentInfo: + title: Gateway Policy Mapping and Deployment Information + type: object + properties: + id: + type: string + example: 121223q41-24141-124124124-12414 + description: + type: string + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header set with served server name + displayName: + type: string + description: Meaningful name to identify the policy mapping + example: item_type_setter + appliedGatewayLabels: + type: array + items: + type: string + example: gatewayLabel_1 + GatewayPolicyMappingInfo: + title: Gateway Policy Mapping Information + type: object + properties: + id: + type: string + example: 121223q41-24141-124124124-12414 + description: + type: string + description: A brief description about the policy mapping + example: Set header value to the request with item type and response header set with served server name + displayName: + type: string + description: Meaningful name to identify the policy mapping + example: item_type_setter + GatewayPolicyDeployment: + title: Details to map, deploy, undeploy policy mappings to gateways + required: + - gatewayLabel + - gatewayDeployment + type: object + properties: + gatewayLabel: + type: string + example: gatewayLabel_1 + gatewayDeployment: + type: boolean + example: true + mappingUUID: + type: string + example: 01234567-0123-0123-0123-012345678901 + GatewayPolicyMappingDataList: + title: Gateway Policy Mapping List + type: object + properties: + count: + type: integer + description: | + Number of gateway policy mappings returned. + example: 1 + list: + type: array + items: + $ref: '#/components/schemas/GatewayPolicyMappingDeploymentInfo' + pagination: + $ref: '#/components/schemas/Pagination' GatewayEnvironmentProtocolURI: title: Gateway Environment protocols and URIs required: @@ -12263,6 +12620,14 @@ components: required: true schema: type: string + gatewayPolicyMappingId: + name: gatewayPolicyMappingId + in: path + description: | + Gateway policy mapping Id + required: true + schema: + type: string # API Revision Identifier # Specified as part of the path expression diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java index 49e473418a..a6e74cb072 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java @@ -44,9 +44,12 @@ import org.wso2.am.integration.clients.publisher.api.v1.ClientCertificatesApi; import org.wso2.am.integration.clients.publisher.api.v1.CommentsApi; import org.wso2.am.integration.clients.publisher.api.v1.EndpointCertificatesApi; +import org.wso2.am.integration.clients.publisher.api.v1.GatewayPoliciesApi; import org.wso2.am.integration.clients.publisher.api.v1.GraphQlPoliciesApi; import org.wso2.am.integration.clients.publisher.api.v1.GraphQlSchemaApi; import org.wso2.am.integration.clients.publisher.api.v1.GraphQlSchemaIndividualApi; +import org.wso2.am.integration.clients.publisher.api.v1.ImportExportApi; +import org.wso2.am.integration.clients.publisher.api.v1.LinterCustomRulesApi; import org.wso2.am.integration.clients.publisher.api.v1.OperationPoliciesApi; import org.wso2.am.integration.clients.publisher.api.v1.RolesApi; import org.wso2.am.integration.clients.publisher.api.v1.ScopesApi; @@ -55,8 +58,6 @@ import org.wso2.am.integration.clients.publisher.api.v1.ThrottlingPoliciesApi; import org.wso2.am.integration.clients.publisher.api.v1.UnifiedSearchApi; import org.wso2.am.integration.clients.publisher.api.v1.ValidationApi; -import org.wso2.am.integration.clients.publisher.api.v1.ImportExportApi; -import org.wso2.am.integration.clients.publisher.api.v1.LinterCustomRulesApi; 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.APIDTO; @@ -79,6 +80,9 @@ import org.wso2.am.integration.clients.publisher.api.v1.dto.CommentListDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.DocumentDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.DocumentListDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyDeploymentDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingInfoDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingsDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.GraphQLQueryComplexityInfoDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.GraphQLSchemaDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.GraphQLSchemaTypeListDTO; @@ -159,6 +163,7 @@ public class RestAPIPublisherImpl { private String disableVerification = System.getProperty("disableVerification"); private ApiOperationPoliciesApi apisOperationPoliciesApi = new ApiOperationPoliciesApi(); private OperationPoliciesApi operationPoliciesApi = new OperationPoliciesApi(); + private GatewayPoliciesApi gatewayPoliciesApi = new GatewayPoliciesApi(); private ImportExportApi importExportApi = new ImportExportApi(); @@ -2541,6 +2546,94 @@ public Map mapPolicyNameToId(OperationPolicyDataListDTO policyLi return policyMap; } + /** + * Add a new gateway policy + * + * @param gatewayPolicyMappingsDTO Gateway policy mapping DTO + * @return http response of add gateway policy + * @throws ApiException - throws if add gateway policy fails + */ + public HttpResponse addGatewayPolicy(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + + Gson gson = new Gson(); + ApiResponse addGatewayPolicyResponse = gatewayPoliciesApi.addGatewayPoliciesToFlowsWithHttpInfo( + gatewayPolicyMappingsDTO); + return new HttpResponse(gson.toJson(addGatewayPolicyResponse.getData()), addGatewayPolicyResponse.getStatusCode()); + } + + /** + * Deploy gateway policy + * + * @param gatewayPolicyMappingId Gateway policy mapping Id + * @param gatewayPolicyDeploymentDTO Gateway policy deployment DTO + * @return http response of add gateway policy + * @throws ApiException - throws if add gateway policy fails + */ + public HttpResponse deployGatewayPolicy(String gatewayPolicyMappingId, + List gatewayPolicyDeploymentDTO) throws ApiException { + + Gson gson = new Gson(); + ApiResponse policyDeployResponse = gatewayPoliciesApi.engageGlobalPolicyWithHttpInfo( + gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + return new HttpResponse(gson.toJson(policyDeployResponse.getData()), policyDeployResponse.getStatusCode()); + } + + /** + * Delete gateway policy + * + * @param gatewayPolicyMappingId Gateway policy mapping Id to be deleted + * @return http response of add gateway policy + * @throws ApiException - throws if add gateway policy fails + */ + public HttpResponse deleteGatewayPolicy(String gatewayPolicyMappingId) throws ApiException { + + Gson gson = new Gson(); + ApiResponse deleteResponse = gatewayPoliciesApi.deleteGatewayPolicyByPolicyIdWithHttpInfo( + gatewayPolicyMappingId); + HttpResponse response = null; + if (deleteResponse.getStatusCode() == 200) { + response = new HttpResponse("Successfully deleted the gateway policy", 200); + } + return response; + } + + /** + * Get gateway policy by policy mapping UUID + * + * @param gatewayPolicyMappingId Gateway policy mapping Id to be retrieved + * @return GatewayPolicyMappingsDTO Gateway policy mapping DTO + * @throws ApiException - throws if add gateway policy fails + */ + public GatewayPolicyMappingsDTO getGatewayPolicy(String gatewayPolicyMappingId) throws ApiException { + + setActivityID(); + ApiResponse getGatewayPolicyResponse = gatewayPoliciesApi.getGatewayPolicyMappingContentByPolicyMappingIdWithHttpInfo( + gatewayPolicyMappingId); + Assert.assertEquals(getGatewayPolicyResponse.getStatusCode(), HttpStatus.SC_OK, + "Unable to retrieve gateway policy for policy mapping Id " + gatewayPolicyMappingId + " " + + getGatewayPolicyResponse.getData()); + + return getGatewayPolicyResponse.getData(); + } + + /** + * Update gateway policy + * + * @param gatewayPolicyMappingId Gateway policy mapping Id + * @param gatewayPolicyMappingsDTO Gateway policy mapping DTO + * @return http response of add gateway policy + * @throws ApiException - throws if add gateway policy fails + */ + public HttpResponse updateGatewayPolicy(String gatewayPolicyMappingId, + GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + + Gson gson = new Gson(); + ApiResponse updateDeployedPolicyResponse = gatewayPoliciesApi.updateGatewayPoliciesToFlowsWithHttpInfo( + gatewayPolicyMappingId, gatewayPolicyMappingsDTO); + return new HttpResponse(gson.toJson(updateDeployedPolicyResponse.getData()), + updateDeployedPolicyResponse.getStatusCode()); + } + private void waitUntilStatusToBlock(String apiId, String action) throws APIManagerIntegrationTestException { if (Constants.BLOCK.equals(action)) { log.info("Wait until " + apiId + " to be Blocked"); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java index 235c848af8..1ee2142d2b 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/api/lifecycle/APIManagerLifecycleBaseTest.java @@ -64,6 +64,7 @@ public class APIManagerLifecycleBaseTest extends APIMIntegrationBaseTest { Response.Status.SERVICE_UNAVAILABLE.getStatusCode(); protected static final int HTTP_RESPONSE_CODE_TOO_MANY_REQUESTS = 429; // Define manually since value is not available in enum protected static final int HTTP_RESPONSE_CODE_FORBIDDEN = Response.Status.FORBIDDEN.getStatusCode(); + protected static final int HTTP_RESPONSE_PRECONDITION_FAILED = Response.Status.PRECONDITION_FAILED.getStatusCode(); protected static final String HTTP_RESPONSE_DATA_API_BLOCK = "{\"code\":\"700700\",\"type\":\"API blocked\",\"description\":\"This API has been blocked temporarily. " + "Please try again later or contact the system administrators.\"}"; diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java new file mode 100644 index 0000000000..3e819ae9b1 --- /dev/null +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java @@ -0,0 +1,314 @@ +/* + * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.am.integration.tests.gatewayPolicy; + +import com.google.gson.Gson; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.ssl.AllowAllHostnameVerifier; +import org.apache.http.impl.client.HttpClientBuilder; +import org.testng.Assert; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.wso2.am.integration.clients.publisher.api.ApiException; +import org.wso2.am.integration.clients.publisher.api.v1.dto.APIOperationPoliciesDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyDeploymentDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingInfoDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingsDTO; +import org.wso2.am.integration.clients.publisher.api.v1.dto.OperationPolicyDTO; +import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO; +import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyDTO; +import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyGenerateRequestDTO; +import org.wso2.am.integration.test.Constants; +import org.wso2.am.integration.test.utils.base.APIMIntegrationConstants; +import org.wso2.am.integration.test.utils.bean.APIRequest; +import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest; +import org.wso2.carbon.automation.test.utils.http.client.HttpResponse; + +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +public class GatewayPolicyTestCase extends APIManagerLifecycleBaseTest { + + private final Log log = LogFactory.getLog(GatewayPolicyTestCase.class); + private final String API_NAME = "GatewayPolicyApplicableAPITest"; + private final String API_CONTEXT = "gatewayPolicyApplicableAPITest"; + private final String API_END_POINT_POSTFIX_URL = "xmlapi"; + private String applicationId; + private String apiId; + String gatewayPolicyId; + String newGatewayPolicyId; + private String accessToken; + private Map policyMap; + + @BeforeClass(alwaysRun = true) + public void initialize() throws Exception { + + super.init(); + HttpResponse applicationResponse = restAPIStore.createApplication(APPLICATION_NAME, + "Test Application AccessibilityOfBlockAPITestCase", APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED, + ApplicationDTO.TokenTypeEnum.JWT); + applicationId = applicationResponse.getData(); + policyMap = restAPIPublisher.getAllCommonOperationPolicies(); + + String apiEndPointUrl = getAPIInvocationURLHttp(API_END_POINT_POSTFIX_URL, API_VERSION_1_0_0); + APIRequest apiRequest = new APIRequest(API_NAME, API_CONTEXT, new URL(apiEndPointUrl)); + apiRequest.setVersion(API_VERSION_1_0_0); + apiRequest.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED); + apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED); + apiRequest.setTags(API_TAGS); + apiId = createPublishAndSubscribeToAPIUsingRest(apiRequest, restAPIPublisher, restAPIStore, applicationId, + APIMIntegrationConstants.API_TIER.UNLIMITED); + + ArrayList grantTypes = new ArrayList(); + grantTypes.add("client_credentials"); + + ApplicationKeyDTO applicationKeyDTO = restAPIStore.generateKeys(applicationId, "3600", null, + ApplicationKeyGenerateRequestDTO.KeyTypeEnum.PRODUCTION, null, grantTypes); + accessToken = applicationKeyDTO.getToken().getAccessToken(); + } + + @Test(groups = {"wso2.am"}, description = "Invoke the API before deploying a gateway policy") + public void testAPIInvocationBeforeAddingNewGatewayPolicy() throws Exception { + + org.apache.http.HttpResponse invokeAPIResponse = invokeAPI(API_VERSION_1_0_0); + assertEquals(invokeAPIResponse.getStatusLine().getStatusCode(), HTTP_RESPONSE_CODE_OK, + "Invocation fails for GET request"); + assertEquals(invokeAPIResponse.getHeaders("TestHeader").length, 0); + assertEquals(invokeAPIResponse.getHeaders("Content-Type")[0].getValue(), "application/xml; charset=UTF-8"); + + } + + @Test(groups = {"wso2.am"}, description = "Add gateway policy", dependsOnMethods = "testAPIInvocationBeforeAddingNewGatewayPolicy") + public void testAddNewGatewayPolicy() throws ApiException { + + GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); + policyMapping.setDisplayName("Policy_Mapping"); + policyMapping.setDescription("Description about the policy mapping"); + String policyName = "addHeader"; + Assert.assertNotNull(policyMap.get(policyName), "Unable to find a common policy with name " + policyName); + + Map attributeMap = new HashMap<>(); + attributeMap.put("headerName", "TestHeader"); + attributeMap.put("headerValue", "TestValue"); + + APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO(); + apiOperationPoliciesDTO.setResponse(getPolicyList(policyName, policyMap, attributeMap)); + policyMapping.setPolicyMapping(apiOperationPoliciesDTO); + HttpResponse addPolicyResponse = restAPIPublisher.addGatewayPolicy(policyMapping); + assertEquals(addPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_CREATED, + "Error while adding gateway policy"); + GatewayPolicyMappingInfoDTO policyMappingInfoDTO = new Gson().fromJson(addPolicyResponse.getData(), + GatewayPolicyMappingInfoDTO.class); + gatewayPolicyId = policyMappingInfoDTO.getId(); + assertNotNull(gatewayPolicyId, "Policy Id is null"); + } + + @Test(groups = {"wso2.am"}, description = "Deploy sample gateway policy", dependsOnMethods = "testAddNewGatewayPolicy") + public void testDeployGatewayPolicy() throws Exception { + + List gatewayPolicyDeploymentDTOList = new ArrayList<>(); + GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO = new GatewayPolicyDeploymentDTO(); + gatewayPolicyDeploymentDTO.setGatewayLabel(Constants.GATEWAY_ENVIRONMENT); + gatewayPolicyDeploymentDTO.setGatewayDeployment(true); + gatewayPolicyDeploymentDTOList.add(gatewayPolicyDeploymentDTO); + HttpResponse deployPolicyResponse = restAPIPublisher.deployGatewayPolicy(gatewayPolicyId, + gatewayPolicyDeploymentDTOList); + assertEquals(deployPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, + "Error while deploying gateway policy"); + GatewayPolicyDeploymentDTO policyMappingDeploymentDTO = new Gson().fromJson(deployPolicyResponse.getData(), + GatewayPolicyDeploymentDTO.class); + String policyMappingId = policyMappingDeploymentDTO.getMappingUUID(); + assertEquals(policyMappingId, gatewayPolicyId, "Policy Id mismatch"); + } + + @Test(groups = {"wso2.am"}, description = "Invoke the API after deploying the gateway policy", dependsOnMethods = "testDeployGatewayPolicy") + public void testAPIInvocationAfterDeployingNewGatewayPolicy() throws Exception { + + int maxAttempts = 10; + int currentAttempt = 0; + boolean conditionMet = false; + + while (!conditionMet && currentAttempt < maxAttempts) { + org.apache.http.HttpResponse invokeAPIResponse = invokeAPI(API_VERSION_1_0_0); + if (invokeAPIResponse.getStatusLine().getStatusCode() == HTTP_RESPONSE_CODE_OK) { + assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "TestValue"); + conditionMet = true; + } else { + currentAttempt++; + Thread.sleep(2000); + } + } + if (!conditionMet) { + Assert.fail("Header value was not set correctly after the gateway policy was deployed."); + } + } + + @Test(groups = {"wso2.am"}, description = "Update deployed gateway policy", dependsOnMethods = "testAPIInvocationAfterDeployingNewGatewayPolicy") + public void testUpdateDeployGatewayPolicy() throws Exception { + GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); + policyMapping.setDisplayName("Policy_Mapping"); + policyMapping.setDescription("Description about the policy mapping"); + String policyName = "addHeader"; + Assert.assertNotNull(policyMap.get(policyName), "Unable to find a common policy with name " + policyName); + + Map attributeMap = new HashMap<>(); + attributeMap.put("headerName", "TestHeader"); + attributeMap.put("headerValue", "UpdatedTestValue"); + + APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO(); + apiOperationPoliciesDTO.setResponse(getPolicyList(policyName, policyMap, attributeMap)); + policyMapping.setPolicyMapping(apiOperationPoliciesDTO); + HttpResponse updatePolicyResponse = restAPIPublisher.updateGatewayPolicy(gatewayPolicyId, policyMapping); + assertEquals(updatePolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, + "Error while updating gateway policy"); + + int maxAttempts = 10; + int currentAttempt = 0; + boolean conditionMet = false; + + while (!conditionMet && currentAttempt < maxAttempts) { + org.apache.http.HttpResponse invokeAPIResponse = invokeAPI(API_VERSION_1_0_0); + if (invokeAPIResponse.getStatusLine().getStatusCode() == HTTP_RESPONSE_CODE_OK) { + assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "UpdatedTestValue"); + conditionMet = true; + } else { + currentAttempt++; + Thread.sleep(2000); + } + } + if (!conditionMet) { + Assert.fail("Header value was not set correctly after the gateway policy was updated."); + } + } + + @Test(groups = {"wso2.am"}, description = "Deploy another gateway policy to same gateway", dependsOnMethods = "testUpdateDeployGatewayPolicy") + public void testDeployAnotherGatewayPolicyInSameGateway() throws Exception { + GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); + policyMapping.setDisplayName("Policy_Mapping_1"); + policyMapping.setDescription("Description about the new policy mapping"); + String policyName = "addHeader"; + Assert.assertNotNull(policyMap.get(policyName), "Unable to find a common policy with name " + policyName); + + Map attributeMap = new HashMap<>(); + attributeMap.put("headerName", "TestHeader1"); + attributeMap.put("headerValue", "TestValue1"); + + APIOperationPoliciesDTO apiOperationPoliciesDTO = new APIOperationPoliciesDTO(); + apiOperationPoliciesDTO.setResponse(getPolicyList(policyName, policyMap, attributeMap)); + policyMapping.setPolicyMapping(apiOperationPoliciesDTO); + HttpResponse addPolicyResponse = restAPIPublisher.addGatewayPolicy(policyMapping); + assertEquals(addPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_CREATED, + "Error while adding gateway policy"); + GatewayPolicyMappingInfoDTO policyMappingInfoDTO = new Gson().fromJson(addPolicyResponse.getData(), + GatewayPolicyMappingInfoDTO.class); + newGatewayPolicyId = policyMappingInfoDTO.getId(); + assertNotNull(newGatewayPolicyId, "Policy Id is null"); + + List gatewayPolicyDeploymentDTOList = new ArrayList<>(); + GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO = new GatewayPolicyDeploymentDTO(); + gatewayPolicyDeploymentDTO.setGatewayLabel(Constants.GATEWAY_ENVIRONMENT); + gatewayPolicyDeploymentDTO.setGatewayDeployment(true); + gatewayPolicyDeploymentDTOList.add(gatewayPolicyDeploymentDTO); + HttpResponse deployPolicyResponse = restAPIPublisher.deployGatewayPolicy(gatewayPolicyId, + gatewayPolicyDeploymentDTOList); + assertEquals(deployPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_BAD_REQUEST, + "Not allowed to deploy multiple gateway policies in a single gateway"); + } + + @Test(groups = {"wso2.am"}, description = "Delete active gateway deployments available gateway policy", dependsOnMethods = "testDeployAnotherGatewayPolicyInSameGateway") + public void testDeployedGatewayPolicyDeletion() throws Exception { + + HttpResponse deletePolicyResponse = restAPIPublisher.deleteGatewayPolicy(gatewayPolicyId); + assertEquals(deletePolicyResponse.getResponseCode(), HTTP_RESPONSE_PRECONDITION_FAILED, + "Should not allow to delete active deployments available gateway policy"); + GatewayPolicyMappingsDTO getPolicyResponse = restAPIPublisher.getGatewayPolicy(gatewayPolicyId); + assertNotNull(getPolicyResponse, "Gateway policy should not be deleted since it has active deployments"); + } + + @Test(groups = {"wso2.am"}, description = "Undeploy sample gateway policy", dependsOnMethods = "testDeployedGatewayPolicyDeletion") + public void testUndeployGatewayPolicy() throws Exception { + + List gatewayPolicyDeploymentDTOList = new ArrayList<>(); + GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO = new GatewayPolicyDeploymentDTO(); + gatewayPolicyDeploymentDTO.setGatewayLabel(Constants.GATEWAY_ENVIRONMENT); + gatewayPolicyDeploymentDTO.setGatewayDeployment(false); + gatewayPolicyDeploymentDTOList.add(gatewayPolicyDeploymentDTO); + HttpResponse deployPolicyResponse = restAPIPublisher.deployGatewayPolicy(gatewayPolicyId, + gatewayPolicyDeploymentDTOList); + assertEquals(deployPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, + "Error while un-deploying gateway policy"); + } + + @Test(groups = {"wso2.am"}, description = "Delete active gateway deployments unavailable gateway policy", dependsOnMethods = "testUndeployGatewayPolicy") + public void testGatewayPolicyDeletion() throws Exception { + HttpResponse deletePolicyResponse = restAPIPublisher.deleteGatewayPolicy(gatewayPolicyId); + assertEquals(deletePolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, + "Error while deleting gateway policy"); + GatewayPolicyMappingsDTO getPolicyResponse = restAPIPublisher.getGatewayPolicy(gatewayPolicyId); + Assert.assertNull(getPolicyResponse, + "Gateway policy is not deleted even though it does not have any active deployments"); + } + + @AfterClass(alwaysRun = true) + public void cleanUpArtifacts() throws Exception { + + restAPIStore.deleteApplication(applicationId); + undeployAndDeleteAPIRevisionsUsingRest(apiId, restAPIPublisher); + restAPIPublisher.deleteAPI(apiId); + restAPIPublisher.deleteGatewayPolicy(newGatewayPolicyId); + } + + public org.apache.http.HttpResponse invokeAPI(String version) throws XPathExpressionException, IOException { + + HttpClient client = HttpClientBuilder.create().setHostnameVerifier(new AllowAllHostnameVerifier()).build(); + HttpGet request = new HttpGet(getAPIInvocationURLHttp(API_CONTEXT, version)); + request.setHeader("Authorization", "Bearer " + accessToken); + org.apache.http.HttpResponse response = client.execute(request); + + assertEquals(response.getStatusLine().getStatusCode(), HTTP_RESPONSE_CODE_OK, + "Invocation fails for GET request"); + + return response; + } + + public List getPolicyList(String policyName, Map policyMap, + Map attributeMap) { + + List policyList = new ArrayList<>(); + OperationPolicyDTO policyDTO = new OperationPolicyDTO(); + policyDTO.setPolicyName(policyName); + policyDTO.setPolicyId(policyMap.get(policyName)); + policyDTO.setParameters(attributeMap); + policyList.add(policyDTO); + + return policyList; + } +} From c1fa8cf9d81a5ba4cc88e0d5cdb7907ee37461df Mon Sep 17 00:00:00 2001 From: yasasrangika Date: Wed, 10 Jan 2024 18:08:30 +0530 Subject: [PATCH 2/4] improve tests --- .../publisher-api.yaml.sha256 | 2 +- .../clients/publisher/api/openapi.yaml | 20 +++++- .../publisher/docs/GatewayPoliciesApi.md | 7 ++- .../publisher/api/v1/GatewayPoliciesApi.java | 20 +++--- .../src/main/resources/publisher-api.yaml | 8 ++- .../test/impl/RestAPIPublisherImpl.java | 62 +++++++++++++------ .../gatewayPolicy/GatewayPolicyTestCase.java | 49 ++++++++------- 7 files changed, 114 insertions(+), 54 deletions(-) diff --git a/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 b/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 index 8e761e046a..c1342177fa 100644 --- a/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 +++ b/modules/integration/tests-common/clients/publisher/.openapi-generator/publisher-api.yaml.sha256 @@ -1 +1 @@ -98955626332fa43085771a8f446ec2195a5b9335f93b89baf64b29bafcafbedd \ No newline at end of file +391b6c495dd81ff0bce5c843cc2eee5079b934390ab6a51a0241e883cb34d575 \ No newline at end of file diff --git a/modules/integration/tests-common/clients/publisher/api/openapi.yaml b/modules/integration/tests-common/clients/publisher/api/openapi.yaml index cc8b54eba4..57e97008bd 100644 --- a/modules/integration/tests-common/clients/publisher/api/openapi.yaml +++ b/modules/integration/tests-common/clients/publisher/api/openapi.yaml @@ -14934,6 +14934,20 @@ paths: schema: $ref: '#/components/schemas/Error' description: Not Found. The specified resource does not exist. + "412": + content: + application/json: + example: + code: 412 + message: Precondition Failed + description: The request has not been performed because one of the + preconditions is not met + moreInfo: "" + error: [] + schema: + $ref: '#/components/schemas/Error' + description: Precondition Failed. The request has not been performed because + one of the preconditions is not met. "500": content: application/json: @@ -15142,7 +15156,9 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/GatewayPolicyDeployment' + items: + $ref: '#/components/schemas/GatewayPolicyDeployment' + type: array description: | OK. Gateway policy mapping engaged successfully. @@ -21961,6 +21977,8 @@ components: apim:common_operation_policy_view: View common operation policies apim:common_operation_policy_manage: Add, Update and Delete common operation policies + apim:gateway_policy_view: View gateway policies + apim:gateway_policy_manage: Add, Update and Delete gateway policies apim:client_certificates_view: View client certificates apim:client_certificates_add: Add client certificates apim:client_certificates_update: Update and delete client certificates diff --git a/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md b/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md index 3c951a90dd..7cb668df08 100644 --- a/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md +++ b/modules/integration/tests-common/clients/publisher/docs/GatewayPoliciesApi.md @@ -149,11 +149,12 @@ null (empty response body) **200** | OK. Resource successfully deleted. | - | **403** | Forbidden. The request must be conditional but no condition has been specified. | - | **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. | - | **500** | Internal Server Error. | - | # **engageGlobalPolicy** -> GatewayPolicyDeploymentDTO engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO) +> List<GatewayPolicyDeploymentDTO> engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO) Engage gateway policy mapping to the gateways @@ -182,7 +183,7 @@ public class Example { String gatewayPolicyMappingId = "gatewayPolicyMappingId_example"; // String | Gateway policy mapping Id List gatewayPolicyDeploymentDTO = Arrays.asList(); // List | Policy details object that needs to be added. try { - GatewayPolicyDeploymentDTO result = apiInstance.engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + List result = apiInstance.engageGlobalPolicy(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); System.out.println(result); } catch (ApiException e) { System.err.println("Exception when calling GatewayPoliciesApi#engageGlobalPolicy"); @@ -204,7 +205,7 @@ Name | Type | Description | Notes ### Return type -[**GatewayPolicyDeploymentDTO**](GatewayPolicyDeploymentDTO.md) +[**List<GatewayPolicyDeploymentDTO>**](GatewayPolicyDeploymentDTO.md) ### Authorization diff --git a/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java index 8d1b042ac6..6f5ed3914b 100644 --- a/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java +++ b/modules/integration/tests-common/clients/publisher/src/gen/java/org/wso2/am/integration/clients/publisher/api/v1/GatewayPoliciesApi.java @@ -192,6 +192,7 @@ public okhttp3.Call addGatewayPoliciesToFlowsAsync(GatewayPolicyMappingsDTO gate 200 OK. Resource successfully deleted. - 403 Forbidden. The request must be conditional but no condition has been specified. - 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. - 500 Internal Server Error. - */ @@ -250,6 +251,7 @@ private okhttp3.Call deleteGatewayPolicyByPolicyIdValidateBeforeCall(String gate 200 OK. Resource successfully deleted. - 403 Forbidden. The request must be conditional but no condition has been specified. - 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. - 500 Internal Server Error. - */ @@ -269,6 +271,7 @@ public void deleteGatewayPolicyByPolicyId(String gatewayPolicyMappingId) throws 200 OK. Resource successfully deleted. - 403 Forbidden. The request must be conditional but no condition has been specified. - 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. - 500 Internal Server Error. - */ @@ -290,6 +293,7 @@ public ApiResponse deleteGatewayPolicyByPolicyIdWithHttpInfo(String gatewa 200 OK. Resource successfully deleted. - 403 Forbidden. The request must be conditional but no condition has been specified. - 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. - 500 Internal Server Error. - */ @@ -369,7 +373,7 @@ private okhttp3.Call engageGlobalPolicyValidateBeforeCall(String gatewayPolicyMa * This operation can be used to engage gateway policy mapping to the gateway/s. * @param gatewayPolicyMappingId Gateway policy mapping Id (required) * @param gatewayPolicyDeploymentDTO Policy details object that needs to be added. (required) - * @return GatewayPolicyDeploymentDTO + * @return List<GatewayPolicyDeploymentDTO> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -380,8 +384,8 @@ private okhttp3.Call engageGlobalPolicyValidateBeforeCall(String gatewayPolicyMa
500 Internal Server Error. -
*/ - public GatewayPolicyDeploymentDTO engageGlobalPolicy(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { - ApiResponse localVarResp = engageGlobalPolicyWithHttpInfo(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + public List engageGlobalPolicy(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { + ApiResponse> localVarResp = engageGlobalPolicyWithHttpInfo(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); return localVarResp.getData(); } @@ -390,7 +394,7 @@ public GatewayPolicyDeploymentDTO engageGlobalPolicy(String gatewayPolicyMapping * This operation can be used to engage gateway policy mapping to the gateway/s. * @param gatewayPolicyMappingId Gateway policy mapping Id (required) * @param gatewayPolicyDeploymentDTO Policy details object that needs to be added. (required) - * @return ApiResponse<GatewayPolicyDeploymentDTO> + * @return ApiResponse<List<GatewayPolicyDeploymentDTO>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details @@ -401,9 +405,9 @@ public GatewayPolicyDeploymentDTO engageGlobalPolicy(String gatewayPolicyMapping
500 Internal Server Error. -
*/ - public ApiResponse engageGlobalPolicyWithHttpInfo(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { + public ApiResponse> engageGlobalPolicyWithHttpInfo(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO) throws ApiException { okhttp3.Call localVarCall = engageGlobalPolicyValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO, null); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } @@ -424,10 +428,10 @@ public ApiResponse engageGlobalPolicyWithHttpInfo(St 500 Internal Server Error. - */ - public okhttp3.Call engageGlobalPolicyAsync(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO, final ApiCallback _callback) throws ApiException { + public okhttp3.Call engageGlobalPolicyAsync(String gatewayPolicyMappingId, List gatewayPolicyDeploymentDTO, final ApiCallback> _callback) throws ApiException { okhttp3.Call localVarCall = engageGlobalPolicyValidateBeforeCall(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } diff --git a/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml b/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml index 066e2a3b70..e1fde0a44c 100644 --- a/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml +++ b/modules/integration/tests-common/clients/publisher/src/main/resources/publisher-api.yaml @@ -8385,6 +8385,8 @@ paths: $ref: '#/components/responses/Forbidden' 404: $ref: '#/components/responses/NotFound' + 412: + $ref: '#/components/responses/PreconditionFailed' 500: $ref: '#/components/responses/InternalServerError' security: @@ -8473,7 +8475,9 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/GatewayPolicyDeployment' + type: array + items: + $ref: '#/components/schemas/GatewayPolicyDeployment' 400: $ref: '#/components/responses/BadRequest' 404: @@ -12916,6 +12920,8 @@ components: apim:mediation_policy_manage: Update and delete mediation policies apim:common_operation_policy_view: View common operation policies apim:common_operation_policy_manage: Add, Update and Delete common operation policies + apim:gateway_policy_view: View gateway policies + apim:gateway_policy_manage: Add, Update and Delete gateway policies apim:client_certificates_view: View client certificates apim:client_certificates_add: Add client certificates apim:client_certificates_update: Update and delete client certificates diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java index a6e74cb072..12a57ee242 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java @@ -191,7 +191,7 @@ 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:policies_import_export apim:gateway_policy_view apim:gateway_policy_manage", appName, callBackURL, tokenScope, appOwner, grantType, dcrURL, username, password, tenantDomain, tokenURL); apiPublisherClient.addDefaultHeader("Authorization", "Bearer " + accessToken); @@ -226,6 +226,7 @@ public RestAPIPublisherImpl(String username, String password, String tenantDomai productLifecycleApi.setApiClient(apiPublisherClient); importExportApi.setApiClient(apiPublisherClient); linterCustomRulesApi.setApiClient(apiPublisherClient); + gatewayPoliciesApi.setApiClient(apiPublisherClient); this.tenantDomain = tenantDomain; this.restAPIGateway = new RestAPIGatewayImpl(this.username, this.password, tenantDomain); } @@ -2553,12 +2554,18 @@ public Map mapPolicyNameToId(OperationPolicyDataListDTO policyLi * @return http response of add gateway policy * @throws ApiException - throws if add gateway policy fails */ - public HttpResponse addGatewayPolicy(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + public HttpResponse addGatewayPolicy(GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) { Gson gson = new Gson(); - ApiResponse addGatewayPolicyResponse = gatewayPoliciesApi.addGatewayPoliciesToFlowsWithHttpInfo( - gatewayPolicyMappingsDTO); - return new HttpResponse(gson.toJson(addGatewayPolicyResponse.getData()), addGatewayPolicyResponse.getStatusCode()); + HttpResponse response; + try { + ApiResponse addGatewayPolicyResponse = gatewayPoliciesApi.addGatewayPoliciesToFlowsWithHttpInfo( + gatewayPolicyMappingsDTO); + response = new HttpResponse(gson.toJson(addGatewayPolicyResponse.getData()), addGatewayPolicyResponse.getStatusCode()); + } catch (ApiException e) { + response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + return response; } /** @@ -2570,12 +2577,19 @@ public HttpResponse addGatewayPolicy(GatewayPolicyMappingsDTO gatewayPolicyMappi * @throws ApiException - throws if add gateway policy fails */ public HttpResponse deployGatewayPolicy(String gatewayPolicyMappingId, - List gatewayPolicyDeploymentDTO) throws ApiException { + List gatewayPolicyDeploymentDTO) { Gson gson = new Gson(); - ApiResponse policyDeployResponse = gatewayPoliciesApi.engageGlobalPolicyWithHttpInfo( - gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); - return new HttpResponse(gson.toJson(policyDeployResponse.getData()), policyDeployResponse.getStatusCode()); + HttpResponse response; + try { + ApiResponse> policyDeployResponse = gatewayPoliciesApi.engageGlobalPolicyWithHttpInfo( + gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + response = new HttpResponse(gson.toJson(policyDeployResponse.getData()), + policyDeployResponse.getStatusCode()); + } catch (ApiException e) { + response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + return response; } /** @@ -2585,14 +2599,19 @@ public HttpResponse deployGatewayPolicy(String gatewayPolicyMappingId, * @return http response of add gateway policy * @throws ApiException - throws if add gateway policy fails */ - public HttpResponse deleteGatewayPolicy(String gatewayPolicyMappingId) throws ApiException { + public HttpResponse deleteGatewayPolicy(String gatewayPolicyMappingId) { Gson gson = new Gson(); - ApiResponse deleteResponse = gatewayPoliciesApi.deleteGatewayPolicyByPolicyIdWithHttpInfo( - gatewayPolicyMappingId); HttpResponse response = null; - if (deleteResponse.getStatusCode() == 200) { - response = new HttpResponse("Successfully deleted the gateway policy", 200); + try { + ApiResponse deleteResponse = gatewayPoliciesApi.deleteGatewayPolicyByPolicyIdWithHttpInfo( + gatewayPolicyMappingId); + if (deleteResponse.getStatusCode() == 200) { + response = new HttpResponse("Successfully deleted the gateway policy", 200); + } + } catch (ApiException e) { + response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + return response; } return response; } @@ -2625,13 +2644,18 @@ public GatewayPolicyMappingsDTO getGatewayPolicy(String gatewayPolicyMappingId) * @throws ApiException - throws if add gateway policy fails */ public HttpResponse updateGatewayPolicy(String gatewayPolicyMappingId, - GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) throws ApiException { + GatewayPolicyMappingsDTO gatewayPolicyMappingsDTO) { Gson gson = new Gson(); - ApiResponse updateDeployedPolicyResponse = gatewayPoliciesApi.updateGatewayPoliciesToFlowsWithHttpInfo( - gatewayPolicyMappingId, gatewayPolicyMappingsDTO); - return new HttpResponse(gson.toJson(updateDeployedPolicyResponse.getData()), - updateDeployedPolicyResponse.getStatusCode()); + HttpResponse response; + try { + ApiResponse updateDeployedPolicyResponse = gatewayPoliciesApi.updateGatewayPoliciesToFlowsWithHttpInfo( + gatewayPolicyMappingId, gatewayPolicyMappingsDTO); + response = new HttpResponse(gson.toJson(updateDeployedPolicyResponse.getData()), updateDeployedPolicyResponse.getStatusCode()); + } catch (ApiException e) { + response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); + } + return response; } private void waitUntilStatusToBlock(String apiId, String action) throws APIManagerIntegrationTestException { diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java index 3e819ae9b1..2d35734dc0 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java @@ -19,6 +19,7 @@ package org.wso2.am.integration.tests.gatewayPolicy; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.client.HttpClient; @@ -29,7 +30,6 @@ import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.am.integration.clients.publisher.api.ApiException; import org.wso2.am.integration.clients.publisher.api.v1.dto.APIOperationPoliciesDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyDeploymentDTO; import org.wso2.am.integration.clients.publisher.api.v1.dto.GatewayPolicyMappingInfoDTO; @@ -57,7 +57,6 @@ public class GatewayPolicyTestCase extends APIManagerLifecycleBaseTest { - private final Log log = LogFactory.getLog(GatewayPolicyTestCase.class); private final String API_NAME = "GatewayPolicyApplicableAPITest"; private final String API_CONTEXT = "gatewayPolicyApplicableAPITest"; private final String API_END_POINT_POSTFIX_URL = "xmlapi"; @@ -107,7 +106,7 @@ public void testAPIInvocationBeforeAddingNewGatewayPolicy() throws Exception { } @Test(groups = {"wso2.am"}, description = "Add gateway policy", dependsOnMethods = "testAPIInvocationBeforeAddingNewGatewayPolicy") - public void testAddNewGatewayPolicy() throws ApiException { + public void testAddNewGatewayPolicy() { GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); policyMapping.setDisplayName("Policy_Mapping"); @@ -132,7 +131,7 @@ public void testAddNewGatewayPolicy() throws ApiException { } @Test(groups = {"wso2.am"}, description = "Deploy sample gateway policy", dependsOnMethods = "testAddNewGatewayPolicy") - public void testDeployGatewayPolicy() throws Exception { + public void testDeployGatewayPolicy() { List gatewayPolicyDeploymentDTOList = new ArrayList<>(); GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO = new GatewayPolicyDeploymentDTO(); @@ -143,9 +142,9 @@ public void testDeployGatewayPolicy() throws Exception { gatewayPolicyDeploymentDTOList); assertEquals(deployPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Error while deploying gateway policy"); - GatewayPolicyDeploymentDTO policyMappingDeploymentDTO = new Gson().fromJson(deployPolicyResponse.getData(), - GatewayPolicyDeploymentDTO.class); - String policyMappingId = policyMappingDeploymentDTO.getMappingUUID(); + List policyMappingDeploymentDTOList = new Gson().fromJson(deployPolicyResponse.getData(), + new TypeToken>() {}.getType()); + String policyMappingId = policyMappingDeploymentDTOList.get(0).getMappingUUID(); assertEquals(policyMappingId, gatewayPolicyId, "Policy Id mismatch"); } @@ -159,10 +158,14 @@ public void testAPIInvocationAfterDeployingNewGatewayPolicy() throws Exception { while (!conditionMet && currentAttempt < maxAttempts) { org.apache.http.HttpResponse invokeAPIResponse = invokeAPI(API_VERSION_1_0_0); if (invokeAPIResponse.getStatusLine().getStatusCode() == HTTP_RESPONSE_CODE_OK) { - assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "TestValue"); - conditionMet = true; - } else { - currentAttempt++; + if (invokeAPIResponse.getHeaders("TestHeader").length > 0 && + invokeAPIResponse.getHeaders("TestHeader")[0].getValue().equals("TestValue")) { + conditionMet = true; + assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "TestValue"); + } + } + currentAttempt++; + if (!conditionMet && currentAttempt < maxAttempts) { Thread.sleep(2000); } } @@ -172,7 +175,7 @@ public void testAPIInvocationAfterDeployingNewGatewayPolicy() throws Exception { } @Test(groups = {"wso2.am"}, description = "Update deployed gateway policy", dependsOnMethods = "testAPIInvocationAfterDeployingNewGatewayPolicy") - public void testUpdateDeployGatewayPolicy() throws Exception { + public void testUpdateDeployedGatewayPolicy() throws Exception { GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); policyMapping.setDisplayName("Policy_Mapping"); policyMapping.setDescription("Description about the policy mapping"); @@ -197,10 +200,14 @@ public void testUpdateDeployGatewayPolicy() throws Exception { while (!conditionMet && currentAttempt < maxAttempts) { org.apache.http.HttpResponse invokeAPIResponse = invokeAPI(API_VERSION_1_0_0); if (invokeAPIResponse.getStatusLine().getStatusCode() == HTTP_RESPONSE_CODE_OK) { - assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "UpdatedTestValue"); - conditionMet = true; - } else { - currentAttempt++; + if (invokeAPIResponse.getHeaders("TestHeader").length > 0 && + invokeAPIResponse.getHeaders("TestHeader")[0].getValue().equals("UpdatedTestValue")) { + conditionMet = true; + assertEquals(invokeAPIResponse.getHeaders("TestHeader")[0].getValue(), "UpdatedTestValue"); + } + } + currentAttempt++; + if (!conditionMet && currentAttempt < maxAttempts) { Thread.sleep(2000); } } @@ -209,8 +216,8 @@ public void testUpdateDeployGatewayPolicy() throws Exception { } } - @Test(groups = {"wso2.am"}, description = "Deploy another gateway policy to same gateway", dependsOnMethods = "testUpdateDeployGatewayPolicy") - public void testDeployAnotherGatewayPolicyInSameGateway() throws Exception { + @Test(groups = {"wso2.am"}, description = "Deploy another gateway policy to same gateway", dependsOnMethods = "testUpdateDeployedGatewayPolicy") + public void testDeployAnotherGatewayPolicyInSameGateway() { GatewayPolicyMappingsDTO policyMapping = new GatewayPolicyMappingsDTO(); policyMapping.setDisplayName("Policy_Mapping_1"); policyMapping.setDescription("Description about the new policy mapping"); @@ -237,7 +244,7 @@ public void testDeployAnotherGatewayPolicyInSameGateway() throws Exception { gatewayPolicyDeploymentDTO.setGatewayLabel(Constants.GATEWAY_ENVIRONMENT); gatewayPolicyDeploymentDTO.setGatewayDeployment(true); gatewayPolicyDeploymentDTOList.add(gatewayPolicyDeploymentDTO); - HttpResponse deployPolicyResponse = restAPIPublisher.deployGatewayPolicy(gatewayPolicyId, + HttpResponse deployPolicyResponse = restAPIPublisher.deployGatewayPolicy(newGatewayPolicyId, gatewayPolicyDeploymentDTOList); assertEquals(deployPolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_BAD_REQUEST, "Not allowed to deploy multiple gateway policies in a single gateway"); @@ -254,7 +261,7 @@ public void testDeployedGatewayPolicyDeletion() throws Exception { } @Test(groups = {"wso2.am"}, description = "Undeploy sample gateway policy", dependsOnMethods = "testDeployedGatewayPolicyDeletion") - public void testUndeployGatewayPolicy() throws Exception { + public void testUndeployGatewayPolicy() { List gatewayPolicyDeploymentDTOList = new ArrayList<>(); GatewayPolicyDeploymentDTO gatewayPolicyDeploymentDTO = new GatewayPolicyDeploymentDTO(); @@ -273,7 +280,7 @@ public void testGatewayPolicyDeletion() throws Exception { assertEquals(deletePolicyResponse.getResponseCode(), HTTP_RESPONSE_CODE_OK, "Error while deleting gateway policy"); GatewayPolicyMappingsDTO getPolicyResponse = restAPIPublisher.getGatewayPolicy(gatewayPolicyId); - Assert.assertNull(getPolicyResponse, + Assert.assertNull(getPolicyResponse.getId(), "Gateway policy is not deleted even though it does not have any active deployments"); } From 3e323f41814ca91f4b6b5efe40545b3c480ab226 Mon Sep 17 00:00:00 2001 From: yasasrangika Date: Thu, 11 Jan 2024 10:27:40 +0530 Subject: [PATCH 3/4] fix formatting issues --- .../test/impl/RestAPIPublisherImpl.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java index 12a57ee242..daa6b09b0b 100644 --- a/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java +++ b/modules/integration/tests-common/integration-test-utils/src/main/java/org/wso2/am/integration/test/impl/RestAPIPublisherImpl.java @@ -2559,9 +2559,10 @@ public HttpResponse addGatewayPolicy(GatewayPolicyMappingsDTO gatewayPolicyMappi Gson gson = new Gson(); HttpResponse response; try { - ApiResponse addGatewayPolicyResponse = gatewayPoliciesApi.addGatewayPoliciesToFlowsWithHttpInfo( - gatewayPolicyMappingsDTO); - response = new HttpResponse(gson.toJson(addGatewayPolicyResponse.getData()), addGatewayPolicyResponse.getStatusCode()); + ApiResponse addGatewayPolicyResponse = + gatewayPoliciesApi.addGatewayPoliciesToFlowsWithHttpInfo(gatewayPolicyMappingsDTO); + response = new HttpResponse(gson.toJson(addGatewayPolicyResponse.getData()), + addGatewayPolicyResponse.getStatusCode()); } catch (ApiException e) { response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); } @@ -2582,8 +2583,8 @@ public HttpResponse deployGatewayPolicy(String gatewayPolicyMappingId, Gson gson = new Gson(); HttpResponse response; try { - ApiResponse> policyDeployResponse = gatewayPoliciesApi.engageGlobalPolicyWithHttpInfo( - gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); + ApiResponse> policyDeployResponse = + gatewayPoliciesApi.engageGlobalPolicyWithHttpInfo(gatewayPolicyMappingId, gatewayPolicyDeploymentDTO); response = new HttpResponse(gson.toJson(policyDeployResponse.getData()), policyDeployResponse.getStatusCode()); } catch (ApiException e) { @@ -2626,8 +2627,8 @@ public HttpResponse deleteGatewayPolicy(String gatewayPolicyMappingId) { public GatewayPolicyMappingsDTO getGatewayPolicy(String gatewayPolicyMappingId) throws ApiException { setActivityID(); - ApiResponse getGatewayPolicyResponse = gatewayPoliciesApi.getGatewayPolicyMappingContentByPolicyMappingIdWithHttpInfo( - gatewayPolicyMappingId); + ApiResponse getGatewayPolicyResponse = + gatewayPoliciesApi.getGatewayPolicyMappingContentByPolicyMappingIdWithHttpInfo(gatewayPolicyMappingId); Assert.assertEquals(getGatewayPolicyResponse.getStatusCode(), HttpStatus.SC_OK, "Unable to retrieve gateway policy for policy mapping Id " + gatewayPolicyMappingId + " " + getGatewayPolicyResponse.getData()); @@ -2649,9 +2650,11 @@ public HttpResponse updateGatewayPolicy(String gatewayPolicyMappingId, Gson gson = new Gson(); HttpResponse response; try { - ApiResponse updateDeployedPolicyResponse = gatewayPoliciesApi.updateGatewayPoliciesToFlowsWithHttpInfo( - gatewayPolicyMappingId, gatewayPolicyMappingsDTO); - response = new HttpResponse(gson.toJson(updateDeployedPolicyResponse.getData()), updateDeployedPolicyResponse.getStatusCode()); + ApiResponse updateDeployedPolicyResponse = + gatewayPoliciesApi.updateGatewayPoliciesToFlowsWithHttpInfo(gatewayPolicyMappingId, + gatewayPolicyMappingsDTO); + response = new HttpResponse(gson.toJson(updateDeployedPolicyResponse.getData()), + updateDeployedPolicyResponse.getStatusCode()); } catch (ApiException e) { response = new HttpResponse(gson.toJson(e.getResponseBody()), e.getCode()); } From f1f32cdea86d8b9d82d90ecae572779401fbe05b Mon Sep 17 00:00:00 2001 From: yasasrangika Date: Mon, 22 Jan 2024 11:26:48 +0530 Subject: [PATCH 4/4] fix license header year to 2024 --- .../integration/tests/gatewayPolicy/GatewayPolicyTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java index 2d35734dc0..e46cccf3a2 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/am/integration/tests/gatewayPolicy/GatewayPolicyTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except