diff --git a/admin/admin-domain-service/ballerina/KeyManagerClient.bal b/admin/admin-domain-service/ballerina/KeyManagerClient.bal index e78a41c0f1..d24e6e2a4c 100644 --- a/admin/admin-domain-service/ballerina/KeyManagerClient.bal +++ b/admin/admin-domain-service/ballerina/KeyManagerClient.bal @@ -241,7 +241,7 @@ public class KeyManagerClient { certificateValue = check string:fromBytes(encodedBytes); } KeyManager_signingCertificate certificates = { - 'type: certificateType, + 'type: <"JWKS"|"PEM"|()>certificateType, value: certificateValue }; keymanager.signingCertificate = certificates; diff --git a/admin/admin-domain-service/ballerina/SettingsClient.bal b/admin/admin-domain-service/ballerina/SettingsClient.bal deleted file mode 100644 index 12de45389a..0000000000 --- a/admin/admin-domain-service/ballerina/SettingsClient.bal +++ /dev/null @@ -1,56 +0,0 @@ -import apk_keymanager_libs; -import wso2/apk_common_lib as commons; - -public class SettingsClient { - - public isolated function getSettings(commons:Organization? organization) returns Settings { - Settings settings = {}; - settings.keyManagerConfiguration = self.setKeyManagerConfigsToSettings(); - return settings; - } - private isolated function setKeyManagerConfigsToSettings() returns Settings_keyManagerConfiguration[] { - Settings_keyManagerConfiguration[] keyManagerConfigs = []; - apk_keymanager_libs:KeyManagerConfigurations[] kmconfigs = keyManagerInitializer.retrieveAllKeyManagerConfigs(); - foreach apk_keymanager_libs:KeyManagerConfigurations item in kmconfigs { - Settings_keyManagerConfiguration keyManagerConfig = {}; - keyManagerConfig.'type = item.'type; - keyManagerConfig.displayName = item.'display_name; - keyManagerConfig.defaultConsumerKeyClaim = item.consumerKeyClaim; - keyManagerConfig.defaultScopesClaim = item.scopesClaim; - KeyManagerConfiguration[] endpointConfiguration = []; - apk_keymanager_libs:EndpointConfiguration[] endpointConfigs = item.endpoints; - foreach apk_keymanager_libs:EndpointConfiguration endpointConfig in endpointConfigs { - KeyManagerConfiguration endpointConfigGenerated = { - name: endpointConfig.name, - tooltip: endpointConfig.toolTip, - label: endpointConfig.display_name, - 'type: "input", - mask: false, - required: endpointConfig.required, - multiple: false - }; - endpointConfiguration.push(endpointConfigGenerated); - } - keyManagerConfig.endpointConfigurations = endpointConfiguration; - apk_keymanager_libs:KeyManagerConfiguration[] keyManagerConnectorConfigs = item.endpointConfigurations; - KeyManagerConfiguration[] generatedConnectorConfigs = []; - foreach apk_keymanager_libs:KeyManagerConfiguration keyManagerConnectorConfig in keyManagerConnectorConfigs { - KeyManagerConfiguration generatedConnectorConfig = { - name: keyManagerConnectorConfig.name, - tooltip: keyManagerConnectorConfig.toolTip, - label: keyManagerConnectorConfig.display_name, - 'type: keyManagerConnectorConfig.'type, - mask: keyManagerConnectorConfig.masked, - required: keyManagerConnectorConfig.required, - multiple: keyManagerConnectorConfig.multiple, - default: keyManagerConnectorConfig?.default, - values: keyManagerConnectorConfig.values - }; - - generatedConnectorConfigs.push(generatedConnectorConfig); - } - keyManagerConfigs.push(keyManagerConfig); - } - return keyManagerConfigs; - } -} diff --git a/admin/admin-domain-service/ballerina/admin-api_service.bal b/admin/admin-domain-service/ballerina/admin-api_service.bal index d6be998b61..36f458c61e 100644 --- a/admin/admin-domain-service/ballerina/admin-api_service.bal +++ b/admin/admin-domain-service/ballerina/admin-api_service.bal @@ -25,196 +25,7 @@ service http:InterceptableService /api/admin on ep0 { http:Interceptor[] interceptors = [jwtValidationInterceptor, requestErrorInterceptor, responseErrorInterceptor]; return interceptors; } - # Retrieve/Search Policies - # - # + query - **Search**. You can search by providing a keyword. Allowed to search by type and name only. - # + return - OK. List of qualifying Policies is returned. - // resource function get policies/search(string? query) returns PolicyDetailsList { - // } - # Get all Application Rate Plans - # - # + accept - Media types acceptable for the response. Default is application/json. - # + return - returns can be any of following types - # ApplicationRatePlanList (OK. Policies returned) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - isolated resource function get 'application\-rate\-plans(http:RequestContext requestContext, @http:Header string? accept = "application/json") returns ApplicationRatePlanList|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - ApplicationRatePlanList|commons:APKError appPolicyList = getApplicationUsagePlans(organization); - if appPolicyList is ApplicationRatePlanList { - log:printDebug(appPolicyList.toString()); - } - return appPolicyList; - } - # Add an Application Rate Plan - # - # + 'content\-type - Media type of the entity in the body. Default is application/json. - # + payload - Application level policy object that should to be added - # + return - returns can be any of following types - # ApplicationRatePlan (Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity.) - # BadRequestError (Bad Request. Invalid request or validation error.) - # UnsupportedMediaTypeError (Unsupported Media Type. The entity of the request was not in a supported format.) - isolated resource function post 'application\-rate\-plans(http:RequestContext requestContext, @http:Payload ApplicationRatePlan payload, @http:Header string 'content\-type = "application/json") returns ApplicationRatePlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - ApplicationRatePlan|commons:APKError createdAppPol = addApplicationUsagePlan(payload, organization); - if createdAppPol is ApplicationRatePlan { - log:printDebug(createdAppPol.toString()); - } - return createdAppPol; - } - # Get an Application Rate Plan - # - # + planId - Policy UUID - # + return - returns can be any of following types - # ApplicationRatePlan (OK. Plan returned) - # NotFoundError (Not Found. The specified resource does not exist.) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - isolated resource function get 'application\-rate\-plans/[string planId](http:RequestContext requestContext) returns ApplicationRatePlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - ApplicationRatePlan|commons:APKError appPolicy = getApplicationUsagePlanById(planId, organization); - if appPolicy is ApplicationRatePlan { - log:printDebug(appPolicy.toString()); - } - return appPolicy; - } - # Update an Application Rate Plan - # - # + planId - Policy UUID - # + 'content\-type - Media type of the entity in the body. Default is application/json. - # + payload - Policy object that needs to be modified - # + return - returns can be any of following types - # ApplicationRatePlan (OK. Plan updated.) - # BadRequestError (Bad Request. Invalid request or validation error.) - # NotFoundError (Not Found. The specified resource does not exist.) - isolated resource function put 'application\-rate\-plans/[string planId](http:RequestContext requestContext, @http:Payload ApplicationRatePlan payload, @http:Header string 'content\-type = "application/json") returns ApplicationRatePlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - ApplicationRatePlan|commons:APKError appPolicy = updateApplicationUsagePlan(planId, payload, organization); - if appPolicy is ApplicationRatePlan { - log:printDebug(appPolicy.toString()); - } - return appPolicy; - } - # Delete an Application Rate Plan - # - # + planId - Policy UUID - # + return - returns can be any of following types - # http:Ok (OK. Resource successfully deleted.) - # NotFoundError (Not Found. The specified resource does not exist.) - isolated resource function delete 'application\-rate\-plans/[string planId](http:RequestContext requestContext) returns http:Ok|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - string|commons:APKError ex = removeApplicationUsagePlan(planId, organization); - if ex is commons:APKError { - return ex; - } else { - return http:OK; - } - } - # Get all Business Plans - # - # + accept - Media types acceptable for the response. Default is application/json. - # + return - returns can be any of following types - # BusinessPlanList (OK. Plans returned) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - isolated resource function get 'business\-plans(http:RequestContext requestContext, @http:Header string? accept = "application/json") returns BusinessPlanList|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - BusinessPlanList|commons:APKError subPolicyList = getBusinessPlans(organization); - if subPolicyList is BusinessPlanList { - log:printDebug(subPolicyList.toString()); - } - return subPolicyList; - } - # Add a Business Plan - # - # + 'content\-type - Media type of the entity in the body. Default is application/json. - # + payload - Business Plan object that should to be added - # + return - returns can be any of following types - # BusinessPlan (Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity.) - # BadRequestError (Bad Request. Invalid request or validation error.) - # UnsupportedMediaTypeError (Unsupported Media Type. The entity of the request was not in a supported format.) - isolated resource function post 'business\-plans(http:RequestContext requestContext, @http:Payload BusinessPlan payload, @http:Header string 'content\-type = "application/json") returns BusinessPlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - BusinessPlan|commons:APKError createdSubPol = addBusinessPlan(payload, organization); - if createdSubPol is BusinessPlan { - log:printDebug(createdSubPol.toString()); - } - return createdSubPol; - } - # Get a Business Plan - # - # + planId - Policy UUID - # + return - returns can be any of following types - # BusinessPlan (OK. Plan returned) - # NotFoundError (Not Found. The specified resource does not exist.) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - isolated resource function get 'business\-plans/[string planId](http:RequestContext requestContext) returns BusinessPlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - BusinessPlan|commons:APKError subPolicy = getBusinessPlanById(planId, organization); - if subPolicy is BusinessPlan { - log:printDebug(subPolicy.toString()); - } - return subPolicy; - } - # Update a Business Plan - # - # + planId - Policy UUID - # + 'content\-type - Media type of the entity in the body. Default is application/json. - # + payload - Plan object that needs to be modified - # + return - returns can be any of following types - # BusinessPlan (OK. Plan updated.) - # BadRequestError (Bad Request. Invalid request or validation error.) - # NotFoundError (Not Found. The specified resource does not exist.) - isolated resource function put 'business\-plans/[string planId](http:RequestContext requestContext, @http:Payload BusinessPlan payload, @http:Header string 'content\-type = "application/json") returns BusinessPlan|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - return updateBusinessPlan(planId, payload, organization); - } - # Delete a Business Plan - # - # + planId - Policy UUID - # + return - returns can be any of following types - # http:Ok (OK. Resource successfully deleted.) - # NotFoundError (Not Found. The specified resource does not exist.) - isolated resource function delete 'business\-plans/[string planId](http:RequestContext requestContext) returns http:Ok|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - string|commons:APKError ex = removeBusinessPlan(planId, organization); - if ex is commons:APKError { - return ex; - } else { - return http:OK; - } - } - # Export a Throttling Policy - # - # + policyId - UUID of the ThrottlingPolicy - # + name - Throttling Policy Name - # + 'type - Type of the Throttling Policy - # + format - Format of output documents. Can be YAML or JSON. - # + return - returns can be any of following types - # ExportPolicy (OK. Export Successful.) - # NotFoundError (Not Found. The specified resource does not exist.) - # InternalServerErrorError (Internal Server Error.) - // resource function get throttling/policies/export(string? policyId, string? name, string? 'type, string? format) returns ExportPolicy|NotFoundError|InternalServerErrorError { - // } - # Import a Throttling Policy - # - # + overwrite - Update an existing throttling policy with the same name. - # + request - parameter description - # + return - returns can be any of following types - # http:Ok (Created. Throttling Policy Imported Successfully.) - # ForbiddenError (Forbidden. The request must be conditional but no condition has been specified.) - # NotFoundError (Not Found. The specified resource does not exist.) - # ConflictError (Conflict. Specified resource already exists.) - # InternalServerErrorError (Internal Server Error.) - // resource function post throttling/policies/'import(boolean? overwrite, http:Request request) returns http:Ok|ForbiddenError|NotFoundError|ConflictError|InternalServerErrorError { - // } + # Get all Deny Policies # # + accept - Media types acceptable for the response. Default is application/json. @@ -435,18 +246,6 @@ service http:InterceptableService /api/admin on ep0 { return http:OK; } } - # Retrieve Admin Settings - # - # + return - returns can be any of following types - # Settings (OK. Settings returned) - # NotFoundError (Not Found. The specified resource does not exist.) - resource function get settings(http:RequestContext requestContext) returns Settings|NotFoundError|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - - SettingsClient settingsClient = new; - return settingsClient.getSettings(organization); - } # Get all Key managers # # + return - OK. KeyManagers returned @@ -513,13 +312,6 @@ service http:InterceptableService /api/admin on ep0 { http:Ok okResponse = {}; return okResponse; } - # Retrieve Well-known information from Key Manager Well-known Endpoint - # - # + request - parameter description - # + return - OK. KeyManagers returned - // resource function post 'key\-managers/discover(http:Request request) returns OkKeyManagerWellKnownResponse { - // } - # Retrieve All Pending Workflow Processes # diff --git a/admin/admin-domain-service/ballerina/policyDAO.bal b/admin/admin-domain-service/ballerina/policyDAO.bal new file mode 100644 index 0000000000..50384e43c8 --- /dev/null +++ b/admin/admin-domain-service/ballerina/policyDAO.bal @@ -0,0 +1,108 @@ +// +// Copyright (c) 2022, WSO2 LLC. (http://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. +// + +import ballerina/log; +import ballerinax/postgresql; +import ballerina/sql; +import wso2/apk_common_lib as commons; + +public isolated function addDenyPolicyDAO(BlockingCondition bc, string org) returns BlockingCondition|commons:APKError { + postgresql:Client | error dbClient = getConnection(); + if dbClient is error { + return e909401(dbClient); + } else { + sql:ParameterizedQuery query = `INSERT INTO BLOCK_CONDITION (TYPE,BLOCK_CONDITION,ENABLED,ORGANIZATION,UUID) + VALUES (${bc.conditionType},${bc.conditionValue},${bc.conditionStatus},${org},${bc.policyId})`; + sql:ExecutionResult | sql:Error result = dbClient->execute(query); + if result is sql:ExecutionResult { + return bc; + } else { + log:printError(result.toString()); + return e909402(result); + } + } +} + +public isolated function getDenyPolicyByIdDAO(string policyId, string org) returns BlockingCondition|commons:APKError { + postgresql:Client | error dbClient = getConnection(); + if dbClient is error { + return e909401(dbClient); + } else { + sql:ParameterizedQuery query = `SELECT UUID as POLICYID, TYPE as CONDITIONTYPE, BLOCK_CONDITION as CONDITIONVALUE, ENABLED::BOOLEAN as CONDITIONSTATUS FROM BLOCK_CONDITION WHERE UUID =${policyId} AND ORGANIZATION =${org}`; + BlockingCondition | sql:Error result = dbClient->queryRow(query); + if result is sql:NoRowsError { + log:printDebug(result.toString()); + return e909431(); + } else if result is BlockingCondition { + log:printDebug(result.toString()); + return result; + } else { + log:printError(result.toString()); + return e909422(result); + } + } +} + +public isolated function getDenyPoliciesDAO(string org) returns BlockingCondition[]|commons:APKError { + postgresql:Client | error dbClient = getConnection(); + if dbClient is error { + return e909401(dbClient); + } else { + do { + sql:ParameterizedQuery query = `SELECT UUID as POLICYID, TYPE as CONDITIONTYPE, BLOCK_CONDITION as CONDITIONVALUE, ENABLED::BOOLEAN as CONDITIONSTATUS FROM BLOCK_CONDITION WHERE ORGANIZATION =${org}`; + stream denyPoliciesStream = dbClient->query(query); + BlockingCondition[] denyPolicies = check from BlockingCondition denyPolicy in denyPoliciesStream select denyPolicy; + check denyPoliciesStream.close(); + return denyPolicies; + } on fail var e { + return e909423(e); + } + } +} + +public isolated function updateDenyPolicyDAO(BlockingConditionStatus status) returns string|commons:APKError { + postgresql:Client | error dbClient = getConnection(); + if dbClient is error { + return e909401(dbClient); + } else { + sql:ParameterizedQuery query = `UPDATE BLOCK_CONDITION SET ENABLED = ${status.conditionStatus} WHERE UUID = ${status.policyId}`; + sql:ExecutionResult | sql:Error result = dbClient->execute(query); + if result is sql:ExecutionResult { + return ""; + } else { + log:printError(result.toString()); + return e909402(result); + } + } +} + +public isolated function deleteDenyPolicyDAO(string policyId, string org) returns string|commons:APKError { + postgresql:Client | error dbClient = getConnection(); + if dbClient is error { + return e909401(dbClient); + } else { + sql:ParameterizedQuery query = `DELETE FROM BLOCK_CONDITION WHERE UUID = ${policyId} AND ORGANIZATION = ${org}`; + sql:ExecutionResult | sql:Error result = dbClient->execute(query); + if result is sql:ExecutionResult { + return ""; + } else { + log:printError(result.toString()); + return e909406(result); + } + } +} \ No newline at end of file diff --git a/admin/admin-domain-service/ballerina/policyImpl.bal b/admin/admin-domain-service/ballerina/policyImpl.bal new file mode 100644 index 0000000000..1d3b080554 --- /dev/null +++ b/admin/admin-domain-service/ballerina/policyImpl.bal @@ -0,0 +1,81 @@ +// +// Copyright (c) 2022, WSO2 LLC. (http://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. +// + +import ballerina/uuid; +import wso2/apk_common_lib as commons; + +isolated function addDenyPolicy(BlockingCondition body, commons:Organization org) returns BlockingCondition|commons:APKError { + string policyId = uuid:createType1AsString(); + body.policyId = policyId; + //Todo : need to validate each type + match body.conditionType { + "APPLICATION" => { + } + "API" => { + } + "IP" => { + } + "IPRANGE" => { + } + "USER" => { + } + } + BlockingCondition|commons:APKError policy = addDenyPolicyDAO(body, org.uuid); + return policy; +} + +isolated function getDenyPolicyById(string policyId, commons:Organization org) returns BlockingCondition|commons:APKError { + BlockingCondition|commons:APKError policy = getDenyPolicyByIdDAO(policyId, org.uuid); + return policy; +} + +isolated function getAllDenyPolicies(commons:Organization org) returns BlockingConditionList|commons:APKError { + BlockingCondition[]|commons:APKError denyPolicies = getDenyPoliciesDAO(org.uuid); + if denyPolicies is BlockingCondition[] { + int count = denyPolicies.length(); + BlockingConditionList denyPoliciesList = {count: count, list: denyPolicies}; + return denyPoliciesList; + } else { + return denyPolicies; + } +} + +isolated function updateDenyPolicy(string policyId, BlockingConditionStatus status, commons:Organization org) returns BlockingCondition|commons:APKError { + BlockingCondition|commons:APKError existingPolicy = getDenyPolicyByIdDAO(policyId, org.uuid); + if existingPolicy !is BlockingCondition { + return existingPolicy; + } else { + status.policyId = policyId; + } + string|commons:APKError response = updateDenyPolicyDAO(status); + if response is commons:APKError{ + return response; + } + BlockingCondition|commons:APKError updatedPolicy = getDenyPolicyByIdDAO(policyId, org.uuid); + if updatedPolicy is BlockingCondition { + return updatedPolicy; + } else { + return updatedPolicy; + } +} + +isolated function removeDenyPolicy(string policyId, commons:Organization org) returns commons:APKError|string { + commons:APKError|string status = deleteDenyPolicyDAO(policyId, org.uuid); + return status; +} + diff --git a/admin/admin-domain-service/ballerina/resources/admin-api.yaml b/admin/admin-domain-service/ballerina/resources/admin-api.yaml index e84310292e..9223da8dfb 100644 --- a/admin/admin-domain-service/ballerina/resources/admin-api.yaml +++ b/admin/admin-domain-service/ballerina/resources/admin-api.yaml @@ -29,672 +29,6 @@ servers: - url: https://apis.wso2.com/api/admin/v1 paths: ###################################################### - # The "Content Search Results" Throttling Policies - ###################################################### - /policies/search: - get: - tags: - - Unified Search - summary: | - Retrieve/Search Policies - description: | - This operation provides you a list of available Policies qualifying the given keyword match. - parameters: - - name: query - in: query - description: | - **Search**. - You can search by providing a keyword. Allowed to search by type and name only. - schema: - type: string - responses: - 200: - description: | - OK.List of qualifying Policies is returned. - headers: - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/PolicyDetailsList' - security: - - OAuth2Security: - - apk:admin - - apk:tier_view - - apk:policies_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/throttling/policies/search?query=type:sub"' - operationId: policySearch - - ###################################################### - # The "Application Rate Plans Collection" resource API - ###################################################### - /application-rate-plans: - get: - tags: - - Application Rate Plan (Collection) - summary: Get all Application Rate Plans - description: | - Retrieves all existing application rate plans. - parameters: - - $ref: '#/components/parameters/Accept' - responses: - 200: - description: | - OK. Policies returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlanList' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/application-rate-plans"' - operationId: getApplicationRatePlans - - post: - tags: - - Application Rate Plan (Collection) - summary: Add an Application Rate Plan - description: | - This operation can be used to add a new application level rate plan. - parameters: - - $ref: '#/components/parameters/Content-Type' - requestBody: - description: | - Application level policy object that should to be added - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlan' - required: true - responses: - 201: - description: | - Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity. - headers: - Location: - description: | - Location of the newly created Policy object. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlan' - example: - policyId: e0fd4a15-969e-4056-94c8-8a7b56f8103f - policyName: 20PerMin - displayName: 20PerMin - description: Allows 20 request per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 20 - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apk:tier_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/admin/application-rate-plans"' - operationId: addApplicationRatePlan - - ###################################################### - # The "Individual Application Rate Plan" resource API - ###################################################### - /application-rate-plans/{planId}: - get: - tags: - - Application Rate Plan (Individual) - summary: Get an Application Rate Plan - description: | - Retrieves an application rate plan. - parameters: - - $ref: '#/components/parameters/planId' - responses: - 200: - description: | - OK. Plan returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlan' - example: - policyId: e0fd4a15-969e-4056-94c8-8a7b56f8103f - policyName: 20PerMin - displayName: 20PerMin - description: Allows 20 request per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 20 - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/application-rate-plans/4e098fff-7f94-459a-981f-d257332f69d0"' - operationId: getApplicationRatePlanById - - put: - tags: - - Application Rate Plan (Individual) - summary: Update an Application Rate Plan - description: | - Updates an existing application level rate plan. Upon a successful update, you will receive the updated application plan as the response. - parameters: - - $ref: '#/components/parameters/planId' - - $ref: '#/components/parameters/Content-Type' - requestBody: - description: | - Policy object that needs to be modified - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlan' - required: true - responses: - 200: - description: | - OK. Plan updated. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationRatePlan' - example: - policyId: e0fd4a15-969e-4056-94c8-8a7b56f8103f - policyName: 20PerMin - displayName: 20PerMin - description: Allows 20 request per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 20 - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:tier_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/admin/application-rate-plans/4e098fff-7f94-459a-981f-d257332f69d0"' - operationId: updateApplicationRatePlan - - delete: - tags: - - Application Rate Plan (Individual) - summary: Delete an Application Rate Plan - description: | - Deletes an application level rate plan. - parameters: - - $ref: '#/components/parameters/planId' - responses: - 200: - description: | - OK. Resource successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:tier_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/admin/application-rate-plans/4e098fff-7f94-459a-981f-d257332f69d0"' - operationId: removeApplicationRatePlan - - - ###################################################### - # The "Business Plans Collection" resource API - ###################################################### - /business-plans: - get: - tags: - - Business Plan (Collection) - summary: Get all Business Plans - description: | - This operation can be used to retrieve all Business Plans. - parameters: - - $ref: '#/components/parameters/Accept' - responses: - 200: - description: | - OK. Plans returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlanList' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/business-plans"' - operationId: getAllBusinessPlans - - post: - tags: - - Business Plan (Collection) - summary: Add a Business Plan - description: | - This operation can be used to add a Business Plan specifying the details of the plan in the payload. - parameters: - - $ref: '#/components/parameters/Content-Type' - requestBody: - description: | - Business Plan object that should to be added - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlan' - required: true - responses: - 201: - description: | - Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity. - headers: - Location: - description: | - Location of the newly created Plan object. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlan' - example: - policyId: 78c3ebff-176d-40d8-9377-fb3276528291 - policyName: Gold - displayName: Gold - description: Allows 5000 requests per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 5000 - rateLimitCount: 0 - customAttributes: [] - stopOnQuotaReach: true - billingPlan: FREE - 400: - $ref: '#/components/responses/BadRequest' - 415: - $ref: '#/components/responses/UnsupportedMediaType' - security: - - OAuth2Security: - - apk:tier_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/admin/business-plans"' - operationId: addBusinessPlan - - ###################################################### - # The "Individual Business Plan" resource API - ###################################################### - /business-plans/{planId}: - get: - tags: - - Business Plan (Individual) - summary: Get a Business Plan - description: | - This operation can be used to retrieves Business Plan by specifying the Id of the plan as a path parameter - parameters: - - $ref: '#/components/parameters/planId' - responses: - 200: - description: | - OK. Plan returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlan' - example: - policyId: 78c3ebff-176d-40d8-9377-fb3276528291 - policyName: Gold - displayName: Gold - description: Allows 5000 requests per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 5000 - rateLimitCount: 0 - customAttributes: [] - stopOnQuotaReach: true - billingPlan: FREE - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/business-plans/c948c723-71dd-4d50-8c77-0a0e99c8cbb1"' - operationId: getBusinessPlanById - - put: - tags: - - Business Plan (Individual) - summary: Update a Business Plan - description: | - Updates an existing Business Plan. - parameters: - - $ref: '#/components/parameters/planId' - - $ref: '#/components/parameters/Content-Type' - requestBody: - description: | - Plan object that needs to be modified - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlan' - required: true - responses: - 200: - description: | - OK. Plan updated. - headers: - Location: - description: | - The URL of the newly created resource. - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlan' - example: - policyId: 78c3ebff-176d-40d8-9377-fb3276528291 - policyName: Gold - displayName: Gold - description: Allows 5000 requests per minute - isDeployed: true - defaultLimit: - type: REQUESTCOUNTLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 5000 - rateLimitCount: 0 - customAttributes: [] - stopOnQuotaReach: true - billingPlan: FREE - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:tier_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/admin/business-plans/c948c723-71dd-4d50-8c77-0a0e99c8cbb1"' - operationId: updateBusinessPlan - - delete: - tags: - - Business Plan (Individual) - summary: Delete a Business Plan - description: | - This operation can be used to delete a business plan by specifying the Id of the plan as a path parameter. - parameters: - - $ref: '#/components/parameters/planId' - responses: - 200: - description: | - OK. Resource successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:tier_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/admin/business-plans/c948c723-71dd-4d50-8c77-0a0e99c8cbb1"' - operationId: removeBusinessPlan - - ###################################################### - # "Export Throttling Policy" resource API - ###################################################### - /throttling/policies/export: - get: - tags: - - Import Export - summary: Export a Throttling Policy - description: | - This operation can be used to export the details of a particular Throttling Policy. - parameters: - - name: policyId - in: query - description: UUID of the ThrottlingPolicy - schema: - type: string - - name: name - in: query - description: | - Throttling Policy Name - schema: - type: string - - name: type - in: query - description: | - Type of the Throttling Policy - schema: - type: string - enum: - - sub - - app - - api - - global - - name: format - in: query - description: | - Format of output documents. Can be YAML or JSON. - schema: - type: string - enum: - - JSON - - YAML - responses: - 200: - description: | - OK. Export Successful. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ExportPolicy' - example: - type: rate-limiting policy - subtype: application - version: v4.1.0 - data: - policyId: cd828243-a0db-430c-97e9-9e41fd865d48 - policyName: 50PerMin - displayName: 50PerMin - description: Allows 50 request per minute - isDeployed: true - type: ApplicationThrottlePolicy - defaultLimit: - type: BANDWIDTHLIMIT - requestCount: - timeUnit: min - unitTime: 1 - requestCount: 50 - bandwidth: - timeUnit: min - unitTime: 5 - dataAmount: 100 - dataUnit: MB - eventCount: - timeUnit: min - unitTime: 5 - eventCount: 16 - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/throttling/policies/export?policyId=96077508-fd01-4fae-bc64-5de0e2baf43c&name=Bronze&type=subscription&format=YAML"' - operationId: exportThrottlingPolicy - #################################################################### - # Import Throttling Policy - #################################################################### - /throttling/policies/import: - post: - tags: - - Import Export - summary: Import a Throttling Policy - description: | - This operation can be used to import a Throttling Policy. - parameters: - - name: overwrite - in: query - description: | - Update an existing throttling policy with the same name. - required: false - schema: - type: boolean - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: Json File - format: binary - required: true - responses: - 200: - description: | - Created. Throttling Policy Imported Successfully. - 403: - $ref: '#/components/responses/Forbidden' - 404: - $ref: '#/components/responses/NotFound' - 409: - $ref: '#/components/responses/Conflict' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: - - apk:tier_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/throttling/policies/import?overwrite=True"' - operationId: importThrottlingPolicy - ###################################################### # The "Deny Policy Collection" resource API ###################################################### /deny-policies: @@ -724,11 +58,12 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - - apk:bl_manage + - apk:admin + - apk:deny_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/throttling/deny-policies"' + "https://api.am.wso2.com:9095/api/am/admin/throttling/deny-policies"' operationId: getAllDenyPolicies post: @@ -772,11 +107,12 @@ paths: $ref: '#/components/responses/UnsupportedMediaType' security: - OAuth2Security: - - apk:bl_manage + - apk:admin + - apk:deny_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/admin/v3/throttling/deny-policies"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/throttling/deny-policies"' operationId: addDenyPolicy ###################################################### @@ -811,11 +147,12 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - - apk:bl_manage + - apk:admin + - apk:deny_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' + "https://api.am.wso2.com:9095/api/am/admin/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' operationId: getDenyPolicyById delete: @@ -835,11 +172,11 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:bl_manage + - apk:deny_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/admin/v3/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' + "https://api.am.wso2.com:9095/api/am/admin/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' operationId: removeDenyPolicy patch: @@ -873,11 +210,12 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:bl_manage + - apk:admin + - apk:deny_manage x-code-samples: - lang: Curl source: 'curl -k -X PATCH -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://127.0.0.1:9443/api/admin/v3/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/throttling/deny-policy/b513eb68-69e8-4c32-92cf-852c101363c"' operationId: updateDenyPolicy ###################################################### @@ -948,11 +286,12 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - - apk:admin_application_manage + - apk:admin + - apk:application_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/applications"' + "https://api.am.wso2.com:9095/api/am/admin/applications"' operationId: getApplicationsByUser ###################################################### @@ -984,11 +323,12 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - - apk:admin_application_manage + - apk:admin + - apk:application_manage x-code-samples: - lang: Curl source: 'curl -k -X GET -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' + "https://api.am.wso2.com:9095/api/am/admin/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' operationId: getApplicationById delete: @@ -1022,11 +362,12 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:admin_application_manage + - apk:admin + - apk:application_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/admin/v3/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' + "https://api.am.wso2.com:9095/api/am/admin/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' operationId: removeApplication /applications/{applicationId}/change-owner: @@ -1055,11 +396,12 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:admin_application_manage + - apk:admin + - apk:application_manage x-code-samples: - lang: Curl source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b/change-owner?owner=admin"' + "https://api.am.wso2.com:9095/api/am/admin/applications/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b/change-owner?owner=admin"' operationId: changeApplicationOwner ###################################################### @@ -1083,11 +425,11 @@ paths: security: - OAuth2Security: - apk:admin - - apk:environment_read + - apk:environment_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/environments"' + "https://api.am.wso2.com:9095/api/am/admin/environments"' operationId: getEnvironments post: @@ -1121,7 +463,7 @@ paths: 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/admin/v3/environments"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/environments"' operationId: addEnvironment ###################################################### @@ -1162,130 +504,35 @@ paths: - apk:environment_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/admin/v3/environments/d7cf8523-9180-4255-84fa-6cb171c1f779"' - operationId: updateEnvironment - - delete: - tags: - - Environments - summary: Delete an Environment - description: | - Delete a Environment by Environment Id - parameters: - - $ref: '#/components/parameters/environmentId' - responses: - 200: - description: | - OK. Environment successfully deleted. - content: {} - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:admin - - apk:environment_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/admin/v3/environments/d7cf8523-9180-4255-84fa-6cb171c1f779"' - operationId: removeEnvironment - - - ###################################################### - # The Tenant Info resource API - ###################################################### - /tenant-info/{username}: - get: - tags: - - Tenants - summary: | - Get Tenant Id of User - description: | - This operation is to get tenant id of the provided user - operationId: getTenantInfoByUsername - parameters: - - name: username - in: path - description: | - The state represents the current state of the tenant. Supported states are [ active, inactive] - required: true - schema: - type: string - default: john - responses: - 200: - description: | - OK. Tenant id of the user retrieved. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/TenantInfo' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:admin - - apk:tenantInfo - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/tenant-info/john"' + source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/environments/d7cf8523-9180-4255-84fa-6cb171c1f779"' + operationId: updateEnvironment - ###################################################### - # The Custom URL Info resource API - ###################################################### - /custom-urls/{tenantDomain}: - get: + delete: tags: - - Tenants - summary: | - Get Custom URL Info of a Tenant Domain + - Environments + summary: Delete an Environment description: | - This operation is to get custom-url information of the provided tenant-domain - operationId: getCustomUrlInfoByTenantDomain + Delete a Environment by Environment Id parameters: - - name: tenantDomain - in: path - description: | - The tenant domain name. - required: true - schema: - type: string + - $ref: '#/components/parameters/environmentId' responses: 200: description: | - OK. Custom url info of the tenant is retrieved. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/CustomUrlInfo' + OK. Environment successfully deleted. + content: {} 404: $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - apk:admin - - apk:tenantInfo + - apk:environment_manage x-code-samples: - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/custom-urls/wso2.com"' + source: 'curl -k -X DELETE -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" + "https://api.am.wso2.com:9095/api/am/admin/environments/d7cf8523-9180-4255-84fa-6cb171c1f779"' + operationId: removeEnvironment + ###################################################### # The "Category Collection" resource API @@ -1307,11 +554,12 @@ paths: $ref: '#/components/schemas/APICategoryList' security: - OAuth2Security: + - apk:admin - apk:category_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/api-categories"' + "https://api.am.wso2.com:9095/api/am/admin/api-categories"' operationId: getAllCategories post: @@ -1340,11 +588,12 @@ paths: $ref: '#/components/responses/BadRequest' security: - OAuth2Security: + - apk:admin - apk:category_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/admin/v3/api-categories"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/api-categories"' operationId: addCategory ###################################################### @@ -1381,11 +630,12 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: + - apk:admin - apk:category_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/admin/v3/api-categories/d7cf8523-9180-4255-84fa-6cb171c1f779"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/api-categories/d7cf8523-9180-4255-84fa-6cb171c1f779"' operationId: updateCategory delete: @@ -1405,39 +655,14 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: + - apk:admin - apk:category_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/admin/v3/api-categories/d7cf8523-9180-4255-84fa-6cb171c1f779"' + "https://api.am.wso2.com:9095/api/am/admin/api-categories/d7cf8523-9180-4255-84fa-6cb171c1f779"' operationId: removeCategory - ###################################################### - # The Admin settings List - ###################################################### - /settings: - get: - tags: - - Settings - summary: Retrieve Admin Settings - description: | - Retrieve admin settings - responses: - 200: - description: | - OK. Settings returned - content: - application/json: - schema: - $ref: '#/components/schemas/Settings' - 404: - $ref: '#/components/responses/NotFound' - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/settings"' - operationId: getAdminSettings - ###################################################### # The "Key Manager Collection" resource API ###################################################### @@ -1458,11 +683,12 @@ paths: $ref: '#/components/schemas/KeyManagerList' security: - OAuth2Security: - - apk:keymanager_operations + - apk:admin + - apk:keymanager_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/key-managers"' + "https://api.am.wso2.com:9095/api/am/admin/key-managers"' operationId: getAllKeyManagers post: @@ -1491,11 +717,12 @@ paths: $ref: '#/components/responses/BadRequest' security: - OAuth2Security: - - apk:keymanager_operations + - apk:admin + - apk:keymanager_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/admin/v3/key-managers"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/key-managers"' operationId: addNewKeyManager ###################################################### @@ -1530,11 +757,12 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: - - apk:keymanager_operations + - apk:admin + - apk:keymanager_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/v3/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' + "https://api.am.wso2.com:9095/api/am/admin/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' operationId: getKeyManagerConfiguration put: @@ -1567,11 +795,12 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:keymanager_operations + - apk:admin + - apk:keymanager_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/admin/v3/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/admin/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' operationId: updateKeyManager delete: @@ -1591,50 +820,14 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: - - apk:keymanager_operations + - apk:admin + - apk:keymanager_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/admin/v3/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' + "https://api.am.wso2.com:9095/api/am/admin/key-managers/8d263942-a6df-4cc2-a804-7a2525501450"' operationId: removeKeyManager - /key-managers/discover: - post: - tags: - - Key Manager (Collection) - summary: Retrieve Well-known information from Key Manager Well-known Endpoint - description: | - Retrieve well-known information from key manager's well-known endpoint - requestBody: - content: - multipart/form-data: - schema: - properties: - url: - type: string - description: Well-Known Endpoint - type: - type: string - description: | - Key Manager Type - default: "false" - responses: - 200: - description: | - OK. KeyManagers returned - content: - application/json: - schema: - $ref: '#/components/schemas/KeyManagerWellKnownResponse' - security: - - OAuth2Security: - - apk:keymanager_operations - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F "type=WSO2-IS" "https://127.0.0.1:9443/api/admin/v3/key-managers/discover"' - operationId: getWellKnownInfoKeyManager - ###################################################### # The "Organization" resource API ###################################################### @@ -1659,7 +852,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/organizations"' + "https://api.am.wso2.com:9095/api/admin/organizations"' operationId: getAllOrganization post: @@ -1692,7 +885,7 @@ paths: 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/admin/organizations"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/admin/organizations"' operationId: addOrganization /organizations/{organizationId}: get: @@ -1724,7 +917,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -X GET -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/organizations/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' + "https://api.am.wso2.com:9095/api/admin/organizations/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' operationId: getOrganizationById put: tags: @@ -1760,7 +953,7 @@ paths: 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/admin/organizations/d7cf8523-9180-4255-84fa-6cb171c1f779"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/admin/organizations/d7cf8523-9180-4255-84fa-6cb171c1f779"' operationId: updateOrganization delete: tags: @@ -1783,7 +976,7 @@ paths: 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/admin/organizations/d7cf8523-9180-4255-84fa-6cb171c1f779"' + "https://api.am.wso2.com:9095/api/admin/organizations/d7cf8523-9180-4255-84fa-6cb171c1f779"' operationId: removeOrganization /organization-info: get: @@ -1811,7 +1004,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -X GET -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://127.0.0.1:9443/api/admin/organization-info/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' + "https://api.am.wso2.com:9095/api/admin/organization-info/0a043c2b-ee75-4ef3-9e1c-fc2610ccfa8b"' operationId: getOrganizationByClaimValue ###################################################### @@ -1863,6 +1056,7 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:admin - apk:workflow_manage /workflows/update-workflow-status: @@ -1902,6 +1096,7 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: + - apk:admin - apk:workflow_manage components: @@ -1949,289 +1144,6 @@ components: type: string description: | Description about individual errors occurred - PolicyDetailsList: - title: Policy List - type: object - properties: - count: - type: integer - description: | - Number of Throttling Policies returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/PolicyDetails' - PolicyDetails: - title: Generic Policy - required: - - policyName - type: object - properties: - policyId: - type: integer - description: Id of policy - readOnly: true - example: 3 - uuid: - type: string - description: UUId of policy - readOnly: true - example: 0c6439fd-9b16-3c2e-be6e-1086e0b9aa93 - policyName: - maxLength: 60 - minLength: 1 - type: string - description: Name of policy - example: 30PerMin - displayName: - type: string - description: Display name of the policy - example: 30PerMin - maxLength: 512 - description: - maxLength: 1024 - type: string - description: Description of the policy - example: Allows 30 request per minute - isDeployed: - type: boolean - description: Indicates whether the policy is deployed successfully or not. - default: false - type: - type: string - description: Indicates the type of throttle policy - Policy: - title: Generic Throttling Policy - required: - - planName - type: object - properties: - planId: - type: string - description: Id of plan - readOnly: true - example: 0c6439fd-9b16-3c2e-be6e-1086e0b9aa93 - planName: - maxLength: 60 - minLength: 1 - type: string - description: Name of plan - example: 30PerMin - displayName: - type: string - description: Display name of the policy - example: 30PerMin - maxLength: 512 - description: - maxLength: 1024 - type: string - description: Description of the policy - example: Allows 30 request per minute - isDeployed: - type: boolean - description: Indicates whether the policy is deployed successfully or not. - default: false - type: - type: string - description: Indicates the type of throttle policy - discriminator: - propertyName: type - ExportPolicy: - title: Export Policy - type : object - properties: - type: - type: string - subtype: - type: string - version: - type: string - data: - type: object - ApplicationRatePlan: - title: Application Throttling Policy - allOf: - - $ref: '#/components/schemas/Policy' - - required: - - defaultLimit - type: object - properties: - defaultLimit: - $ref: '#/components/schemas/ThrottleLimit' - ApplicationRatePlanList: - title: Application level Rate Plan List - type: object - properties: - count: - type: integer - description: | - Number of Application Rate Plans returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/ApplicationRatePlan' - BusinessPlan: - title: Business Plan - allOf: - - $ref: '#/components/schemas/Policy' - - $ref: '#/components/schemas/GraphQLQuery' - - required: - - defaultLimit - type: object - properties: - defaultLimit: - $ref: '#/components/schemas/ThrottleLimit' - rateLimitCount: - type: integer - description: Burst control request count - example: 10 - rateLimitTimeUnit: - type: string - description: Burst control time unit - example: min - subscriberCount: - type: integer - description: Number of subscriptions allowed - example: 10 - customAttributes: - type: array - description: | - Custom attributes added to the Subscription Throttling Policy - example: [] - items: - $ref: '#/components/schemas/CustomAttribute' - permissions: - $ref: '#/components/schemas/BusinessPlanPermission' - BusinessPlanPermission: - title: Business Plan Permission - required: - - permissionType - - roles - type: object - properties: - permissionType: - type: string - example: deny - enum: - - ALLOW - - DENY - roles: - type: array - example: - - Internal/everyone - items: - type: string - GraphQLQuery: - title: GraphQL Query - type: object - properties: - graphQLMaxComplexity: - type: integer - description: Maximum Complexity of the GraphQL query - example: 400 - graphQLMaxDepth: - type: integer - description: Maximum Depth of the GraphQL query - example: 10 - BusinessPlanList: - title: Business Plan List - type: object - properties: - count: - type: integer - description: | - Number of Business Plans returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/BusinessPlan' - ThrottleLimitBase: - title: Throttle Limit Base - required: - - timeUnit - - unitTime - type: object - properties: - timeUnit: - type: string - description: Unit of the time. Allowed values are "sec", "min", "hour", - "day" - example: min - unitTime: - type: integer - description: Time limit that the throttling limit applies. - example: 10 - ThrottleLimit: - title: Throttle Limit - required: - - type - type: object - properties: - type: - type: string - description: | - Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in - Definitions section. - example: REQUESTCOUNTLIMIT - enum: - - REQUESTCOUNTLIMIT - - BANDWIDTHLIMIT - - EVENTCOUNTLIMIT - requestCount: - $ref: '#/components/schemas/RequestCountLimit' - bandwidth: - $ref: '#/components/schemas/BandwidthLimit' - eventCount: - $ref: '#/components/schemas/EventCountLimit' - BandwidthLimit: - title: Bandwidth Limit object - allOf: - - $ref: '#/components/schemas/ThrottleLimitBase' - - required: - - dataAmount - - dataUnit - type: object - properties: - dataAmount: - type: integer - description: Amount of data allowed to be transferred - format: int64 - example: 1000 - dataUnit: - type: string - description: Unit of data allowed to be transferred. Allowed values are - "KB", "MB" and "GB" - example: KB - RequestCountLimit: - title: Request Count Limit object - allOf: - - $ref: '#/components/schemas/ThrottleLimitBase' - - required: - - requestCount - type: object - properties: - requestCount: - type: integer - description: Maximum number of requests allowed - format: int64 - example: 30 - EventCountLimit: - title: Event Count Limit object - allOf: - - $ref: '#/components/schemas/ThrottleLimitBase' - - required: - - eventCount - type: object - properties: - eventCount: - type: integer - description: Maximum number of events allowed - format: int64 - example: 3000 BlockingCondition: title: Blocking Conditions required: @@ -2539,60 +1451,6 @@ components: type: string description: detailed message of the status example: Records published successfully - MonetizationUsagePublishInfo: - title: Usage publish status - type: object - properties: - state: - type: string - description: State of usage publish job - example: RUNNING - status: - type: string - description: Status of usage publish job - example: SUCCESSFULL - startedTime: - type: string - description: Timestamp of the started time of the Job - example: "1599196134000" - lastPublsihedTime: - type: string - description: Timestamp of the last published time - example: "1599196134000" - TenantInfo: - title: Tenant information - type: object - properties: - username: - type: string - example: john - tenantDomain: - type: string - example: carbon.super - tenantId: - type: integer - example: -1234 - description: The tenant information of the user - CustomUrlInfo: - title: Custom url information - type: object - properties: - tenantDomain: - type: string - example: carbon.super - tenantAdminUsername: - type: string - example: john@foo.com - enabled: - type: boolean - example: true - devPortal: - type: object - properties: - url: - type: string - example: http://example.com - description: The custom url information of the tenant domain Organization: title: Organization required: @@ -2700,6 +1558,10 @@ components: title: Workflow info object with basic workflow details type: object properties: + workflowReferenceId: + type: string + description: | + Id of the Workflow Request. workflowType: type: string description: | @@ -2790,53 +1652,6 @@ components: type: array items: $ref: '#/components/schemas/APICategory' - Settings: - title: Settings - type: object - properties: - scopes: - type: array - items: - type: string - keyManagerConfiguration: - type: array - items: - type: object - properties: - type: - type: string - example: default - displayName: - type: string - example: default - defaultConsumerKeyClaim: - type: string - example: azp - defaultScopesClaim: - type: string - example: scope - configurations: - type: array - items: - $ref: '#/components/schemas/KeyManagerConfiguration' - endpointConfigurations: - type: array - items: - $ref: '#/components/schemas/KeyManagerConfiguration' - analyticsEnabled: - type: boolean - description: To determine whether analytics is enabled or not - example: false - KeyManagerWellKnownResponse: - title: Key Manager Well-Known Response. - type: object - properties: - valid: - type: boolean - example: true - default: false - value: - $ref: '#/components/schemas/KeyManager' KeyManager: title: Key Manager required: @@ -2945,7 +1760,7 @@ components: example: 'token_endpoint' value: type: string - example: 'https://localhost:9443/oauth2/token' + example: 'https://localhost:9095/oauth2/token' KeyManagerInfo: title: Key Manager Info required: @@ -2968,38 +1783,6 @@ components: enabled: type: boolean example: true - KeyManagerConfiguration: - title: Key Manager Configuration - type: object - properties: - name: - type: string - example: consumer_key - label: - type: string - example: Consumer Key - type: - type: string - example: select - required: - type: boolean - example: true - mask: - type: boolean - example: true - multiple: - type: boolean - example: true - tooltip: - type: string - example: Enter username to connect to key manager - default: - type: string - example: admin - values: - type: array - items: - type: string KeyManagerList: title: Key Manager List type: object @@ -3379,18 +2162,17 @@ components: type: oauth2 flows: password: - tokenUrl: https://localhost:9443/oauth2/token + tokenUrl: https://localhost:9095/oauth2/token scopes: openid: Authorize access to user details apk:organization_manage: Manage all organization apk:admin: Manage all admin operations - apk:tier_manage: Update and delete throttling policies - apk:bl_manage: Update and delete deny policies + apk:deny_manage: Update and delete deny policies apk:environment_manage: Manage gateway environments apk:category_manage: Manage API Categories - apk:keymanager_operations: Manage Key Managers related + apk:keymanager_manage: Manage Key Managers related operations - apk:admin_application_manage: Manage All Applications + apk:application_manage: Manage All Applications apk:workflow_manage: manage All Workflows \ No newline at end of file diff --git a/admin/admin-domain-service/ballerina/tests/apiCategoriesTests.bal b/admin/admin-domain-service/ballerina/tests/apiCategoriesTests.bal index 2191113749..94fa0c4864 100644 --- a/admin/admin-domain-service/ballerina/tests/apiCategoriesTests.bal +++ b/admin/admin-domain-service/ballerina/tests/apiCategoriesTests.bal @@ -19,6 +19,15 @@ import ballerina/test; import wso2/apk_common_lib as commons; +commons:Organization organiztion = { + name: "org1", + displayName: "org1", + uuid: "a3b58ccf-6ecc-4557-b5bb-0a35cce38256", + organizationClaimValue: "org1", + enabled: true, + serviceListingNamespaces: ["*"], + properties: [] +}; APICategory apiCategory = {name: "MyCat1", description: "My Desc 1", id: "01ed9241-2d5d-1b98-8ecb-40f85676b081", numberOfAPIs: 2}; @test:Config {} diff --git a/admin/admin-domain-service/ballerina/tests/organizationTest.bal b/admin/admin-domain-service/ballerina/tests/organizationTest.bal index 49a3f1609c..a98ae40edc 100644 --- a/admin/admin-domain-service/ballerina/tests/organizationTest.bal +++ b/admin/admin-domain-service/ballerina/tests/organizationTest.bal @@ -35,7 +35,7 @@ Organization organization = { }; string orgId = ""; WorkflowProperties workflowProperties = { - name: "ApplicationCreation", + name: "APPLICATION_CREATION", properties: [], enable: true }; @@ -62,7 +62,7 @@ function updateOrganizationTest() { organizationClaimValue: "01234567-0123-0123-0123", workflows: [ { - name: "ApplicationCreation", + name: "APPLICATION_CREATION", enable: false, properties: [] } diff --git a/admin/admin-domain-service/ballerina/tests/throttlePolicyTests.bal b/admin/admin-domain-service/ballerina/tests/throttlePolicyTests.bal deleted file mode 100644 index 81b4bacc6b..0000000000 --- a/admin/admin-domain-service/ballerina/tests/throttlePolicyTests.bal +++ /dev/null @@ -1,308 +0,0 @@ -// -// Copyright (c) 2022, WSO2 LLC. (http://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. -// - -import ballerina/test; -import ballerina/log; -import wso2/apk_common_lib as commons; - -commons:Organization organiztion = { - name: "org1", - displayName: "org1", - uuid: "a3b58ccf-6ecc-4557-b5bb-0a35cce38256", - organizationClaimValue: "org1", - enabled: true, - serviceListingNamespaces: ["*"], - properties: [] -}; - -ApplicationRatePlan applicationUsagePlan = {planName: "25PerMin", description: "25 Per Minute", -'type:"ApplicationThrottlePolicy",defaultLimit: {'type: "REQUESTCOUNTLIMIT"}}; - -BusinessPlan businessPlan = {planName: "MySubPol1", description: "test sub pol", -'type:"SubscriptionThrottlePolicy",defaultLimit: {'type: "REQUESTCOUNTLIMIT"}, -subscriberCount: 12, rateLimitCount: 10,rateLimitTimeUnit: "sec", planId: "123456"}; - -BlockingCondition denyPolicy = {policyId: "123456",conditionType: "APPLICATION", -conditionValue: "admin:MyApp5",conditionStatus: true}; - -@test:Config {} -function addApplicationUsagePlanTest() { - ApplicationRatePlan payload = { - "planName": "25PerMin", - "displayName": "25PerMin", - "description": "25 Per Min", - "defaultLimit": { - "type": "REQUESTCOUNTLIMIT", - "requestCount": { - "requestCount": 25, - "timeUnit": "min", - "unitTime": 1 - } - } - }; - ApplicationRatePlan|commons:APKError createdAppPol = addApplicationUsagePlan(payload, organiztion); - if createdAppPol is ApplicationRatePlan { - test:assertTrue(true,"Application usage plan added successfully"); - applicationUsagePlan = createdAppPol; - log:printInfo(createdAppPol.toString()); - } else if createdAppPol is commons:APKError { - log:printError(createdAppPol.toString()); - test:assertFail("Error occured while adding Application Usage Plan"); - } -} - -@test:Config {dependsOn: [addApplicationUsagePlanTest]} -function getApplicationUsagePlanByIdTest(){ - string? planId = applicationUsagePlan.planId; - if planId is string { - ApplicationRatePlan|commons:APKError policy = getApplicationUsagePlanById(planId, organiztion); - if policy is ApplicationRatePlan { - test:assertTrue(true, "Successfully retrieved Application Usage Plan"); - log:printInfo(policy.toString()); - } else { - test:assertFail("Error occured while retrieving Application Usage Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config {dependsOn: [getApplicationUsagePlanByIdTest]} -function getApplicationUsagePlansTest(){ - ApplicationRatePlanList|commons:APKError appPolicyList = getApplicationUsagePlans(organiztion); - if appPolicyList is ApplicationRatePlanList { - test:assertTrue(true, "Successfully retrieved all Application Usage Plans"); - log:printInfo(appPolicyList.toString()); - } else if appPolicyList is commons:APKError { - test:assertFail("Error occured while retrieving all Application Usage Plans"); - } -} - -@test:Config {dependsOn: [getApplicationUsagePlansTest]} -function updateApplicationUsagePlanTest() { - ApplicationRatePlan payload = { - "planName": "25PerMin", - "displayName": "25PerMin", - "description": "25 Per Min Updated", - "defaultLimit": { - "type": "REQUESTCOUNTLIMIT", - "requestCount": { - "requestCount": 26, - "timeUnit": "min", - "unitTime": 1 - } - } - }; - string? planId = applicationUsagePlan.planId; - if planId is string { - ApplicationRatePlan|commons:APKError createdAppPol = updateApplicationUsagePlan(planId, payload, organiztion); - if createdAppPol is ApplicationRatePlan { - test:assertTrue(true,"Application usage plan updated successfully"); - } else if createdAppPol is commons:APKError { - log:printError(createdAppPol.toString()); - test:assertFail("Error occured while updating Application Usage Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config {dependsOn: [updateApplicationUsagePlanTest]} -function removeApplicationUsagePlanTest(){ - string? planId = applicationUsagePlan.planId; - if planId is string { - error?|string status = removeApplicationUsagePlan(planId, organiztion); - if status is string { - test:assertTrue(true, "Successfully deleted Application Usage Plan"); - } else if status is error { - test:assertFail("Error occured while deleting Application Usage Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config -function addBusinessPlanTest() { - BusinessPlan payload = { - "planName": "BusinessPlan2", - "displayName": "BusinessPlan2", - "description": "test sub pol test2", - "defaultLimit": { - "type": "REQUESTCOUNTLIMIT", - "requestCount": { - "requestCount": 20, - "timeUnit": "min", - "unitTime": 1 - } - }, - "rateLimitCount": 10, - "rateLimitTimeUnit": "sec", - "customAttributes": [] - }; - BusinessPlan|commons:APKError createdBusinessPlan = addBusinessPlan(payload, organiztion); - if createdBusinessPlan is BusinessPlan { - test:assertTrue(true,"Business Plan added successfully"); - businessPlan.planId = createdBusinessPlan.planId; - } else if createdBusinessPlan is commons:APKError { - test:assertFail("Error occured while adding Business Plan"); - } -} - -@test:Config {dependsOn: [addBusinessPlanTest]} -function getBusinessPlanByIdTest() { - string? planId = businessPlan.planId; - if planId is string { - BusinessPlan|commons:APKError businessPlanResponse = getBusinessPlanById(planId, organiztion); - if businessPlanResponse is BusinessPlan { - test:assertTrue(true,"Successfully retrieved Business Plan"); - } else { - test:assertFail("Error occured while retrieving Business Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config {dependsOn: [getBusinessPlanByIdTest]} -function getBusinessPlansTest() { - BusinessPlanList|commons:APKError businessPlansResponse = getBusinessPlans(organiztion); - if businessPlansResponse is BusinessPlanList { - test:assertTrue(true,"Successfully retrieved all Business Plans"); - } else if businessPlansResponse is commons:APKError { - test:assertFail("Error occured while retrieving all Business Plans"); - } -} - -@test:Config {dependsOn: [getBusinessPlansTest]} -function updateBusinessPlanTest() { - BusinessPlan payload = { - "planName": "BusinessPlan2", - "displayName": "BusinessPlan2", - "description": "test sub pol test2 updated", - "defaultLimit": { - "type": "REQUESTCOUNTLIMIT", - "requestCount": { - "requestCount": 25, - "timeUnit": "min", - "unitTime": 1 - } - }, - "rateLimitCount": 10, - "rateLimitTimeUnit": "sec", - "customAttributes": [] - }; - string? planId = businessPlan.planId; - if planId is string { - BusinessPlan|commons:APKError updatedBusinessPlan = updateBusinessPlan(planId, payload, organiztion); - if updatedBusinessPlan is BusinessPlan { - test:assertTrue(true,"Business Plan updated successfully"); - } else if updatedBusinessPlan is commons:APKError { - test:assertFail("Error occured while updating Business Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config {dependsOn: [updateBusinessPlanTest]} -function removeBusinessPlanTest(){ - string? planId = businessPlan.planId; - if planId is string { - commons:APKError|string status = removeBusinessPlan(planId, organiztion); - if status is string { - test:assertTrue(true, "Successfully deleted Business Plan"); - } else if status is commons:APKError { - test:assertFail("Error occured while deleting Business Plan"); - } - } else { - test:assertFail("Plan ID isn't a string"); - } -} - -@test:Config {} -function addDenyPolicyTest() { - BlockingCondition payload = { - "conditionType": "APPLICATION", - "conditionValue": "admin:MyApp6", - "conditionStatus": true - }; - BlockingCondition|commons:APKError createdDenyPolicy = addDenyPolicy(payload, organiztion); - if createdDenyPolicy is BlockingCondition { - test:assertTrue(true,"Deny Policy added successfully"); - denyPolicy.policyId = createdDenyPolicy.policyId; - } else if createdDenyPolicy is commons:APKError { - test:assertFail("Error occured while adding Deny Policy"); - } -} - -@test:Config {dependsOn: [addDenyPolicyTest]} -function getDenyPolicyByIdTest() { - string? policyId = denyPolicy.policyId; - if policyId is string { - BlockingCondition|commons:APKError denyPolicyResponse = getDenyPolicyById(policyId, organiztion); - if denyPolicyResponse is BlockingCondition { - test:assertTrue(true,"Successfully retrieved Deny Policy"); - } else { - test:assertFail("Error occured while retrieving Deny Policy"); - } - } else { - test:assertFail("Policy ID isn't a string"); - } -} - -@test:Config {dependsOn: [getDenyPolicyByIdTest]} -function getAllDenyPoliciesTest() { - BlockingConditionList|commons:APKError denyPoliciesResponse = getAllDenyPolicies(organiztion); - if denyPoliciesResponse is BlockingConditionList { - test:assertTrue(true,"Successfully retrieved all Deny Policy"); - } else if denyPoliciesResponse is commons:APKError { - test:assertFail("Error occured while retrieving all Deny Policy"); - } -} - -@test:Config {dependsOn: [getAllDenyPoliciesTest]} -function updateDenyPolicyTest() { - string? policyId = denyPolicy.policyId; - if policyId is string { - BlockingConditionStatus status = {conditionStatus: false, policyId: policyId}; - string?|BlockingCondition|commons:APKError denyPolicyResponse = updateDenyPolicy(policyId, status, organiztion); - if denyPolicyResponse is BlockingCondition { - test:assertTrue(true,"Successfully updated Deny Policy Status"); - } else if denyPolicyResponse is commons:APKError { - test:assertFail("Error occured while updating Deny Policy Status"); - } - } else { - test:assertFail("Policy ID isn't a string"); - } -} - -@test:Config {dependsOn: [updateDenyPolicyTest]} -function removeDenyPolicyTest(){ - string? policyId = denyPolicy.policyId; - if policyId is string { - commons:APKError|string status = removeDenyPolicy(policyId, organiztion); - if status is string { - test:assertTrue(true, "Successfully deleted Deny Policy"); - } else if status is commons:APKError { - test:assertFail("Error occured while deleting Deny Policy"); - } - } else { - test:assertFail("Policy ID isn't a string"); - } -} diff --git a/admin/admin-domain-service/ballerina/throttlingPolicyDAO.bal b/admin/admin-domain-service/ballerina/throttlingPolicyDAO.bal deleted file mode 100644 index c6bb2eeda3..0000000000 --- a/admin/admin-domain-service/ballerina/throttlingPolicyDAO.bal +++ /dev/null @@ -1,414 +0,0 @@ -// -// Copyright (c) 2022, WSO2 LLC. (http://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. -// - -import ballerina/log; -import ballerinax/postgresql; -import ballerina/sql; -import wso2/apk_common_lib as commons; - -public isolated function addApplicationUsagePlanDAO(ApplicationRatePlan atp, string org) returns ApplicationRatePlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `INSERT INTO APPLICATION_USAGE_PLAN (NAME, DISPLAY_NAME, - ORGANIZATION, DESCRIPTION, QUOTA_TYPE, QUOTA, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID) - VALUES (${atp.planName},${atp.displayName},${org},${atp.description},${atp.defaultLimit.'type}, - ${atp.defaultLimit.requestCount?.requestCount},${atp.defaultLimit.requestCount?.unitTime}, - ${atp.defaultLimit.requestCount?.timeUnit},${atp.isDeployed},${atp.planId})`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return atp; - } else if result is sql:Error { - log:printDebug(result.toString()); - return e909402(result); - } - } -} - -public isolated function getApplicationUsagePlanByIdDAO(string policyId, string org) returns ApplicationRatePlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `SELECT NAME as PLANNAME, DISPLAY_NAME as DISPLAYNAME, DESCRIPTION, - UUID as PLANID, IS_DEPLOYED as ISDEPLOYED, - QUOTA_TYPE as DefaulLimitType, QUOTA , TIME_UNIT as TIMEUNIT, UNIT_TIME as - UNITTIME, QUOTA_UNIT as DATAUNIT FROM APPLICATION_USAGE_PLAN WHERE UUID =${policyId} AND ORGANIZATION =${org}`; - ApplicationRatePlanDAO | sql:Error result = dbClient->queryRow(query); - if result is sql:NoRowsError { - log:printDebug(result.toString()); - return e909429(); - } else if result is ApplicationRatePlanDAO { - if result.defaulLimitType == "requestCount" { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, requestCount: - {requestCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(arp.toString()); - return arp; - } else if result.defaulLimitType == "bandwidth" { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, bandwidth: - {dataAmount: result.quota, dataUnit: result.dataUnit, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(arp.toString()); - return arp; - } else { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, eventCount: - {eventCount:result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(arp.toString()); - return arp; - } - } else { - log:printError(result.toString()); - return e909418(); - } - } -} - -public isolated function getApplicationUsagePlansDAO(string org) returns ApplicationRatePlan[]|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - do { - sql:ParameterizedQuery query = `SELECT NAME as PLANNAME, DISPLAY_NAME as DISPLAYNAME, DESCRIPTION, - UUID as PLANID, IS_DEPLOYED as ISDEPLOYED, - QUOTA_TYPE as DefaulLimitType, QUOTA , TIME_UNIT as TIMEUNIT, UNIT_TIME as - UNITTIME, QUOTA_UNIT as DATAUNIT FROM APPLICATION_USAGE_PLAN WHERE ORGANIZATION =${org}`; - stream usagePlanStream = dbClient->query(query); - ApplicationRatePlanDAO[] usagePlansDAO = check from ApplicationRatePlanDAO usagePlan in usagePlanStream select usagePlan; - check usagePlanStream.close(); - ApplicationRatePlan[] usagePlans = []; - if usagePlansDAO is ApplicationRatePlanDAO[]{ - foreach ApplicationRatePlanDAO result in usagePlansDAO { - if result.defaulLimitType == "requestCount" { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, requestCount: - {requestCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - usagePlans.push(arp); - } else if result.defaulLimitType == "bandwidth" { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, bandwidth: - {dataAmount: result.quota, dataUnit: result.dataUnit, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - usagePlans.push(arp); - } else { - ApplicationRatePlan arp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - defaultLimit: {'type: result.defaulLimitType, eventCount: - {eventCount:result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - usagePlans.push(arp); - } - } - } - return usagePlans; - } on fail var e { - return e909419(e); - } - } -} - -public isolated function updateApplicationUsagePlanDAO(ApplicationRatePlan atp, string org) returns ApplicationRatePlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `UPDATE APPLICATION_USAGE_PLAN SET DISPLAY_NAME = ${atp.displayName}, - DESCRIPTION = ${atp.description}, QUOTA_TYPE = ${atp.defaultLimit.'type}, QUOTA = ${atp.defaultLimit.requestCount?.requestCount}, - UNIT_TIME = ${atp.defaultLimit.requestCount?.unitTime}, TIME_UNIT = ${atp.defaultLimit.requestCount?.timeUnit} - WHERE UUID = ${atp.planId} AND ORGANIZATION = ${org}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return atp; - } else { - log:printDebug(result.toString()); - return e909405(result); - } - } -} - -public isolated function deleteApplicationUsagePlanDAO(string policyId, string org) returns string|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `DELETE FROM APPLICATION_USAGE_PLAN WHERE UUID = ${policyId} AND ORGANIZATION = ${org}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return "deleted"; - } else { - log:printError(result.toString()); - return e909406(result); - } - } -} - -public isolated function addBusinessPlanDAO(BusinessPlan stp, string org) returns BusinessPlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `INSERT INTO BUSINESS_PLAN (NAME, DISPLAY_NAME, ORGANIZATION, DESCRIPTION, - QUOTA_TYPE, QUOTA, UNIT_TIME, TIME_UNIT, IS_DEPLOYED, UUID, - RATE_LIMIT_COUNT,RATE_LIMIT_TIME_UNIT,MAX_DEPTH, MAX_COMPLEXITY, - BILLING_PLAN,CONNECTIONS_COUNT) VALUES (${stp.planName},${stp.displayName},${org},${stp.description},${stp.defaultLimit.'type}, - ${stp.defaultLimit.requestCount?.requestCount},${stp.defaultLimit.requestCount?.unitTime},${stp.defaultLimit.requestCount?.timeUnit}, - ${stp.isDeployed},${stp.planId},${stp.rateLimitCount},${stp.rateLimitTimeUnit},0, - 0,'FREE',0)`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - log:printDebug(result.toString()); - return stp; - } else { - log:printError(result.toString()); - return e909402(result); - } - } -} - -public isolated function getBusinessPlanByIdDAO(string policyId, string org) returns BusinessPlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `SELECT NAME as PLANNAME, DISPLAY_NAME as DISPLAYNAME, DESCRIPTION, - UUID as PLANID, IS_DEPLOYED as ISDEPLOYED, - QUOTA_TYPE as DefaulLimitType, QUOTA , TIME_UNIT as TIMEUNIT, UNIT_TIME as - UNITTIME, RATE_LIMIT_COUNT as RATELIMITCOUNT, RATE_LIMIT_TIME_UNIT as RATELIMITTIMEUNIT FROM BUSINESS_PLAN WHERE UUID =${policyId} AND ORGANIZATION =${org}`; - BusinessPlanDAO | sql:Error result = dbClient->queryRow(query); - if result is sql:NoRowsError { - log:printDebug(result.toString()); - return e909430(); - } else if result is BusinessPlanDAO { - if result.defaulLimitType == "requestCount" { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, requestCount: - {requestCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(bp.toString()); - return bp; - } else if result.defaulLimitType == "bandwidth" { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, bandwidth: - {dataAmount: result.quota, dataUnit: result.dataUnit, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(bp.toString()); - return bp; - } else { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, eventCount: - {eventCount:result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - log:printDebug(bp.toString()); - return bp; - } - } else { - log:printError(result.toString()); - return e909420(result); - } - } -} - -public isolated function getBusinessPlansDAO(string org) returns BusinessPlan[]|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - do { - sql:ParameterizedQuery query = `SELECT NAME as PLANNAME, DISPLAY_NAME as DISPLAYNAME, DESCRIPTION, - UUID as PLANID, IS_DEPLOYED as ISDEPLOYED, - QUOTA_TYPE as DefaulLimitType, QUOTA , TIME_UNIT as TIMEUNIT, UNIT_TIME as - UNITTIME, RATE_LIMIT_COUNT as RATELIMITCOUNT, RATE_LIMIT_TIME_UNIT as RATELIMITTIMEUNIT FROM BUSINESS_PLAN WHERE ORGANIZATION =${org}`; - stream businessPlanStream = dbClient->query(query); - BusinessPlanDAO[] businessPlansDAO = check from BusinessPlanDAO businessPlan in businessPlanStream select businessPlan; - check businessPlanStream.close(); - BusinessPlan[] businessPlans =[]; - if businessPlansDAO is BusinessPlanDAO[] { - foreach BusinessPlanDAO result in businessPlansDAO { - if result.defaulLimitType == "requestCount" { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, requestCount: - {requestCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - businessPlans.push(bp); - } else if result.defaulLimitType == "bandwidth" { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, bandwidth: - {dataAmount: result.quota, dataUnit: result.dataUnit, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - businessPlans.push(bp); - } else { - BusinessPlan bp = {planName: result.planName, displayName: result.displayName, - description: result.description, planId: result.planId, isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: {'type: result.defaulLimitType, eventCount: - {eventCount:result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - }}; - businessPlans.push(bp); - } - } - } - return businessPlans; - } on fail var e { - return e909421(e); - } - } -} - -public isolated function updateBusinessPlanDAO(BusinessPlan stp, string org) returns BusinessPlan|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `UPDATE BUSINESS_PLAN SET DISPLAY_NAME = ${stp.displayName}, - DESCRIPTION = ${stp.description}, QUOTA_TYPE = ${stp.defaultLimit.'type}, QUOTA = ${stp.defaultLimit.requestCount?.requestCount}, - UNIT_TIME = ${stp.defaultLimit.requestCount?.unitTime}, TIME_UNIT = ${stp.defaultLimit.requestCount?.timeUnit}, - RATE_LIMIT_COUNT = ${stp.rateLimitCount} , RATE_LIMIT_TIME_UNIT = ${stp.rateLimitTimeUnit}, CONNECTIONS_COUNT = 0 - WHERE UUID = ${stp.planId} AND ORGANIZATION = ${org}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return stp; - } else { - log:printError(result.toString()); - return e909405(result); - } - } -} - -public isolated function deleteBusinessPlanDAO(string policyId, string org) returns string|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `DELETE FROM BUSINESS_PLAN WHERE UUID = ${policyId} AND ORGANIZATION = ${org}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return ""; - } else { - log:printError(result.toString()); - return e909406(result); - } - } -} - -public isolated function addDenyPolicyDAO(BlockingCondition bc, string org) returns BlockingCondition|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `INSERT INTO BLOCK_CONDITION (TYPE,BLOCK_CONDITION,ENABLED,ORGANIZATION,UUID) - VALUES (${bc.conditionType},${bc.conditionValue},${bc.conditionStatus},${org},${bc.policyId})`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return bc; - } else { - log:printError(result.toString()); - return e909402(result); - } - } -} - -public isolated function getDenyPolicyByIdDAO(string policyId, string org) returns BlockingCondition|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `SELECT UUID as POLICYID, TYPE as CONDITIONTYPE, BLOCK_CONDITION as CONDITIONVALUE, ENABLED::BOOLEAN as CONDITIONSTATUS FROM BLOCK_CONDITION WHERE UUID =${policyId} AND ORGANIZATION =${org}`; - BlockingCondition | sql:Error result = dbClient->queryRow(query); - if result is sql:NoRowsError { - log:printDebug(result.toString()); - return e909431(); - } else if result is BlockingCondition { - log:printDebug(result.toString()); - return result; - } else { - log:printError(result.toString()); - return e909422(result); - } - } -} - -public isolated function getDenyPoliciesDAO(string org) returns BlockingCondition[]|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - do { - sql:ParameterizedQuery query = `SELECT UUID as POLICYID, TYPE as CONDITIONTYPE, BLOCK_CONDITION as CONDITIONVALUE, ENABLED::BOOLEAN as CONDITIONSTATUS FROM BLOCK_CONDITION WHERE ORGANIZATION =${org}`; - stream denyPoliciesStream = dbClient->query(query); - BlockingCondition[] denyPolicies = check from BlockingCondition denyPolicy in denyPoliciesStream select denyPolicy; - check denyPoliciesStream.close(); - return denyPolicies; - } on fail var e { - return e909423(e); - } - } -} - -public isolated function updateDenyPolicyDAO(BlockingConditionStatus status) returns string|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `UPDATE BLOCK_CONDITION SET ENABLED = ${status.conditionStatus} WHERE UUID = ${status.policyId}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return ""; - } else { - log:printError(result.toString()); - return e909402(result); - } - } -} - -public isolated function deleteDenyPolicyDAO(string policyId, string org) returns string|commons:APKError { - postgresql:Client | error dbClient = getConnection(); - if dbClient is error { - return e909401(dbClient); - } else { - sql:ParameterizedQuery query = `DELETE FROM BLOCK_CONDITION WHERE UUID = ${policyId} AND ORGANIZATION = ${org}`; - sql:ExecutionResult | sql:Error result = dbClient->execute(query); - if result is sql:ExecutionResult { - return ""; - } else { - log:printError(result.toString()); - return e909406(result); - } - } -} \ No newline at end of file diff --git a/admin/admin-domain-service/ballerina/throttlingPolicyImpl.bal b/admin/admin-domain-service/ballerina/throttlingPolicyImpl.bal deleted file mode 100644 index e50a910f4c..0000000000 --- a/admin/admin-domain-service/ballerina/throttlingPolicyImpl.bal +++ /dev/null @@ -1,206 +0,0 @@ -// -// Copyright (c) 2022, WSO2 LLC. (http://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. -// - -import ballerina/uuid; -import wso2/apk_common_lib as commons; - -isolated function addApplicationUsagePlan(ApplicationRatePlan body, commons:Organization org) returns ApplicationRatePlan|commons:APKError { - string policyId = uuid:createType1AsString(); - body.planId = policyId; - match body.defaultLimit.'type { - "REQUESTCOUNTLIMIT" => { - body.defaultLimit.'type = "requestCount"; - } - "BANDWIDTHLIMIT" => { - body.defaultLimit.'type = "bandwidth"; - } - "EVENTCOUNTLIMIT" => { - body.defaultLimit.'type = "eventCount"; - } - } - ApplicationRatePlan|commons:APKError policy = addApplicationUsagePlanDAO(body , org.uuid); - return policy; -} - -isolated function getApplicationUsagePlanById(string policyId, commons:Organization org) returns ApplicationRatePlan|commons:APKError { - ApplicationRatePlan|commons:APKError policy = getApplicationUsagePlanByIdDAO(policyId, org.uuid); - return policy; -} - -isolated function getApplicationUsagePlans(commons:Organization org) returns ApplicationRatePlanList|commons:APKError { - ApplicationRatePlan[]|commons:APKError usagePlans = getApplicationUsagePlansDAO(org.uuid); - if usagePlans is ApplicationRatePlan[] { - int count = usagePlans.length(); - ApplicationRatePlanList usagePlansList = {count: count, list: usagePlans}; - return usagePlansList; - } else { - return usagePlans; - } -} - -isolated function updateApplicationUsagePlan(string policyId, ApplicationRatePlan body, commons:Organization org) returns ApplicationRatePlan|commons:APKError { - ApplicationRatePlan|commons:APKError existingPolicy = getApplicationUsagePlanByIdDAO(policyId, org.uuid); - if existingPolicy is ApplicationRatePlan { - body.planId = policyId; - //body.policyName = existingPolicy.name; - } else { - return existingPolicy; - } - - match body.defaultLimit.'type { - "REQUESTCOUNTLIMIT" => { - body.defaultLimit.'type = "requestCount"; - } - "BANDWIDTHLIMIT" => { - body.defaultLimit.'type = "bandwidth"; - } - "EVENTCOUNTLIMIT" => { - body.defaultLimit.'type = "eventCount"; - } - } - ApplicationRatePlan|commons:APKError policy = updateApplicationUsagePlanDAO(body, org.uuid); - return policy; -} - -isolated function removeApplicationUsagePlan(string policyId, commons:Organization org) returns commons:APKError|string { - commons:APKError|string status = deleteApplicationUsagePlanDAO(policyId, org.uuid); - return status; -} - -isolated function addBusinessPlan(BusinessPlan body, commons:Organization org) returns BusinessPlan|commons:APKError { - string policyId = uuid:createType1AsString(); - body.planId = policyId; - match body.defaultLimit.'type { - "REQUESTCOUNTLIMIT" => { - body.defaultLimit.'type = "requestCount"; - } - "BANDWIDTHLIMIT" => { - body.defaultLimit.'type = "bandwidth"; - } - "EVENTCOUNTLIMIT" => { - body.defaultLimit.'type = "eventCount"; - } - } - BusinessPlan|commons:APKError policy = addBusinessPlanDAO(body, org.uuid); - return policy; -} - -isolated function getBusinessPlanById(string policyId, commons:Organization org) returns BusinessPlan|commons:APKError { - BusinessPlan|commons:APKError policy = getBusinessPlanByIdDAO(policyId, org.uuid); - return policy; -} - -isolated function getBusinessPlans(commons:Organization org) returns BusinessPlanList|commons:APKError { - BusinessPlan[]|commons:APKError businessPlans = getBusinessPlansDAO(org.uuid); - if businessPlans is BusinessPlan[] { - int count = businessPlans.length(); - BusinessPlanList BusinessPlansList = {count: count, list: businessPlans}; - return BusinessPlansList; - } else { - return businessPlans; - } -} - -isolated function updateBusinessPlan(string policyId, BusinessPlan body, commons:Organization org) returns BusinessPlan|commons:APKError { - BusinessPlan|commons:APKError existingPolicy = getBusinessPlanByIdDAO(policyId, org.uuid); - if existingPolicy is BusinessPlan { - body.planId = policyId; - //body.policyName = existingPolicy.name; - } else { - return existingPolicy; - } - match body.defaultLimit.'type { - "REQUESTCOUNTLIMIT" => { - body.defaultLimit.'type = "requestCount"; - } - "BANDWIDTHLIMIT" => { - body.defaultLimit.'type = "bandwidth"; - } - "EVENTCOUNTLIMIT" => { - body.defaultLimit.'type = "eventCount"; - } - } - BusinessPlan|commons:APKError policy = updateBusinessPlanDAO(body, org.uuid); - return policy; -} - -isolated function removeBusinessPlan(string policyId, commons:Organization org) returns commons:APKError|string { - commons:APKError|string status = deleteBusinessPlanDAO(policyId, org.uuid); - return status; -} - -isolated function addDenyPolicy(BlockingCondition body, commons:Organization org) returns BlockingCondition|commons:APKError { - string policyId = uuid:createType1AsString(); - body.policyId = policyId; - //Todo : need to validate each type - match body.conditionType { - "APPLICATION" => { - } - "API" => { - } - "IP" => { - } - "IPRANGE" => { - } - "USER" => { - } - } - BlockingCondition|commons:APKError policy = addDenyPolicyDAO(body, org.uuid); - return policy; -} - -isolated function getDenyPolicyById(string policyId, commons:Organization org) returns BlockingCondition|commons:APKError { - BlockingCondition|commons:APKError policy = getDenyPolicyByIdDAO(policyId, org.uuid); - return policy; -} - -isolated function getAllDenyPolicies(commons:Organization org) returns BlockingConditionList|commons:APKError { - BlockingCondition[]|commons:APKError denyPolicies = getDenyPoliciesDAO(org.uuid); - if denyPolicies is BlockingCondition[] { - int count = denyPolicies.length(); - BlockingConditionList denyPoliciesList = {count: count, list: denyPolicies}; - return denyPoliciesList; - } else { - return denyPolicies; - } -} - -isolated function updateDenyPolicy(string policyId, BlockingConditionStatus status, commons:Organization org) returns BlockingCondition|commons:APKError { - BlockingCondition|commons:APKError existingPolicy = getDenyPolicyByIdDAO(policyId, org.uuid); - if existingPolicy !is BlockingCondition { - return existingPolicy; - } else { - status.policyId = policyId; - } - string|commons:APKError response = updateDenyPolicyDAO(status); - if response is commons:APKError{ - return response; - } - BlockingCondition|commons:APKError updatedPolicy = getDenyPolicyByIdDAO(policyId, org.uuid); - if updatedPolicy is BlockingCondition { - return updatedPolicy; - } else { - return updatedPolicy; - } -} - -isolated function removeDenyPolicy(string policyId, commons:Organization org) returns commons:APKError|string { - commons:APKError|string status = deleteDenyPolicyDAO(policyId, org.uuid); - return status; -} - diff --git a/admin/admin-domain-service/ballerina/types.bal b/admin/admin-domain-service/ballerina/types.bal index c3195ddb79..9185f475f6 100644 --- a/admin/admin-domain-service/ballerina/types.bal +++ b/admin/admin-domain-service/ballerina/types.bal @@ -1,5 +1,8 @@ -import ballerina/http; +// AUTO-GENERATED FILE. +// This file is auto-generated by the Ballerina OpenAPI tool. + import ballerina/constraint; +import ballerina/http; public type AcceptedWorkflowResponse record {| *http:Accepted; @@ -11,28 +14,18 @@ public type NotAcceptableError record {| Error body; |}; -public type UnsupportedMediaTypeError record {| - *http:UnsupportedMediaType; - Error body; -|}; - -public type OkKeyManagerWellKnownResponse record {| - *http:Ok; - KeyManagerWellKnownResponse body; -|}; - -public type InternalServerErrorError record {| - *http:InternalServerError; +public type NotFoundError record {| + *http:NotFound; Error body; |}; -public type ForbiddenError record {| - *http:Forbidden; +public type UnsupportedMediaTypeError record {| + *http:UnsupportedMediaType; Error body; |}; -public type ConflictError record {| - *http:Conflict; +public type BadRequestError record {| + *http:BadRequest; Error body; |}; @@ -41,275 +34,8 @@ public type OkWorkflowInfo record {| WorkflowInfo body; |}; -public type NotFoundError record {| - *http:NotFound; - Error body; -|}; - -public type BadRequestError record {| - *http:BadRequest; - Error body; -|}; - -public type Policy record { - # Id of plan - string planId?; - # Name of plan - @constraint:String {maxLength: 60, minLength: 1} - string planName; - # Display name of the policy - @constraint:String {maxLength: 512} - string displayName?; - # Description of the policy - @constraint:String {maxLength: 1024} - string description?; - # Indicates whether the policy is deployed successfully or not. - boolean isDeployed = false; - # Indicates the type of throttle policy - string 'type?; -}; - -public type EnvironmentList record { - # Number of Environments returned. - int count?; - Environment[] list?; -}; - -# Blocking Conditions -public type BlockingCondition record { - # Id of the blocking condition - string policyId?; - # Type of the blocking condition - string conditionType; - # Value of the blocking condition - string conditionValue; - # Status of the blocking condition - boolean conditionStatus?; -}; - -public type WorkflowProperties record { - string name?; - boolean enable?; - string[] properties?; -}; - -public type ApplicationRatePlan record { - *Policy; - ThrottleLimit defaultLimit; -}; - -public type Pagination record { - int offset?; - int 'limit?; - int total?; - # Link to the next subset of resources qualified. - # Empty if no more resources are to be returned. - # example: "" - string next?; - # Link to the previous subset of resources qualified. - # Empty if current subset is the first subset returned. - # example: "" - string previous?; -}; - -public type EventCountLimit record { - *ThrottleLimitBase; - # Maximum number of events allowed - int eventCount; -}; - -public type ThrottleLimitBase record { - # Unit of the time. Allowed values are "sec", "min", "hour", "day" - string timeUnit; - # Time limit that the throttling limit applies. - int unitTime; -}; - -public type ClaimMappingEntry record { - string remoteClaim?; - string localClaim?; -}; - -public type BusinessPlan record { - *Policy; - *GraphQLQuery; - ThrottleLimit defaultLimit; - # Burst control request count - int rateLimitCount?; - # Burst control time unit - string rateLimitTimeUnit?; - # Number of subscriptions allowed - int subscriberCount?; - # Custom attributes added to the Subscription Throttling Policy - CustomAttribute[] customAttributes?; - BusinessPlanPermission permissions?; -}; - -public type PolicyDetails record { - # Id of policy - int policyId?; - # UUId of policy - string uuid?; - # Name of policy - @constraint:String {maxLength: 60, minLength: 1} - string policyName; - # Display name of the policy - @constraint:String {maxLength: 512} - string displayName?; - # Description of the policy - @constraint:String {maxLength: 1024} - string description?; - # Indicates whether the policy is deployed successfully or not. - boolean isDeployed = false; - # Indicates the type of throttle policy - string 'type?; -}; - -public type KeyManagerWellKnownResponse record { - boolean valid?; - KeyManager value?; -}; - -public type KeyManager record { - string id?; - @constraint:String {maxLength: 100, minLength: 1} - string name; - # display name of Key Manager to show in UI - @constraint:String {maxLength: 100} - string displayName?; - @constraint:String {maxLength: 45, minLength: 1} - string 'type; - @constraint:String {maxLength: 256} - string description?; - # Well-Known Endpoint of Identity Provider. - string wellKnownEndpoint?; - KeyManagerEndpoint[] endpoints?; - KeyManager_signingCertificate signingCertificate?; - # PEM type certificate - string tlsCertificate?; - string issuer; - string[] availableGrantTypes?; - boolean enableTokenGeneration = true; - boolean enableMapOAuthConsumerApps = false; - boolean enableOauthAppValidation = true; - boolean enableOAuthAppCreation = true; - string consumerKeyClaim?; - string scopesClaim?; - boolean enabled = true; - record {} additionalProperties?; -}; - -public type CustomUrlInfo_devPortal record { - string url?; -}; - -public type Settings record { - string[] scopes?; - Settings_keyManagerConfiguration[] keyManagerConfiguration?; - # To determine whether analytics is enabled or not - boolean analyticsEnabled?; -}; - -public type KeyManagerConfiguration record { - string name?; - string label?; - string 'type?; - boolean required?; - boolean mask?; - boolean multiple?; - string tooltip?; - string default?; - string[] values?; -}; - -public type BusinessPlanList record { - # Number of Business Plans returned. - int count?; - BusinessPlan[] list?; -}; - -public type ApplicationRatePlanList record { - # Number of Application Rate Plans returned. - int count?; - ApplicationRatePlan[] list?; -}; - -public type OrganizationList record { - # Number of Organization returned. - int count?; - Organization[] list?; -}; - -public type ThrottleLimit record { - # Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - # Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in - # Definitions section. - string 'type; - RequestCountLimit requestCount?; - BandwidthLimit bandwidth?; - EventCountLimit eventCount?; -}; - -public type TokenValidation record { - int id?; - boolean enable?; - string 'type?; - record {} value?; -}; - -public type Keymanagers_discover_body record { - # Well-Known Endpoint - string url?; - # Key Manager Type - string 'type?; -}; - -public type Environment record { - string id?; - @constraint:String {maxLength: 255, minLength: 1} - string name; - @constraint:String {maxLength: 255, minLength: 1} - string displayName?; - string provider?; - @constraint:String {maxLength: 1023} - string description?; - boolean isReadOnly?; - @constraint:Array {minLength: 1} - VHost[] vhosts; - GatewayEnvironmentProtocolURI[] endpointURIs?; - AdditionalProperty[] additionalProperties?; -}; - -public type KeyManager_signingCertificate record { - string 'type?; - string value?; -}; - -public type BusinessPlanPermission record { - string permissionType; - string[] roles; -}; - -public type Application record { - string applicationId?; - string name?; - string throttlingPolicy?; - string description?; - # Type of the access token generated for this application. - # **OAUTH:** A UUID based access token which is issued by default. - # **JWT:** A self-contained, signed JWT based access token. **Note:** This can be only used in Microgateway environments. - string tokenType?; - string status?; - string[] groups?; - int subscriptionCount?; - record {|string...;|} attributes?; - ScopeInfo[] subscriptionScopes?; - # Application created user - string owner?; -}; - public type VHost record { - @constraint:String {maxLength: 255, minLength: 1} + @constraint:String {maxLength: 255, minLength: 1, pattern: re `^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`} string host; @constraint:String {maxLength: 255} string httpContext?; @@ -334,17 +60,6 @@ public type Organization record { string[] sandbox?; }; -public type MonetizationUsagePublishInfo record { - # State of usage publish job - string state?; - # Status of usage publish job - string status?; - # Timestamp of the started time of the Job - string startedTime?; - # Timestamp of the last published time - string lastPublsihedTime?; -}; - public type ErrorListItem record { # Error code string code; @@ -379,11 +94,22 @@ public type ApplicationInfo record { string groupId?; }; -# The tenant information of the user -public type TenantInfo record { - string username?; - string tenantDomain?; - int tenantId?; +public type EnvironmentList record { + # Number of Environments returned. + int count?; + Environment[] list?; +}; + +# Blocking Conditions +public type BlockingCondition record { + # Id of the blocking condition + string policyId?; + # Type of the blocking condition + "API"|"APPLICATION"|"IP"|"IPRANGE"|"USER" conditionType; + # Value of the blocking condition + record {} conditionValue; + # Status of the blocking condition + boolean conditionStatus?; }; public type KeyManagerList record { @@ -392,9 +118,10 @@ public type KeyManagerList record { KeyManagerInfo[] list?; }; -public type Policies_import_body record { - # Json File - record {byte[] fileContent; string fileName;} file; +public type WorkflowProperties record { + "APPLICATION_CREATION"|"KEY_GENERATION"|"SUBSCRIPTION_CREATION"|"LIFECYCLE_CHANGE" name?; + boolean enable?; + string[] properties?; }; # Blocking Conditions Status @@ -405,20 +132,25 @@ public type BlockingConditionStatus record { boolean conditionStatus; }; +public type Pagination record { + int offset?; + int 'limit?; + int total?; + # Link to the next subset of resources qualified. + # Empty if no more resources are to be returned. + # example: "" + string next?; + # Link to the previous subset of resources qualified. + # Empty if current subset is the first subset returned. + # example: "" + string previous?; +}; + public type KeyManagerEndpoint record { string name; string value; }; -public type Settings_keyManagerConfiguration record { - string 'type?; - string displayName?; - string defaultConsumerKeyClaim?; - string defaultScopesClaim?; - KeyManagerConfiguration[] configurations?; - KeyManagerConfiguration[] endpointConfigurations?; -}; - public type WorkflowList record { # Number of workflow processes returned. int count?; @@ -431,6 +163,11 @@ public type WorkflowList record { WorkflowInfo[] list?; }; +public type ClaimMappingEntry record { + string remoteClaim?; + string localClaim?; +}; + public type ApplicationList record { # Number of applications returned. int count?; @@ -438,6 +175,35 @@ public type ApplicationList record { Pagination pagination?; }; +public type KeyManager record { + string id?; + @constraint:String {maxLength: 100, minLength: 1} + string name; + # display name of Key Manager to show in UI + @constraint:String {maxLength: 100} + string displayName?; + @constraint:String {maxLength: 45, minLength: 1} + string 'type; + @constraint:String {maxLength: 256} + string description?; + # Well-Known Endpoint of Identity Provider. + string wellKnownEndpoint?; + KeyManagerEndpoint[] endpoints?; + KeyManager_signingCertificate signingCertificate?; + # PEM type certificate + string tlsCertificate?; + string issuer; + string[] availableGrantTypes?; + boolean enableTokenGeneration = true; + boolean enableMapOAuthConsumerApps = false; + boolean enableOauthAppValidation = true; + boolean enableOAuthAppCreation = true; + string consumerKeyClaim?; + string scopesClaim?; + boolean enabled = true; + record {} additionalProperties?; +}; + public type PublishStatus record { # Status of the usage publish request string status?; @@ -445,12 +211,6 @@ public type PublishStatus record { string message?; }; -public type RequestCountLimit record { - *ThrottleLimitBase; - # Maximum number of requests allowed - int requestCount; -}; - public type KeyManagerInfo record { string id?; string name; @@ -460,11 +220,12 @@ public type KeyManagerInfo record { }; public type WorkflowInfo record { + # Id of the Workflow Request. string workflowReferenceId?; # Type of the Workflow Request. It shows which type of request is it. - string workflowType?; + "APPLICATION_CREATION"|"KEY_GENERATION"|"SUBSCRIPTION_CREATION"|"LIFECYCLE_CHANGE" workflowType?; # Show the Status of the the workflow request whether it is approved or created. - string workflowStatus?; + "APPROVED"|"CREATED" workflowStatus?; string[] workflowProperties?; # Time of the the workflow request created. string createdTime?; @@ -474,13 +235,6 @@ public type WorkflowInfo record { string description?; }; -public type ExportPolicy record { - string 'type?; - string subtype?; - string version?; - record {} data?; -}; - public type Error record { # Error code int code; @@ -504,39 +258,70 @@ public type ScopeInfo record { string description?; }; +public type OrganizationList record { + # Number of Organization returned. + int count?; + Organization[] list?; +}; + public type GatewayEnvironmentProtocolURI record { string protocol; string endpointURI; }; -public type GraphQLQuery record { - # Maximum Complexity of the GraphQL query - int graphQLMaxComplexity?; - # Maximum Depth of the GraphQL query - int graphQLMaxDepth?; -}; - -public type PolicyDetailsList record { - # Number of Throttling Policies returned. - int count?; - PolicyDetails[] list?; +public type TokenValidation record { + int id?; + boolean enable?; + "REFERENCE"|"JWT"|"CUSTOM" 'type?; + record {} value?; }; -# The custom url information of the tenant domain -public type CustomUrlInfo record { - string tenantDomain?; - string tenantAdminUsername?; - boolean enabled?; - CustomUrlInfo_devPortal devPortal?; +public type Environment record { + string id?; + @constraint:String {maxLength: 255, minLength: 1, pattern: re `^[a-zA-Z0-9_-]+$`} + string name; + @constraint:String {maxLength: 255, minLength: 1} + string displayName?; + string provider?; + @constraint:String {maxLength: 1023} + string description?; + boolean isReadOnly?; + @constraint:Array {minLength: 1} + VHost[] vhosts; + GatewayEnvironmentProtocolURI[] endpointURIs?; + AdditionalProperty[] additionalProperties?; }; public type WorkflowResponse record { # This attribute declares whether this workflow task is approved or rejected. - string workflowStatus; + "CREATED"|"APPROVED"|"REJECTED"|"REGISTERED" workflowStatus; # Attributes that returned after the workflow execution string jsonPayload?; }; +public type KeyManager_signingCertificate record { + "JWKS"|"PEM" 'type?; + string value?; +}; + +public type Application record { + string applicationId?; + string name?; + string throttlingPolicy?; + string description?; + # Type of the access token generated for this application. + # **OAUTH:** A UUID based access token which is issued by default. + # **JWT:** A self-contained, signed JWT based access token. **Note:** This can be only used in Microgateway environments. + "OAUTH"|"JWT" tokenType?; + string status?; + string[] groups?; + int subscriptionCount?; + record {|string...;|} attributes?; + ScopeInfo[] subscriptionScopes?; + # Application created user + string owner?; +}; + public type AdditionalProperty record { string 'key?; string value?; @@ -550,11 +335,3 @@ public type APICategory record { string description?; int numberOfAPIs?; }; - -public type BandwidthLimit record { - *ThrottleLimitBase; - # Amount of data allowed to be transferred - int dataAmount; - # Unit of data allowed to be transferred. Allowed values are "KB", "MB" and "GB" - string dataUnit; -}; diff --git a/admin/admin-domain-service/ballerina/typesDAO.bal b/admin/admin-domain-service/ballerina/typesDAO.bal index 3ad486283e..8b13789179 100644 --- a/admin/admin-domain-service/ballerina/typesDAO.bal +++ b/admin/admin-domain-service/ballerina/typesDAO.bal @@ -1,34 +1 @@ -public type ApplicationRatePlanDAO record { - *Policy; - string defaulLimitType; - # Unit of the time. Allowed values are "sec", "min", "hour", "day" - string timeUnit; - # Time limit that the throttling limit applies. - int unitTime; - int quota; - # Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" - string dataUnit?; -}; - -public type BusinessPlanDAO record { - *Policy; - *GraphQLQuery; - string defaulLimitType; - # Unit of the time. Allowed values are "sec", "min", "hour", "day" - string timeUnit; - # Time limit that the throttling limit applies. - int unitTime; - int quota; - # Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" - string dataUnit?; - # Burst control request count - int rateLimitCount?; - # Burst control time unit - string rateLimitTimeUnit?; - # Number of subscriptions allowed - int subscriberCount?; - # Custom attributes added to the Subscription Throttling Policy - CustomAttribute[] customAttributes?; - BusinessPlanPermission permissions?; -}; diff --git a/admin/admin-domain-service/ballerina/workflowImpl.bal b/admin/admin-domain-service/ballerina/workflowImpl.bal index 4c61924d05..63d67e8c2f 100644 --- a/admin/admin-domain-service/ballerina/workflowImpl.bal +++ b/admin/admin-domain-service/ballerina/workflowImpl.bal @@ -30,8 +30,8 @@ isolated function getWorkflowList(string? workflowType, commons:Organization org WorkflowInfo workFlowInfo = {}; string[] applicationProperty = []; workFlowInfo.workflowReferenceId = appWorkflow.workflowReferenceId; - workFlowInfo.workflowType = appWorkflow.workflowType; - workFlowInfo.workflowStatus = appWorkflow.workflowStatus; + workFlowInfo.workflowType = <"APPLICATION_CREATION"|"KEY_GENERATION"|"SUBSCRIPTION_CREATION"|"LIFECYCLE_CHANGE"|()>appWorkflow.workflowType; + workFlowInfo.workflowStatus = <"APPROVED"|"CREATED"|()>appWorkflow.workflowStatus; workFlowInfo.createdTime = appWorkflow.createdTime; workFlowInfo.updatedTime = appWorkflow.updatedTime; applicationProperty.push("applicationName:",appWorkflow.applicationName); @@ -49,8 +49,8 @@ isolated function getWorkflowList(string? workflowType, commons:Organization org WorkflowInfo workFlowInfo = {}; string[] subscriptionProperty = []; workFlowInfo.workflowReferenceId = subWorkflow.workflowReferenceId; - workFlowInfo.workflowType = subWorkflow.workflowType; - workFlowInfo.workflowStatus = subWorkflow.workflowStatus; + workFlowInfo.workflowType = <"APPLICATION_CREATION"|"KEY_GENERATION"|"SUBSCRIPTION_CREATION"|"LIFECYCLE_CHANGE"|()>subWorkflow.workflowType; + workFlowInfo.workflowStatus = <"APPROVED"|"CREATED"|()>subWorkflow.workflowStatus; workFlowInfo.createdTime = subWorkflow.createdTime; workFlowInfo.updatedTime = subWorkflow.updatedTime; subscriptionProperty.push("applicationName",subWorkflow.applicationName); diff --git a/backoffice/backoffice-domain-service/ballerina/BusinessPlan.bal b/backoffice/backoffice-domain-service/ballerina/BusinessPlan.bal deleted file mode 100644 index 9d5e000967..0000000000 --- a/backoffice/backoffice-domain-service/ballerina/BusinessPlan.bal +++ /dev/null @@ -1,21 +0,0 @@ -public type BusinessPlanDAO record { - *Policy; - *GraphQLQuery; - string defaulLimitType; - # Unit of the time. Allowed values are "sec", "min", "hour", "day" - string timeUnit; - # Time limit that the throttling limit applies. - int unitTime; - int quota; - # Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" - string dataUnit?; - # Burst control request count - int rateLimitCount?; - # Burst control time unit - string rateLimitTimeUnit?; - # Number of subscriptions allowed - int subscriberCount?; - # Custom attributes added to the Subscription Throttling Policy - CustomAttribute[] customAttributes?; - BusinessPlanPermission permissions?; -}; \ No newline at end of file diff --git a/backoffice/backoffice-domain-service/ballerina/Dependencies.toml b/backoffice/backoffice-domain-service/ballerina/Dependencies.toml index 418ee5d3dd..74b4bd9c73 100644 --- a/backoffice/backoffice-domain-service/ballerina/Dependencies.toml +++ b/backoffice/backoffice-domain-service/ballerina/Dependencies.toml @@ -80,7 +80,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.10.1" +version = "2.10.2" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/backoffice/backoffice-domain-service/ballerina/backoffice-api_service.bal b/backoffice/backoffice-domain-service/ballerina/backoffice-api_service.bal index 7263d746df..ac94f5317e 100644 --- a/backoffice/backoffice-domain-service/ballerina/backoffice-api_service.bal +++ b/backoffice/backoffice-domain-service/ballerina/backoffice-api_service.bal @@ -46,7 +46,7 @@ service http:InterceptableService /api/backoffice on ep0 { http:Interceptor[] interceptors = [jwtValidationInterceptor, requestErrorInterceptor, responseErrorInterceptor]; return interceptors; } - isolated resource function get apis(http:RequestContext requestContext, string? query, @http:Header string? 'if\-none\-match, int 'limit = 25, int offset = 0, string sortBy = "createdTime", string sortOrder = "desc", @http:Header string? accept = "application/json") returns APIList|http:NotModified|commons:APKError { + isolated resource function get apis(http:RequestContext requestContext, string? query, @http:Header string? 'if\-none\-match, int 'limit = 25, int offset = 0, "apiName"|"version"|"createdTime"|"status" sortBy = "createdTime", string sortOrder = "desc", @http:Header string? accept = "application/json") returns APIList|http:NotModified|commons:APKError { commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); commons:Organization organization = authenticatedUserContext.organization; return getAPIList('limit, offset, query, organization.uuid); @@ -66,8 +66,6 @@ service http:InterceptableService /api/backoffice on ep0 { } return apiDefinition; } - // resource function get apis/[string apiId]/'resource\-paths(@http:Header string? 'if\-none\-match, int 'limit = 25, int offset = 0) returns ResourcePathList|http:NotModified|NotFoundError|NotAcceptableError { - // } isolated resource function get apis/[string apiId]/thumbnail(@http:Header string? 'if\-none\-match, @http:Header string? accept = "application/json") returns http:Response|http:NotModified|NotFoundError|NotAcceptableError|commons:APKError { return getThumbnail(apiId); } @@ -77,18 +75,11 @@ service http:InterceptableService /api/backoffice on ep0 { resource function get apis/[string apiId]/documents(@http:Header string? 'if\-none\-match, int 'limit = 25, int offset = 0, @http:Header string? accept = "application/json") returns DocumentList|http:NotModified|NotFoundError|NotAcceptableError|commons:APKError { return getDocumentList(apiId, 'limit, offset); } - isolated resource function post apis/[string apiId]/documents(@http:Payload Document payload) returns CreatedDocument|BadRequestError|UnsupportedMediaTypeError|commons:APKError|error { + isolated resource function post apis/[string apiId]/documents(@http:Payload Document payload) returns Document|BadRequestError|UnsupportedMediaTypeError|commons:APKError|error { Document documentBody = check payload.cloneWithType(Document); Document|commons:APKError createdDocument = createDocument(apiId, documentBody); - if createdDocument is Document { - CreatedDocument createdDoc = { - body: createdDocument - }; - return createdDoc; - } else { - return createdDocument; - } + return createdDocument; } resource function get apis/[string apiId]/documents/[string documentId](@http:Header string? 'if\-none\-match, @http:Header string? accept = "application/json") returns Document|http:NotModified|NotFoundError|NotAcceptableError|commons:APKError { return getDocumentMetaData(apiId, documentId); @@ -174,13 +165,4 @@ service http:InterceptableService /api/backoffice on ep0 { return error("Error while getting LC state of API" + currentState.message()); } } - resource function get 'business\-plans(http:RequestContext requestContext, @http:Header string? accept = "application/json") returns BusinessPlanList|commons:APKError { - commons:UserContext authenticatedUserContext = check commons:getAuthenticatedUserContext(requestContext); - commons:Organization organization = authenticatedUserContext.organization; - BusinessPlanList|commons:APKError subPolicyList = getBusinessPlans(organization.uuid); - if subPolicyList is BusinessPlanList { - log:printDebug(subPolicyList.toString()); - } - return subPolicyList; - } } diff --git a/backoffice/backoffice-domain-service/ballerina/backoffice_dao.bal b/backoffice/backoffice-domain-service/ballerina/backoffice_dao.bal index 1959f11edd..871bf59ade 100644 --- a/backoffice/backoffice-domain-service/ballerina/backoffice_dao.bal +++ b/backoffice/backoffice-domain-service/ballerina/backoffice_dao.bal @@ -23,7 +23,7 @@ import ballerina/io; import wso2/apk_common_lib as commons; import ballerina/log; -isolated function db_getAPIsDAO(string organization) returns API[]|commons:APKError { +isolated function db_getAPIsDAO(string organization) returns APIInfo[]|commons:APKError { postgresql:Client|error db_Client = getConnection(); if db_Client is error { return e909601(db_Client); @@ -32,8 +32,8 @@ isolated function db_getAPIsDAO(string organization) returns API[]|commons:APKEr sql:ParameterizedQuery GET_API = `SELECT UUID AS ID, API_NAME as NAME, API_VERSION as VERSION,CONTEXT, ORGANIZATION, STATUS as STATE, string_to_array(SDK::text,',')::text[] AS SDK,string_to_array(API_TIER::text,',') AS POLICIES, ARTIFACT as ARTIFACT FROM API where ORGANIZATION = ${organization}`; - stream apisStream = db_Client->query(GET_API); - API[] apis = check from API api in apisStream + stream apisStream = db_Client->query(GET_API); + APIInfo[] apis = check from APIInfo api in apisStream select api; check apisStream.close(); return apis; @@ -159,9 +159,9 @@ isolated function db_getSubscriptionsForAPI(string apiId) returns Subscription[] Subscription[] subsList = []; check from Subscriptions subitem in result1 do { - Subscription sub = {applicationInfo: {}, subscriptionId: "", subscriptionStatus: "", usagePlan: ""}; + Subscription sub = {applicationInfo: {}, subscriptionId: "", subscriptionStatus: <"BLOCKED"|"PROD_ONLY_BLOCKED"|"UNBLOCKED"|"ON_HOLD"|"REJECTED"|"TIER_UPDATE_PENDING"|"DELETE_PENDING">"", usagePlan: ""}; sub.subscriptionId = subitem.subscriptionId; - sub.subscriptionStatus = subitem.subscriptionStatus; + sub.subscriptionStatus = <"BLOCKED"|"PROD_ONLY_BLOCKED"|"UNBLOCKED"|"ON_HOLD"|"REJECTED"|"TIER_UPDATE_PENDING"|"DELETE_PENDING">subitem.subscriptionStatus; sub.applicationInfo.applicationId = subitem.applicationId; sub.usagePlan = subitem.usagePlan; sub.applicationInfo.name = subitem.name; @@ -332,7 +332,7 @@ isolated function getAPICategoriesDAO(string org) returns APICategory[]|commons: } } -isolated function getAPIsByQueryDAO(string payload, string org) returns API[]|commons:APKError { +isolated function getAPIsByQueryDAO(string payload, string org) returns APIInfo[]|commons:APKError { postgresql:Client|error dbClient = getConnection(); if dbClient is error { return e909601(dbClient); @@ -342,8 +342,8 @@ isolated function getAPIsByQueryDAO(string payload, string org) returns API[]|co API_NAME as NAME, API_VERSION as VERSION,CONTEXT, ORGANIZATION,STATUS, ARTIFACT as ARTIFACT FROM API JOIN JSONB_EACH_TEXT(ARTIFACT) e ON true WHERE e.value LIKE ${payload} AND ORGANIZATION = ${org}`; - stream apisStream = dbClient->query(query); - API[] apis = check from API api in apisStream + stream apisStream = dbClient->query(query); + APIInfo[] apis = check from APIInfo api in apisStream select api; check apisStream.close(); return apis; @@ -354,81 +354,6 @@ isolated function getAPIsByQueryDAO(string payload, string org) returns API[]|co } } -public isolated function getBusinessPlansDAO(string org) returns BusinessPlan[]|commons:APKError { - postgresql:Client|error dbClient = getConnection(); - if dbClient is error { - return e909601(dbClient); - } else { - do { - sql:ParameterizedQuery query = `SELECT NAME as PLANNAME, DISPLAY_NAME as DISPLAYNAME, DESCRIPTION, - UUID as PLANID, IS_DEPLOYED as ISDEPLOYED, - QUOTA_TYPE as DefaulLimitType, QUOTA , TIME_UNIT as TIMEUNIT, UNIT_TIME as - UNITTIME, RATE_LIMIT_COUNT as RATELIMITCOUNT, RATE_LIMIT_TIME_UNIT as RATELIMITTIMEUNIT FROM BUSINESS_PLAN WHERE ORGANIZATION =${org}`; - stream businessPlanStream = dbClient->query(query); - BusinessPlanDAO[] businessPlansDAO = check from BusinessPlanDAO businessPlan in businessPlanStream - select businessPlan; - check businessPlanStream.close(); - BusinessPlan[] businessPlans = []; - if businessPlansDAO is BusinessPlanDAO[] { - foreach BusinessPlanDAO result in businessPlansDAO { - if result.defaulLimitType == "requestCount" { - BusinessPlan bp = { - planName: result.planName, - displayName: result.displayName, - description: result.description, - planId: result.planId, - isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, - rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: { - 'type: result.defaulLimitType, - requestCount: - {requestCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - } - }; - businessPlans.push(bp); - } else if result.defaulLimitType == "bandwidth" { - BusinessPlan bp = { - planName: result.planName, - displayName: result.displayName, - description: result.description, - planId: result.planId, - isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, - rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: { - 'type: result.defaulLimitType, - bandwidth: - {dataAmount: result.quota, dataUnit: result.dataUnit, timeUnit: result.timeUnit, unitTime: result.unitTime} - } - }; - businessPlans.push(bp); - } else { - BusinessPlan bp = { - planName: result.planName, - displayName: result.displayName, - description: result.description, - planId: result.planId, - isDeployed: result.isDeployed, - rateLimitCount: result.rateLimitCount, - rateLimitTimeUnit: result.rateLimitTimeUnit, - defaultLimit: { - 'type: result.defaulLimitType, - eventCount: - {eventCount: result.quota, timeUnit: result.timeUnit, unitTime: result.unitTime} - } - }; - businessPlans.push(bp); - } - } - } - return businessPlans; - } on fail var e { - return e909620(e); - } - } -} - isolated function db_getResourceByResourceCategory(string apiId, int resourceCategoryId) returns Resource|NotFoundError|commons:APKError { postgresql:Client|error db_Client = getConnection(); if db_Client is error { diff --git a/backoffice/backoffice-domain-service/ballerina/backoffice_impl.bal b/backoffice/backoffice-domain-service/ballerina/backoffice_impl.bal index 698eebd446..9aaa6eec29 100644 --- a/backoffice/backoffice-domain-service/ballerina/backoffice_impl.bal +++ b/backoffice/backoffice-domain-service/ballerina/backoffice_impl.bal @@ -29,9 +29,9 @@ import ballerina/mime; # + return - Return Value string?|APIList|error isolated function getAPIList(int 'limit, int offset, string? query, string organization) returns APIList|commons:APKError { if query !is string { - API[]|commons:APKError apis = db_getAPIsDAO(organization); - if apis is API[] { - API[] limitSet = []; + APIInfo[]|commons:APKError apis = db_getAPIsDAO(organization); + if apis is APIInfo[] { + APIInfo[] limitSet = []; if apis.length() > offset { foreach int i in offset ... (apis.length() - 1) { if limitSet.length() < 'limit { @@ -50,9 +50,9 @@ isolated function getAPIList(int 'limit, int offset, string? query, string organ int? index = query.indexOf(":"); if index is int { string modifiedQuery = "%" + query.substring(index + 1) + "%"; - API[]|commons:APKError apis = getAPIsByQueryDAO(modifiedQuery, organization); - if apis is API[] { - API[] limitSet = []; + APIInfo[]|commons:APKError apis = getAPIsByQueryDAO(modifiedQuery, organization); + if apis is APIInfo[] { + APIInfo[] limitSet = []; if apis.length() > offset { foreach int i in offset ... (apis.length() - 1) { if limitSet.length() < 'limit { @@ -307,17 +307,6 @@ isolated function getAllCategoryList(string organization) returns APICategoryLis } } -isolated function getBusinessPlans(string organization) returns BusinessPlanList|commons:APKError { - BusinessPlan[]|commons:APKError businessPlans = getBusinessPlansDAO(organization); - if businessPlans is BusinessPlan[] { - int count = businessPlans.length(); - BusinessPlanList BusinessPlansList = {count: count, list: businessPlans}; - return BusinessPlansList; - } else { - return businessPlans; - } -} - isolated function retrieveManagementServerHostsList() returns string[]|commons:APKError { string managementServerServiceName = managementServerConfig.serviceName; string managementServerNamespace = managementServerConfig.namespace; @@ -450,7 +439,7 @@ isolated function createDocument(string apiId, Document documentPayload) returns sourceType: documentPayload.sourceType, sourceUrl: documentPayload.sourceUrl, fileName: documentPayload.fileName, - documentType: documentPayload.documentType, + documentType: documentPayload.documentType ?: "HOWTO", otherTypeName: documentPayload.otherTypeName, visibility: documentPayload.visibility, inlineContent: documentPayload.inlineContent @@ -461,12 +450,12 @@ isolated function createDocument(string apiId, Document documentPayload) returns documentId: addedDocMetaData.documentId, name: addedDocMetaData.name, summary: addedDocMetaData.summary, - sourceType: addedDocMetaData.sourceType, + sourceType: <"INLINE"|"MARKDOWN"|"URL"|"FILE">addedDocMetaData.sourceType, sourceUrl: addedDocMetaData.sourceUrl, fileName: addedDocMetaData.fileName, - documentType: addedDocMetaData.documentType, + documentType: <"HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER">addedDocMetaData.documentType, otherTypeName: addedDocMetaData.otherTypeName, - visibility: addedDocMetaData.visibility, + visibility: <"OWNER_ONLY"|"PRIVATE"|"API_LEVEL">addedDocMetaData.visibility, inlineContent: addedDocMetaData.inlineContent }; return document; @@ -496,7 +485,7 @@ isolated function UpdateDocumentMetaData(string apiId, string documentId, Docume sourceType: documentPayload.sourceType, sourceUrl: documentPayload.sourceUrl, fileName: documentPayload.fileName, - documentType: documentPayload.documentType, + documentType: documentPayload.documentType ?: "HOWTO", otherTypeName: documentPayload.otherTypeName, visibility: documentPayload.visibility, inlineContent: documentPayload.inlineContent @@ -508,12 +497,12 @@ isolated function UpdateDocumentMetaData(string apiId, string documentId, Docume documentId: updatedDocMetaData.documentId, name: updatedDocMetaData.name, summary: updatedDocMetaData.summary, - sourceType: updatedDocMetaData.sourceType, + sourceType: <"INLINE"|"MARKDOWN"|"URL"|"FILE">updatedDocMetaData.sourceType, sourceUrl: updatedDocMetaData.sourceUrl, fileName: updatedDocMetaData.fileName, - documentType: updatedDocMetaData.documentType, + documentType: <"HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER">updatedDocMetaData.documentType, otherTypeName: updatedDocMetaData.otherTypeName, - visibility: updatedDocMetaData.visibility, + visibility: <"OWNER_ONLY"|"PRIVATE"|"API_LEVEL">updatedDocMetaData.visibility, inlineContent: updatedDocMetaData.inlineContent }; return document; @@ -538,12 +527,12 @@ isolated function addDocumentContent(string apiId, string documentId, http:Reque documentId: getDocumentMetaData.documentId, name: getDocumentMetaData.name, summary: getDocumentMetaData.summary, - sourceType: getDocumentMetaData.sourceType, + sourceType: <"INLINE"|"MARKDOWN"|"URL"|"FILE">getDocumentMetaData.sourceType, sourceUrl: getDocumentMetaData.sourceUrl, fileName: getDocumentMetaData.fileName, - documentType: getDocumentMetaData.documentType, + documentType: <"HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER">getDocumentMetaData.documentType, otherTypeName: getDocumentMetaData.otherTypeName, - visibility: getDocumentMetaData.visibility, + visibility: <"OWNER_ONLY"|"PRIVATE"|"API_LEVEL">getDocumentMetaData.visibility, inlineContent: getDocumentMetaData.inlineContent }; byte[]|() fileContent = (); @@ -633,12 +622,12 @@ isolated function getDocumentMetaData(string apiId, string documentId) returns D documentId: getDocumentMetaData.documentId, name: getDocumentMetaData.name, summary: getDocumentMetaData.summary, - sourceType: getDocumentMetaData.sourceType, + sourceType: <"INLINE"|"MARKDOWN"|"URL"|"FILE">getDocumentMetaData.sourceType, sourceUrl: getDocumentMetaData.sourceUrl, fileName: getDocumentMetaData.fileName, - documentType: getDocumentMetaData.documentType, + documentType: <"HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER">getDocumentMetaData.documentType, otherTypeName: getDocumentMetaData.otherTypeName, - visibility: getDocumentMetaData.visibility, + visibility: <"OWNER_ONLY"|"PRIVATE"|"API_LEVEL">getDocumentMetaData.visibility, inlineContent: getDocumentMetaData.inlineContent }; return document; diff --git a/backoffice/backoffice-domain-service/ballerina/modules/backoffice/resources/backoffice-api.yaml b/backoffice/backoffice-domain-service/ballerina/modules/backoffice/resources/backoffice-api.yaml index c50642d1cd..96064e0f6e 100644 --- a/backoffice/backoffice-domain-service/ballerina/modules/backoffice/resources/backoffice-api.yaml +++ b/backoffice/backoffice-domain-service/ballerina/modules/backoffice/resources/backoffice-api.yaml @@ -104,6 +104,7 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view x-code-samples: - lang: Curl @@ -161,6 +162,7 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view x-code-samples: - lang: Curl @@ -225,8 +227,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_publish - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -280,72 +282,14 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:api_definition_view x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://api.am.wso2.com:9095/api/backoffice/v1/apis/01234567-0123-0123-0123-012345678901/definition"' operationId: getAPIDefinition - /apis/{apiId}/resource-paths: - get: - tags: - - APIs - summary: Get Resource Paths of an API - description: | - This operation can be used to retrieve resource paths defined for a specific API. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - ResourcePaths returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in the future). - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modified the last time. - Used by caches, or in conditional requests (Will be supported in the future). - schema: - type: string - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ResourcePathList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in the future). - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:api_view - - apk:api_manage - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://api.am.wso2.com:9095/api/backoffice/v1/apis/01234567-0123-0123-0123-012345678901/resource-paths"' - operationId: getAPIResourcePaths - /apis/{apiId}/thumbnail: get: tags: @@ -392,9 +336,8 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:api_publish - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -463,8 +406,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_publish - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -X PUT -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -515,8 +458,8 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:document_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -571,7 +514,8 @@ paths: $ref: '#/components/responses/UnsupportedMediaType' security: - OAuth2Security: - - apk:api_view + - apk:backoffice_admin + - apk:api_publish - apk:document_manage x-code-samples: - lang: Curl @@ -629,8 +573,8 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:document_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -694,7 +638,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: - - apk:api_view + - apk:backoffice_admin + - apk:api_publish - apk:document_manage x-code-samples: - lang: Curl @@ -724,7 +669,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: - - apk:api_view + - apk:backoffice_admin + - apk:api_publish - apk:document_manage x-code-samples: - lang: Curl @@ -801,8 +747,8 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:document_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -876,7 +822,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: - - apk:api_view + - apk:backoffice_admin + - apk:api_publish - apk:document_manage x-code-samples: - lang: Curl @@ -912,9 +859,8 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:comment_view - - apk:comment_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -984,8 +930,9 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin + - apk:api_publish - apk:comment_write - - apk:comment_manage x-code-samples: - lang: Curl source: 'curl -k -X POST -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1038,15 +985,14 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:comment_view - - apk:comment_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/apk/backoffice/v1/apis/01234567-0123-0123-0123-012345678901/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4"' - patch: + put: tags: - Comments summary: Edit a comment @@ -1111,8 +1057,9 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:comment_write - - apk:comment_manage + - apk:api_publish x-code-samples: - lang: Curl source: 'curl -k -X PATCH -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1150,9 +1097,9 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:comment_write - - apk:comment_manage - - apk:admin # special scope added to moderate other comments as well + - apk:api_publish x-code-samples: - lang: Curl source: curl -k -X DELETE -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1205,9 +1152,8 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:comment_view - - apk:comment_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1271,9 +1217,8 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:subscription_view - - apk:subscription_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1302,9 +1247,8 @@ paths: $ref: '#/components/responses/NotFound' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:subscription_view - - apk:subscription_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1361,7 +1305,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: - - apk:subscription_block + - apk:backoffice_admin + - apk:api_publish - apk:subscription_manage x-code-samples: - lang: Curl @@ -1406,7 +1351,8 @@ paths: $ref: '#/components/responses/PreconditionFailed' security: - OAuth2Security: - - apk:subscription_block + - apk:backoffice_admin + - apk:api_publish - apk:subscription_manage x-code-samples: - lang: Curl @@ -1414,58 +1360,6 @@ paths: "https://api.am.wso2.com:9095/api/backoffice/v1/subscriptions/unblock-subscription?subscriptionId=64eca60b-2e55-4c38-8603-e9e6bad7d809"' operationId: unBlockSubscription - - ###################################################### - # The "Thorttling Tier Collection" resource APIs - ###################################################### - /usage-plans: - get: - tags: - - Usage Plan - summary: Get All Usage Plans - description: | - This operation can be used to list the available usage plans. - operationId: getAllUsagePlans - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. - List of policies returned. - headers: - ETag: - description: | - Entity Tag of the response resource. - Used by caches, or in conditional requests (Will be supported in the future). - schema: - type: string - Content-Type: - description: The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/UsagePlanList' - 304: - description: | - Not Modified. - Empty body because the client has already the latest version of the requested resource (Will be supported in the future). - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:api_view - - apk:tier_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://api.am.wso2.com:9095/api/backoffice/v1/usage-plans"' - ###################################################### # The "Content Search Results" resource APIs ###################################################### @@ -1517,45 +1411,14 @@ paths: $ref: '#/components/responses/NotAcceptable' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://api.am.wso2.com:9095/api/backoffice/v1/search?query=pizza"' operationId: search - ###################################################### - # The BackOffice settings resource APIs - ###################################################### - /settings: - get: - tags: - - Settings - summary: Retrieve BackOffice Settings - description: | - Retrieve BackOffice settings - responses: - 200: - description: | - OK. - Settings returned - content: - application/json: - schema: - $ref: '#/components/schemas/Settings' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:api_view - - apk:backoffice_settings - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://api.am.wso2.com:9095/api/backoffice/v1/settings"' - operationId: getSettings - ###################################################### # The "API Category Collection" resource API ###################################################### @@ -1577,8 +1440,8 @@ paths: $ref: '#/components/schemas/APICategoryList' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_view - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1633,8 +1496,8 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: + - apk:backoffice_admin - apk:api_publish - - apk:api_manage x-code-samples: - lang: Curl source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1668,8 +1531,8 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: - - apk:api_publish - - apk:api_manage + - apk:backoffice_admin + - apk:api_view x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" @@ -1703,52 +1566,14 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: - - apk:api_publish - - apk:api_create - - apk:api_manage + - apk:backoffice_admin + - apk:api_view x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://api.am.wso2.com:9095/api/backoffice/v1/apis/01234567-0123-0123-0123-012345678901/lifecycle-state"' operationId: getAPILifecycleState -###################################################### -# The "Business Plans Collection" resource API -###################################################### - /business-plans: - get: - tags: - - Business Plan (Collection) - summary: Get all Business Plans - description: | - This operation can be used to retrieve all Business Plans - parameters: - - $ref: '#/components/parameters/Accept' - responses: - 200: - description: | - OK. - Plans returned - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/BusinessPlanList' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:admin - - apk:tier_view - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://api.am.wso2.com:9095/api/backoffice/v1/business-plans"' - operationId: getAllBusinessPlans + components: schemas: APIDefinition: @@ -1922,6 +1747,21 @@ components: minLength: 1 type: string example: pizza + organization: + maxLength: 232 + minLength: 1 + type: string + example: org1 + lifeCycleStatus: + maxLength: 232 + minLength: 1 + type: string + example: CREATED + provider: + maxLength: 232 + minLength: 1 + type: string + example: user1 version: maxLength: 30 minLength: 1 @@ -2040,91 +1880,7 @@ components: items: $ref: '#/components/schemas/APIDeployment' - BusinessPlanList: - title: Business Plan List - type: object - properties: - count: - type: integer - description: | - Number of Business Plans returned. - example: 1 - list: - type: array - items: - $ref: '#/components/schemas/BusinessPlan' - BusinessPlan: - title: Business Plan - allOf: - - required: - - defaultLimit - type: object - properties: - defaultLimit: - $ref: '#/components/schemas/ThrottleLimit' - rateLimitCount: - type: integer - description: Burst control request count - example: 10 - rateLimitTimeUnit: - type: string - description: Burst control time unit - example: min - subscriberCount: - type: integer - description: Number of subscriptions allowed - example: 10 - customAttributes: - type: array - description: | - Custom attributes added to the Subscription Throttling Policy - example: [] - items: - $ref: '#/components/schemas/CustomAttribute' - permissions: - $ref: '#/components/schemas/BusinessPlanPermission' - BusinessPlanPermission: - title: Business Plan Permission - required: - - permissionType - - roles - type: object - properties: - permissionType: - type: string - example: deny - enum: - - ALLOW - - DENY - roles: - type: array - example: - - Internal/everyone - items: - type: string - ThrottleLimit: - title: Throttle Limit - required: - - type - type: object - properties: - type: - type: string - description: | - Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in - Definitions section. - example: REQUESTCOUNTLIMIT - enum: - - REQUESTCOUNTLIMIT - - BANDWIDTHLIMIT - - EVENTCOUNTLIMIT - requestCount: - $ref: '#/components/schemas/RequestCountLimit' - bandwidth: - $ref: '#/components/schemas/BandwidthLimit' - eventCount: - $ref: '#/components/schemas/EventCountLimit' + #----------------------------------------------------- # The API Revision resource #----------------------------------------------------- @@ -2408,23 +2164,6 @@ components: type: string readOnly: true example: admin - UsagePlanList: - title: Usage Plan list - type: object - properties: - count: - type: integer - description: | - Number of Usage Plans returned. - example: 1 - list: - type: array - description: | - Array of Usage Policies - items: - $ref: '#/components/schemas/UsagePlan' - pagination: - $ref: '#/components/schemas/Pagination' SubscriptionList: title: Subscription List type: object @@ -2468,159 +2207,7 @@ components: - REJECTED - TIER_UPDATE_PENDING - DELETE_PENDING - UsageLimitBase: - title: Throttle Limit Base - required: - - timeUnit - - unitTime - type: object - properties: - timeUnit: - type: string - description: Unit of the time. Allowed values are "sec", "min", "hour", - "day" - example: min - unitTime: - type: integer - description: Time limit that the usage limit applies. - example: 10 - UsageLimit: - title: Usage Limit - required: - - type - type: object - properties: - type: - type: string - description: | - Type of the usage limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - Please see schemas of "RequestCountLimit" and "BandwidthLimit" usage limit types in - Definitions section. - example: REQUESTCOUNTLIMIT - enum: - - REQUESTCOUNTLIMIT - - BANDWIDTHLIMIT - - EVENTCOUNTLIMIT - requestCount: - $ref: '#/components/schemas/RequestCountLimit' - bandwidth: - $ref: '#/components/schemas/BandwidthLimit' - eventCount: - $ref: '#/components/schemas/EventCountLimit' - BandwidthLimit: - title: Bandwidth Limit object - allOf: - - $ref: '#/components/schemas/UsageLimitBase' - - required: - - dataAmount - - dataUnit - type: object - properties: - dataAmount: - type: integer - description: Amount of data allowed to be transferred - format: int64 - example: 1000 - dataUnit: - type: string - description: Unit of data allowed to be transferred. Allowed values are - "KB", "MB" and "GB" - example: KB - RequestCountLimit: - title: Request Count Limit object - allOf: - - $ref: '#/components/schemas/UsageLimitBase' - - required: - - requestCount - type: object - properties: - requestCount: - type: integer - description: Maximum number of requests allowed - format: int64 - example: 30 - EventCountLimit: - title: Event Count Limit object - allOf: - - $ref: '#/components/schemas/UsageLimitBase' - - required: - - eventCount - type: object - properties: - eventCount: - type: integer - description: Maximum number of events allowed - format: int64 - example: 3000 - UsagePlan: - title: Usage Plan - allOf: - - required: - - defaultLimit - type: object - properties: - policyId: - type: integer - description: Id of policy - example: 1 - uuid: - type: string - description: policy uuid - example: 0c6439fd-9b16-3c2e-be6e-1086e0b9aa93 - policyName: - maxLength: 60 - minLength: 1 - type: string - description: Name of policy - example: 30PerMin - displayName: - type: string - description: Display name of the policy - example: 30PerMin - maxLength: 512 - description: - maxLength: 1024 - type: string - description: Description of the policy - example: Allows 30 request per minute - organization: - type: string - description: Usage policy organization - example: wso2 - defaultLimit: - $ref: '#/components/schemas/UsageLimit' - rateLimitCount: - type: integer - description: Burst control request count - example: 10 - rateLimitTimeUnit: - type: string - description: Burst control time unit - example: min - subscriberCount: - type: integer - description: Number of subscriptions allowed - example: 10 - customAttributes: - type: array - description: | - Custom attributes added to the Usage plan - example: [ ] - items: - $ref: '#/components/schemas/CustomAttribute' - stopOnQuotaReach: - type: boolean - description: | - This indicates the action to be taken when a user goes beyond the allocated quota. If checked, the user's requests will be dropped. If unchecked, the requests will be allowed to pass through. - default: false - billingPlan: - type: string - description: | - define whether this is Paid or a Free plan. Allowed values are FREE or COMMERCIAL. - example: FREE - permissions: - $ref: '#/components/schemas/SubscriptionThrottlePolicyPermission' CustomAttribute: title: Name-Value pair required: @@ -2655,24 +2242,6 @@ components: - Internal/everyone items: type: string - APIMonetizationUsage: - title: API monetization usage object - type: object - properties: - properties: - type: object - additionalProperties: - type: string - description: Map of custom properties related to monetization usage - APIRevenue: - title: API revenue data object - type: object - properties: - properties: - type: object - additionalProperties: - type: string - description: Map of custom properties related to API revenue Error: title: Error object returned with 4XX HTTP Status required: @@ -3680,5 +3249,10 @@ components: password: tokenUrl: https://localhost:9443/oauth2/token scopes: - type: array - items: test + openid: Authorize access to user details + apk:backoffice_admin: Manage all admin operations + apk:api_view: View API + apk:api_publish: Manage all API related operations + apk:document_manage: Create, update and delete API documents + apk:comment_write: Write permission to comments + apk:subscription_manage: Manage all Subscription related operations diff --git a/backoffice/backoffice-domain-service/ballerina/tests/apiTests.bal b/backoffice/backoffice-domain-service/ballerina/tests/apiTests.bal index f2777ff882..11a4f341b9 100644 --- a/backoffice/backoffice-domain-service/ballerina/tests/apiTests.bal +++ b/backoffice/backoffice-domain-service/ballerina/tests/apiTests.bal @@ -47,7 +47,7 @@ function getAPIByIdTest() { @test:Config {dependsOn: [createAPITest]} function getAPIDefinitionTest() { APIDefinition|commons:APKError getAPIDef = getAPIDefinition("01ed75e2-b30b-18c8-wwf2-25da7edd2231"); - if getAPIDef is API { + if getAPIDef is APIDefinition { test:assertTrue(true, "Successfully retrieve API Definition"); log:printInfo(getAPIDef.toString()); } else if getAPIDef is commons:APKError { diff --git a/backoffice/backoffice-domain-service/ballerina/tests/internalAPITests.bal b/backoffice/backoffice-domain-service/ballerina/tests/internalAPITests.bal index 63a48a6ebe..2a979195c0 100644 --- a/backoffice/backoffice-domain-service/ballerina/tests/internalAPITests.bal +++ b/backoffice/backoffice-domain-service/ballerina/tests/internalAPITests.bal @@ -116,6 +116,8 @@ public function getApiDataProvider() returns map<[string, string, anydata]> { "context": "pizzssa", "version": "1.0.0", "organization": "1111-1111-1111-1111", + "lifeCycleStatus" : (), + "provider": (), "type": "HTTP", "state": "CREATED", "status": "CREATED" @@ -135,7 +137,8 @@ function updateInternalAPITest() { "version":"1.0.0", "lifeCycleStatus":"CREATED", "organization":"1111-1111-1111-1111", - "type":"HTTP" + "type":"HTTP", + "provider":"admin" }, "Definition" : { "openapi": "3.0.0", diff --git a/backoffice/backoffice-domain-service/ballerina/types.bal b/backoffice/backoffice-domain-service/ballerina/types.bal index c802bda536..13427813ff 100644 --- a/backoffice/backoffice-domain-service/ballerina/types.bal +++ b/backoffice/backoffice-domain-service/ballerina/types.bal @@ -1,5 +1,8 @@ -import ballerina/http; +// AUTO-GENERATED FILE. +// This file is auto-generated by the Ballerina OpenAPI tool. + import ballerina/constraint; +import ballerina/http; public type NotAcceptableError record {| *http:NotAcceptable; @@ -11,6 +14,11 @@ public type UnsupportedMediaTypeError record {| Error body; |}; +public type OkLifecycleState record {| + *http:Ok; + LifecycleState body; +|}; + public type ForbiddenError record {| *http:Forbidden; Error body; @@ -31,18 +39,13 @@ public type PreconditionFailedError record {| Error body; |}; -public type CreatedComment record {| - *http:Created; - Comment body; -|}; - public type NotFoundError record {| *http:NotFound; Error body; |}; -public type CreatedDocument record {| - *http:Created; +public type OkDocument record {| + *http:Ok; Document body; |}; @@ -63,13 +66,6 @@ public type DocumentList record { Pagination pagination?; }; -public type UsageLimitBase record { - # Unit of the time. Allowed values are "sec", "min", "hour", "day" - string timeUnit; - # Time limit that the usage limit applies. - int unitTime; -}; - public type APIScope record { Scope scope; }; @@ -78,7 +74,7 @@ public type Document record { string documentId?; @constraint:String {maxLength: 60, minLength: 1} string name; - string documentType; + string documentType?; @constraint:String {maxLength: 32766, minLength: 1} string summary?; string sourceType; @@ -116,12 +112,6 @@ public type Pagination record { string previous?; }; -public type EventCountLimit record { - *UsageLimitBase; - # Maximum number of events allowed - int eventCount; -}; - public type ResourcePath record { int id; string resourcePath?; @@ -135,7 +125,7 @@ public type API_additionalProperties record { }; public type FileInfo record { - # relative location of the file (excluding the base context and host of the Publisher API) + # name of the file string fileName?; # media-type of the file string mediaType?; @@ -151,67 +141,21 @@ public type APIOperations record { public type APIList record { # Number of APIs returned. int count?; - API[] list?; + APIInfo[] list?; Pagination pagination?; }; -public type BusinessPlan record { - *Policy; - *GraphQLQuery; - ThrottleLimit defaultLimit; - # Burst control request count - int rateLimitCount?; - # Burst control time unit - string rateLimitTimeUnit?; - # Number of subscriptions allowed - int subscriberCount?; - # Custom attributes added to the Subscription Throttling Policy - CustomAttribute[] customAttributes?; - BusinessPlanPermission permissions?; -}; - -public type Policy record { - # Id of plan - string planId?; - # Name of plan - @constraint:String {maxLength: 60, minLength: 1} - string planName; - # Display name of the policy - @constraint:String {maxLength: 512} - string displayName?; - # Description of the policy - @constraint:String {maxLength: 1024} - string description?; - # Indicates whether the policy is deployed successfully or not. - boolean isDeployed = false; - # Indicates the type of throttle policy - string 'type?; -}; - -public type GraphQLQuery record { - # Maximum Complexity of the GraphQL query - int graphQLMaxComplexity?; - # Maximum Depth of the GraphQL query - int graphQLMaxDepth?; -}; - -public type APIMonetizationUsage record { - # Map of custom properties related to monetization usage - record {} properties?; -}; - public type Subscription record { string subscriptionId; ApplicationInfo applicationInfo; string usagePlan; - string subscriptionStatus; + "BLOCKED"|"PROD_ONLY_BLOCKED"|"UNBLOCKED"|"ON_HOLD"|"REJECTED"|"TIER_UPDATE_PENDING"|"DELETE_PENDING" subscriptionStatus; }; public type Settings record { # The Developer Portal URL string devportalUrl?; Environment[] environment?; - string[] scopes?; MonetizationAttribute[] monetizationAttributes?; # Is Document Visibility configuration enabled boolean docVisibilityEnabled?; @@ -227,12 +171,6 @@ public type APIRevision record { string createdTime?; }; -public type BusinessPlanList record { - # Number of Business Plans returned. - int count?; - BusinessPlan[] list?; -}; - public type APIExternalStoreList record { # Number of external stores returned. int count?; @@ -259,17 +197,7 @@ public type APIMonetizationInfo record { # Flag to indicate the monetization status boolean enabled; # Map of custom properties related to monetization - record {} properties?; -}; - -public type ThrottleLimit record { - # Type of the throttling limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - # Please see schemas of "RequestCountLimit" and "BandwidthLimit" throttling limit types in - # Definitions section. - string 'type; - RequestCountLimit requestCount?; - BandwidthLimit bandwidth?; - EventCountLimit eventCount?; + record {|string...;|} properties?; }; public type LifecycleHistoryItem record { @@ -279,14 +207,6 @@ public type LifecycleHistoryItem record { string updatedTime?; }; -public type UsagePlanList record { - # Number of Usage Plans returned. - int count?; - # Array of Usage Policies - UsagePlan[] list?; - Pagination pagination?; -}; - public type APIDeployment record { @constraint:String {maxLength: 255, minLength: 1} string name?; @@ -338,11 +258,6 @@ public type CommentList record { Pagination pagination?; }; -public type BusinessPlanPermission record { - string permissionType; - string[] roles; -}; - public type CustomAttribute record { # Name of the custom attribute string name; @@ -358,11 +273,6 @@ public type ErrorListItem record { string description?; }; -public type APIRevenue record { - # Map of custom properties related to API revenue - record {} properties?; -}; - public type APICategoryList record { # Number of API categories returned. int count?; @@ -371,7 +281,7 @@ public type APICategoryList record { public type DocumentId_content_body record { # Document to upload - string file?; + record {byte[] fileContent; string fileName;} file?; # Inline content of the document string inlineContent?; }; @@ -396,9 +306,9 @@ public type ModifiableAPI record { string description?; boolean hasThumbnail?; # State of the API. Only published APIs are visible on the Developer Portal - string state = "CREATED"; + "CREATED"|"PUBLISHED" state = "CREATED"; string[] tags?; - record {} additionalProperties?; + record {|API_additionalProperties...;|} additionalProperties?; APIMonetizationInfo monetization?; APIBusinessInformation businessInformation?; # API categories @@ -415,11 +325,11 @@ public type LifecycleState record { public type ApiId_thumbnail_body record { # Image to upload - string file; + record {byte[] fileContent; string fileName;} file; }; public type SubscriptionThrottlePolicyPermission record { - string permissionType; + "ALLOW"|"DENY" permissionType; string[] roles; }; @@ -446,38 +356,6 @@ public type ExternalStoreList record { ExternalStore[] list?; }; -public type UsagePlan record { - # Id of policy - int policyId?; - # policy uuid - string uuid?; - # Name of policy - @constraint:String {maxLength: 60, minLength: 1} - string policyName?; - # Display name of the policy - @constraint:String {maxLength: 512} - string displayName?; - # Description of the policy - @constraint:String {maxLength: 1024} - string description?; - # Usage policy organization - string organization?; - UsageLimit defaultLimit; - # Burst control request count - int rateLimitCount?; - # Burst control time unit - string rateLimitTimeUnit?; - # Number of subscriptions allowed - int subscriberCount?; - # Custom attributes added to the Usage plan - CustomAttribute[] customAttributes?; - # This indicates the action to be taken when a user goes beyond the allocated quota. If checked, the user's requests will be dropped. If unchecked, the requests will be allowed to pass through. - boolean stopOnQuotaReach = false; - # define whether this is Paid or a Free plan. Allowed values are FREE or COMMERCIAL. - string billingPlan?; - SubscriptionThrottlePolicyPermission permissions?; -}; - public type Comment record { string id?; @constraint:String {maxLength: 512} @@ -487,17 +365,11 @@ public type Comment record { string updatedTime?; string category = "general"; string parentCommentId?; - string entryPoint?; + "devPortal"|"publisher" entryPoint?; CommenterInfo commenterInfo?; CommentList replies?; }; -public type RequestCountLimit record { - *UsageLimitBase; - # Maximum number of requests allowed - int requestCount; -}; - public type ThreatProtectionPolicy record { # Policy ID string uuid?; @@ -514,13 +386,13 @@ public type APIInfo record { string name?; string description?; string context?; - string 'version?; + string version?; string 'type?; string createdTime?; string updatedTime?; boolean hasThumbnail?; # State of the API. Only published APIs are visible on the Developer Portal - string state?; + "CREATED"|"PUBLISHED" state?; }; public type APIExternalStore record { @@ -546,7 +418,7 @@ public type Error record { public type SearchResult record { string id?; string name; - string 'type?; + "DOC"|"API" 'type?; # Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL string transportType?; }; @@ -556,16 +428,6 @@ public type GatewayEnvironmentProtocolURI record { string endpointURI; }; -public type UsageLimit record { - # Type of the usage limit. Allowed values are "REQUESTCOUNTLIMIT" and "BANDWIDTHLIMIT". - # Please see schemas of "RequestCountLimit" and "BandwidthLimit" usage limit types in - # Definitions section. - string 'type; - RequestCountLimit requestCount?; - BandwidthLimit bandwidth?; - EventCountLimit eventCount?; -}; - public type Scope record { # UUID of the Scope. Valid only for shared scopes. string id?; @@ -609,7 +471,7 @@ public type SubscriptionList record { public type WorkflowResponse record { # This attribute declares whether this workflow task is approved or rejected. - string workflowStatus; + "CREATED"|"APPROVED"|"REJECTED"|"REGISTERED" workflowStatus; # Attributes that returned after the workflow execution string jsonPayload?; LifecycleState lifecycleState?; @@ -625,24 +487,24 @@ public type API record { @constraint:String {maxLength: 232, minLength: 1} string context; @constraint:String {maxLength: 30, minLength: 1} - string 'version; + string version; string organization; + string lifeCycleStatus; + string provider; # The api creation type to be used. Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL, WEBSUB, SSE, WEBHOOK, ASYNC - string 'type = "HTTP"; + "HTTP"|"WS"|"SOAPTOREST"|"SOAP"|"GRAPHQL"|"WEBSUB"|"SSE"|"WEBHOOK"|"ASYNC" 'type = "HTTP"; # Supported transports for the API (http and/or https). string[] transport?; boolean hasThumbnail?; # State of the API. Only published APIs are visible on the Developer Portal - string state = "CREATED"; + "CREATED"|"PUBLISHED" state = "CREATED"; string[] tags?; # API categories string[] categories?; # Supported SDK string[] sdk?; string[] policies?; - string provider?; - string lifeCycleStatus?; - record {} additionalProperties?; + record {|API_additionalProperties...;|} additionalProperties?; string createdTime?; string lastUpdatedTime?; APIOperations[] operations?; @@ -668,11 +530,3 @@ public type APICategory record { public type SubscriberInfo record { string name?; }; - -public type BandwidthLimit record { - *UsageLimitBase; - # Amount of data allowed to be transfered - int dataAmount; - # Unit of data allowed to be transfered. Allowed values are "KB", "MB" and "GB" - string dataUnit; -}; diff --git a/devportal/devportal-domain-service/ballerina/Dependencies.toml b/devportal/devportal-domain-service/ballerina/Dependencies.toml index 44d7d0eb78..0295362e09 100644 --- a/devportal/devportal-domain-service/ballerina/Dependencies.toml +++ b/devportal/devportal-domain-service/ballerina/Dependencies.toml @@ -86,7 +86,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.10.1" +version = "2.10.2" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, diff --git a/devportal/devportal-domain-service/ballerina/apiDAO.bal b/devportal/devportal-domain-service/ballerina/apiDAO.bal index 9de3af9491..a18f7e2d63 100644 --- a/devportal/devportal-domain-service/ballerina/apiDAO.bal +++ b/devportal/devportal-domain-service/ballerina/apiDAO.bal @@ -50,7 +50,7 @@ isolated function getAPIByIdDAO(string apiId) returns API|commons:APKError|NotFo } } -isolated function getAPIsDAO(string org) returns API[]|commons:APKError { +isolated function getAPIsDAO(string org) returns APIInfo[]|commons:APKError { postgresql:Client | error dbClient = getConnection(); if dbClient is error { string message = "Error while retrieving connection"; @@ -61,8 +61,8 @@ isolated function getAPIsDAO(string org) returns API[]|commons:APKError { API_NAME as NAME, API_VERSION as VERSION,CONTEXT, ORGANIZATION,STATUS, API_TYPE as TYPE, ARTIFACT as ARTIFACT FROM API WHERE ORGANIZATION =${org} AND STATUS IN (${PUBLISHED},${PROTOTYPED},${DEPRECATED})`; - stream apisStream = dbClient->query(query); - API[] apis = check from API api in apisStream select api; + stream apisStream = dbClient->query(query); + APIInfo[] apis = check from APIInfo api in apisStream select api; check apisStream.close(); return apis; } on fail var e { @@ -72,7 +72,7 @@ isolated function getAPIsDAO(string org) returns API[]|commons:APKError { } } -isolated function getAPIsByQueryDAO(string payload, string org) returns API[]|commons:APKError { +isolated function getAPIsByQueryDAO(string payload, string org) returns APIInfo[]|commons:APKError { postgresql:Client | error dbClient = getConnection(); if dbClient is error { string message = "Error while retrieving connection"; @@ -84,8 +84,8 @@ isolated function getAPIsByQueryDAO(string payload, string org) returns API[]|co API_TYPE as TYPE, ARTIFACT as ARTIFACT FROM API JOIN JSONB_EACH_TEXT(ARTIFACT) e ON true WHERE ORGANIZATION =${org} AND e.value LIKE ${payload} AND STATUS IN (${PUBLISHED},${PROTOTYPED},${DEPRECATED})`; - stream apisStream = dbClient->query(query); - API[] apis = check from API api in apisStream select api; + stream apisStream = dbClient->query(query); + APIInfo[] apis = check from APIInfo api in apisStream select api; check apisStream.close(); return apis; } on fail var e { diff --git a/devportal/devportal-domain-service/ballerina/apiImpl.bal b/devportal/devportal-domain-service/ballerina/apiImpl.bal index 628caa18a5..d48b538e33 100644 --- a/devportal/devportal-domain-service/ballerina/apiImpl.bal +++ b/devportal/devportal-domain-service/ballerina/apiImpl.bal @@ -30,9 +30,9 @@ isolated function getAPIByAPIId(string apiId) returns API|NotFoundError|commons: isolated function getAPIList(int 'limit, int offset, string? query, commons:Organization organization) returns APIList|commons:APKError { if query !is string { - API[]|commons:APKError apis = getAPIsDAO(organization.uuid); - if apis is API[] { - API[] limitSet = []; + APIInfo[]|commons:APKError apis = getAPIsDAO(organization.uuid); + if apis is APIInfo[] { + APIInfo[] limitSet = []; if apis.length() > offset { foreach int i in offset ... (apis.length() - 1) { if limitSet.length() < 'limit { @@ -51,9 +51,9 @@ isolated function getAPIList(int 'limit, int offset, string? query, commons:Orga int? index = query.indexOf(":"); if index is int { string modifiedQuery = "%" + query.substring(index + 1) + "%"; - API[]|commons:APKError apis = getAPIsByQueryDAO(modifiedQuery, organization.uuid); - if apis is API[] { - API[] limitSet = []; + APIInfo[]|commons:APKError apis = getAPIsByQueryDAO(modifiedQuery, organization.uuid); + if apis is APIInfo[] { + APIInfo[] limitSet = []; if apis.length() > offset { foreach int i in offset ... (apis.length() - 1) { if limitSet.length() < 'limit { @@ -181,9 +181,9 @@ isolated function getDocumentMetaData(string apiId, string documentId) returns D documentId: getDocumentMetaData.documentId, name: getDocumentMetaData.name, summary: getDocumentMetaData.summary, - sourceType: getDocumentMetaData.sourceType, + sourceType: <"INLINE"|"MARKDOWN"|"URL"|"FILE">getDocumentMetaData.sourceType, sourceUrl: getDocumentMetaData.sourceUrl, - documentType: getDocumentMetaData.documentType, + documentType: <"HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER">getDocumentMetaData.documentType, otherTypeName: getDocumentMetaData.otherTypeName }; return document; @@ -241,6 +241,8 @@ isolated function getDocumentList(string apiId, int 'limit, int offset) returns } else { return documents; } + } else if api is NotFoundError { + return api; } else { string message = "Internal Error occured while retrieving API for Docuements retieval"; return error(message, message = message, description = message, code = 909001, statusCode = 500); diff --git a/devportal/devportal-domain-service/ballerina/applicationDAO.bal b/devportal/devportal-domain-service/ballerina/applicationDAO.bal index a25d9df3aa..e24aa1a75e 100644 --- a/devportal/devportal-domain-service/ballerina/applicationDAO.bal +++ b/devportal/devportal-domain-service/ballerina/applicationDAO.bal @@ -110,7 +110,7 @@ isolated function getApplicationByIdDAO(string appId, string org) returns Applic } } -isolated function getApplicationsDAO(string org) returns Application[]|commons:APKError { +isolated function getApplicationsDAO(string org) returns ApplicationInfo[]|commons:APKError { postgresql:Client|error dbClient = getConnection(); if dbClient is error { string message = "Error while retrieving connection"; @@ -119,8 +119,8 @@ isolated function getApplicationsDAO(string org) returns Application[]|commons:A do { sql:ParameterizedQuery query = `SELECT NAME, UUID as APPLICATIONID, DESCRIPTION, APPLICATION_TIER as THROTTLINGPOLICY, TOKEN_TYPE as TOKENTYPE, ORGANIZATION, APPLICATION_STATUS as STATUS FROM APPLICATION WHERE ORGANIZATION =${org}`; - stream applicationStream = dbClient->query(query); - Application[] applications = check from Application application in applicationStream + stream applicationStream = dbClient->query(query); + ApplicationInfo[] applications = check from ApplicationInfo application in applicationStream select application; check applicationStream.close(); return applications; diff --git a/devportal/devportal-domain-service/ballerina/applicationImpl.bal b/devportal/devportal-domain-service/ballerina/applicationImpl.bal index 2f4f2386de..b0a05064e2 100644 --- a/devportal/devportal-domain-service/ballerina/applicationImpl.bal +++ b/devportal/devportal-domain-service/ballerina/applicationImpl.bal @@ -15,14 +15,14 @@ // specific language governing permissions and limitations // under the License. // - import ballerina/log; +import ballerina/time; import ballerina/uuid; + import wso2/apk_common_lib as commons; import wso2/notification_grpc_client; import devportal_service.types; import devportal_service.kmclient; -import ballerina/time; isolated function addApplication(Application application, commons:Organization org, string user) returns NotFoundError|Application|commons:APKError { string applicationId = uuid:createType1AsString(); @@ -98,8 +98,8 @@ isolated function getApplicationById(string appId, commons:Organization org) ret } isolated function getApplicationList(string? sortBy, string? groupId, string? query, string? sortOrder, int 'limit, int offset, commons:Organization org) returns ApplicationList|commons:APKError { - Application[]|commons:APKError applications = getApplicationsDAO(org.uuid); - if applications is Application[] { + ApplicationInfo[]|commons:APKError applications = getApplicationsDAO(org.uuid); + if applications is ApplicationInfo[] { int count = applications.length(); ApplicationList applicationsList = {count: count, list: applications}; return applicationsList; @@ -199,11 +199,10 @@ isolated function deleteOauthApps(string appId, commons:Organization organizatio isolated function generateAPIKey(APIKeyGenerateRequest payload, string appId, string keyType, string user, commons:Organization org) returns APIKey|commons:APKError|NotFoundError { Application|NotFoundError application = check getApplicationById(appId, org); - if application !is Application { - string message = "Internal Error occured while retrieving Application Info for API Key"; - return error(message, message = message, description = message, code = 909001, statusCode = 500); + if application is NotFoundError { + return application; } else { - boolean userAllowed = checkUserAccessAllowedForApplication(application, user); + boolean userAllowed = checkUserAccessAllowedForApplication(application, user); if userAllowed { int validityPeriod = 0; int? payloadValPeriod = payload.validityPeriod; @@ -245,7 +244,7 @@ isolated function generateAPIKey(APIKeyGenerateRequest payload, string appId, st } } } - APIKey|commons:APKError apiKey = generateAPIKeyForApplication(user, application, apiList, keyType, validityPeriod, addProperties); + APIKey|commons:APKError apiKey = generateAPIKeyForApplication(user, application, apiList, keyType, validityPeriod, addProperties); return apiKey; } else { string message = "User:" + user + " doesn't have permission to Application with application id:" + appId; @@ -295,7 +294,7 @@ isolated function retrieveManagementServerHostsList() returns string[]|commons:A public isolated function generateKeysForApplication(Application application, ApplicationKeyGenerateRequest applicationKeyGenRequest, commons:Organization organization) returns OkApplicationKey|commons:APKError { string? keyManager = applicationKeyGenRequest.keyManager; if keyManager is string { - if check isKeyMappingEntryByApplicationAndKeyManagerExist(application.applicationId, keyManager,applicationKeyGenRequest.keyType) { + if check isKeyMappingEntryByApplicationAndKeyManagerExist(application.applicationId, keyManager, applicationKeyGenRequest.keyType) { return error("Key Mapping Entry already exists for application " + application.name + " and keyManager " + keyManager, message = "Key Mapping Entry already exists for application " + application.name + " and keyManager " + keyManager, description = "Key Mapping Entry already exists for application " + application.name + " and keyManager " + keyManager, code = 900950, statusCode = 400); } KeyManagerDaoEntry keyManagerById = check getKeyManagerById(keyManager, organization); @@ -439,8 +438,8 @@ isolated function fromKeyMappingDaoEntryToApplicationKey(types:KeyMappingDaoEntr keyMappingId: item.uuid, consumerKey: item.consumer_key, keyManager: item.key_manager_uuid, - keyType: item.key_type, - mode: item.create_mode, + keyType: <"PRODUCTION"|"SANDBOX">item.key_type, + mode: <"MAPPED"|"CREATED">item.create_mode, keyState: "CREATED" }; if oauthAppResponse is kmclient:ClientRegistrationResponse { @@ -527,18 +526,19 @@ public isolated function updateOauthApp(Application application, string keyMappi types:KeyMappingDaoEntry updatedKeyMappingentry = keyMappingEntry.clone(); updatedKeyMappingentry.app_info = oauthApplicationByClientId.toJsonString().toBytes(); check updateKeyMappingEntry(updatedKeyMappingentry); - return { + ApplicationKey applicationKey = { keyMappingId: keyMappingEntry.uuid, consumerKey: oauthApplicationByClientId.client_id, consumerSecret: oauthApplicationByClientId.client_secret, keyManager: keyMappingEntry.key_manager_uuid, - keyType: keyMappingEntry.key_type, - mode: keyMappingEntry.create_mode, + keyType: <"PRODUCTION"|"SANDBOX">keyMappingEntry.key_type, + mode: <"MAPPED"|"CREATED">keyMappingEntry.create_mode, keyState: "CREATED", callbackUrls: oauthApplicationByClientId.redirect_uris, supportedGrantTypes: oauthApplicationByClientId.grant_types, additionalProperties: oauthApplicationByClientId.additional_properties }; + return applicationKey; } else { return error("Key Manager is disabled", message = "Key Manager is disabled", description = "Key Manager is disabled", code = 900951, statusCode = 400); } diff --git a/devportal/devportal-domain-service/ballerina/devportal-api_service.bal b/devportal/devportal-domain-service/ballerina/devportal-api_service.bal index 207cbae728..99a60beedf 100644 --- a/devportal/devportal-domain-service/ballerina/devportal-api_service.bal +++ b/devportal/devportal-domain-service/ballerina/devportal-api_service.bal @@ -757,89 +757,9 @@ isolated service http:InterceptableService /api/devportal on ep0 { string|json sdkLanguages = check getSDKLanguages(); return sdkLanguages; } - # Get available web hook subscriptions for a given application. - # - # + applicationId - **Application Identifier** consisting of the UUID of the Application. - # + apiId - **API ID** consisting of the **UUID** of the API. - # + 'x\-wso2\-tenant - For cross-tenant invocations, this is used to specify the tenant/organization domain, where the resource need to be retrieved from. - # + return - returns can be any of following types - # WebhookSubscriptionList (OK. Topic list returned.) - # NotFoundError (Not Found. The specified resource does not exist.) - # InternalServerErrorError (Internal Server Error.) - // resource function get webhooks/subscriptions(string? applicationId, string? apiId, @http:Header string? 'x\-wso2\-tenant) returns WebhookSubscriptionList|NotFoundError|InternalServerErrorError { - // } - # Retrieve Developer Portal settings - # - # + 'x\-wso2\-tenant - For cross-tenant invocations, this is used to specify the tenant/organization domain, where the resource need to be retrieved from. - # + return - returns can be any of following types - # Settings (OK. Settings returned) - # NotFoundError (Not Found. The specified resource does not exist.) - // resource function get settings(@http:Header string? 'x\-wso2\-tenant) returns Settings|NotFoundError { - // } - # Get All Application Attributes from Configuration - # - # + 'if\-none\-match - Validator for conditional requests; based on the ETag of the formerly retrieved variant of the resource. - # + return - returns can be any of following types - # ApplicationAttributeList (OK. Application attributes returned.) - # NotFoundError (Not Found. The specified resource does not exist.) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - // resource function get settings/'application\-attributes(@http:Header string? 'if\-none\-match) returns ApplicationAttributeList|NotFoundError|NotAcceptableError { - // } - # Get Tenants by State - # - # + state - The state represents the current state of the tenant - # + 'limit - Maximum size of resource array to return. - # + offset - Starting point within the complete list of items qualified. - # + return - returns can be any of following types - # TenantList (OK. Tenant names returned.) - # NotFoundError (Not Found. The specified resource does not exist.) - # NotAcceptableError (Not Acceptable. The requested media type is not supported.) - // resource function get tenants(string state = "active", int 'limit = 25, int offset = 0) returns TenantList|NotFoundError|NotAcceptableError { - // } - # Give API Recommendations for a User - # - # + return - returns can be any of following types - # Recommendations (OK. Requested recommendations are returned) - # NotFoundError (Not Found. The specified resource does not exist.) - // resource function get recommendations() returns Recommendations|NotFoundError { - // } - # Get All API Categories - # - # + 'x\-wso2\-tenant - For cross-tenant invocations, this is used to specify the tenant/organization domain, where the resource need to be retrieved from. - # + return - OK. Categories returned // resource function get 'api\-categories(@http:Header string? 'x\-wso2\-tenant) returns APICategoryList { + // return; // } - # Get All Key Managers - # - # + 'x\-wso2\-tenant - For cross-tenant invocations, this is used to specify the tenant/organization domain, where the resource need to be retrieved from. - # + return - OK. Key Manager list returned // resource function get 'key\-managers(@http:Header string? 'x\-wso2\-tenant) returns KeyManagerList { // } - # Get the Complexity Related Details of an API - # - # + apiId - **API ID** consisting of the **UUID** of the API. - # + return - returns can be any of following types - # GraphQLQueryComplexityInfo (OK. Requested complexity details returned.) - # http:NotFound (Not Found. Requested API does not contain any complexity details.) - // resource function get apis/[string apiId]/'graphql\-policies/complexity() returns GraphQLQueryComplexityInfo|http:NotFound { - // } - # Retrieve Types and Fields of a GraphQL Schema - # - # + apiId - **API ID** consisting of the **UUID** of the API. - # + return - returns can be any of following types - # GraphQLSchemaTypeList (OK. Types and fields returned successfully.) - # http:NotFound (Not Found. Retrieving types and fields failed.) - // resource function get apis/[string apiId]/'graphql\-policies/complexity/types() returns GraphQLSchemaTypeList|http:NotFound { - // } - # Change the Password of the user - # - # + payload - Current and new password of the user - # + return - returns can be any of following types - # http:Ok (OK. User password changed successfully) - # BadRequestError (Bad Request. Invalid request or validation error.) - isolated resource function post me/'change\-password(@http:Payload CurrentAndNewPasswords payload) returns http:Ok|BadRequestError { - BadRequestError badRequest = {body: {code: 400, message: "Invalid request or validation error."}}; - return badRequest; - } - } diff --git a/devportal/devportal-domain-service/ballerina/resources/devportal-api.yaml b/devportal/devportal-domain-service/ballerina/resources/devportal-api.yaml index 6ca5a2b5ff..15b460460f 100644 --- a/devportal/devportal-domain-service/ballerina/resources/devportal-api.yaml +++ b/devportal/devportal-domain-service/ballerina/resources/devportal-api.yaml @@ -64,7 +64,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis" /apis/{apiId}: get: @@ -109,7 +109,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed" /apis/{apiId}/definition: get: @@ -196,11 +196,11 @@ paths: $ref: '#/components/responses/InternalServerError' security: - OAuth2Security: - - apk:subscribe + - [] x-code-samples: - lang: Curl source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/sdks/java" + "https://api.am.wso2.com:9095/api/am/devportal/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/sdks/java" > Petstore_java_1.0.0.zip ###################################################### @@ -246,7 +246,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents" ###################################################### # The "Individual Document" resource APIs @@ -290,7 +290,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/c43a325c-260b-4302-81cb-768eafaa3aed/documents/850a4f34-db2c-4d23-9d85-3f95fbfb082c" /apis/{apiId}/documents/{documentId}/content: get: @@ -343,7 +343,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/890a4f4d-09eb-4877-a323-57f6ce2ed79b/documents/0bcb7f05-599d-4e1a-adce-5cb89bfe58d5/content" /apis/{apiId}/thumbnail: get: @@ -389,7 +389,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: 'curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail" > image.jpeg' + source: 'curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/thumbnail" > image.jpeg' /apis/{apiId}/ratings: get: @@ -417,7 +417,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/ratings" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/ratings" /apis/{apiId}/user-rating: get: @@ -463,7 +463,7 @@ paths: x-code-samples: - lang: Curl source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating" + "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating" put: tags: @@ -502,11 +502,11 @@ paths: $ref: '#/components/responses/UnsupportedMediaType' security: - OAuth2Security: - - apk:subscribe + - [] 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://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating"' delete: tags: @@ -525,11 +525,11 @@ paths: content: {} security: - OAuth2Security: - - apk:subscribe + - [] x-code-samples: - lang: Curl source: curl -k -X DELETE -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating" + "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/user-rating" /apis/{apiId}/comments: get: @@ -561,7 +561,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments" post: tags: @@ -624,12 +624,11 @@ paths: 500: $ref: '#/components/responses/InternalServerError' security: - - OAuth2Security: - - apk:subscribe + - OAuth2Security: [] 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://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments"' /apis/{apiId}/comments/{commentId}: get: @@ -678,7 +677,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" patch: tags: @@ -749,7 +748,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -X PATCH -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -d @data.json "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4"' + -H "Content-Type: application/json" -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4"' delete: tags: @@ -784,11 +783,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:admin # special scope added to moderate comments x-code-samples: - lang: Curl source: curl -k -X DELETE -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" + "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4" /apis/{apiId}/comments/{commentId}/replies: get: @@ -837,88 +835,8 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4/replies" - - /apis/{apiId}/topics: - get: - tags: - - Topics - summary: | - Get a list of available topics for a given Async API - description: | - This operation will provide a list of topics available for a given Async API, based on the provided API ID. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - responses: - 200: - description: | - OK. Topic list returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/TopicList' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/apis/5b65808c-cdf2-43e1-a695-de63e3ad0ae9/topics" + source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://api.am.wso2.com:9095/api/am/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/comments/d4cf1704-5d09-491c-bc48-4d19ce6ea9b4/replies" - /apis/{apiId}/subscription-policies: - get: - tags: - - APIs - summary: | - Get Details of the Subscription Throttling Policies of an API - description: | - This operation can be used to retrieve details of the subscription throttling policy of an API by specifying the API Id. - parameters: - - $ref: '#/components/parameters/apiId' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. Throttling Policy returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modified the last time. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicy' - 304: - description: | - Not Modified. Empty body because the client has already the latest version of the requested resource. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/268c9e55-3dc1-4f47-82e7-977e5343d077/subscription-policies" ###################################################### # The "Application Collection" resource APIs @@ -982,12 +900,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage - - apk:app_import_export x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/applications?query=CalculatorApp"' + "https://api.am.wso2.com:9095/api/am/devportal/applications?query=CalculatorApp"' post: tags: @@ -1045,11 +961,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications"' ###################################################### # The "Individual Application" resource APIs @@ -1096,11 +1011,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' + "https://api.am.wso2.com:9095/api/am/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' put: tags: @@ -1153,11 +1067,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X PUT -d @data.json "https://localhost:9443/api/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' + -H "Content-Type: application/json" -X PUT -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' delete: tags: @@ -1194,12 +1107,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage - - apk:app_import_export x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -X DELETE "https://localhost:9443/api/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' + -X DELETE "https://api.am.wso2.com:9095/api/am/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015"' /applications/{applicationId}/generate-keys: post: @@ -1236,11 +1147,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015/generate-keys"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015/generate-keys"' /applications/{applicationId}/map-keys: post: @@ -1277,11 +1187,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015/map-keys"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/896658a0-b4ee-4535-bbfa-806c894a4015/map-keys"' /applications/{applicationId}/oauth-keys: @@ -1311,11 +1220,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys"' + "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys"' /applications/{applicationId}/oauth-keys/{keyMappingId}: get: @@ -1345,11 +1253,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584"' + "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584"' put: tags: @@ -1386,11 +1293,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X PUT -d @data.json "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584"' + -H "Content-Type: application/json" -X PUT -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584"' /applications/{applicationId}/oauth-keys/{keyMappingId}/regenerate-secret: post: @@ -1436,11 +1342,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584/regenerate-secret"' + -H "Content-Type: application/json" -X POST "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584/regenerate-secret"' /applications/{applicationId}/oauth-keys/{keyMappingId}/clean-up: post: @@ -1467,11 +1372,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584/clean-up"' + -H "Content-Type: application/json" -X POST "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/df972173-c957-46d4-96ac-99be8e303584/clean-up"' /applications/{applicationId}/oauth-keys/{keyMappingId}/generate-token: post: @@ -1509,11 +1413,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/{keyMappingId}/generate-token"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/oauth-keys/{keyMappingId}/generate-token"' /applications/{applicationId}/api-keys/{keyType}/generate: post: @@ -1551,12 +1454,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage - - apk:api_key x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/api-keys/PRODUCTION/generate"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/api-keys/PRODUCTION/generate"' /applications/{applicationId}/api-keys/{keyType}/revoke: post: @@ -1589,164 +1490,11 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:app_manage - - apk:api_key - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/api-keys/PRODUCTION/revoke"' - - /applications/export: - get: - tags: - - Import Export - summary: Export an Application - description: | - This operation can be used to export the details of a particular application as a zip file. - parameters: - - name: appName - in: query - description: | - Application Name - required: true - schema: - type: string - - name: appOwner - in: query - description: | - Owner of the Application - required: true - schema: - type: string - - name: withKeys - in: query - description: | - Export application keys - schema: - type: boolean - - name: format - in: query - description: | - Format of output documents. Can be YAML or JSON. - schema: - type: string - enum: - - JSON - - YAML - responses: - 200: - description: | - OK. Export Successful. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/zip: - schema: - type: string - format: binary - 400: - $ref: '#/components/responses/BadRequest' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:app_import_export x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/applications/export?appName=sampleApp&appOwner=admin&withKeys=true" - > exportedApplication.zip' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/applications/16cd2684-9657-4a01-a956-4efd89e96077/api-keys/PRODUCTION/revoke"' - /applications/import: - post: - tags: - - Import Export - summary: Import an Application - description: | - This operation can be used to import an application. - parameters: - - name: preserveOwner - in: query - description: | - Preserve Original Creator of the Application - schema: - type: boolean - - name: skipSubscriptions - in: query - description: | - Skip importing Subscriptions of the Application - schema: - type: boolean - - name: appOwner - in: query - description: | - Expected Owner of the Application in the Import Environment - schema: - type: string - - name: skipApplicationKeys - in: query - description: | - Skip importing Keys of the Application - schema: - type: boolean - - name: update - in: query - description: | - Update if application exists - schema: - type: boolean - requestBody: - content: - multipart/form-data: - schema: - required: - - file - properties: - file: - type: string - description: | - Zip archive consisting of exported Application Configuration. - format: binary - required: true - responses: - 200: - description: | - OK. Successful response with the updated object information as entity in the body. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationInfo' - # 207: - # description: | - # Multi Status. - # Partially successful response with skipped APIs information object as entity in the body. - # content: - # application/json: - # schema: - # $ref: '#/components/schemas/APIInfoList' - 400: - $ref: '#/components/responses/BadRequest' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:app_import_export - x-code-samples: - - lang: Curl - source: 'curl -k -X POST -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -F file=@exportedApplication.zip "https://127.0.0.1:9443/api/devportal/applications/import?preserveOwner=true&skipSubscriptions=false&appOwner=admin&skipApplicationKeys=false&update=true"' ###################################################### # The "Subscription Collection" resource APIs @@ -1790,11 +1538,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340"' + "https://api.am.wso2.com:9095/api/am/devportal/subscriptions?apiId=02e658e7-71c7-4b1d-a623-be145b789340"' post: tags: @@ -1856,11 +1603,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/subscriptions"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/subscriptions"' /subscriptions/multiple: post: @@ -1917,11 +1663,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/subscriptions/multiple"' + -H "Content-Type: application/json" -X POST -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/multiple"' ###################################################### # The "Subscriptions related to API" resource API @@ -1964,7 +1709,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://localhost:9443/api/devportal/subscriptions/e93fb282-b456-48fc-8981-003fb89086ae/additionalInfo"' + source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/e93fb282-b456-48fc-8981-003fb89086ae/additionalInfo"' ###################################################### # The "Individual Subscription" resource APIs @@ -2006,11 +1751,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9"' + "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9"' put: tags: @@ -2079,11 +1823,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X PUT -d @data.json "https://localhost:9443/api/devportal/subscriptions/80369180-7d90-4ee8-99a1-19fa68512aa5"' + -H "Content-Type: application/json" -X PUT -d @data.json "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/80369180-7d90-4ee8-99a1-19fa68512aa5"' delete: tags: @@ -2120,11 +1863,10 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X DELETE "https://localhost:9443/api/devportal/subscriptions/80369180-7d90-4ee8-99a1-19fa68512aa5"' + -H "Content-Type: application/json" -X DELETE "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/80369180-7d90-4ee8-99a1-19fa68512aa5"' /subscriptions/{subscriptionId}/usage: get: @@ -2166,146 +1908,11 @@ paths: security: - OAuth2Security: - apk:subscribe - - apk:sub_manage x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9/usage"' - - ###################################################### - # The "Throttling Policy Collection" resource APIs - ###################################################### - /throttling-policies/{policyLevel}: - get: - tags: - - Throttling Policies - summary: Get All Available Throttling Policies - description: | - This operation can be used to get all available application or subscription level throttling policies - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/policyLevel' - - $ref: '#/components/parameters/If-None-Match' - - $ref: '#/components/parameters/requestedTenant' - responses: - 200: - description: | - OK. List of throttling policies returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicyList' - 304: - description: | - Not Modified. Empty body because the client has already the latest version of the requested resource. - content: {} - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/throttling-policies/application" - - ###################################################### - # The "Individual Throttling Policy" resource APIs - ###################################################### - /throttling-policies/{policyLevel}/{policyId}: - get: - tags: - - Throttling Policies - summary: | - Get Details of a Throttling Policy - description: | - This operation can be used to retrieve details of a single throttling policy by specifying the policy level and policy name. - parameters: - - $ref: '#/components/parameters/policyId' - - $ref: '#/components/parameters/policyLevel' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. Throttling Policy returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - Last-Modified: - description: | - Date and time the resource has been modified the last time. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ThrottlingPolicy' - 304: - description: | - Not Modified. Empty body because the client has already the latest version of the requested resource. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/throttling-policies/application/10PerMin" + "https://api.am.wso2.com:9095/api/am/devportal/subscriptions/5b65808c-cdf2-43e1-a695-de63e3ad0ae9/usage"' - ###################################################### - # The "Tag Collection" resource API - ###################################################### - /tags: - get: - tags: - - Tags - summary: | - Get All Tags - description: | - This operation can be used to retrieve a list of tags that are already added to APIs. - parameters: - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - - $ref: '#/components/parameters/requestedTenant' - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. Tag list is returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/TagList' - 304: - description: | - Not Modified. Empty body because the client has already the latest version of the requested resource. - content: {} - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/tags" ###################################################### # The "Content Search Results" resource APIs @@ -2357,7 +1964,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/search?query=PizzaShackAPI" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/search?query=PizzaShackAPI" ###################################################### # The "SDK Generation Languages" list resource APIs @@ -2387,194 +1994,8 @@ paths: x-code-samples: - lang: Curl source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/sdk-gen/languages" - - ###################################################### - # The Web hook API topic details - ###################################################### - /webhooks/subscriptions: - get: - tags: - - Webhooks - summary: | - Get available web hook subscriptions for a given application. - description: | - This operation will provide a list of web hook topic subscriptions for a given application. If the api id is provided results will be filtered by the api Id. - parameters: - - $ref: '#/components/parameters/applicationId-Q' - - $ref: '#/components/parameters/apiId-Q' - - $ref: '#/components/parameters/requestedTenant' - responses: - 200: - description: | - OK. Topic list returned. - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/WebhookSubscriptionList' - 404: - $ref: '#/components/responses/NotFound' - 500: - $ref: '#/components/responses/InternalServerError' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k -H "Authorization:Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/webhooks/subscriptions?applicationId=5b65808c-cdf2-43e1-a695-de63e3ad0ae9&apiId=ae4eae22-3f65-387b-a171-d37eaa366fa8" - - ###################################################### - # The Developer Portal settings List - ###################################################### - /settings: - get: - tags: - - Settings - summary: Retrieve Developer Portal settings - description: | - Retreive Developer Portal settings - parameters: - - $ref: '#/components/parameters/requestedTenant' - responses: - 200: - description: | - OK. Settings returned - content: - application/json: - schema: - $ref: '#/components/schemas/Settings' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:store_settings - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/settings"' - - /settings/application-attributes: - get: - tags: - - Settings - summary: | - Get All Application Attributes from Configuration - description: | - This operation can be used to retrieve the application attributes from configuration. It will not return hidden attributes. - parameters: - - $ref: '#/components/parameters/If-None-Match' - responses: - 200: - description: | - OK. Application attributes returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/ApplicationAttributeList' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: - - apk:subscribe - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/settings/application-attributes"' - - ###################################################### - # The tenant resource APIs - ###################################################### - /tenants: - get: - tags: - - Tenants - summary: | - Get Tenants by State - description: | - This operation is used to get tenants by state - parameters: - - name: state - in: query - description: | - The state represents the current state of the tenant - schema: - type: string - default: active - enum: - - active - - inactive - - $ref: '#/components/parameters/limit' - - $ref: '#/components/parameters/offset' - responses: - 200: - description: | - OK. Tenant names returned. - headers: - Content-Type: - description: | - The content type of the body. - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/TenantList' - 404: - $ref: '#/components/responses/NotFound' - 406: - $ref: '#/components/responses/NotAcceptable' - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/tenants" + "https://api.am.wso2.com:9095/api/am/devportal/sdk-gen/languages" - ###################################################### - # The "Recommendations" resource API - ###################################################### - /recommendations: - get: - tags: - - Recommendations - summary: Give API Recommendations for a User - description: This API can be used to get recommended APIs for a user who logs into the API Developer Portal - responses: - 200: - description: | - OK. Requested recommendations are returned - headers: - ETag: - description: | - Entity Tag of the response resource. Used by caches, or in conditional requests - schema: - type: string - content: - application/json: - schema: - $ref: '#/components/schemas/Recommendations' - 404: - $ref: '#/components/responses/NotFound' - security: - - OAuth2Security: - - apk:subscribe - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/recommendations"' ###################################################### # The "Category Collection" resource API @@ -2600,7 +2021,7 @@ paths: - OAuth2Security: [] x-code-samples: - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/api-categories" + source: curl -k "https://api.am.wso2.com:9095/api/am/devportal/api-categories" ###################################################### # The "Key Manager Collection" resource API @@ -2628,111 +2049,7 @@ paths: x-code-samples: - lang: Curl source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - "https://localhost:9443/api/devportal/key-managers"' - - ###################################################### - # GraphQL "Query Complexity" resource APIs - ###################################################### - /apis/{apiId}/graphql-policies/complexity: - get: - tags: - - GraphQL Policies - summary: Get the Complexity Related Details of an API - description: | - This operation can be used to retrieve complexity related details belonging to an API by providing the API id. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. Requested complexity details returned. - headers: - Content-Type: - description: | - The content of the body. - schema: - type: string - default: application/json - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLQueryComplexityInfo' - 404: - description: | - Not Found. Requested API does not contain any complexity details. - content: {} - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/graphql-policies/complexity" - - /apis/{apiId}/graphql-policies/complexity/types: - get: - tags: - - GraphQL Policies - summary: Retrieve Types and Fields of a GraphQL Schema - description: | - This operation can be used to retrieve all types and fields of the GraphQL Schema by providing the API id. - parameters: - - $ref: '#/components/parameters/apiId' - responses: - 200: - description: | - OK. Types and fields returned successfully. - headers: - Content-Type: - description: | - The content of the body. - schema: - type: string - default: application/json - content: - application/json: - schema: - $ref: '#/components/schemas/GraphQLSchemaTypeList' - 404: - description: | - Not Found. Retrieving types and fields failed. - content: {} - security: - - OAuth2Security: [] - x-code-samples: - - lang: Curl - source: curl -k "https://localhost:9443/api/devportal/apis/e93fb282-b456-48fc-8981-003fb89086ae/graphql-policies/complexity/types" - - ###################################################### - # User resource APIs - ###################################################### - /me/change-password: - post: - tags: - - Users - summary: Change the Password of the user - description: | - Using this operation, logged-in user can change their password. - operationId: changeUserPassword - requestBody: - description: | - Current and new password of the user - content: - application/json: - schema: - $ref: '#/components/schemas/CurrentAndNewPasswords' - required: true - responses: - 200: - description: OK. User password changed successfully - content: {} - 400: - $ref: '#/components/responses/BadRequest' - security: - - OAuth2Security: - - apk:subscribe - x-code-samples: - - lang: Curl - source: 'curl -k -H "Authorization: Bearer ae4eae22-3f65-387b-a171-d37eaa366fa8" - -H "Content-Type: application/json" -X POST -d @data.json "https://localhost:9443/api/devportal/me/change-password"' + "https://api.am.wso2.com:9095/api/am/devportal/key-managers"' components: schemas: @@ -3566,6 +2883,9 @@ components: - REJECTED - TIER_UPDATE_PENDING - DELETE_PENDING + subscriptionCreateState: + type: string + example: CREATED redirectionParams: type: string description: A url and other parameters the subscriber can be redirected. @@ -5163,5 +4483,10 @@ components: password: tokenUrl: https://localhost:9443/oauth2/token scopes: - type: array - items: test + openid: Authorize access to user details + apk:subscribe: Subscribe API + apk:app_manage: Retrieve, Manage and Import, Export applications + apk:app_import_export: Import and export applications related operations + apk:api_key: Generate API Keys + apk:sub_manage: Retrieve, Manage subscriptions + apk:store_settings: Retrieve Developer Portal settings diff --git a/devportal/devportal-domain-service/ballerina/subscriptionImpl.bal b/devportal/devportal-domain-service/ballerina/subscriptionImpl.bal index 67d7ed4c2b..704974709b 100644 --- a/devportal/devportal-domain-service/ballerina/subscriptionImpl.bal +++ b/devportal/devportal-domain-service/ballerina/subscriptionImpl.bal @@ -250,6 +250,8 @@ isolated function getSubscriptions(string? apiId, string? applicationId, string? int count = subs.length(); SubscriptionList subList = {count: count, list: subs}; return subList; + } else if subscription is NotFoundError { + return subscription; } else { string message = "Internal Error occured while retrieving Subscription"; return error(message, message = message, description = message, code = 909001, statusCode = 500); diff --git a/devportal/devportal-domain-service/ballerina/tests/apiTests.bal b/devportal/devportal-domain-service/ballerina/tests/apiTests.bal index 5567540ad8..ad235f51b8 100644 --- a/devportal/devportal-domain-service/ballerina/tests/apiTests.bal +++ b/devportal/devportal-domain-service/ballerina/tests/apiTests.bal @@ -188,6 +188,7 @@ function getAPIDefinitionByIdTest(){ if apiDefResponse is APIDefinition { test:assertTrue(true, "Successfully retrieved API Definition"); } else if apiDefResponse is commons:APKError { + log:printInfo(apiDefResponse.toBalString()); log:printError(apiDefResponse.toString()); test:assertFail("Error occured while retrieving API"); } else if apiDefResponse is NotFoundError { @@ -223,6 +224,7 @@ function generateSDKImplTestNegative(){ if sdk is http:Response { test:assertFail("Successfully generated API SDK"); } else if sdk is sdk:APIClientGenerationException|commons:APKError { + log:printInfo(sdk.toBalString()); test:assertTrue(true,"Error while generating API SDK"); } } diff --git a/devportal/devportal-domain-service/ballerina/types.bal b/devportal/devportal-domain-service/ballerina/types.bal index 026dc191f6..b65e2d54a9 100644 --- a/devportal/devportal-domain-service/ballerina/types.bal +++ b/devportal/devportal-domain-service/ballerina/types.bal @@ -1,23 +1,8 @@ -// -// Copyright (c) 2022, WSO2 LLC. (http://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. -// +// AUTO-GENERATED FILE. +// This file is auto-generated by the Ballerina OpenAPI tool. -import ballerina/http; import ballerina/constraint; +import ballerina/http; public type AcceptedWorkflowResponse record {| *http:Accepted; @@ -89,11 +74,6 @@ public type OkApplicationKeyReGenerateResponse record {| ApplicationKeyReGenerateResponse body; |}; -public type OkApplicationInfo record {| - *http:Ok; - ApplicationInfo body; -|}; - public type DocumentList record { # Number of Documents returned. int count?; @@ -117,9 +97,9 @@ public type ApplicationKey record { # Describes the state of the key generation. string keyState?; # Describes to which endpoint the key belongs - string keyType?; + "PRODUCTION"|"SANDBOX" keyType?; # Describe the which mode Application Mapped. - string mode?; + "MAPPED"|"CREATED" mode?; ApplicationToken token?; # additionalProperties (if any). record {} additionalProperties?; @@ -143,7 +123,7 @@ public type APIInfo_additionalProperties record { }; public type ApplicationKeyGenerateRequest record { - string keyType; + "PRODUCTION"|"SANDBOX" keyType; # key Manager to Generate Keys string keyManager?; # Grant types that should be supported by the application @@ -160,9 +140,9 @@ public type ApplicationKeyGenerateRequest record { public type Document record { string documentId?; string name; - string documentType; + "HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER" documentType?; string summary?; - string sourceType; + "INLINE"|"MARKDOWN"|"URL"|"FILE" sourceType; string sourceUrl?; string otherTypeName?; }; @@ -216,7 +196,7 @@ public type ScopeList record { public type APIList record { # Number of APIs returned. int count?; - API[] list?; + APIInfo[] list?; Pagination pagination?; }; @@ -248,7 +228,7 @@ public type Subscription record { string apiId; APIInfo apiInfo?; ApplicationInfo applicationInfo?; - string status?; + "BLOCKED"|"PROD_ONLY_BLOCKED"|"UNBLOCKED"|"ON_HOLD"|"REJECTED"|"TIER_UPDATE_PENDING"|"DELETE_PENDING" status?; string subscriptionCreateState?; # A url and other parameters the subscriber can be redirected. string redirectionParams?; @@ -276,7 +256,7 @@ public type Settings record { }; public type ThrottlingPolicyPermissionInfo record { - string 'type?; + "allow"|"deny" 'type?; # roles for this permission string[] roles?; }; @@ -358,18 +338,13 @@ public type CommenterInfo record { string fullName?; }; -public type Applications_import_body record { - # Zip archive consisting of exported Application Configuration. - record {byte[] fileContent; string fileName;} file; -}; - public type AdvertiseInfo record { boolean advertised?; string apiExternalProductionEndpoint?; string apiExternalSandboxEndpoint?; string originalDevPortalUrl?; string apiOwner?; - string vendor?; + "WSO2"|"AWS" vendor?; }; public type CommentList record { @@ -543,7 +518,7 @@ public type KeyManagerApplicationConfiguration record { public type ApplicationList record { # Number of applications returned. int count?; - Application[] list?; + ApplicationInfo[] list?; Pagination pagination?; }; @@ -581,7 +556,7 @@ public type ApplicationKeyMappingRequest record { string consumerSecret?; # Key Manager Name string keyManager?; - string keyType; + "PRODUCTION"|"SANDBOX" keyType; }; public type Topic record { @@ -606,7 +581,7 @@ public type Comment record { string updatedTime?; string category = "general"; string parentCommentId?; - string entryPoint?; + "devPortal"|"publisher" entryPoint?; CommenterInfo commenterInfo?; CommentList replies?; }; @@ -618,7 +593,8 @@ public type ApplicationTokenGenerateRequest record { int validityPeriod?; # Token to be revoked, if any string revokeToken?; - string grantType?; + "CLIENT_CREDENTIALS"|"TOKEN_EXCHANGE" grantType?; + # Scopes to be assigned to the access token string[] scopes?; # Additional parameters if Authorization server needs any record {} additionalProperties?; @@ -647,7 +623,7 @@ public type KeyManagerInfo record { string alias?; record {} additionalProperties?; # The type of the tokens to be used (exchanged or without exchanged). Accepted values are EXCHANGED, DIRECT and BOTH. - string tokenType = "DIRECT"; + "EXCHANGED"|"DIRECT"|"BOTH" tokenType = "DIRECT"; }; public type WebhookSubscription record { @@ -699,7 +675,7 @@ public type Error record { public type APIKeyGenerateRequest record { # Token validity period - int validityPeriod?; + int:Signed32 validityPeriod?; # Additional parameters if Authorization server needs any record {} additionalProperties?; }; @@ -716,7 +692,7 @@ public type ScopeInfo record { public type SearchResult record { string id?; string name; - string 'type?; + "DOC"|"API" 'type?; # Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL string transportType?; }; @@ -724,7 +700,7 @@ public type SearchResult record { public type ThrottlingPolicy record { string name; string description?; - string policyLevel?; + "application"|"subscription" policyLevel?; # Custom attributes added to the throttling policy record {|string...;|} attributes?; # Maximum number of requests which can be sent within a provided unit time @@ -738,9 +714,9 @@ public type ThrottlingPolicy record { # Burst control time unit string rateLimitTimeUnit?; # Default quota limit type - string quotaPolicyType?; + "REQUESTCOUNT"|"BANDWIDTHVOLUME" quotaPolicyType?; # This attribute declares whether this tier is available under commercial or free - string tierPlan; + "FREE"|"COMMERCIAL" tierPlan; # If this attribute is set to false, you are capable of sending requests # even if the request count exceeded within a unit time boolean stopOnQuotaReach; @@ -751,17 +727,17 @@ public type ThrottlingPolicy record { public type APIKey record { # API Key string apikey?; - int validityTime?; + int:Signed32 validityTime?; }; public type DocumentSearchResult record { *SearchResult; - string docType?; + "HOWTO"|"SAMPLES"|"PUBLIC_FORUM"|"SUPPORT_FORUM"|"API_MESSAGE_FORMAT"|"SWAGGER_DOC"|"OTHER" docType?; string summary?; - string sourceType?; + "INLINE"|"URL"|"FILE"|"MARKDOWN" sourceType?; string sourceUrl?; string otherTypeName?; - string visibility?; + "OWNER_ONLY"|"PRIVATE"|"API_LEVEL" visibility?; # The name of the associated API string apiName?; # The version of the associated API @@ -806,7 +782,7 @@ public type SubscriptionList record { public type WorkflowResponse record { # This attribute declares whether this workflow task is approved or rejected. - string workflowStatus; + "CREATED"|"APPROVED"|"REJECTED"|"REGISTERED" workflowStatus; # Attributes that returned after the workflow execution string jsonPayload?; }; @@ -883,7 +859,7 @@ public type Tag record { }; public type MonetizationInfo record { - string billingType?; + "fixedPrice"|"dynamicRate" billingType?; string billingCycle?; string fixedPrice?; string pricePerRequest?;