List Incidents Associated with a Resource

This use case describes the requirements for listing incidents associated with players or edge servers on your domain.

SOAP API Method Reference

To list incidents associated with a resource, use one of the following methods:

Code Samples
<?php
  ## List all incidents for a player or edge server
  ##
  ## Usage : php incident_mgr_list_v3 --domain=domainId [--resource_id=playerId|edgeserverId]
  ## Usage : php incident_mgr_list_v3 --domain=domainId [--ids=playerId,edgeserverId,playerId,edgeserverId,...]
  ## Usage example : php incident_mgr_list_v3 --domain=123456789 --resource_id=123698745
  ## Usage example : php incident_mgr_list_v3 --domain=123456789 --ids=123698745,147896325


  include "soaplib.php";
  include "cmdutil.php";
  
  $options = get_arguments("domain!", "resource_id", "ids");
  
  if (isset($options["ids"])) 
  {
    # Show a list of selected incidents
    $body = new stdClass();
    $body -> domain_id = $options["domain"]; # ID of your domain
    $body -> ids = $options["ids"];  # comma separated ids of player(s) and/or edge server(s) (e.g:  $body -> ids = "362,631")
      $response = performSimpleOperation("incident", "list_many", 3, $body);
  } 
  else 
  { 
      if (isset($options["resource_id"]))
      {
          # Show all incidents
        $body = new stdClass();
        $body -> domain_id = $options["domain"]; # The ID of your domain
        $body -> resource_id = $options["resource_id"]; # The ID of the player or edge server
        $response = performSimpleOperation("incident", "list", 3, $body);
      }
      else
      {
        echo "\nPLease provide at least one \"resource_id\" or one \"id\" parameter.\n";
        return;
          
      }
  }

  #echo json_encode($response) . "\n";
    
?>

/*
 * (c) 2002 - 2015 Broadsign International, LLC
 */

import java.util.List;

import org.apache.axis2.Constants.Configuration;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.axis2.transport.http.HTTPConstants;

import com.broadsign.www.wsdl_ops.BsapiStub;
import com.broadsign.www.wsdl_ops.IncidentMgrListResponseBody;

class Main {

  public static void main(String[] args) throws Exception
  {
    setupKeystore();
    BsapiStub javaStub = createStub();

    String basicPlayerId = "12345678";
    IncidentFactory incidentFactory = new IncidentFactory(javaStub);
    
    List<IncidentMgrListResponseBody> rBodies = incidentFactory.list(basicPlayerId, "");
    for(IncidentMgrListResponseBody rBody : rBodies) {
      System.out.println(rBody.getId() + " : " + rBody.getResourceId() + " : " + rBody.getProblemDescription());
    }
  }


  private static BsapiStub createStub()
  {
    try {
      ConfigurationContext config = ConfigurationContextFactory.createDefaultConfigurationContext();
      TransportOutDescription transport = new TransportOutDescription("https_mutual_auth");
      CommonsHTTPTransportSender sender = new CommonsHTTPTransportSender();

      sender.init(config, transport);
      BsapiStub javaStub = new BsapiStub();
      transport.setSender(sender);
      javaStub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "utf-16");
      javaStub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, "false");
      javaStub._getServiceClient().getOptions().setTransportOut(transport);
      return javaStub;
    } catch (java.lang.Exception e) {
      System.out.println("Error:" + e.toString());
    }
    return null;
  }
  private static void setupKeystore()
  {
    // NOTE: Make sure to update the folders where your keystore files are located
        //       as well as the actual passwords for your keystores
    System.setProperty("javax.net.ssl.keyStoreType", "jks");
    System.setProperty("javax.net.ssl.keyStore", "YOUR_SOAP_KEYSTORE_HERE.keystore");
    System.setProperty("javax.net.ssl.keyStorePassword", "YOUR_SOAP_KEYSTORE_PASSWORD_HERE");
    System.setProperty("javax.net.ssl.trustStoreType", "jks");
    System.setProperty("javax.net.ssl.trustStore", "YOUR_TRUSTED_KEYSTORE_HERE.keystore");
    System.setProperty("javax.net.ssl.trustStorePassword", "YOUR_TRUSTED_KEYSTORE_PASSWORD_HERE");
  }
}

/*
 * (c) 2002 - 2015 Broadsign International, LLC
 */

/*
 * IncidentFactory Class
 *
 * This class allows the listing of Incidents
 */

import java.util.ArrayList;
import java.util.List;

import org.apache.xmlbeans.*;

import com.broadsign.www.wsdl_ops.*;

class IncidentFactory {

  public IncidentFactory(BsapiStub stub)
  {
    assert(stub != null);
    m_stub = stub;
  }

