Example #1
0
class ConsumptionSummaryByDomain(Statistic):
    base_path = '/cdn/statistics/domain'
    resources_key = 'domain'
    query_page_size_key = None
    query_page_number_key = None

    allow_list = True

    _query_mapping = cdn_resource.StatisticParameters('stat_type',
                                                      'service_area')

    #: The domain name.
    domain_name = resource.Body('domain_name')
    #: The statistics type. Available values include:
    #: bw (bandwidth),
    #: flux,
    #: bs_bw (retrieval bandwidth),
    #: bs_flux (retrieval flux),
    #: req_num (number of total requests, or PVs),
    #: req_hit_rate (rate of hitting requests),
    #: flux_hit_rate (rate of hitting flux),
    #: bs_fail_rate (rate of retrieval failures),
    #: qps (requests per second),
    #: http_code_2xx (status code 2xx),
    #: http_code_3xx (status code 3xx),
    #: http_code_4xx (status code 4xx),
    #: http_code_5xx (status code 5xx),
    #: bs_num (total number of retrieval requests),
    #: bs_fail_num (number of content retrieval failures).
    stat_type = resource.Body('stat_type')
    #: Includes mainland_china and outside_mainland_china.
    service_area = resource.Body('service_area')
    def test_basic(self):
        sot = cdn_resource.StatisticParameters()

        self.assertDictEqual(
            {
                'start_time': 'start_time',
                'end_time': 'end_time',
                'domain_name': 'domain_name'
            }, sot._mapping)
Example #3
0
class Statistic(cdn_resource.Resource):
    base_path = None
    resource_key = None
    resources_key = None
    service = cdn_service.CDNService()

    allow_create = False
    allow_get = False
    allow_update = False
    allow_delete = False
    allow_list = False

    _query_mapping = cdn_resource.StatisticParameters()

    #: The timestamp marking the start of the query, which is expressed as
    #: milliseconds since 1970-01-01 00:00:00 UTC.
    start_time = resource.Body('start_time')
    #: The timestamp marking the end of the query, which is expressed as
    #: milliseconds since 1970-01-01 00:00:00 UTC.
    end_time = resource.Body('end_time')
    #: The value matching the query.
    value = resource.Body('value')

    def query(self, session, **query):
        """Queries the total network traffic

        :param session: The session to use for making this request.
        :type session: :class:`~openstack.session.Session`
        :param \*\*query: The query parameters. Available parameters include:

            * start_time: The timestamp marking the start of the query.
            * end_time: The timestamp marking the end of the query.
            * domain_name: A domain name list. Use commas (,) to separate
                domain names from each other.
                For example, 'www.test1.com,www.test2.com'.
                The value 'ALL' indicates that all domain names under
                a tenant are queried.

        :returns: The total network traffic matching the query
        :rtype: subclass of :class:`~openstack.cdn.v1.statistic.Statistic`
        """
        endpoint_override = self.service.get_endpoint_override()
        resp = session.get(self.base_path,
                           endpoint_filter=self.service,
                           endpoint_override=endpoint_override,
                           params=query)
        self._translate_response(resp)
        return self
Example #4
0
class StatisticDetail(cdn_resource.Resource):
    base_path = None
    resource_key = None
    resources_key = None
    service = cdn_service.CDNService()

    allow_create = False
    allow_get = False
    allow_update = False
    allow_delete = False
    allow_list = False

    _query_mapping = cdn_resource.StatisticParameters('interval')

    #: The timestamp marking the start of the query, which is expressed as
    #: milliseconds since 1970-01-01 00:00:00 UTC.
    start_time = resource.Body('start_time')
    #: The timestamp marking the end of the query, which is expressed as
    #: milliseconds since 1970-01-01 00:00:00 UTC.
    end_time = resource.Body('end_time')
    #: The granularity of a time span during which the data is monitored.
    #: It is measured by seconds.
    interval = resource.Body('interval', type=int)
    #: The values matching the query.
    values = resource.Body('values', type=list)

    def query(self, session, **query):
        """Queries the detail of the statistic

        :param session: The session to use for making this request.
        :type session: :class:`~openstack.session.Session`
        :param \*\*query: The query parameters. Available parameters include:

        :returns: The statistic data matching the query
        :rtype: subclasses of
                :class:`~openstack.cdn.v1.statistic.StatisticDetail`
        """
        endpoint_override = self.service.get_endpoint_override()
        resp = session.get(self.base_path,
                           endpoint_filter=self.service,
                           endpoint_override=endpoint_override,
                           params=query)
        self._translate_response(resp)
        return self