...
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
This topic is discussed in the "Grouper API - Part 2" training video. |
GrouperShell (gsh)
gsh is a command line shell for administering and interacting with the Grouper API. See architectural diagram. It can be used in both a batch and interactive manner. For Grouper 2.3.0 patch 72+, it is built on GroovyShell. For older versions of Grouper, it is built on Java BeanShell. The legacy BeanShell version is now deprecated, but you can switch back to it by using one of the options:
- Setting gsh.useLegacy = true in grouper.properties.
- Using a command line argument (gsh.sh -forceLegacyGsh)
GrouperShell is for Grouper admins. End users can script with the grouper client command line utility
GSH operations
NOTE: Some classes were added a later 2.5.x releases. Not all are documented as to when they were initially added.
Category | Subtype | Action | Class |
---|---|---|---|
Attestation | Folders | insert / update / delete | AttestationStemSave |
Groups | insert / update / delete | AttestationGroupSave | |
Attribute assignment | Attribute assignment | insert / update / delete | AttributeAssignToAssignmentSave (2.5.48+) |
Folders | insert / update / delete | AttributeAssignToStemSave | |
Group | insert / update / delete | AttributeAssignToGroupSave | |
Attribute definition | insert / update / delete | AttributeDefSave | |
Attribute name | insert / update / delete | AttributeDefNameSave | |
Attribute value | insert / update / delete | AttributeAssignValueSave | |
Composite | insert /update / delete | CompositeSave | |
finder | CompositeFinder | ||
Email SMTP | GrouperEmail | ||
Gc db access | gc db access | GcDbAccess | |
Grouper session | GrouperSession | ||
Group | insert / update / delete | GroupSave | |
finder | GroupFinder | ||
copy | GroupCopy | ||
gsh | gsh template exec | GshTemplateExec | |
Http | GrouperHttpClient | ||
Ldap | ldap session utils | LdapSessionUtils | |
Member | finder | MemberFinder | |
Membership | insert / update / delete | MembershipSave | |
finder | MembershipFinder | ||
Password | insert / update / delete | GrouperPasswordSave | |
Privilege inheritance | Attribute definitions | insert / update / delete | PrivilegeAttributeDefInheritanceSave |
Folders | insert / update / delete | PrivilegeStemInheritanceSave | |
Groups | insert / update / delete | PrivilegeGroupInheritanceSave | |
Provisionable | Folders | finder | ProvisionableStemFinder |
insert / update / delete | ProvisionableStemSave | ||
Groups | finder | ProvisionableGroupFinder | |
insert / update / delete | ProvisionableGroupSave | ||
Stem | insert/update/delete | StemSave | |
finder | StemFinder | ||
copy | StemCopy | ||
Subject | finder | SubjectFinder | |
Sync data to SQL table | GcTableSyncFromData | ||
Types | Folders | finder | GdgTypeStemFinder |
insert / update / delete | GdgTypeStemSave | ||
Groups | finder | GdgTypeGroupFinder | |
insert / update / delete | GdgTypeGroupSave |
GrouperShell (gsh)
gsh is a command line shell for administering and interacting with the Grouper API. See architectural diagram. It can be used in both a batch and interactive manner. For Grouper 2.3.0 patch 72+, it is built on GroovyShell. For older versions of Grouper, it is built on Java BeanShell. The legacy BeanShell version is now deprecated, but you can switch back to it by using one of the options:
- Setting gsh.useLegacy = true in grouper.properties.
- Using a command line argument (gsh.sh -forceLegacyGsh)
GrouperShell is for Grouper admins. End users can script with the grouper client command line utility
Hints and tricks
Hints and tricks
Escape things in Escape things in groovysh with single backslash. e.g.
...
Code Block |
---|
'$' + "{something}" |
API Compability
Externalized text
Code Block |
---|
if you add to externalized text (config in ui), just make a key, e.g. mySchoolEmailKey, then refer to it like this
import edu.internet2.middleware.grouper.cfg.text.GrouperTextContainer;
String template = GrouperTextContainer.textOrNull("mySchoolEmailKey"); |
API Compability
gsh is now a core part gsh is now a core part of the Grouper API and so is always compatible with the current release.
...
For more information, see Bad Membership Finder Utility
Command | Description |
---|---|
findBadMemberships() | complete findBadMemberships run |
...
See the WIKI for running the Grouper Report manually
External systems
Test all external systems
Code Block |
---|
import java.util.List;
import edu.internet2.middleware.grouper.app.externalSystem.GrouperExternalSystem;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateOutput;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2input;
import edu.internet2.middleware.grouper.app.gsh.template.GshTemplateV2output;
import edu.internet2.middleware.grouper.util.GrouperUtil;
public class Test77externalSystemTest extends GshTemplateV2 {
@Override
public void gshRunLogic(GshTemplateV2input gshTemplateV2input, GshTemplateV2output gshTemplateV2output) {
GshTemplateOutput gsh_builtin_gshTemplateOutput = gshTemplateV2output.getGsh_builtin_gshTemplateOutput();
gsh_builtin_gshTemplateOutput.assignRedirectToGrouperOperation("NONE");
List<GrouperExternalSystem> grouperExternalSystems = GrouperExternalSystem.retrieveAllGrouperExternalSystems();
for (GrouperExternalSystem grouperExternalSystem : grouperExternalSystems) {
try {
List<String> errors = grouperExternalSystem.test();
if (GrouperUtil.length(errors) == 0) {
gsh_builtin_gshTemplateOutput.addOutputLine("Success: extenal system '" + grouperExternalSystem.getConfigId() + "' passed its test");
continue;
}
for (String error : errors) {
gsh_builtin_gshTemplateOutput.addOutputLine("error", "Error: extenal system '" + grouperExternalSystem.getConfigId() + "': " + error);
}
} catch (Exception e) {
gsh_builtin_gshTemplateOutput.addOutputLine("error", "Error: extenal system '" + grouperExternalSystem.getConfigId() + "' failed: " + e.getMessage());
}
}
}
}
|
Create a script from SQL
Here is an example to remove access from someone... run a SQL to generate a GSH script, e.g. in oracle:
...