Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Initial Governance Core Implementation #12749

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
76c89f0
Add initial impl for governance component
Avishka-Shamendra Nov 7, 2024
a688b7b
Add logic to create and get rulesets
Avishka-Shamendra Nov 8, 2024
ebabacb
Add code to add default rulesets
Avishka-Shamendra Nov 11, 2024
ccf08e7
Add missing dependency
Avishka-Shamendra Nov 11, 2024
9ff8c1f
Add rulesets endpoint implementation
Avishka-Shamendra Nov 12, 2024
129a7ee
Add policy endpoint implementation
Avishka-Shamendra Nov 18, 2024
b1f3289
Fix ruleset delete to check for policies
Avishka-Shamendra Nov 19, 2024
a67bf97
Add APIM client for governance
Avishka-Shamendra Nov 27, 2024
201f275
Fix ruleset and policy cruds
Avishka-Shamendra Jan 4, 2025
b376713
Add pagination and validation resource to api
Avishka-Shamendra Jan 5, 2025
13e20f0
Change attribute names of ruleset and policy
Avishka-Shamendra Jan 6, 2025
1697ce4
Add spectral interface
Avishka-Shamendra Jan 7, 2025
49815ee
Change ruleset create, update to multipart
Avishka-Shamendra Jan 7, 2025
6b5e074
Contd validation endpoint impl
Avishka-Shamendra Jan 12, 2025
6b7b430
Change db script
Avishka-Shamendra Jan 12, 2025
be62fc0
Start impl of scheduler
Avishka-Shamendra Jan 13, 2025
90fd834
Contd impl
Avishka-Shamendra Jan 16, 2025
75e701e
Restructure code
Avishka-Shamendra Jan 16, 2025
430ab79
Restructure code
Avishka-Shamendra Jan 17, 2025
df3b9e1
Added service to call governance from apim
Avishka-Shamendra Jan 17, 2025
7bdbf76
Add rule category column
Avishka-Shamendra Jan 18, 2025
00879dc
Add validation engine as a service
Avishka-Shamendra Jan 18, 2025
5017d9a
Add method to get governable states for artifact
Avishka-Shamendra Jan 20, 2025
1bf9737
Fix build issues
Avishka-Shamendra Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
65 changes: 65 additions & 0 deletions components/apimgt/org.wso2.carbon.apimgt.governance.api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2025, 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.wso2.carbon.apimgt</groupId>
<artifactId>apimgt</artifactId>
<version>9.30.99-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.apimgt.governance.api</artifactId>
<packaging>bundle</packaging>
<name>WSO2 API Manager Governance API</name>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
org.wso2.carbon.apimgt.governance.api.*;version="${carbon.apimgt.version}"
</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2025, 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.
*/

package org.wso2.carbon.apimgt.governance.api;

import org.wso2.carbon.apimgt.governance.api.error.GovernanceException;
import org.wso2.carbon.apimgt.governance.api.model.ArtifactType;

import java.util.List;

