Source

cloudster / api / shelf / configuration / accounts.py

Full commit
import os
from api.shelf.registry.clients import StorageClientsRegistry

import simplejson as json
from api.shelf.configuration import config

__author__ = 'guillermo'



class AccountsManager():

    def __init__(self, client_class):
        self.__client_class = client_class
        self.__account_type_class = self.__client_class.registry_metadata().account_type_class()

    def get_configuration_descriptor(self):
        return self.__account_type_class.get_configuration_fields()

    def create(self, account_config_values):
        return self.__account_type_class(json.dumps(account_config_values))

    def authorize(self, account_data):
        print 'Connects using account info and expected adapter in order to authorize our application and return new account data'

    def load(self, id=None):
        pass

    def save(self, account_data):

        filename= self.__client_class.registry_metadata().unique_id() + "_" + account_data.unique_id() + ".json"
        account_data.save(os.path.join(config.ConfigurationManager.APP_INSTANCES_PATH, filename))

    def delete(self, id=None):
        pass