# Path: lamvery/clients/base.py
# class BaseClient:
# 
#     __metaclass__ = ABCMeta
# 
#     def __init__(self, region=None, profile=None, dry_run=False):
#         self._session = boto3.session.Session(
#             profile_name=profile, region_name=region)
#         self._dry_run = dry_run
#         self._sts = self._session.client('sts')
# 
#     def get_account_id(self):
#         return self._sts.get_caller_identity().get('Account')
# 
# Path: lamvery/utils.py
# def previous_alias(alias):
#     return '{}-pre'.format(alias)


import botocore
import hashlib
import lamvery.config
from lamvery.clients.base import BaseClient
from lamvery.utils import previous_alias

    def remove_permission(self, function, alias, rule):
        kwargs = {}
        kwargs['FunctionName'] = function
        kwargs['StatementId'] = self._generate_statement_id(function, rule, alias)

        if alias is not None:
            kwargs['Qualifier'] = alias

        if not self._dry_run:
            self._lambda.remove_permission(**kwargs)

    def _generate_statement_id(self, function, rule, alias):
        return hashlib.sha256(
            'lamvery-{}-{}-{}'.format(function, rule, alias)).hexdigest()

    def invoke(self, name, qualifier=None, payload=None):
        kwargs = {}
        kwargs['FunctionName'] = name
        kwargs['InvocationType'] = 'RequestResponse'
        kwargs['LogType'] = 'Tail'

        if payload is not None:
            kwargs['Payload'] = payload
        if qualifier is not None:
            kwargs['Qualifier'] = qualifier

        return self._lambda.invoke(**kwargs)

    def get_previous_version(self, function, alias):

# Path: lamvery/clients/base.py
# class BaseClient:
# 
#     __metaclass__ = ABCMeta
# 
#     def __init__(self, region=None, profile=None, dry_run=False):
#         self._session = boto3.session.Session(
#             profile_name=profile, region_name=region)
#         self._dry_run = dry_run
#         self._sts = self._session.client('sts')
# 
#     def get_account_id(self):
#         return self._sts.get_caller_identity().get('Account')
# 
# Path: lamvery/utils.py
# def previous_alias(alias):
#     return '{}-pre'.format(alias)


# Path: lamvery/clients/function.py
import botocore
import hashlib
import lamvery.config
from lamvery.clients.base import BaseClient
from lamvery.utils import previous_alias


    def remove_permission(self, function, alias, rule):
        kwargs = {}
        kwargs['FunctionName'] = function
        kwargs['StatementId'] = self._generate_statement_id(function, rule, alias)

        if alias is not None:
            kwargs['Qualifier'] = alias

        if not self._dry_run:
            self._lambda.remove_permission(**kwargs)

    def _generate_statement_id(self, function, rule, alias):
        return hashlib.sha256(
            'lamvery-{}-{}-{}'.format(function, rule, alias)).hexdigest()

    def invoke(self, name, qualifier=None, payload=None):
        kwargs = {}
        kwargs['FunctionName'] = name
        kwargs['InvocationType'] = 'RequestResponse'
        kwargs['LogType'] = 'Tail'

        if payload is not None:
            kwargs['Payload'] = payload
        if qualifier is not None:
            kwargs['Qualifier'] = qualifier

        return self._lambda.invoke(**kwargs)

    def get_previous_version(self, function, alias):

        ver = self.get_alias(function, previous_alias(alias))