/**
* This interface represents the Compliance Manager, which is responsible for managing compliance related operations
*/
public interface ComplianceManager {

/**
* Handle Policy Change Event
*
* @param policyId Policy ID
* @param organization Organization
*/
void handlePolicyChangeEvent(String policyId, String organization) throws GovernanceException;


/**
* Handle Ruleset Change Event
*
* @param rulesetId Ruleset ID
* @param organization Organization
*/
void handleRulesetChangeEvent(String rulesetId, String organization) throws GovernanceException;


/**
* Handle API Compliance Evaluation Request Async
*
* @param artifactId Artifact ID
* @param artifactType Artifact Type
* @param govPolicies List of governance policies to be evaluated
* @param organization Organization
* @throws GovernanceException If an error occurs while handling the API compliance evaluation
*/
void handleComplianceEvaluationAsync(String artifactId, ArtifactType artifactType,
List<String> govPolicies, String organization)
throws GovernanceException;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2025, 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.
*/

package org.wso2.carbon.apimgt.governance.api;

/**
* This class represents a governance API constants
*/
public class GovernanceAPIConstants {
public static final String ORGANIZATION = "organization";
public static final String RULESET_PATH = "/rulesets";
public static final String POLICY_PATH = "/governance-policies";

public static final String LIMIT_PARAM = "{limit}";
public static final String OFFSET_PARAM = "{offset}";

public static final String RULESETS_GET_URL =
RULESET_PATH + "?limit=" + LIMIT_PARAM + "&offset=" + OFFSET_PARAM;

public static final String POLICIES_GET_URL =
POLICY_PATH + "?limit=" + LIMIT_PARAM + "&offset=" + OFFSET_PARAM;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (c) 2025, 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.
*/

package org.wso2.carbon.apimgt.governance.api;

import org.wso2.carbon.apimgt.governance.api.error.GovernanceException;
import org.wso2.carbon.apimgt.governance.api.model.GovernableState;
import org.wso2.carbon.apimgt.governance.api.model.GovernancePolicy;
import org.wso2.carbon.apimgt.governance.api.model.GovernancePolicyList;
import org.wso2.carbon.apimgt.governance.api.model.Ruleset;

import java.util.List;

/**
* This interface represents the Governance Policy Manager
*/
public interface PolicyManager {
/**
* Create a new Governance Policy
*
* @param organization Organization
* @param governancePolicy Governance Policy
* @return GovernancePolicyInfo Created object
* @throws GovernanceException If an error occurs while creating the policy
*/
GovernancePolicy createGovernancePolicy(String organization, GovernancePolicy
governancePolicy) throws GovernanceException;

/**
* Get Governance Policy by Name
*
* @param organization Organization
* @param policyID Policy ID
* @return GovernancePolicyInfo
* @throws GovernanceException If an error occurs while retrieving the policy
*/
GovernancePolicy getGovernancePolicyByID(String organization, String policyID) throws GovernanceException;

/**
* Get Governance Policies
*
* @param organization Organization
* @return GovernancePolicyList
* @throws GovernanceException If an error occurs while retrieving the policies
*/
GovernancePolicyList getGovernancePolicies(String organization) throws GovernanceException;

/**
* Delete a Governance Policy
*
* @param policyId Policy ID
* @param organization Organization
* @throws GovernanceException If an error occurs while deleting the policy
*/
void deletePolicy(String policyId, String organization) throws GovernanceException;

/**
* Update a Governance Policy
*
* @param policyId Policy ID
* @param organization Organization
* @param governancePolicy Governance Policy Info
* @return GovernancePolicyInfo Updated object
* @throws GovernanceException If an error occurs while updating the policy
*/
GovernancePolicy updateGovernancePolicy(String policyId, String organization,
GovernancePolicy
governancePolicy)
throws GovernanceException;


/**
* Get the list of rulesets for a given policy
*
* @param policyId Policy ID
* @return List of rulesets
* @throws GovernanceException If an error occurs while getting the rulesets
*/
List<Ruleset> getRulesetsByPolicyId(String policyId) throws GovernanceException;

/**
* Get the list of policies by label and state
*
* @param label label
* @param state governable state for policy
* @param organization organization
* @return List of policy IDs
* @throws GovernanceException If an error occurs while getting the policies
*/
List<String> getPoliciesByLabelAndState(String label, GovernableState state,
String organization) throws GovernanceException;

/**
* Get the list of organization wide policies by state
*
* @param state governable state for policy
* @param organization organization
* @return List of policy IDs
* @throws GovernanceException If an error occurs while getting the policies
*/
List<String> getOrganizationWidePoliciesByState(GovernableState state,
String organization) throws GovernanceException;

/**
* This method checks whether a blocking action is present for a given governable state of a policy
*
* @param policyId Policy ID
* @param state Governable State
* @return
* @throws GovernanceException
*/
boolean isBlockingActionPresentForState(String policyId, GovernableState state)
throws GovernanceException;

}
Loading