Skip to content

Commit 5ca98c4

Browse files
authored
Merge pull request #1 from outscale-dev/osc_provider_new_accounts_features
Add new accounts features for outscale provider
2 parents 3cceb9c + fd5991b commit 5ca98c4

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

docs/compute/drivers/outscale.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Accounts
130130
* ``ex_send_reset_password_email`` - Returns a ``bool``
131131
* ``ex_create_account`` - Returns a ``bool``
132132
* ``ex_update_account`` - Returns a ``dict``
133+
* ``ex_list_consumption_account`` - Returns a ``list`` of ``dict``
133134

134135
Tags
135136
----

libcloud/compute/drivers/outscale.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,45 @@ def ex_read_account(self, dry_run: bool = False):
13251325
data = json.dumps({"DryRun": dry_run})
13261326
return self._call_api(action, data).json()["Accounts"][0]
13271327

1328+
def ex_list_consumption_account(
1329+
self,
1330+
from_date: str = None,
1331+
to_date: str = None,
1332+
dry_run: bool = False
1333+
):
1334+
"""
1335+
Displays information about the consumption of your account for
1336+
each billable resource within the specified time period.
1337+
1338+
1339+
:param from_date: The beginning of the time period, in
1340+
ISO 8601 date-time format (for example, 2017-06-14 or
1341+
2017-06-14T00:00:00Z). (required)
1342+
:type from_date: ``str``
1343+
1344+
:param to_date: The end of the time period, in
1345+
ISO 8601 date-time format (for example, 2017-06-30 or
1346+
2017-06-30T00:00:00Z). (required)
1347+
:type to_date: ``str``
1348+
1349+
:param dry_run: If true, checks whether you have the required
1350+
permissions to perform the action.
1351+
:type dry_run: ``bool``
1352+
1353+
:return: a list of Consumption Entries
1354+
:rtype: ``list`` of ``dict``
1355+
"""
1356+
action = "ReadConsumptionAccount"
1357+
data = {"DryRun": dry_run}
1358+
if from_date is not None:
1359+
data.update({"FromDate": from_date})
1360+
if to_date is not None:
1361+
data.update({"ToDate": to_date})
1362+
response = self._call_api(action, json.dumps(data))
1363+
if response.status_code == 200:
1364+
return response.json()["ConsumptionEntries"]
1365+
return response.json()
1366+
13281367
def ex_create_account(
13291368
self,
13301369
city: str = None,

0 commit comments

Comments
 (0)