Remove A Policy Assignment - Juniper NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1 Manual

Api guide
Table of Contents

Advertisement

Remove a Policy Assignment

Copyright © 2010, Juniper Networks, Inc.
UpdateObjectViewType updateObject = new UpdateObjectViewType();
updateObject.setObjectIdentifier(new ObjectIdentifierType[]
{objectId});
modifyCmd.setUpdateObject(updateObject);
NodeModificationType nodeModificationType = new NodeModificationType();
PathValueType pathValueType = new PathValueType();
nodeModificationType.setUpdateNode(pathValueType);
//adds the policy ID to the deviceobj:
pathValueType.setXpath("./nsmpolicy-id"):
pathValueType.setValue(this.createOpaqueDataType
("<nsmpolicy-id>&1.nsmpolicy.?????????test </nsmpolicy-id>"));
updateObject.setObjectModification(new ObjectModificationType());
updateObject.getObjectModification().addModification(nodeModificationType);
request.addCommand(modifyCmd);
//invokes the service:
ModifyObjectViewResponse response =
PolicyAssignmentTest.stub.ModifyObjectViewRequest(request);
assertTrue(response.getStatus() == StatusCodeType.Success);
} catch (Exception e) {
e.printStackTrace();
}
}
This Data Centric Service API code sample removes a policy assignment from a device.
/**
* Prerequisite: there is a device with id 2
*
there is a policy with name test
*/
public void testUnAssignPolicy2Device() {
try {
System.out.println("Running testUnAssignPolicy2Device()");
ModifyObjectViewRequest request = new ModifyObjectViewRequest();
request.setAuthToken(PolicyUnAssignmentTest.authToken);
//creates an object of ModifyViewCommandType:
ModifyViewCommandType modifyCmd = new ModifyViewCommandType();
//specifies the device from which to unassign the policy:
ObjectIdentifierType objectId = new ObjectIdentifierType();
objectId.setCategory("deviceobj");
objectId.setDomainId(new UnsignedShort("1"));
ObjectIdOrNameType objIdOrName = new ObjectIdOrNameType();
objIdOrName.setObjectId(new UnsignedInt(0));
objectId.setObjectIdOrName(objIdOrName);
Chapter 10: Using APIs for Policy Management
103

Advertisement

Table of Contents
loading

This manual is also suitable for:

Network and security manager 2010.4

Table of Contents