File: Account.py

package info (click to toggle)
python-digitalocean 1.16.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 912 kB
  • sloc: python: 4,961; makefile: 46
file content (35 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
from .baseapi import BaseAPI


class Account(BaseAPI):
    def __init__(self, *args, **kwargs):
        self.droplet_limit = None
        self.floating_ip_limit = None
        self.email = None
        self.uuid = None
        self.email_verified = None
        self.status = None
        self.status_message = None

        super(Account, self).__init__(*args, **kwargs)

    @classmethod
    def get_object(cls, api_token):
        """
            Class method that will return an Account object.
        """
        acct = cls(token=api_token)
        acct.load()
        return acct

    def load(self):
        # URL https://api.digitalocean.com/v2/account
        data = self.get_data("account/")
        account = data['account']

        for attr in account.keys():
            setattr(self, attr, account[attr])

    def __str__(self):
        return "%s" % (self.email)