Cloud Cruiser became HPE Consumption Analytics on Nov. 1st. You'll still see the old name in places while we update this site.

 

 

Consumption Analytics Documentation

Home > Cloud Cruiser 3 > REST API reference > Reports > Run a report

Run a report

Runs a report based on the provided input information. A report name and user group name are required input, and you can optionally provide other parameters such as date or account ranges.

You can run multiple reports programmatically using a batch job. For more information, see Automating reports.

Resource URL

POST http://<ccServerURL>/rest/v1/reports

Request

Parameters

None.

Content-Type

application/xml

Body

The input parameters required to run a report, as XML text with a root element of type reportInput or JAXB type com.cloudcruiser.server.webservices.v1.dto.report.ReportInput.

Schema

This XML schema describes the input for running a standard report.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.cloudcruiser.com/webservices/v1/Report" targetNamespace="http://www.cloudcruiser.com/webservices/v1/Report">
<xs:element name="reportInput" type="tns:ReportInput"/>
<xs:complexType name="ReportInput">
  <xs:sequence>
    <!‐‐ Required element, may use getReportNames API to retrieve/query ‐‐>
    <!‐‐ the available report names. ‐‐>
    <xs:element name="reportName" type="xs:string"/>
    <!‐‐ Required element ‐‐>
    <xs:element name="userGroupName" type="xs:string"/>
    <!‐‐ The valid values are "PDF", "XLS" and "CSV". The default is "PDF". ‐‐>
    <xs:element minOccurs="0" name="format" type="reportJobFormatType"/>
    <!‐‐ See dateRangeType for valid values. The default is "PREVPERIOD" ‐‐>
    <!‐‐ If accountingYear or accountingPeriod is set, dateRange cannot be set. ‐‐>
    <xs:element minOccurs="0" name="dateRange" type="dateRangeType"/>
    <!‐‐ The default value is 0 ‐‐>
    <xs:element minOccurs="0" name="accountLevel" type="xs:short"/>
    <!‐‐ The default value is 0 ‐‐>
    <xs:element minOccurs="0" name="accountStructure" type="xs:short"/>
    <!‐‐ The default value is "lowest" ‐‐>
    <xs:element minOccurs="0" name="accountRangeStart" type="xs:string"/>
    <!‐‐ The default value is "highest" ‐‐>
    <xs:element minOccurs="0" name="accountRangeEnd" type="xs:string"/>
    <!‐‐ accountingYear/accountingPeriod and dateRange cannot be set at the same time
    <xs:element minOccurs="0" name="accountingYear" type="xs:string"/>
    <xs:element minOccurs="0" name="accountingPeriod" type="xs:string"/>
    <!‐‐ The default value is 1 ‐‐>
    <xs:element minOccurs="0" name="accountingDay" type="xs:short"/>
    <xs:element minOccurs="0" name="customStartDate" type="ns1:Date"/>
    <xs:element minOccurs="0" name="customEndDate" type="ns1:Date"/>
    <xs:element minOccurs="0" name="extraParameters">
  </xs:sequence>
</xs:complexType>
<xs:simpleType name="reportJobFormatType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="PDF"/>
    <xs:enumeration value="XLS"/>
    <xs:enumeration value="CSV"/>
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="dateRangeType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="ALL"/>
    <xs:enumeration value="CURRPERIOD"/>
    <xs:enumeration value="PREVPERIOD"/>
    <xs:enumeration value="CURRMON"/>
    <xs:enumeration value="MONTHTODATE"/>
    <xs:enumeration value="PREVMON"/>
    <xs:enumeration value="CURRYEAR"/>
    <xs:enumeration value="YEARTODATE"/>
    <xs:enumeration value="PREVYEAR"/>
    <xs:enumeration value="TODAY"/>
    <xs:enumeration value="PREVTODAY"/>
    <xs:enumeration value="CURRWEEK"/>
    <xs:enumeration value="WEEKTODATE"/>
    <xs:enumeration value="PREVWEEK"/>
    <xs:enumeration value="CUSTOM"/>
  </xs:restriction>
</xs:simpleType>
</xs:schema>

Response

Content-Type

Based on the report format type:

  • PDF: application/pdf
  • XLS: application/vnd.ms-excel
  • CSV: text/csv
Body

Binary content with the following Java syntax:

// Retrieves a StandardInvoice report and save it to a local file.
import java.io.*;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.Client;
import org.apache.cxf.jaxrs.client.WebClient;
import com.cloudcruiser.server.webservices.v1.services.IReportWebService;
import com.cloudcruiser.server.webservices.v1.dto.report.ReportInput;
IReportWebService reportServiceProxy = JAXRSClientFactory.create(URI, IReportWebService .class);
Client client = WebClient.client(reportServiceProxy);
ReportInput input = new ReportInput();
input.setReportName("StandardInvoice");
input.setUserGroupName("admin");
input.setDateRange("YEARTODATE");
input.setFormat("PDF");
reportServiceProxy.getReports(input));
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("<localDir>/report.pdf");
  BufferedInputStream bis = new BufferedInputStream((java.io.InputStream)response.getEntity())))
{
  byte[] bytesBuf = new byte[1024];
  while ((int count = bis.read(bytesBuf)) > 0)
    bos.write(bytesBuf, 0, count);
}
catch (IOException e) {
  // Handle or log the exception
}

Examples

URL invocation

POST http://localhost:8080/rest/v1/reports

Request body (year to date)
<?xml version="1.0" encoding="UTF-8"?>
<reportInput xmlns="http://www.cloudcruiser.com/webservices/v1/Report">
  <reportName>StandardInvoice</reportName>
  <userGroupName>buBgroup</userGroupName>
  <format>PDF</format>
  <dateRange>YEARTODATE</dateRange>
  <accountRangeStart>lowest</accountRangeStart>
  <accountRangeEnd>highest</accountRangeEnd>
</reportInput>
Request body (custom date range, extra parameters)
<?xml version="1.0" encoding="UTF-8"?>
<reportInput xmlns="http://www.cloudcruiser.com/webservices/v1/Report">
  <reportName>StandardInvoice</reportName>
  <userGroupName>buBgroup</userGroupName>
  <format>PDF</format>
  <dateRange>CUSTOM</dateRange>
  <accountRangeStart>lowest</accountRangeStart>
  <accountRangeEnd>highest</accountRangeEnd>
  <customStartDate year="2013" month="1" day="1"/>
  <customEndDate year="2014" month="5" day="1"/>
  <extraParameters>
    <param key="inAccountingDay" value="1"/>
    <param key="inReportTitle" value="Monthly Invoice"/>
  </extraParameters>
</reportInput>
Response header
Content‐Disposition: attachment; filename="StandardInvoice.pdf"
Content‐Length: 52002
Content‐Type: application/pdf
Last modified

Tags

Classifications

This page has no classifications.
© Copyright 2018 Hewlett Packard Enterprise Development LP