Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide...

48
CHAPTER 3-1 Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This chapter introduces the Reply Timeout, a feature unique to the Blocking API. The chapter also lists all the operations of the Blocking API, and provides code examples. Note If you need to develop only an automatic integration, skip this chapter and go directly to Chapter 4, “Nonblocking API.” This chapter consists of the following sections: Multithreading Support, page 3-2 ReplyTimeout and OperationTimeout Exception, page 3-3 Cisco Service Control Subscriber Manager Blocking API Methods, page 3-4 Quota Manager Blocking API Methods, page 3-37 Blocking API Code Examples, page 3-45

Transcript of Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide...

Page 1: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Cisco Service ControOL-26795-02

C H A P T E R 3

Blocking API

Revised: December 21, 2012, OL-26795-02

IntroductionThis chapter introduces the Reply Timeout, a feature unique to the Blocking API.

The chapter also lists all the operations of the Blocking API, and provides code examples.

Note If you need to develop only an automatic integration, skip this chapter and go directly to Chapter 4, “Nonblocking API.”

This chapter consists of the following sections:

• Multithreading Support, page 3-2

• ReplyTimeout and OperationTimeout Exception, page 3-3

• Cisco Service Control Subscriber Manager Blocking API Methods, page 3-4

• Quota Manager Blocking API Methods, page 3-37

• Blocking API Code Examples, page 3-45

3-1l Subscriber Manager Java API Programmer Guide

Page 2: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Multithreading Support

Multithreading SupportThe Blocking API supports an unlimited number of threads calling its methods simultaneously.

Note In a multithreaded scenario for the Blocking API, the order of invocation is not guaranteed.

Example:

Thread-0 calls operation-0 at time-0, and thread-1 calls operation-1 at time-1, where time-1 is later than time-0. In this example, it is possible that operation-1 might be performed before operation-0, as shown in Figure 3-1 (the vertical scale is time):

Figure 3-1 Multithreading Support

The Cisco Service Control Subscriber Manager allocates five threads to manage each API instance. Develop a multithreaded application that uses the API with several threads in the order of the five threads. Implementing with more threads might result in longer delays for the calling threads.

1571

10

Thread 0 :

op-0 : operation

op-1 : operation

op-1 : result

op-0 : result

Thread 1 : SM Blocking API :

3-2Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 3: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API ReplyTimeout and OperationTimeout Exception

ReplyTimeout and OperationTimeout ExceptionA blocking operation returns only when the operation result is retrieved from the Cisco Service Control Subscriber Manager. If a networking malfunction or other error prevents the operation result from being retrieved, the caller waits indefinitely. The Cisco Service Control Subscriber Manager API provides a means of working around this situation.

The reply timeout feature (the setReplyTimeout method) enables the caller to set a timeout. It will generate com.pcube.management.framework.rpc.OperationTimeoutException when a reply does not return within the timeout period.

Calling the setReplyTimeout method with a long value sets a reply timeout. The reply timeout is interpreted in milliseconds. A zero value indicates that the operation should wait (freeze, stop responding) until a result arrives—or indefinitely, if no result arrives.

There is an alternative way to release a method call that is blocking the caller, who is waiting for a result to arrive. Call the interrupt method of the calling thread; java.lang.InterruptedException will then be returned to the caller.

3-3Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 4: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Cisco Service Control Subscriber Manager Blocking API Methods

Cisco Service Control Subscriber Manager Blocking API Methods

This section lists the methods of the Cisco Service Control Subscriber Manager Blocking API. The description of each method includes its syntax, input parameters, and return values.

The Blocking API is a superset of the Nonblocking API. Except for differences in return values and result handling, identical operations in both APIs have the same functions and syntax structure. All the methods generate java.lang.IllegalStateException when called before the API establishes a connection with the Cisco Service Control Subscriber Manager.

The Blocking API methods are classified as follows:

• Dynamic IP and property allocation—Use the following methods to integrate the Cisco Service Control Subscriber Manager API with an authentication, authorization, and accounting (AAA) system. These methods are not designed to add or remove subscribers from the database. Instead, they modify dynamic parameters (such as IP addresses) of the existing subscribers:

– login, page 3-5

– logoutByName, page 3-8

– logoutByNameFromDomain, page 3-10

– logoutByMapping, page 3-11

– loginCable, page 3-13

– logoutCable, page 3-16

• Static or Manual Subscriber configuration—Use the following methods for a GUI:

– addSubscriber, page 3-17

– removeSubscriber, page 3-19

– removeAllSubscribers, page 3-20

– setPropertiesToDefault, page 3-34

– removeCustomProperties, page 3-35

• Use the following methods for simple read-only operations, performed independently in the subscriber awareness mode:

– getNumberOfSubscribers, page 3-21

– getNumberOfSubscribersInDomain, page 3-21

– getSubscriber, page 3-22

– subscriberExists, page 3-25

– subscriberLoggedIn, page 3-25

– getSubscriberNameByMapping, page 3-26

– getSubscriberNames (all), page 3-28

– getSubscriberNames (filter by property), page 3-29

– getSubscriberNamesInDomain, page 3-30

– getSubscriberNamesWithPrefix, page 3-31

– getSubscriberNamesWithSuffix, page 3-32

– getDomains, page 3-33

3-4Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 5: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API login

You can mix methods from different categories in a single application. The classification is presented only for clarity.

loginThe following sections provide information about the login operation:

• Syntax, page 3-5

• Description, page 3-5

• Parameters, page 3-5

• RPC Exception Error Codes, page 3-6

• Return Value, page 3-6

• Examples, page 3-6

Syntax

The login syntax is as follows:

public void login(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String domain, boolean isMappingAdditive, int autoLogoutTime)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The login method adds or modifies a domain, mappings, and possibly properties of a subscriber that already exists in the Cisco Service Control Subscriber Manager database. The login method can be called with partial data; for example, it might provide mappings or properties only, and put NULL ++++ in the unchanged fields.

If another subscriber with the same (or conflicting) mappings already exists in the same domain, the conflicting mappings are removed from the other subscriber and assigned to the new subscriber.

If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, the login method creates it with the data provided.

Parameters

