Hi @bkkothari2255, you can try to reuse below code, this is not a full solution but it shows how msm api can be used programmatically - the result will be canceled inheritance (suspend) for given page resource.
In general LiveRelationshipManager allows you to full manage relationships (including, cancel inheritance, detach etc) - here you can find link to java docs - [1]
import com.day.cq.wcm.msm.api.LiveRelationshipManager;
import com.day.cq.wcm.msm.api.LiveRelationship;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.service.component.annotations.Reference;
// place for your class definition
@Reference
private LiveRelationshipManager liveRelationshipManager;
// place for other code
public void cancelPageInheritance(Resource pageResource, ResourceResolver resourceResolver) {
if (liveRelationshipManager.hasLiveRelationship(pageResource)) {
LiveRelationship liveRelationship = liveRelationshipManager.getLiveRelationship(pageResource, true);
if (liveRelationship != null) {
liveRelationshipManager.cancelRelationship(resourceResolver, liveRelationship, false, true);
}
}
}
[1] - https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/msm/ap...