  public List<IncidentMgrListResponseBody> list(String resourceId, String domainId) throws Exception
  {
    List<IncidentMgrListResponseBody> results = new ArrayList<IncidentMgrListResponseBody>();
    WsdlRequest wsdlRequest = WsdlRequest.Factory.newInstance();
    XmlObject xmlBodies[];
    RequestDocument requestDocument = RequestDocument.Factory.newInstance();
    ResponseDocument responseDocument;
    WsdlResponse response;

    IncidentMgrListRequestBody requestBody = IncidentMgrListRequestBody.Factory.newInstance();

    if(!domainId.isEmpty()) {
      requestBody.setDomainId(domainId);
    }
    if(!resourceId.isEmpty()) {
      requestBody.setResourceId(resourceId);
    }
    wsdlRequest.setName("incident_mgr_list");
    wsdlRequest.setVersion(3);
    wsdlRequest.setIncident(requestBody);

    requestDocument.setRequest(wsdlRequest);
    requestDocument.documentProperties().setEncoding("utf-16");
    System.out.println(requestDocument.xmlText());

    responseDocument = m_stub.incident_mgr_list_v3(requestDocument);

    System.out.println(responseDocument.xmlText());
    response = responseDocument.getResponse();
    xmlBodies = response.getIncidentArray();

    if (xmlBodies.length > 0) {
      for (XmlObject xmlBody : xmlBodies) {
        IncidentMgrListResponseBody incident = IncidentMgrListResponseBody.Factory.parse(xmlBody.xmlText());
        results.add(incident);
      }
    }

    return results;
  }

  public List<IncidentMgrListScopedResponseBody> listScoped(String domainId, String parentContainerIds) throws Exception
  {
    List<IncidentMgrListScopedResponseBody> results = new ArrayList<IncidentMgrListScopedResponseBody>();
    WsdlRequest wsdlRequest = WsdlRequest.Factory.newInstance();
    XmlObject xmlBodies[];
    RequestDocument requestDocument = RequestDocument.Factory.newInstance();
    ResponseDocument responseDocument;
    WsdlResponse response;

    IncidentMgrListScopedRequestBody requestBody = IncidentMgrListScopedRequestBody.Factory.newInstance();

    if(!domainId.isEmpty()) { 
      requestBody.setDomainId(domainId);
    }
    requestBody.setParentContainerIds(parentContainerIds);
    wsdlRequest.setName("incident_mgr_list_scoped");
    wsdlRequest.setVersion(3);
    wsdlRequest.setIncident(requestBody);

    requestDocument.setRequest(wsdlRequest);
    requestDocument.documentProperties().setEncoding("utf-16");
    System.out.println(requestDocument.xmlText());

    responseDocument = m_stub.incident_mgr_list_scoped_v3(requestDocument);

    System.out.println(responseDocument.xmlText());
    response = responseDocument.getResponse();
    xmlBodies = response.getIncidentArray();

    if (xmlBodies.length > 0) {
      for (XmlObject xmlBody : xmlBodies) {
        IncidentMgrListScopedResponseBody incident = IncidentMgrListScopedResponseBody.Factory.parse(xmlBody.xmlText());
        results.add(incident);
      }
    }

    return results;
  }

  public List<IncidentMgrListManyResponseBody> listMany(String ids) throws Exception
  {
    List<IncidentMgrListManyResponseBody> results = new ArrayList<IncidentMgrListManyResponseBody>();
    WsdlRequest wsdlRequest = WsdlRequest.Factory.newInstance();
    XmlObject xmlBodies[];
    RequestDocument requestDocument = RequestDocument.Factory.newInstance();
    ResponseDocument responseDocument;
    WsdlResponse response;

    IncidentMgrListManyRequestBody requestBody = IncidentMgrListManyRequestBody.Factory.newInstance();

    requestBody.setIds(ids);
    wsdlRequest.setName("incident_mgr_list_many");
    wsdlRequest.setVersion(3);
    wsdlRequest.setIncident(requestBody);


    requestDocument.setRequest(wsdlRequest);
    requestDocument.documentProperties().setEncoding("utf-16");
    System.out.println(requestDocument.xmlText());

    responseDocument = m_stub.incident_mgr_list_many_v3(requestDocument);

    System.out.println(responseDocument.xmlText());
    response = responseDocument.getResponse();
    xmlBodies = response.getIncidentArray();

    if (xmlBodies.length > 0) {
      for (XmlObject xmlBody : xmlBodies) {
        IncidentMgrListManyResponseBody incident = IncidentMgrListManyResponseBody.Factory.parse(xmlBody.xmlText());
        results.add(incident);
      }
    }

    return results;
  }

  private BsapiStub m_stub = null;
}