Monitoring > 2 - Management Monitoring Services > Purchase Monitoring Service

2.2 Purchase Monitoring Service

By the method SetPurchaseMonitoringService you can purchase a Monitoring Service.

Parameters
monitorMonitoringClassOfServiceID
Type: Integer
monitoring class of service id to purchase.

monitorName
Type: String
monitor service name.

/// WsMonitoring.SetPurchaseMonitoringService Method (c# .NET)
public static string SetPurchaseMonitoringService(WsMonitoringClient client,
    int monitorMonitoringClassOfServiceID, String monitorName)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
 // create the request object
 NewMonitoringServiceEntity request = new NewMonitoringServiceEntity();
 request.MonitoringClassOfServiceID = monitorMonitoringClassOfServiceID;
 request.Name = monitorName;

 // call method SetPurchaseMonitoringService 
 // obtaining a WsResultOfint item
 WsResultOfint result = client.SetPurchaseMonitoringService(request);

 //if the call is Success print value
 if (result.Success)
 {
     // get Value returned from server
     stringBuilder.Append(" Operation successfully. Result Code : ");
     stringBuilder.Append(result.ResultCode);
 }
 else
 {
     throw new ApplicationException(result.ResultMessage);
 }
    }
    catch (Exception ex)
    {
 // re-run the error
 throw new ApplicationException(ex.Message);
    }

    return stringBuilder.ToString();
}
/// WsMonitoring.SetPurchaseMonitoringService Method (JAVA)
public static String SetPurchaseMonitoringService
    (IWsMonitoring client, Integer monitorMaxHourNotification,
    Integer monitorMonitoringClassOfServiceID, String monitorName) 
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
 .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
 .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");

    StringBuilder stringBuilder = new StringBuilder();

    try 
    {
        NewMonitoringServiceEntity newMonitoringServiceEntity = 
            new NewMonitoringServiceEntity();
        newMonitoringServiceEntity.setMaxHourNotification
            (monitorMaxHourNotification);
        newMonitoringServiceEntity.setMonitoringClassOfServiceID
            (monitorMonitoringClassOfServiceID);
        newMonitoringServiceEntity.setName(monitorName);
    
        WsResultOfint result = 
            client.setPurchaseMonitoringService(newMonitoringServiceEntity);

        if (!result.isSuccess()) 
 {
     throw new Exception(result.getResultMessage());
        }
    } 
    catch (Exception ex) 
    {
        System.out.println(ex);
    }

    return stringBuilder.toString();
}
Version
API: v2.8 URL:https://api.services.cloud.it/wsMonitoring/v2.8/wsMonitoring.svc?wsdl

See also