Exemple #1
0
 def make_delete_schema(self) -> BlockchainAccountsDeleteSchema:
     return BlockchainAccountsDeleteSchema(
         self.rest_api.rotkehlchen.chain_manager.ethereum, )
Exemple #2
0
class BlockchainsAccountsResource(BaseResource):

    get_schema = BlockchainAccountsGetSchema()
    put_schema = BlockchainAccountsPutSchema()
    patch_schema = BlockchainAccountsPatchSchema()
    delete_schema = BlockchainAccountsDeleteSchema()

    @use_kwargs(get_schema, locations=('view_args',))
    def get(self, blockchain: SupportedBlockchain) -> Response:
        return self.rest_api.get_blockchain_accounts(blockchain)

    @use_kwargs(put_schema, locations=('json', 'view_args'))
    def put(
            self,
            blockchain: SupportedBlockchain,
            accounts: List[Dict[str, str]],
            async_query: bool,
    ) -> Response:
        account_data = [
            BlockchainAccountData(
                address=entry['address'],
                label=entry['label'],
                tags=entry['tags'],
            ) for entry in accounts
        ]
        return self.rest_api.add_blockchain_accounts(
            blockchain=blockchain,
            account_data=account_data,
            async_query=async_query,
        )

    @use_kwargs(patch_schema, locations=('json', 'view_args'))
    def patch(
            self,
            blockchain: SupportedBlockchain,
            accounts: List[Dict[str, str]],
    ) -> Response:
        account_data = [
            BlockchainAccountData(
                address=entry['address'],
                label=entry['label'],
                tags=entry['tags'],
            ) for entry in accounts
        ]
        return self.rest_api.edit_blockchain_accounts(
            blockchain=blockchain,
            account_data=account_data,
        )

    @use_kwargs(delete_schema, locations=('json', 'view_args'))
    def delete(
            self,
            blockchain: SupportedBlockchain,
            accounts: ListOfBlockchainAddresses,
            async_query: bool,
    ) -> Response:
        return self.rest_api.remove_blockchain_accounts(
            blockchain=blockchain,
            accounts=accounts,
            async_query=async_query,
        )