Skip to content

Commit

Permalink
Merge branch 'master' into endpointIssue
Browse files Browse the repository at this point in the history
  • Loading branch information
shnrndk authored Jul 30, 2024
2 parents ea285be + 52bcb7f commit 419e37e
Show file tree
Hide file tree
Showing 245 changed files with 6,887 additions and 1,553 deletions.
2 changes: 1 addition & 1 deletion components/apimgt/org.wso2.carbon.apimgt.api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.29.103-SNAPSHOT</version>
<version>9.29.174-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ Set<SubscribedAPI> getPaginatedSubscribedAPIsByApplication(Application applicati
*/
Tier getThrottlePolicyByName(String name, int policyType, String organization) throws APIManagementException;

/**
* Send Application Policy Reset Event to Eventhub
*
* @param applicationId Application Identifier used by traffic manager
* @param userId Username for which the policy should be reset
* @param organization Tenant which application owner belongs to
*/
void resetApplicationThrottlePolicy(String applicationId, String userId, String organization)
throws APIManagementException;

/**
* Returns the API Chat execute call response as a string
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,17 @@ APIStateChangeResponse changeLifeCycleStatus(String orgId, ApiTypeWrapper apiTyp
*/
List<BlockConditionsDTO> getBlockConditions() throws APIManagementException;

/**
* Get a lightweight version of list of block Conditions.
*
* @param conditionType type of the condition
* @param conditionValue condition value
* @return list of block conditions
* @throws APIManagementException
*/
List<BlockConditionsDTO> getLightweightBlockConditions(String conditionType, String conditionValue)
throws APIManagementException;

/**
*
* @return Retrieve a block Condition
Expand Down Expand Up @@ -794,6 +805,7 @@ String addBlockCondition(String conditionType, String conditionValue, boolean co
* @param apiTypeWrapper : API Type Wrapper.
* @param certificate : Relevant public certificate.
* @param alias : Alias of the certificate.
* @param keyType : Key type for the certificate (PRODUCTION or SANDBOX).
* @param organization : Organization
* @return SUCCESS : If operation succeeded,
* INTERNAL_SERVER_ERROR : If any internal error occurred,
Expand All @@ -802,7 +814,7 @@ String addBlockCondition(String conditionType, String conditionValue, boolean co
* @throws APIManagementException API Management Exception.
*/
int addClientCertificate(String userName, ApiTypeWrapper apiTypeWrapper, String certificate, String alias,
String tierName, String organization) throws APIManagementException;
String tierName, String keyType, String organization) throws APIManagementException;

/**
* Method to remove the certificate which mapped to the given alias, endpoint from publisher and gateway nodes.
Expand All @@ -824,7 +836,7 @@ int addClientCertificate(String userName, ApiTypeWrapper apiTypeWrapper, String
* 4 : If certificate is not found in the trust store.
* @throws APIManagementException API Management Exception.
*/
int deleteClientCertificate(String userName, ApiTypeWrapper apiTypeWrapper, String alias)
int deleteClientCertificate(String userName, ApiTypeWrapper apiTypeWrapper, String alias, String keyType)
throws APIManagementException;

/**
Expand Down Expand Up @@ -871,8 +883,8 @@ List<CertificateMetadataDTO> searchCertificates(int tenantId, String alias, Stri
* @return list of client certificates that match search criteria.
* @throws APIManagementException API Management Exception.
*/
List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias, APIIdentifier apiIdentifier,
String organization) throws APIManagementException;
List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias, String keyType,
APIIdentifier apiIdentifier, String organization) throws APIManagementException;

/**
* Method to search the client certificates for the provided tenant id, alias and api product identifier.
Expand All @@ -884,7 +896,7 @@ List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias,
* @return list of client certificates that match search criteria.
* @throws APIManagementException API Management Exception.
*/
List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias,
List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias, String keyType,
APIProductIdentifier apiProductIdentifier, String organization) throws APIManagementException;

/**
Expand All @@ -902,7 +914,7 @@ List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias,
* @return count of client certificates that exists for a particular tenant.
* @throws APIManagementException API Management Exception.
*/
int getClientCertificateCount(int tenantId) throws APIManagementException;
int getClientCertificateCount(int tenantId, String keyType) throws APIManagementException;