The parameters of the login method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6. If no mappings are specified, and the isMappingAdditive parameter is TRUE, the previous mappings are retained. If no such mappings exist, the operation fails.

• mappingTypes—See the description of mappings and mapping types in the “Network ID Mappings” section on page 2-6.

3-5Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 6: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API login

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

If the domain is different from the domain that was previously assigned to the subscriber, the subscriber is removed automatically from the Cisco SCEs of the previous domain and moved to the SCEs of the new domain.

• isMappingAdditive

– TRUE—Adds the mappings provided by this call to the subscriber record.

– FALSE—Overrides the mappings provided by this call with mappings that already exist in the subscriber record.

• autoLogoutTime—Applies only to the mappings provided as arguments to this method.

– Positive value (N)—Automatically logs out the mappings (similar to calling a logout method) after N seconds.

– 0 value—Maintains the current expiration time for the given mappings.

– Negative value—Disables any expiration time set for the given mappings.

RPC Exception Error Codes

The following list presents the error codes the login method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DATABASE_EXCEPTION

• ERROR_CODE_UNKNOWN

This error can be caused by the following parameter settings:

– NULL value for the domain parameter for the subscriber that does not exist or does not have a domain

– Invalid values for the propertyValues parameter

For a description of error codes, see Appendix A, “List of Error Codes”.

Return Value

None.

Examples

To add the IP address 192.168.12.5 to an existing subscriber named alpha without affecting existing mappings:

