Assign A Policy To A Device - Juniper NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1 Manual

Api guide
Table of Contents

Advertisement

Network and Security Manager 2010.4 API Guide

Assign a Policy to a Device

102
* <p/>
* Prerequisite:
* A policy object has been added in NSM.
*/
public void testGetPolicyObject() {
try {
System.out.println("Running testGetPolicyObject()");
GetObjectViewByIdRequest request = new GetObjectViewByIdRequest();
request.setAuthToken(DataCentricServiceTest.authToken);
ObjectIdentifierType oid = new ObjectIdentifierType();
oid.setDomainId(new UnsignedShort("1"));
oid.setCategory("nsmpolicy");
ObjectIdOrNameType choice = new ObjectIdOrNameType();
choice.setObjectName("test");
oid.setObjectIdOrName(choice);
request.addObjectIdentifier(oid);
GetObjectViewByIdResponse response =
DataCentricServiceTest.stub.GetObjectViewByIdRequest(request);
DataCentricServiceTest.print(response.getObject());
assertTrue(response.getStatus() == StatusCodeType.Success);
} catch (Exception e) {
e.printStackTrace();
}
}
This Data Centric Service API code sample assigns a policy.
/**
* Prerequisite: there is a device with id 2
*
there is a policy with name test
*/
public void testAssignPolicy2Device() {
try {
System.out.println("Running testAssignPolicy2Device()");
ModifyObjectViewRequest request = new ModifyObjectViewRequest();
request.setAuthToken(PolicyAssignmentTest.authToken);
//creates an object of ModifyViewCommandType:
:
ModifyViewCommandType modifyCmd = new ModifyViewCommandType();
DeleteObjectViewType deleteObject = new DeleteObjectViewType();
//specifies the device to assign 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);
//create an object of UpdateObjectViewType:
Copyright © 2010, Juniper Networks, Inc.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the NETWORK AND SECURITY MANAGER 2010.4 - API GUIDE REV 1 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Network and security manager 2010.4

Table of Contents