<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def createUsageReport(self, reportname, queries, metadata, since="LAST_DAY", fromValue=None, toValue=None, aggregationInterval=None ):
 """ Creates a new usage report. A usage report is created by submitting a JSON representation of the usage report to this operation. Inputs: reportname - the unique name of the report since - the time duration of the report. The supported values are: LAST_DAY, LAST_WEEK, LAST_MONTH, LAST_YEAR, CUSTOM LAST_DAY represents a time range spanning the previous 24 hours. LAST_WEEK represents a time range spanning the previous 7 days. LAST_MONTH represents a time range spanning the previous 30 days. LAST_YEAR represents a time range spanning the previous 365 days. CUSTOM represents a time range that is specified using the from and to parameters. fromValue - optional value - The timestamp (milliseconds since UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the beginning period of the report. Only valid when since is CUSTOM toValue - optional value - The timestamp (milliseconds since UNIX epoch, namely January 1, 1970, 00:00:00 GMT) for the ending period of the report.Only valid when since is CUSTOM. aggregationInterval - Optional. Aggregation interval in minutes. Server metrics are aggregated and returned for time slices aggregated using the specified aggregation interval. The time range for the report, specified using the since parameter (and from and to when since is CUSTOM) is split into multiple slices, each covering an aggregation interval. Server metrics are then aggregated for each time slice and returned as data points in the report data. When the aggregationInterval is not specified, the following defaults are used: LAST_DAY: 30 minutes LAST_WEEK: 4 hours LAST_MONTH: 24 hours LAST_YEAR: 1 week CUSTOM: 30 minutes up to 1 day, 4 hours up to 1 week, 1 day up to 30 days, and 1 week for longer periods. If the samplingInterval specified in Usage Reports Settings is more than the aggregationInterval, the samplingInterval is used instead. queries - A list of queries for which to generate the report. You need to specify the list as an array of JSON objects representing the queries. Each query specifies the list of metrics to be queries for a given set of resourceURIs. The queries parameter has the following sub-parameters: resourceURIs - Comma separated list of resource URIs for which to report metrics. Specifies services or folders for which to gather metrics. The resourceURI is formatted as below: services/ - Entire Site services/Folder/ - Folder within a Site. Reports metrics aggregated across all services within that Folder and Sub-Folders. services/Folder/ServiceName.ServiceType - Service in a specified folder, for example: services/Map_bv_999.MapServer. services/ServiceName.ServiceType - Service in the root folder, for example: Map_bv_999.MapServer. metrics - Comma separated list of metrics to be reported. Supported metrics are: RequestCount - the number of requests received RequestsFailed - the number of requests that failed RequestsTimedOut - the number of requests that timed out RequestMaxResponseTime - the maximum response time RequestAvgResponseTime - the average response time ServiceActiveInstances - the maximum number of active (running) service instances sampled at 1 minute intervals, for a specified service metadata - Can be any JSON Object. Typically used for storing presentation tier data for the usage report, such as report title, colors, line-styles, etc. Also used to denote visibility in ArcGIS Server Manager for reports created with the Administrator Directory. To make any report created in the Administrator Directory visible to Manager, include "managerReport":true in the metadata JSON object. When this value is not set (default), reports are not visible in Manager. This behavior can be extended to any client that wants to interact with the Administrator Directory. Any user-created value will need to be processed by the client. Example: "resourceURIs": ["services/Map_bv_999.MapServer"], "metrics": ["RequestCount"] }] reportname="SampleReport", queries=queryObj, metadata="This could be any String or JSON Object.", since="LAST_DAY" ) """

        url = self._url + "/add"

        params = {
            "f" : "json",
            "usagereport": {
            "reportname" : reportname,
            "since" : since,
            "metadata" : metadata}
        }
        if isinstance(queries, dict):
            params["usagereport"]["queries"] = [queries]
        elif isinstance(queries, list):
            params["usagereport"]["queries"] = queries
        if aggregationInterval is not None:
            params["usagereport"]['aggregationInterval'] = aggregationInterval
        if since.lower() == "custom":
            params["usagereport"]['to'] = toValue
            params["usagereport"]['from'] = fromValue
        res =  self._post(url=url,
                             param_dict=params,
                             securityHandler=self._securityHandler,
                             proxy_port=self._proxy_port,
                             proxy_url=self._proxy_url)
        #  Refresh the metrics object
        self.__init()
        return res