login(

3-6Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 7: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API login

"alpha", // subscriber name new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain true, // isMappingAdditive is true -1); // autoLogoutTime set to infinite

To add the IP address 192.168.12.5 overriding previous mappings:

login( "alpha", // subscriber name new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive is false -1); // autoLogoutTime set to infinite

To extend the auto logout time of 192.168.12.5, which was previously assigned to alpha:

login( "alpha", //the previously assigned IP new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive 300); // autoLogoutTime set to 300 seconds

To modify a dynamic property of alpha (for example, package ID):

login( "alpha", null, null, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain false, -1);

To add the IP address 192.168.12.5 to an existing subscriber named alpha without affecting existing mappings and to modify a dynamic property of alpha (for example, package ID):

login( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain true, // isMappingAdditive is set to true -1);

To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting existing mappings:

login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain true, // isMappingAdditive is true -1); // autoLogoutTime set to infinite

3-7Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 8: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutByName

To add the IPv6 address 2000:2001:2002:abcd::/64 overriding previous mappings:

login( "alpha", // subscriber name new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive is false -1); // autoLogoutTime set to infinite

To extend the auto logout time of 2000:2001:2002:abcd::/64 that was previously assigned to alpha:

login( "alpha", //the previously assigned IP new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, null, null, "subscribers", // domain false, // isMappingAdditive 300); // autoLogoutTime set to 300 seconds

To add the IPv6 address 2000:2001:2002:abcd::/64 to an existing subscriber named alpha without affecting the existing mappings, and to modify a dynamic property of alpha,for example, package ID:

login( "alpha", new String[]{"2000:2001:2002:abcd::/64"}, SMApiConstants.ALL_IPV6_MAPPINGS, new String[]{"packageId"}, // property key new String[]{"10"}, // property value "subscribers", // domain true, // isMappingAdditive is set to true -1);

logoutByNameThe following sections provide information about the logoutByName operation:

• Syntax, page 3-8

• Description, page 3-9

• Parameters, page 3-9

• Return Value, page 3-9

• RPC Exception Error Codes, page 3-9

• Examples, page 3-9

Syntax

The logoutByName syntax is as follows:

public boolean logoutByName(String subscriberName, String[] mappings, short[] mappingTypes)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-8Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 9: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutByName

Description

The logoutByName method locates the subscriber in the database and removes mappings from it. If the subscriber does not exist, the logoutByName operation does not do anything.

Parameters

The parameters of the logoutByName method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

Return Value

• TRUE—If the subscriber was found and the subscriber mappings were removed from the subscriber database

• FALSE—If the subscriber was not found in the subscriber database

RPC Exception Error Codes

The following list presents the error codes the logoutByName method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Examples

To remove IP address 192.168.12.5 of subscriber alpha:

boolean isExist = logoutByName( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS);

To remove all IP addresses of subscriber alpha:

boolean isExist = logoutByName("alpha", null, null);

3-9Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 10: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutByNameFromDomain

logoutByNameFromDomainThe following sections provide information about the logoutByNameFromDomain operation:

• Syntax, page 3-10

• Description, page 3-10

• Parameters, page 3-10

• Return Value, page 3-10

• RPC Exception Error Codes, page 3-11

• Example, page 3-11

Syntax

The logoutByNameFromDomain syntax is as follows:

public boolean logoutByNameFromDomain(String subscriberName, String[] mappings, short[] mappingTypes, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The logoutByNameFromDomain similar to logoutByName, but this method also enables the caller to provide the name of the domain to which the subscriber belongs. When the subscriber domain is known, use this method to improve performance.

Parameters

The parameters of the logoutByNameFromDomain method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description of mappings in the “Network ID Mappings” section on page 2-6. If no mappings are specified, all subscriber mappings are removed.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

The operation fails if either of the following conditions exists:

• Domain is null, but the subscriber exists in the database and belongs to a domain.

• Domain specified is incorrect.

Return Value

• TRUE—If the subscriber was found and removed from the subscriber database

• FALSE—If the subscriber was not found in the subscriber database

3-10Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 11: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutByMapping

RPC Exception Error Codes

The following list presents error codes the logoutByNameFromDomain method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 of subscriber alpha from domain subscribers:

boolean isExist = logoutByNameFromDomain( "alpha", new String[]{"192.168.12.5"}, SMApiConstants.ALL_IP_MAPPINGS, "subscribers");boolean isExist = logoutByNameFromDomain( "alpha", null, null, "subscribers");

logoutByMappingThe following sections provide information about the logoutByMapping operation:

• Syntax, page 3-11

• Description, page 3-12

• Parameters, page 3-12

• Return Value, page 3-12

• RPC Exception Error Codes, page 3-12

• Example, page 3-12

Syntax

The logoutByMapping syntax is as follows:

public boolean logoutByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-11Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 12: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutByMapping

Description

The logoutByMapping locates a subscriber based on domain and mapping, and removes the mapping (the subscriber stays in the database).

Parameters

The parameters of the logoutByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—See the description of the logoutByNameFromDomain operation in the “Parameters” section on page 3-10.

Return Value

• TRUE—If the subscriber was found and removed from the subscriber database.

• FALSE—If the subscriber was not found in the subscriber database.

RPC Exception Error Codes

The following list presents error codes the logoutByMapping method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

To remove IP address 192.168.12.5 from domain subscribers:

boolean isExist = logoutByMapping( "192.168.12.5", SMApiConstants. MAPPING_TYPE_IP, "subscribers");

To remove IPv6 address 2001:db8:85a3::8a2e:370:7334/64 from domain subscribers:

boolean isExist = logoutByMapping( "2001:db8:85a3::8a2e:370:7334/64", SMApiConstants. MAPPING_TYPE_IPV6, "subscribers");

3-12Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 13: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API loginCable

loginCableThe following sections provide information about the loginCable operation:

• Syntax, page 3-13

• Description, page 3-13

• Parameters, page 3-13

• Return Value, page 3-14

• RPC Exception Error Codes, page 3-14

• Examples, page 3-14

Syntax

The loginCable syntax is as follows:

public void loginCable(String CPE, String CM, String IP, int lease, String domain, String[] propertyKeys, String[] propertyValues)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The loginCable method is an operation adapted for the cable environment; it calls the cable support module in the Cisco Service Control Subscriber Manager. This method is designed to log in the customer premise equipment (CPE) and content managers to the Cisco Service Control Subscriber Manager. To log in a CPE, specify its cable modem (CM) MAC in the CM argument and the CPE MAC in the CPE argument. To log in a cable modem, specify the cable modem MAC address in both CPE and CM arguments. Note that the login of a CPE whose CM does not exist in the Cisco Service Control Subscriber Manager database is ignored—the CM has to exist in the database, either by import or by a CM login operation. For additional information, see the CPE as Subscriber in Cable Environment chapter of Cisco Service Control Management Suite Subscriber Manager User Guide.

Note The name of the CPE in the Cisco Service Control Subscriber Manager database is the concatenation of the CPE and CM values with two underscore characters (“_”) between them. The caller must ensure that the lengths of CPE and CM add up to no more than 38 characters.

Parameters

The parameters of the loginCable method are as follows:

• CPE—Unique identifier of the CPE (usually a MAC address)

• CM—Unique identifier of the cable modem (usually a MAC address)

• IP—CPE IP address (IPv4 address or IPv6 address)

• lease—CPE lease time

3-13Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 14: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API loginCable

• domain—See the description of the subscriber domains in the “Subscriber Domains” section on page 2-9. The domain is usually cable modem termination system (CMTS) IP.

Note Domain aliases must be set on the Cisco Service Control Subscriber Manager so that the cable modem termination system (CMTS) IP is correctly interpreted as a domain name. For information about configuring aliases, see the Default Domains Configuration section of Cisco SCMS Subscriber Manager User Guide.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

If the CPE is provided with partial or no application properties, the values for the missing application properties are copied from the application properties of the cable modem to which this CPE belongs. Each cable modem application property thus serves as a default for the CPE with which it is associated.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

Return Value

None.

RPC Exception Error Codes

None.

Examples

To add the IP address 192.168.12.5 to a cable modem called CM1 with two hours of lease time:

loginCable( "CM1", "CM1", "192.168.12.5", 7200, // lease time in seconds "subscribers", null, null);

To add the IP address 192.168.12.50 to a CPE called CPE1, which is behind CM1 with a lease time of one hour:

loginCable( "CPE1", "CM1", "192.168.12.50", 3600, // lease time in seconds "subscribers", null, null);

To add the IPv6 address 2001:db8:85a3::8a2e:370:7334/64 to a cable modem called CM1 with two hours of lease time:

loginCable( "CM1", "CM1", "2001:db8:85a3::8a2e:370:7334/64", 7200, // lease time in seconds

3-14Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 15: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API loginCable

"subscribers", null, null);

3-15Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 16: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API logoutCable

logoutCableThe following sections provide information about the logoutCable operation:

• Syntax, page 3-16

• Description, page 3-16

• Parameters, page 3-16

• Return Value, page 3-16

• RPC Exception Error Codes, page 3-16

• Example, page 3-16

Syntax

The logoutCable syntax is as follows:

public boolean logoutCable(String CPE, String CM, String IP, String domain)

Description

The logoutCable method indicates to the Cisco Service Control Subscriber Manager cable support module that a logout event has happened.

Parameters

The parameters of the logoutCable method are as follows:

• CPE—See the description in the “Parameters” section on page 3-13.

• CM—See the description in the “Parameters” section on page 3-13.

• IP—See the description in the “Parameters” section on page 3-13.

• domain—See the description in the “Parameters” section on page 3-13.

Return Value

• TRUE—If the CPE was found and removed from the subscriber database

• FALSE—If the CPE was not found in the subscriber database

RPC Exception Error Codes

None.

Example

To remove the IP address 192.168.12.5 from CPE1, which is associated with CM1:

boolean isExist = logoutCable( "CPE1",

3-16Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 17: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API addSubscriber

"CM1", "192.168.12.5", "subscribers");

addSubscriberThe following sections provide information about the addSubscriber operation:

• Syntax, page 3-17

• Description, page 3-17

• Example, page 3-18

• Parameters, page 3-18

• Return Value, page 3-18

• RPC Exception Error Codes, page 3-18

• Examples, page 3-19

Syntax

The addSubscriber syntax is as follows:

public void addSubscriber(String subscriberName, String[] mappings, short[] mappingTypes, String[] propertyKeys, String[] propertyValues, String[] customPropertyKeys, String[] customPropertyValues, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriber method creates a new subscriber record according to the method parameters and adds the record to the Cisco Service Control Subscriber Manager database.

When adding a new subscriber name, if the name already exists in Cisco Service Control Subscriber Manager database, the first instance of the name is removed before the new one is added. In contrast to login method, which modifies fields and leaves unspecified fields unchanged, the addSubscriber method sets the subscriber exactly as specified by the parameters passed to it.

Note Use the call login method for existing subscribers, instead of the addSubscriber command. You should set dynamic mappings and properties by using the login command. Set static mappings and properties the first time the subscriber is created by using the addSubscriber command.

Note With the addSubscriber command, the autologout feature is always disabled. To enable autologout, use the login command.

3-17Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 18: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API addSubscriber

Example

Subscriber AB, already set up in the subscriber database, has a single IP mapping (IP1).

If an addSubscriber operation for AB is called with no mappings specified (NULL in both the mappings and mappingTypes fields), AB is left with no mappings.

However, calling the login operation with these NULL-value parameters does not change the subscriber mappings of AB; AB retains its previous IP mapping of IP1.

Parameters

The parameters of the addSubscriber method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• mappings—See the description in the “Network ID Mappings” section on page 2-6.

• mappingTypes—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• propertyKeys—See the description of property keys in the “Subscriber Properties” section on page 2-9.

• propertyValues—See the description of property values in the “Subscriber Properties” section on page 2-9.

• customPropertyKeys—See the description of custom property keys in the “Custom Properties” section on page 2-10.

• customPropertyValues—See the description of custom property values in the “Custom Properties” section on page 2-10.

• domain—See the description of subscriber domains in the “Subscriber Domains” section on page 2-9.

A NULL value indicates that the subscriber has no domain. If domain is NULL, but the subscriber already has a domain, the existing domain is retained.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the addSubscriber method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_SUBSCRIBER_ALREADY_EXISTS

• ERROR_CODE_SUBSCRIBER_DOMAIN_ASSOCIATION

• ERROR_CODE_UNKNOWN

This error code might indicate invalid values that were supplied for the propertyValues parameter.

• ERROR_CODE_DATABASE_EXCEPTION

3-18Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 19: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API removeSubscriber

For a description of error codes, see Appendix A, “List of Error Codes”.

Examples

The following example code adds a new subscriber, alpha, with some custom properties:

addSubscriber("alpha", null, null, // dynamic mappings will be set by login null, null // dynamic properties will be set by login new String[]{ // custom property keys "work phone", "home phone"}, new String[]{ // custom property values "6543212" "5059927"}, "subscribers"); // default domain

removeSubscriberThe following sections provide information about the removeSubscriber operation:

• Syntax, page 3-19

• Description, page 3-19

• Parameters, page 3-19

• Return Value, page 3-19

• RPC Exception Error Codes, page 3-20

• Example, page 3-20

Syntax

The removeSubscriber syntax is as follows:

public boolean removeSubscriber(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeSubscriber method removes a subscriber completely from the Cisco Service Control Subscriber Manager database.

Parameters

The only parameter of the removeSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the database and successfully removed.

• FALSE—If the conditions for TRUE were not met; in other words, the subscriber was not found in the database, or the subscriber was found but was not successfully removed.

3-19Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 20: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API removeAllSubscribers

RPC Exception Error Codes

The following list presents error codes that the removeSubscriber method method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code removes subscriber alpha entirely from the database:

boolean isExist = removeSubscriber("alpha");

removeAllSubscribersThe following sections provide information about the removeAllSubscribers operation:

• Syntax, page 3-20

• Description, page 3-20

• Return Value, page 3-20

• RPC Exception Error Codes, page 3-20

Syntax

The removeAllSubscribers syntax is as follows:

public void removeAllSubscribers()throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeAllSubscribers method removes all subscribers from the Cisco Service Control Subscriber Manager, leaving the database with no subscribers.

Note This method might take time to execute. To avoid operation timeout exceptions, set a high operation timeout (up to 5 minutes) before calling this method.

Return Value

None.

RPC Exception Error Codes

None.

3-20Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 21: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getNumberOfSubscribers

getNumberOfSubscribersThe following sections provide information about the getNumberOfSubscribers operation:

• Syntax, page 3-21

• Description, page 3-21

• Return Value, page 3-21

• RPC Exception Error Codes, page 3-21

Syntax

The getNumberOfSubscribers syntax is as follows:

public int getNumberOfSubscribers()throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getNumberOfSubscribers method retrieves the total number of subscribers in the Cisco Service Control Subscriber Manager database.

Return Value

The number of subscribers in the Cisco Service Control Subscriber Manager.

RPC Exception Error Codes

None.

getNumberOfSubscribersInDomainThe following sections provide information about the getNumberOfSubscribersInDomain operation:

• Syntax, page 3-21

• Description, page 3-22

• Parameters, page 3-22

• Return Value, page 3-22

• RPC Exception Error Codes, page 3-22

Syntax

The getNumberOfSubscribersInDomain syntax is as follows:

public int getNumberOfSubscribersInDomain(String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-21Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 22: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriber

Description

The getNumberOfSubscribersInDomain method retrieves the number of subscribers in a subscriber domain.

Parameters

The only parameter of the getNumberOfSubscribersInDomain method is as follows:

• domain—Name of a subscriber domain that exists in the Cisco Service Control Subscriber Manager domain repository.

Return Value

The number of subscribers in the provided domain.

RPC Exception Error Codes

The following list presents the error codes that the getNumberOfSubscribersInDomain method might return:

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE _DOMAIN_NOT_FOUND

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberThe following sections provide information about the getSubscriber operation:

• Syntax, page 3-22

• Description, page 3-22

• Parameters, page 3-23

• Return Value, page 3-23

• RPC Exception Error Codes, page 3-23

• Example, page 3-23

Syntax

The getSubscriber syntax is as follows:

public Object[] getSubscriber(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriber method retrieves a subscriber record. Each field is formatted as an integer, string, or string array.

3-22Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 23: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriber

If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, the operation returns an exception.

Parameters

The only parameter of the getSubscriber method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with nine elements. Table 3-1 lists the index values and descriptions. No array element has a NULL value.

RPC Exception Error Codes

The following list presents error codes that the getSubscriber method method might return:

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code retrieves the subscriber record of alpha:

Object[] subRecord = getSubscriber("alpha");String[] mappings = (String[])subRecord[1]short[] mappingTypes = {short[])subRecord[2];String domainName = (String)subRecord[3];String[] propertyNames = (String[])subRecord[4];String[] propertyValues = (String[])subRecord[5];

Table 3-1 Indexes and Descriptions

Index Value Description

Index 0 Subscriber name (java.lang.String)

Index 1 Array of mappings (java.lang.String[])

Index 2 Array of mapping types (short[])

Index 3 Domain name (java.lang.String)

Index 4 Array of property names (java.lang.String[])

Index 5 Array of property values (java.lang.String[])

Index 6 Array of custom property names (java.lang.String[])

Index 7 Array of custom property values (java.lang.String[])

Index 8 Autologout time, in seconds from the present time, or -1 if not set (long[])

3-23Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 24: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriber

String[] customPropertyName = (String[])subRecord[6];String[] customPropertyValues = (String[])subRecord[7];long[] autoLogoutTime = (long[])subRecord[8];

3-24Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 25: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API subscriberExists

subscriberExistsThe following sections provide information about the subscriberExists operation:

• Syntax, page 3-25

• Description, page 3-25

• Parameters, page 3-25

• Return Value, page 3-25

• RPC Exception Error Codes, page 3-25

Syntax

The subscriberExists syntax is as follows:

public boolean subscriberExists(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberExists method verifies that a subscriber exists in the Cisco Service Control Subscriber Manager database.

Parameters

The only parameter of the subscriberExists method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber was found in the Cisco Service Control Subscriber Manager database.

• FALSE—If the subscriber was not found.

RPC Exception Error Codes

None.

subscriberLoggedInThe following sections provide information about the subscriberLoggedIn operation:

• Syntax, page 3-26

• Description, page 3-26

• Parameters, page 3-26

• Return Value, page 3-26

• RPC Exception Error Codes, page 3-26

3-25Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 26: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The subscriberLoggedIn syntax is as follows:

public boolean subscriberLoggedIn(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The subscriberLoggedIn method checks whether a subscriber that already exists in the Cisco Service Control Subscriber Manager database is logged in, that is, if the subscriber also exists in a Cisco SCE database.

When the Cisco Service Control Subscriber Manager is configured to work in Pull mode, a TRUE value returned by this method does not guarantee that the subscriber actually exists in an SCE database; but rather, the subscriber is available to be pulled by an SCE if needed.

If the subscriber does not exist in the Cisco Service Control Subscriber Manager database, an exception is generated.

Parameters

The only parameter of the subscriberLoggedIn method is as follows:

subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

• TRUE—If the subscriber is logged in.

• FALSE—If the subscriber is not logged in.

RPC Exception Error Codes

The following list presents error codes that the subscriberLoggedIn method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNameByMappingThe following sections provide information about the getSubscriberNameByMapping operation:

• Syntax, page 3-27

• Description, page 3-27

• Parameters, page 3-27

• Return Value, page 3-27

• RPC Exception Error Codes, page 3-27

3-26Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 27: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNameByMapping

Syntax

The getSubscriberNameByMapping syntax is as follows:

public String getSubscriberNameByMapping(String mapping, short mappingType, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNameByMapping method finds a subscriber name according to a mapping and a domain.

Parameters

The parameters of the getSubscriberNameByMapping method are as follows:

• mapping—See the description of mappings in the “Network ID Mappings” section on page 2-6.

• mappingType—See the description of mapping types in the “Network ID Mappings” section on page 2-6.

• domain—Name of the domain to which the subscriber belongs. The operation fails if either of the following conditions exists:

– Domain is NULL, but the subscriber exists in the database and belongs to a domain.

– The specified domain is incorrect.

Return Value

• Subscriber name—If a subscriber record was found.

• NULL—If no subscriber record was found.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNameByMapping method might return:

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

3-27Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 28: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNames (all)

getSubscriberNames (all)The following sections provide information about the getSubscriberNames (all) operation:

• Syntax, page 3-28

• Description, page 3-28

• Parameters, page 3-28

• Return Value, page 3-28

• RPC Exception Error Codes, page 3-29

• Example, page 3-29

Syntax

The getSubscriberNames (all) syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd, int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNames (all) method retrieves a bulk of subscriber names from the Cisco Service Control Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order).

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Cisco Service Control Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (all) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of subscriber names, alphabetically ordered.

3-28Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 29: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNames (filter by property)

The getSubscriberNames (all) method returns as many subscribers as are found in the Cisco Service Control Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (all) method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

Example

The following example code returns an array of subscriber names:

boolean hasMoreSubscribers;String lastBulkEnd = null;int bulkSize = 100;

do { String[] subscribers = smApi.getSubscriberNames(lastBulkEnd, bulkSize);

hasMoreSubscribers = false; if (subscribers != null) { for (int i = 0; i < subscribers.length; i++) { // do something with subscribers[i] } if (subscribers.length == bulkSize) { hasMoreSubscribers = true; lastBulkEnd = subscribers[bulkSize - 1]; } }} while (hasMoreSubscribers);

getSubscriberNames (filter by property)The following sections provide information about the getSubscriberNames (filter by property) operation:

• Syntax, page 3-29

• Description, page 3-30

• Parameters, page 3-30

• Return Value, page 3-30

• RPC Exception Error Codes, page 3-30

Syntax

The getSubscriberNames (filter by property) method syntax is as follows:

public String[] getSubscriberNames(String lastBulkEnd,String propertyName,String propertyValue,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

3-29Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 30: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNamesInDomain

Description

The getSubscriberNames (filter by property) method retrieves a bulk of subscriber names from the Cisco Service Control Subscriber Manager database, starting with lastBulkEnd followed by numOfSubscribers (in alphabetical order), and based on the property name and property value.

If lastBulkEnd is NULL, the first subscriber name (alphabetically) that exists in the Cisco Service Control Subscriber Manager database is retrieved.

Note There is no guarantee that the total number of subscribers (in all the bulks) will equal the value returned from getNumOfSubscribers at any time. The values might differ if some subscribers are added or removed when the bulks are being retrieved.

Parameters

The parameters of the getSubscriberNames (filter by property) method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• propertyName—The property name of the string type used to filter subscriber names.

• propertyValue—The property value of the string type used to filter subscriber names.

• numOfSubscribers—The limit on the number of subscribers that is returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Note Do not provide a value of more than 500 subscribers.

Return Value

An array of alphabetically ordered subscriber names that matches the property name and its given value. The method returns as many subscribers as are found in the Cisco Service Control Subscriber Manager database, starting at the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNames (filter by property) method might return:

• ERROR_CODE_DATABASE_EXCEPTION

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesInDomainThe following sections provide information about the getSubscriberNamesInDomain operation:

• Syntax, page 3-31

3-30Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 31: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNamesWithPrefix

• Description, page 3-31

• Parameters, page 3-31

• Return Value, page 3-31

• RPC Exception Error Codes, page 3-31

Syntax

The getSubscriberNamesInDomain syntax is as follows:

public String[] getSubscriberNamesInDomain(String lastBulkEnd, int numOfSubscribers, String domain)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesInDomain method retrieves subscribers in the Cisco Service Control Subscriber Manager database that are associated with the specified domain.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesInDomain method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See description in the “Parameters” section on page 3-28.

• domain—The name of a subscriber domain that exists in the Cisco Service Control Subscriber Manager domain repository.

Return Value

An alphabetically ordered array of subscriber names that belong to the domain provided.

See the “Return Value” section on page 3-28 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents the error codes that the getSubscriberNamesInDomain method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DOMAIN_NOT_FOUND

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithPrefixThe following sections provide information about the getSubscriberNamesWithPrefix operation:

3-31Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 32: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberNamesWithSuffix

• Syntax, page 3-32

• Description, page 3-32

• Parameters, page 3-32

• Return Value, page 3-32

• RPC Exception Error Codes, page 3-32

Syntax

The getSubscriberNamesWithPrefix syntax is as follows:

public String[] getSubscriberNamesWithPrefix(String lastBulkEnd, int numOfSubscribers, String prefix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithPrefix method retrieves subscribers in the Cisco Service Control Subscriber Manager database whose name begins with a specified prefix.

The semantics of this operation are the same as that of the getSubscriberNames operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesWithPrefix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See the description in the “Parameters” section on page 3-28.

• prefix—Case-sensitive string that marks the prefix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that begin with the required prefix.

See, the “Return Value” section on page 3-28.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithPrefix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getSubscriberNamesWithSuffixThe following sections provide information about the getSubscriberNamesWithSuffix operation:

• Syntax, page 3-33

3-32Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 33: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getDomains

• Description, page 3-33

• Parameters, page 3-33

• Return Value, page 3-33

• RPC Exception Error Codes, page 3-33

Syntax

The getSubscriberNamesWithSuffix syntax is as follows:

public String[] getSubscriberNamesWithSuffix(String lastBulkEnd, int numOfSubscribers, String suffix)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberNamesWithSuffix method retrieves subscribers in the Cisco Service Control Subscriber Manager database whose names end with the specified suffix.

The semantics of this operation are the same as that of the getSubscriberNames (all) operation described in the “getSubscriberNames (all)” section on page 3-28.

Parameters

The parameters of the getSubscriberNamesWithSuffix method are as follows:

• lastBulkEnd—See the description in the “Parameters” section on page 3-28.

• numOfSubscribers—See the description in the “Parameters” section on page 3-28.

• suffix—Case-sensitive string that represents the suffix of the required subscriber names.

Return Value

An alphabetically ordered array of subscriber names that end with the required suffix.

See, the “Return Value” section on page 3-28 (the getSubscriberNames (all) operation).

RPC Exception Error Codes

The following list presents error codes that the getSubscriberNamesWithSuffix method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

getDomainsThe following sections provide information about the getDomains operation:

• Syntax, page 3-34

• Description, page 3-34

3-33Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 34: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API setPropertiesToDefault

• Return Value, page 3-34

• RPC Exception Error Codes, page 3-34

Syntax

The getDomains syntax is as follows:

public String[] getDomains()throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getDomains method provides the list of current subscriber domains in the Cisco Service Control Subscriber Manager domain repository.

Return Value

A complete list of subscriber domain names in the Cisco Service Control Subscriber Manager.

RPC Exception Error Codes

None.

setPropertiesToDefaultThe following sections provide information about the setPropertiesToDefault operation:

• Syntax, page 3-34

• Description, page 3-34

• Parameters, page 3-35

• Return Value, page 3-35

• RPC Exception Error Codes, page 3-35

Syntax

The setPropertiesToDefault syntax is as follows:

public void setPropertiesToDefault(String subscriberName, String[] properties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setPropertiesToDefault method resets the specified application properties of a subscriber. If an application is installed, the relevant application properties are set to the default values of the properties according to the currently loaded application information. If an application is not installed, the operation returns java.lang.IllegalStateException.

3-34Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 35: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the setPropertiesToDefault method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• properties—See the description of property keys and values in the “Subscriber Properties” section on page 2-9.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the setPropertiesToDefault method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _BAD_SUBSCRIBER_MAPPING

• ERROR_CODE_DOMAIN_NOT_FOUND

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NOT_A_SUBSCRIBER_DOMAIN

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

removeCustomPropertiesThe following sections provide information about the removeCustomProperties operation:

• Syntax, page 3-35

• Description, page 3-35

• Parameters, page 3-36

• Return Value, page 3-36

• RPC Exception Error Codes, page 3-36

Syntax

The removeCustomProperties syntax is as follows:

public void removeCustomProperties(String subscriberName, String[] customProperties)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The removeCustomProperties method resets the specified custom properties of a subscriber.

3-35Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 36: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API removeCustomProperties

Parameters

The parameters of the removeCustomProperties method are as follows:

• subscriberName—See the description of subscriber name formatting in the “Subscriber Name Format” section on page 2-5.

• CustomProperties—See the description of custom property keys and values in the “Custom Properties” section on page 2-10.

Return Value

None.

RPC Exception Error Codes

The following list presents error codes that the removeCustomProperties method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_DATABASE_EXCEPTION

For a description of error codes, see Appendix A, “List of Error Codes”.

3-36Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 37: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Quota Manager Blocking API Methods

Quota Manager Blocking API MethodsThis section lists the methods of the Quota Manager (QM) Blocking API. The description of each method includes the syntax, input parameters, and return values.

• Use the following methods for static or manual subscriber quota configuration:

– addSubscriberQuota, page 3-37

– setSubscriberQuota, page 3-38

– replenishSubscriberQuota, page 3-39

• Use the following methods for basic read-only operations:

– getSubscriberQuotaInformation, page 3-40

– getSubscriberQuotaProfileId, page 3-41

– getBreachedSubscriberNames, page 3-42

– getPenaltySubscriberNames, page 3-43

addSubscriberQuotaThe following sections provide information about the addSubscriberQuota operation:

• Syntax, page 3-37

• Description, page 3-37

• Parameters, page 3-37

• RPC Exception Error Codes, page 3-38

Syntax

The addSubscriberQuota syntax is as follows:

public void addSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The addSubscriberQuota method adds the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the addSubscriberQuota method are as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value for the bucket ID to add.

• bucketSize—A long value for the bucket size to add.

3-37Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 38: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API setSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the addSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

setSubscriberQuotaThe following sections provide information about the setSubscriberQuota operation:

• Syntax, page 3-38

• Description, page 3-38

• Parameters, page 3-38

• RPC Exception Error Codes, page 3-39

Syntax

The setSubscriberQuota syntax is as follows:

public void setSubscriberQuota(String subscriberName,int bucketId,long bucketSize)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The setSubscriberQuota method updates the quota for the given bucket ID of a subscriber.

Parameters

The parameters of the setSubscriberQuota method are as follows:

• subscriberName—See the description for the subscriber name format in the “Subscriber Name Format” section on page 2-5.

• bucketId—An integer value of the bucket ID to update.

• bucketSize—A long value of the bucket size to update.

3-38Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 39: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API replenishSubscriberQuota

RPC Exception Error Codes

The following list presents error codes that the setSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_CODE_INVALID_BUCKETID

• ERROR_CODE_INVALID_BUCKETSIZE

replenishSubscriberQuotaThe following sections provide information about the replenishSubscriberQuota operation:

• Syntax, page 3-39

• Description, page 3-39

• Parameters, page 3-39

• RPC Exception Error Codes, page 3-39

Syntax

The replenishSubscriberQuota syntax is as follows:

public void replenishSubscriberQuota(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The replenishSubscriberQuota method replenishes the quota for the given subscriber.

Parameters

The only parameter of the replenishSubscriberQuota method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

RPC Exception Error Codes

The following list presents error codes that the replenishSubscriberQuota method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

• ERROR_REPLENISH_FAILED

3-39Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 40: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberQuotaInformation

getSubscriberQuotaInformationThe following sections provide information about the getSubscriberQuotaInformation operation:

• Syntax, page 3-40

• Description, page 3-40

• Parameters, page 3-40

• Return Value, page 3-40

• RPC Exception Error Codes, page 3-41

Syntax

The getSubscriberQuotaInformation syntax is as follows:

public Object[] getSubscriberQuotaInformation(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getSubscriberQuotaInformation method gets a bulk of quota information for a specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaInformation method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

An object array with five elements. Table 3-2 lists the index values and descriptions. None of the array elements have a NULL value.

Table 3-2 Indexes and Descriptions

Index Value Description

Index 0 Package ID (java.lang.String)

Index 1 Last replenish time (java.lang.String)

Index 2 Last SCE that consumed quota (java.lang.String)

3-40Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 41: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getSubscriberQuotaProfileId

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaInformation method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_NO_QUOTA_INFO_FOR_SUBSCRIBER

getSubscriberQuotaProfileIdThe following sections provide information about the getSubscriberQuotaProfileId operation:

• Syntax, page 3-41

• Description, page 3-42

• Parameters, page 3-42

• Return Value, page 3-42

• RPC Exception Error Codes, page 3-42

Syntax

The getSubscriberQuotaProfileId syntax is as follows:

public int getSubscriberQuotaProfileId(String subscriberName)throws InterruptedException, OperationTimeoutException, RpcErrorException

Index 3 Aggregation period end (java.lang.String)

Index 4 Quota buckets (java.lang.Object[][])

Bucket 1:

[0][0]=500 (quota size)

[0][1]=500 (remaining quota)

[0][2]=50 (last quota reported by SCE)

[0][3]=time not set (penalty start)

[0][4]=time not set (next penalty monitor)

Bucket 2:

[1][0]=500 (quota size)

[1][1]=500 (remaining quota)

[1][2]=50 (last quota reported by SCE)

[1][3]=time not set (penalty start)

[1][4]=time not set (next penalty monitor)

Table 3-2 Indexes and Descriptions (continued)

Index Value Description

3-41Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 42: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getBreachedSubscriberNames

Description

The getSubscriberQuotaProfileId method returns the quota profile ID for the specified subscriber.

Parameters

The only parameter of the getSubscriberQuotaProfileId method is as follows:

• subscriberName—See the description in the “Subscriber Name Format” section on page 2-5.

Return Value

Quota profile ID.

RPC Exception Error Codes

The following list presents error codes that the getSubscriberQuotaProfileId method might return:

• ERROR_CODE_ILLEGAL_SUBSCRIBER_NAME

• ERROR_CODE _DATABASE_EXCEPTION

• ERROR_CODE_SUBSCRIBER_DOES_NOT_EXIST

• ERROR_CODE_SUBSCRIBER_NOT_ASSIGNED_PROFILE

getBreachedSubscriberNamesThe following sections provide information about the getBreachedSubscriberNames operation:

• Syntax, page 3-42

• Description, page 3-42

• Parameters, page 3-43

• Return Value, page 3-43

• RPC Exception Error Codes, page 3-43

Syntax

The getBreachedSubscriberNames syntax is as follows:

public String[] getBreachedSubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getBreachedSubscriberNames method retrieves the breached subscriber names.

3-42Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 43: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getPenaltySubscriberNames

Parameters

The parameters of the getBreachedSubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a breached state. This method returns all the subscribers found in the Cisco Service Control Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The getBreachedSubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

getPenaltySubscriberNamesThe following sections provide information about the getPenaltySubscriberNames operation:

• Syntax, page 3-43

• Description, page 3-43

• Parameters, page 3-43

• Return Value, page 3-44

• RPC Exception Error Codes, page 3-44

Syntax

The getPenaltySubscriberNames syntax is as follows:

public String[] getPenaltySubscriberNames(String lastBulkEnd,int numOfSubscribers)throws InterruptedException, OperationTimeoutException, RpcErrorException

Description

The getPenaltySubscriberNames method retrieves the subscriber names in a penalty state.

Parameters

The parameters of the getPenaltySubscriberNames method are as follows:

• lastBulkEnd—The last subscriber name from the last bulk. Use NULL to start with the first (alphabetic) subscriber.

3-43Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 44: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API getPenaltySubscriberNames

• numOfSubscribers—The limit on the number of subscribers that will be returned. If this value is higher than the Cisco Service Control Subscriber Manager limit (1000), the operation uses the Cisco Service Control Subscriber Manager limit.

Return Value

An array of alphabetically ordered subscriber names that belong to a penalty state. This method returns all the subscribers found in the Cisco Service Control Subscriber Manager database starting with the requested subscriber. The array size is limited by the smaller of these values—numOfSubscribers or the Cisco Service Control Subscriber Manager limit (1000).

RPC Exception Error Codes

The getPenaltySubscriberNames method might return the ERROR_CODE _DATABASE_EXCEPTION error code.

3-44Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 45: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Blocking API Code Examples

Blocking API Code ExamplesThis section includes the following code examples:

• Getting Number of Subscribers, page 3-45

• Adding a Subscriber, Printing Information, and Removing a Subscriber, page 3-46

• Getting Subscriber Quota Information, page 3-47

Getting Number of Subscribers The following example prints to stdout the total number of subscribers in the Cisco Service Control Subscriber Manager database and the number of subscribers in each subscriber domain:

package blocking;

import com.pcube.management.api.SMBlockingApi;

public class PrintInfo { public static void main (String args[]) throws Exception { SMBlockingApi bapi = new SMBlockingApi(); try { //initiation bapi.setReplyTimeout(300000); //set timeout for 5 minutes bapi.connect(args[0]); // connect to the SM

//operations String[] domains=bapi.getDomains(); int totalSubscribers=bapi.getNumberOfSubscribers(); System.out.println( "number of susbcribers in the database:\t\t "+ totalSubscribers); for (int i=0; i<domains.length; i++) { int numberOfSusbcribersInDomain= bapi.getNumberOfSubscribersInDomain(domains[i]); System.out.println( "number of susbcribers domain "+domains[i]+ ":\t\t "+numberOfSusbcribersInDomain); } } finally { //finalization bapi.disconnect(); } }}

3-45Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 46: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Adding a Subscriber, Printing Information, and Removing a Subscriber

Adding a Subscriber, Printing Information, and Removing a Subscriber The following program adds a subscriber to the subscriber database. It then gets its information and prints it to stdout. Finally, the program removes the subscriber from the subscriber database:

package blocking;

import com.pcube.management.api.SMBlockingApi;import com.pcube.management.api.SMApiConstants;

public class AddPrintRemove { public static void main (String args[]) throws Exception { checkArguments(args); SMBlockingApi bapi = new SMBlockingApi(); try { //initiation bapi.setReplyTimeout(10000); //set timeout for 10 seconds bapi.connect(args[0]); // connect to the SM //add subscriber System.out.println("+ adding subscriber to SM"); bapi.addSubscriber( args[1], //name new String[]{args[2]}, //mapping SMApiConstants.ALL_IP_MAPPINGS, new String[]{args[3]}, //property key new String[]{args[4]}, //property value new String[]{"custom-key"}, //custom property key new String[]{"10"}, //custom property value args[5]); //domain //Print subscriber System.out.println("+ Printing subscriber"); Object[] subfields = bapi.getSubscriber(args[1]); System.out.println("\tname:\t\t"+subfields[0]); System.out.println("\tmapping:\t"+ ((String[])subfields[1])[0]); System.out.println("\tdomain:\t\t"+subfields[3]); System.out.println("\tautologout:\t"+subfields[8]); //Remove subscriber System.out.println("+ removing subscriber from SM"); bapi.removeSubscriber(args[1]); } finally { //finalization bapi.disconnect(); } }

static void checkArguments(String[] args) throws Exception{ if (args.length != 6) { System.err.println( "usage: java AddPrintRemove <SM-address>"+ " <subscriber-name> <IP mapping> <property-key>"+ " <property-value> <domain>"); System.exit(1); } }}

3-46Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 47: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Getting Subscriber Quota Information

Getting Subscriber Quota InformationThe following example gets subscriber quota information, sets subscriber quota, and lists subscribers in the breached state:

package blocking;

import com.pcube.management.api.QuotaManagerApi;public class PrintQuotaInfo {

/** * @param args * @throws Exception */

public static void main(String[] args) throws Exception {QuotaManagerApi qmapi = new QuotaManagerApi();checkArguments(args);String smIP=args[0];//initiation

try{

qmapi .setReplyTimeout(300000); //set timeout for 5 minutesqmapi .connect(smIP); // connect to the SM

//operations//getSubscriberQuotaInformationObject []subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]);

for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getSubscriberQuotaProfileId int profileID = qmapi.getSubscriberQuotaProfileId(args[1]);

System.out.println(profileID); //addSubscriberQuota qmapi.addSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //setSubscriberQuota qmapi.setSubscriberQuota(args[1], 1,300); subQuotaInfo = qmapi.getSubscriberQuotaInformation(args[1]); for(int i=0;i<subQuotaInfo.length;i++){ System.out.println(subQuotaInfo[i]); } //getBreachedSubscriberNames String []breachSubsNames=qmapi.getBreachedSubscriberNames(null, 10); for(int i=0;i<breachSubsNames.length;i++){ System.out.println(breachSubsNames[i]); }

}finally{//finaliztionqmapi.disconnect();

}}static void checkArguments(String[] args) throws Exception{

if (args.length != 2) {System.err.println("usage: java PrintQuotaInfo <SM-address> <subscriber-name> ");System.exit(1);}

}}

3-47Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02

Page 48: Blocking API - cisco.com · Cisco Service Control Subscriber Manager Java API Programmer Guide OL-26795-02 3 Blocking API Revised: December 21, 2012, OL-26795-02 Introduction This

Chapter 3 Blocking API Getting Subscriber Quota Information

3-48Cisco Service Control Subscriber Manager Java API Programmer Guide

OL-26795-02