'Lists the usage details for a scope in reverse chronological order by
billing period. Usage details are available via this API only for
January 1, 2017 or later.
:param scope: The scope of the usage details. The scope can be
\'/subscriptions/{subscriptionId}\' for a subscription, or
\'/subscriptions/{subscriptionId}/providers/Microsoft.Billing/invoices/{invoiceName}\'
for an invoice or
\'/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}\'
for a billing perdiod.
:type scope: str
:param expand: May be used to expand the additionalProperties or
meterDetails property within a list of usage details. By default,
these fields are not included when listing usage details.
:type expand: str
:param filter: May be used to filter usageDetails by usageEnd (Utc
time). The filter supports \'eq\', \'lt\', \'gt\', \'le\', \'ge\', and \'and\'. It
does not currently support \'ne\', \'or\', or \'not\'.
:type filter: str
:param skiptoken: Skiptoken is only used if a previous operation
returned a partial result. If a previous response contains a nextLink
element, the value of the nextLink element will include a skiptoken
parameter that specifies a starting point to use for subsequent calls.
:type skiptoken: str
:param top: May be used to limit the number of results to the most
recent N usageDetails.
:type top: int
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: :class:`UsageDetailPaged
<azure.mgmt.consumption.models.UsageDetailPaged>`
:raises:
:class:`ErrorResponseException<azure.mgmt.consumption.models.ErrorResponseException>`'

def list(self, scope, expand=None, filter=None, skiptoken=None, top=None, custom_headers=None, raw=False, **operation_config):

    def internal_paging(next_link=None, raw=False):
        if (not next_link):
            url = '/{scope}/providers/Microsoft.Consumption/usageDetails'
            path_format_arguments = {'scope': self._serialize.url('scope', scope, 'str', skip_quote=True)}
            url = self._client.format_url(url, **path_format_arguments)
            query_parameters = {}
            if (expand is not None):
                query_parameters['$expand'] = self._serialize.query('expand', expand, 'str')
            if (filter is not None):
                query_parameters['$filter'] = self._serialize.query('filter', filter, 'str')
            if (skiptoken is not None):
                query_parameters['$skiptoken'] = self._serialize.query('skiptoken', skiptoken, 'str')
            if (top is not None):
                query_parameters['$top'] = self._serialize.query('top', top, 'int', maximum=1000, minimum=1)
            query_parameters['api-version'] = self._serialize.query('self.api_version', self.api_version, 'str')
        else:
            url = next_link
            query_parameters = {}
        header_parameters = {}
        header_parameters['Content-Type'] = 'application/json;    charset=utf-8'
        if self.config.generate_client_request_id:
            header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
        if custom_headers:
            header_parameters.update(custom_headers)
        if (self.config.accept_language is not None):
            header_parameters['accept-language'] = self._serialize.header('self.config.accept_language', self.config.accept_language, 'str')
        request = self._client.get(url, query_parameters)
        response = self._client.send(request, header_parameters, **operation_config)
        if (response.status_code not in [200]):
            raise models.ErrorResponseException(self._deserialize, response)
        return response
    deserialized = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies)
    if raw:
        header_dict = {}
        client_raw_response = models.UsageDetailPaged(internal_paging, self._deserialize.dependencies, header_dict)
        return client_raw_response
    return deserialized
