Feilong Wang 33226737b0 Support /credits API
Currently, Distil supports getting credits of current user. This
patch adds the support for Distil client and test cases are added
together.

Change-Id: Ibbfd4858d205f78de7a3cda8748b130151a1e266
2017-06-20 11:57:00 +12:00

33 lines
1.1 KiB
Python

# Copyright 2017 Catalyst IT Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from distilclient import base
class CreditManager(base.Manager):
def list(self, project_id=None):
"""Retrieve a list of credits.
:param project_id: Project ID, there there is no project id given,
Distil will use the project ID from token.
:returns: A list of credits.
"""
url = "/v2/credits"
if project_id:
url = url + "?project_id=" + project_id
return self._list(url, "credits")