/**
* Method to check whether an certificate for the given alias is present in the trust store and the database.
Expand All @@ -918,13 +930,14 @@ List<ClientCertificateDTO> searchClientCertificates(int tenantId, String alias,
* be modified by current user.
*
* @param alias : Relevant alias.
* @param keyType : Key type of the certificate
* @param apiTypeWrapper : The identifier of the api.
* @param organization : Organization
* @return Instance of {@link ClientCertificateDTO} if the client certificate is present and
* modifiable by current user.
* @throws APIManagementException API Management Exception.
*/
ClientCertificateDTO getClientCertificate(String alias, ApiTypeWrapper apiTypeWrapper,
ClientCertificateDTO getClientCertificate(String alias, String keyType, ApiTypeWrapper apiTypeWrapper,
String organization) throws APIManagementException;


Expand Down Expand Up @@ -956,6 +969,7 @@ ClientCertificateDTO getClientCertificate(String alias, ApiTypeWrapper apiTypeWr
* @param alias : Alias of the certificate.
* @param apiTypeWrapper : API Identifier of the certificate.
* @param tier : tier name.
* @param keyType : Key type for the certificate (PRODUCTION or SANDBOX).
* @param tenantId : Id of tenant.
* @param organization : organization
* @return : 1 : If client certificate update is successful,
Expand All @@ -965,7 +979,7 @@ ClientCertificateDTO getClientCertificate(String alias, ApiTypeWrapper apiTypeWr
* @throws APIManagementException API Management Exception.
*/
int updateClientCertificate(String certificate, String alias, ApiTypeWrapper apiTypeWrapper, String tier,
int tenantId, String organization) throws APIManagementException;
String keyType, int tenantId, String organization) throws APIManagementException;

/**
* Retrieve the certificate which matches the given alias.
Expand Down Expand Up @@ -1680,6 +1694,17 @@ Map<String,Object> searchPaginatedAPIProducts(String searchQuery, String tenantD
*/
API getAPIbyUUID(String uuid, String organization) throws APIManagementException;

/**
* Get API UUID by the API Identifier.
*
* @param identifier API Identifier
* @param organization identifier of the organization
* @return String UUID
* @throws APIManagementException if an error occurs
*/
String getUUIDFromIdentifier(APIIdentifier identifier, String organization) throws APIManagementException;


/**
* Returns API Search result based on fqdn of the provided endpoint.
* Returns empty API Search result if endpoint is invalid.
Expand Down Expand Up @@ -1897,4 +1922,25 @@ boolean isPolicyMetadataExists(String gatewayPolicyMappingId)
* @throws APIManagementException
*/
int getPolicyUsageByPolicyUUIDInGatewayPolicies(String commonPolicyUUID) throws APIManagementException;

/**
* Update SoapToRest Sequences for the given API.
* @param organization Organization
* @param apiId API ID
* @param sequences list of SOAPToRestSequence.
* @throws APIPersistenceException
*/
void updateSoapToRestSequences(String organization, String apiId, List<SOAPToRestSequence> sequences)
throws APIManagementException;

/**
* Updates the subscription tier of a given subscription.
*
* @param subscriptionUUID The UUID of the subscription to be updated
* @param subscriptionTier The new subscription tier to be assigned
* @return The updated subscription
* @throws APIManagementException If the subscription is not found, status is TIER_UPDATE_PENDING, the specified
* tier is not allowed for the API or an error occurs while updating the subscription
*/
SubscribedAPI updateSubscriptionTier(String subscriptionUUID, String subscriptionTier) throws APIManagementException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public enum ExceptionCodes implements ErrorHandler {
APPLICATION_NOT_FOUND(900307, "Application not found", 404, "Application not found"),
API_NOT_FOUND(900308, "API Not Found", 404, "Requested API with id '%s' not found"),
APPLICATION_INACTIVE(900309, "Application is not active", 400, "Application is not active"),
SUBSCRIPTION_NOT_FOUND(900310, "Subscription not found", 404, "Couldn't retrieve Subscriptions for API"),
SUBSCRIPTION_NOT_FOUND(900310, "Subscription not found", 404,
"The requested subscription with ID '%s' was not found."),
UPDATE_STATE_CHANGE(900311, "API fields have state changes", 400, "Couldn't Update as API have changes can't be done"),
DOCUMENT_ALREADY_EXISTS(900312, "Document already exists", 409, "Document already exists"),
COULD_NOT_UPDATE_API(900313, "Error has occurred. Could not update the API", 500, "Error has occurred. Could not "
Expand Down Expand Up @@ -93,12 +94,12 @@ public enum ExceptionCodes implements ErrorHandler {
"Cannot remove the resource paths because they are used by one or more API Products",
409, "Cannot update API: %s:%s, due to the resources to remove are used by one or more API Products"),
API_CATEGORY_INVALID(
900345, "The API category is invalid.", 400, " The API category is invalid for API: %s:%s"),
900345, "The API category is invalid.", 400, " The API category is invalid for API: %s"),
INVALID_ADDITIONAL_PROPERTIES(900346, "Invalid additional properties", 400,
"Invalid additional properties for API: %s:%s"),
INVALID_CONTEXT(900346, "Invalid context provided", 400, "Invalid context provided for API: %s:%s"),
INVALID_ENDPOINT_URL(900346, "Endpoint URL(s) is(are) not valid", 400, "Endpoint URL(s) is(are) not valid"),
USER_ROLES_CANNOT_BE_NULL(900610, "User roles cannot be found", 400, "User roles cannot be found"),
USER_ROLES_CANNOT_BE_NULL(900610, "Access control roles cannot be empty", 400, "Access control roles cannot be empty when visibility is restricted"),
API_REVISION_NOT_FOUND(900347, "API Revision Not Found", 404, "Requested API Revision with id %s not found"),
EXISTING_API_REVISION_DEPLOYMENT_FOUND(900348, "Can not delete API Revision ", 400, "Couldn't delete API revision since API revision is currently deployed to a gateway. " +
"You need to undeploy the API Revision from the gateway before attempting deleting API Revision: %s "),
Expand Down Expand Up @@ -371,6 +372,12 @@ public enum ExceptionCodes implements ErrorHandler {
SCOPE_VALIDATION_FAILED(900986, "Scope validation failed", 412, "Scope validation failed"),
SHARED_SCOPE_DISPLAY_NAME_NOT_SPECIFIED(900987, "Shared Scope display name not specified", 400,
"Shared Scope display name not specified"),
BLOCK_CONDITION_RETRIEVE_PARAMS_EXCEPTION(900254, "Block conditions retrieval error", 400,
"Provided query parameters are not valid"),
BLOCK_CONDITION_RETRIEVE_FAILED(900255, "Failed to get Block conditions", 500,
"Failed to retrieve Block conditions from the database"),
INVALID_BLOCK_CONDITION_VALUES(900256, "Error while retrieving Block Conditions", 500,
"Invalid format for condition values"),
SCOPE_ALREADY_ASSIGNED(900988, "Scope already assigned locally by another API", 400,
"Scope already assigned locally by another API"),

Expand Down Expand Up @@ -470,7 +477,7 @@ public enum ExceptionCodes implements ErrorHandler {
"{apiName}#{apiVersion}#{tenantDomain}"),
INVALID_API_NAME(900854, "Invalid API Name",400 ,"Invalid API Name"),
ALIAS_CANNOT_BE_EMPTY(900855, "The alias cannot be empty", 400, "The alias cannot be empty"),

KEY_TYPE_CANNOT_BE_EMPTY(900856, "The key type cannot be empty", 400, "The key type cannot be empty"),
// API import/export related codes
ERROR_READING_META_DATA(900907, "Error while reading meta information from the definition", 400,
"Error while reading meta information from the definition"),
Expand Down Expand Up @@ -515,8 +522,8 @@ public enum ExceptionCodes implements ErrorHandler {
INVALID_OPERATION_POLICY_SPECIFICATION(902006, "Invalid api policy specification found", 400,
"Invalid api policy specification. %s", false),

INVALID_OPERATION_POLICY_PARAMETERS(902007, "Missing required parameters for api policy specification", 400,
"Required parameter(s) %s for api policy specification %s are either missing or empty"),
MISSING_OPERATION_POLICY_PARAMETERS(902007, "Missing required parameters for policy specification", 400,
"Required parameter(s) %s for policy specification %s are either missing or empty"),
OPERATION_POLICY_NOT_ALLOWED_IN_THE_APPLIED_FLOW(902008, "API policy is not allowed in the applied flow", 400,
"%s policy is not allowed in response flow"),
MISSING_MANDATORY_POLICY_ATTRIBUTES(902009, "Missing mandatory api policy attribute", 400,
Expand Down Expand Up @@ -555,8 +562,76 @@ public enum ExceptionCodes implements ErrorHandler {
// AI service invocation related exceptions
AI_SERVICE_INVALID_RESPONSE(903100, "Invalid response from AI service", 500, "Error while invoking AI service. %s", false),
AI_SERVICE_INVALID_ACCESS_TOKEN(903101, "Invalid access token provided for AI service", 401, "Invalid access token provided for AI service"),
AI_SERVICE_QUOTA_EXCEEDED(903102, "Quota exceeded for AI service", 429, "Quota exceeded for AI service");
AI_SERVICE_QUOTA_EXCEEDED(903102, "Quota exceeded for AI service", 429, "Quota exceeded for AI service"),
DOCUMENT_NAME_ILLEGAL_CHARACTERS(902016, "Document name cannot contain illegal characters", 400, "Document name contains one or more illegal characters"),

// Subscriptions related
SUBSCRIPTION_ID_NOT_SPECIFIED(902017, "Subscription ID not specified.", 400,
"Subscription ID not specified."),
BUSINESS_PLAN_NOT_SPECIFIED(902018, "Business plan not specified.", 400,
"Business plan not specified."),
BUSINESS_PLAN_NOT_ALLOWED(902019, "The Business plan is not allowed.", 400,
"Business plan '%s' is not allowed for the API.", false),
INVALID_STATE_FOR_BUSINESS_PLAN_CHANGE(902022, "Cannot change the business plan of the subscription.",
409, "Cannot change the business plan of the subscription with ID '%s' as the " +
"subscription is in '%s' state.", false),
NOT_ALLOWED_TIER_FOR_SUBSCRIBER(902023, "Cannot change the business plan of the subscription.",
403, "Cannot change the business plan of the subscription with ID '%s' as the " +
"subscriber does not have permission to access the specified business plan.", false),

HTTP_METHOD_INVALID(903201,
"Invalid HTTP method provided for API resource", 400,
"The HTTP method '%s' provided for resource '%s' is invalid", false),

OPERATION_TYPE_INVALID(903202, "Invalid operation type provided for API operation", 400,
"The '%s' API operation type '%s' provided for operation '%s' is invalid", false),

KEYMANAGERS_VALUE_NOT_ARRAY(903203, "KeyManagers value needs to be an array", 400,
"Value of the KeyManagers config should be an array", false),

SCOPE_ALREADY_ASSIGNED_FOR_DIFFERENT_API(903204, "Invalid scopes provided for API", 400,
"Error while adding local scopes for API %s. Scope: %s already assigned locally for a different API.",
false),

UNSUPPORTED_TRANSPORT(903205, "Unsupported transport", 400,
"Unsupported transport '%s' provided for the API", false),

OAS_DEFINITION_VERSION_NOT_FOUND(903206, "Invalid OAS definition", 400,
"Could not determine the OAS version as the version element of the definition is not found", false),

API_NAME_PROVIDER_ORG_EMPTY(903207, "API name, provider or organization cannot be empty", 400,
"API name, provider or organization cannot be empty. Provided values: name: %s, provider: %s, org: %s",
false),

ANONYMOUS_USER_NOT_PERMITTED(903208, "Anonymous user not permitted", 401,
"Attempt to execute privileged operation as the anonymous user", false),

GLOBAL_MEDIATION_POLICIES_NOT_FOUND(903209, "Global mediation policies not found", 404,
"Global mediation policies not found", false),

ENDPOINT_URL_NOT_PROVIDED(903210, "Endpoint url not provided", 400,
"Url is not provided for the endpoint type %s in the endpoint config", false),

OPERATION_POLICY_NAME_VERSION_INVALID(903211, "Invalid operation policy name or version", 400,
"policyName and/or policyVersion provided for the applied policy %s_%s does not match the policy " +
"specification identified by the given policyId %s",
false),

INVALID_OPERATION_POLICY_PARAMS(903212, "Invalid operation policy parameters", 400,
"Invalid value provided for the operation policy parameter %s", false),

INVALID_ENDPOINT_SECURITY_CONFIG(903213, "Invalid endpoint security configuration", 400,
"Invalid values provided for %s endpoint security configuration", false),

ENDPOINT_SECURITY_TYPE_NOT_DEFINED(903214, "Endpoint security type not defined", 400,
"Endpoint security type not defined for the %s endpoint", false),

OPERATION_OR_RESOURCE_TYPE_OR_METHOD_NOT_DEFINED(902031,
"Operation type/http method is not specified for the operation/resource", 400,
"Operation type/http method is not specified for the operation/resource: %s", false),

RESOURCE_URI_TEMPLATE_NOT_DEFINED(902032, "Resource URI template value not defined", 400,
"Resource URI template value (target) not defined", false);
private final long errorCode;
private final String errorMessage;
private final int httpStatusCode;
Expand Down
Loading

0 comments on commit 419e37e

Please sign in to comment.