HP CloudSystem Matrix/Matrix Operating Environment 7.2 Integration Interfaces API and CLI Operations Reference Guide

Example 2 reports.py
import suds
import datetime
import locale
import root.reports.reports_file
from reportlab.platypus import Table, TableStyle, Paragraph
from reportlab.platypus.flowables import PageBreak
from reportlab.lib import colors
from reportlab.lib.colors import Color, PCMYKColor, HexColor, black, white
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.graphics.shapes import Drawing
from reportlab.graphics.charts.piecharts import Pie
from reportlab.graphics.charts.legends import Legend
styleSheet = getSampleStyleSheet()
resourcescolumntitles_fontsize = 8
resourcescolumnvalues_fontsize = 7
PAGE_SIZE = 100
PAGE_INDEX = 0
pdf_chart_colors = [
HexColor("#0000e5"),
HexColor("#1f1feb"),
HexColor("#5757f0"),
HexColor("#8f8ff5"),
HexColor("#c7c7fa"),
HexColor("#f5c2c2"),
HexColor("#eb8585"),
HexColor("#e04747"),
HexColor("#d60a0a"),
HexColor("#cc0000"),
HexColor("#ff0000"),
]
class PeriodInformation(object):
def __init__(self, startDate, endDate):
self.start = startDate
self.end = endDate
def getDailyPeriodObj(self, chargebackservice):
reportPeriod = chargebackservice.factory.create('period')
reportPeriod.startDate = self.start
reportPeriod.endDate = self.end
periodType = chargebackservice.factory.create('periodType')
reportPeriod.type = periodType.DAILY
return reportPeriod
def getPeriodObj(self, chargebackservice):
reportPeriod = chargebackservice.factory.create('period')
reportPeriod.startDate = self.start
reportPeriod.endDate = self.end
periodType = chargebackservice.factory.create('periodType')
reportPeriod.type = periodType.PERIOD
return reportPeriod
class Filters(object):
def __init__(self, organizationid="", billingcode="", owner="", service=""):
self.organizationid = organizationid
self.billing_code = billingcode
self.owner = owner
self.service = service
def getFiltersObj(self, chargebackservice):
filterCollection = []
attributefilter = chargebackservice.factory.create("serviceFilterAttribute")
connectorfilter = chargebackservice.factory.create("filterConnector")
operatorfilter = chargebackservice.factory.create("filterOperator")
if len(self.organizationid) > 0:
organizationfilter = chargebackservice.factory.create('serviceFilter')
organizationfilter.filterAttribute = attributefilter.ORGANIZATION_ID
organizationfilter.filterOperator = operatorfilter.EQUAL
organizationfilter.serviceFilterValue = self.organizationid
filterCollection.append(organizationfilter)
if len(self.billing_code) >0 :
billingcodefilter = chargebackservice.factory.create('serviceFilter')
billingcodefilter.filterAttribute = attributefilter.BILLING_CODE
billingcodefilter.filterOperator = operatorfilter.EQUAL
billingcodefilter.serviceFilterValue = self.billing_code
billingcodefilter.filterConnector = connectorfilter.AND
filterCollection.append(billingcodefilter)
if len(self.owner) > 0:
ownerfilter = chargebackservice.factory.create('serviceFilter')
ownerfilter.filterAttribute = attributefilter.OWNER
ownerfilter.filterOperator = operatorfilter.EQUAL
ownerfilter.serviceFilterValue = self.owner
ownerfilter.filterConnector = connectorfilter.AND
filterCollection.append(ownerfilter)
111