From: <rm...@hy...> - 2008-11-26 01:16:06
|
Author: rmorgan Date: 2008-11-25 17:15:58 -0800 (Tue, 25 Nov 2008) New Revision: 311 URL: http://svn.hyperic.org/?view=rev&root=HQApi&revision=311 Removed: trunk/xsd/DataPoint.xsd Modified: trunk/hqu/hqapi1/app/MetricController.groovy trunk/src/org/hyperic/hq/hqapi1/MetricApi.java trunk/src/org/hyperic/hq/hqapi1/test/MetricData_test.java trunk/xsd/HQApi1.xsd trunk/xsd/Metric.xsd Log: Stub out getting metrics for a group. Modified: trunk/hqu/hqapi1/app/MetricController.groovy =================================================================== --- trunk/hqu/hqapi1/app/MetricController.groovy 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/hqu/hqapi1/app/MetricController.groovy 2008-11-26 01:15:58 UTC (rev 311) @@ -362,4 +362,27 @@ } } } + + def getGroupData(params) { + def groupId = params.getOne("groupId")?.toInteger() + def templateId = params.getOne("templateId")?.toInteger() + def start = params.getOne("start")?.toLong() + def end = params.getOne("end")?.toLong() + + def failureXml = null + + if (!groupId || !templateId || !start || !end) { + failureXml = getFailureXML(ErrorCode.INVALID_PARAMETERS) + } + + renderXml() { + GetMetricsDataResponse() { + if (failureXml) { + out << failureXml + } else { + out << getFailureXML(ErrorCode.NOT_IMPLEMENTED) + } + } + } + } } Modified: trunk/src/org/hyperic/hq/hqapi1/MetricApi.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/MetricApi.java 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/src/org/hyperic/hq/hqapi1/MetricApi.java 2008-11-26 01:15:58 UTC (rev 311) @@ -17,6 +17,8 @@ import org.hyperic.hq.hqapi1.types.SetMetricDefaultOnResponse; import org.hyperic.hq.hqapi1.types.SetMetricIntervalResponse; import org.hyperic.hq.hqapi1.types.ListMetricsResponse; +import org.hyperic.hq.hqapi1.types.GetMetricsDataResponse; +import org.hyperic.hq.hqapi1.types.Group; /** * The Hyperic HQ Metric API. @@ -265,4 +267,34 @@ return doGet("metric/getData.hqu", params, GetMetricDataResponse.class); } + + + /** + * Get the {@link org.hyperic.hq.hqapi1.types.MetricData} for the given + * {@link org.hyperic.hq.hqapi1.types.Group} and {@link org.hyperic.hq.hqapi1.types.MetricTemplate}. + * + * @param g The Group to query. + * @param t The MetricTemplate to query for data. + * @param start The start time to query, in epoch-millis. + * @param end The end time to query, in epoch-millis. + * + * @return {@link org.hyperic.hq.hqapi1.types.ResponseStatus#SUCCESS} + * if the data was succesfully queried. The returned data can be retrieved + * via {@link org.hyperic.hq.hqapi1.types.GetMetricsDataResponse#getResourceMetrics()}. + * + * @throws IOException If a network error occurs while making the request. + */ + public GetMetricsDataResponse getMetricData(Group g, MetricTemplate t, + long start, long end) + throws IOException + { + Map<String, String> params = new HashMap<String, String>(); + params.put("groupId", Integer.toString(g.getId())); + params.put("templateId", Integer.toString(t.getId())); + params.put("start", Long.toString(start)); + params.put("end", Long.toString(end)); + + return doGet("metric/getGroupData.hqu", params, + GetMetricsDataResponse.class); + } } Modified: trunk/src/org/hyperic/hq/hqapi1/test/MetricData_test.java =================================================================== --- trunk/src/org/hyperic/hq/hqapi1/test/MetricData_test.java 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/src/org/hyperic/hq/hqapi1/test/MetricData_test.java 2008-11-26 01:15:58 UTC (rev 311) @@ -5,8 +5,16 @@ import org.hyperic.hq.hqapi1.types.MetricData; import org.hyperic.hq.hqapi1.types.Resource; import org.hyperic.hq.hqapi1.types.ListMetricsResponse; +import org.hyperic.hq.hqapi1.types.GetGroupsResponse; +import org.hyperic.hq.hqapi1.types.Group; +import org.hyperic.hq.hqapi1.types.GetMetricsDataResponse; +import org.hyperic.hq.hqapi1.types.MetricTemplate; import org.hyperic.hq.hqapi1.MetricApi; +import org.hyperic.hq.hqapi1.GroupApi; +import org.hyperic.hq.hqapi1.HQApi; +import java.util.List; + public class MetricData_test extends MetricTestBase { Resource _r; @@ -87,4 +95,20 @@ GetMetricDataResponse dataResponse = api.getMetricData(m, end, start); hqAssertFailureInvalidParameters(dataResponse); } + + public void testGetMetricGroupData() throws Exception { + + HQApi api = getApi(); + + MetricTemplate t = new MetricTemplate(); + t.setId(1); + Group g = new Group(); + g.setId(1); + long end = System.currentTimeMillis(); + long start = end - (8 * 60 * 60 * 1000); + + MetricApi metricApi = api.getMetricApi(); + GetMetricsDataResponse response = metricApi.getMetricData(g, t, start, end); + hqAssertFailureNotImplemented(response); + } } Deleted: trunk/xsd/DataPoint.xsd =================================================================== --- trunk/xsd/DataPoint.xsd 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/xsd/DataPoint.xsd 2008-11-26 01:15:58 UTC (rev 311) @@ -1,11 +0,0 @@ -<?xml version="1.0"?> - -<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> - - <xs:complexType name="DataPoint"> - <xs:attribute name="MetricId" type="xs:positiveInteger"/> - <xs:attribute name="Timestamp" type="xs:time"/> - <xs:attribute name="Value" type="xs:decimal"/> - </xs:complexType> - -</xs:schema> Modified: trunk/xsd/HQApi1.xsd =================================================================== --- trunk/xsd/HQApi1.xsd 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/xsd/HQApi1.xsd 2008-11-26 01:15:58 UTC (rev 311) @@ -5,7 +5,6 @@ <xs:include schemaLocation="User.xsd" /> <xs:include schemaLocation="Role.xsd"/> <xs:include schemaLocation="Group.xsd" /> - <xs:include schemaLocation="DataPoint.xsd" /> <xs:include schemaLocation="Metric.xsd" /> <xs:include schemaLocation="MetricTemplate.xsd" /> <xs:include schemaLocation="Escalation.xsd" /> Modified: trunk/xsd/Metric.xsd =================================================================== --- trunk/xsd/Metric.xsd 2008-11-26 00:08:53 UTC (rev 310) +++ trunk/xsd/Metric.xsd 2008-11-26 01:15:58 UTC (rev 311) @@ -2,6 +2,7 @@ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:include schemaLocation="Resource.xsd"/> <xs:include schemaLocation="MetricTemplate.xsd"/> <xs:include schemaLocation="Response.xsd"/> @@ -19,11 +20,20 @@ <xs:attribute name="collectionType" type="xs:string" use="required"/> </xs:complexType> + <!-- Metric data --> + <xs:complexType name="MetricData"> <xs:attribute name="timestamp" type="xs:long" use="required"/> <xs:attribute name="value" type="xs:double" use="required"/> </xs:complexType> + <xs:complexType name="ResourceMetrics"> + <xs:sequence> + <xs:element name="Resource" type="Resource" maxOccurs="1"/> + <xs:element name="MetricData" type="MetricData" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + <!-- Metric Responses --> <xs:element name="EnableMetricResponse"> @@ -88,4 +98,17 @@ </xs:complexType> </xs:element> + <xs:element name="GetMetricsDataResponse"> + <xs:complexType> + <xs:complexContent> + <xs:extension base="Response"> + <xs:sequence> + <xs:element name="ResourceMetrics" type="ResourceMetrics" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:extension> + </xs:complexContent> + </xs:complexType> + </xs:element> + + </xs:schema> |