beautypg.com

Group and member api – Google Search Appliance Policy ACL API Developers Guide User Manual

Page 9

background image

Google Search Appliance: Policy ACL API Developer’s Guide

Policy ACL API Developer’s Guide

9

Retrieving ACL Rules

To retrieve all ACL rules:

GsaFeed feed = myClient.getFeed("policyAcls");
for(GsaEntry entry : feed.getEntries()) {

System.out.println("Url Pattern: " + entry.getGsaContent("urlPattern"));
System.out.println("ACL rules: " + entry.getGsaContent("acl"));

}

To retrieve an ACL rule for a URL pattern:

GsaEntry entry = myClient.getEntry("policyAcls", "http://example.com");
System.out.println("Url Pattern: " + entry.getGsaContent("urlPattern"));
System.out.println("ACL rules: " + entry.getGsaContent("acl"));

To retrieve an ACL rule for a URL pattern in the protocol buffer format:

GsaEntry entry = new GsaEntry();
entry.addGsaContent("urlPattern", "http://abc2.com");
entry.addGsaContent("acl", "group:testGroup user:john");
myClient.updateEntry("policyAcls", "http://example.com", entry);

Updating an ACL Rule

To update an ACL rule:

GsaEntry entry = new GsaEntry();
entry.addGsaContent("urlPattern", "http://abc2.com");
entry.addGsaContent("acl", "group:testGroup user:john");
myClient.updateEntry("policyAcls", "http://example.com", entry);

Deleting an ACL Rule

To delete an ACL rule:

myClient.deleteEntry("policyAcls", "http://example.com");

Group and Member API

The code in the sections that follow specifies which users and groups are allowed to access a URL
pattern that you set in the pattern ACL API.

Creating a Group

To create a new group:

// Create group "testGroup"
GsaEntry groupEntry = new GsaEntry();
groupEntry.addProperty("groupId", "testGroup");
service.insert(new URL("http://Search_Appliance:8000/a/feeds/group/2.0/domain/
"), groupEntry);