Helper function that updates the usage plan identified by plan_id by adding or removing it to each of the stages, specified by apis parameter.

    apis
        a list of dictionaries, where each dictionary contains the following:

        apiId
            a string, which is the id of the created API in AWS ApiGateway

        stage
            a string, which is the stage that the created API is deployed to.

    op
        'add' or 'remove'

def _update_usage_plan_apis(plan_id, apis, op, region=None, key=None, keyid=None, profile=None):
    '''
    Helper function that updates the usage plan identified by plan_id by adding or removing it to each of the stages, specified by apis parameter.

    apis
        a list of dictionaries, where each dictionary contains the following:

        apiId
            a string, which is the id of the created API in AWS ApiGateway

        stage
            a string, which is the stage that the created API is deployed to.

    op
        'add' or 'remove'
    '''
    try:
        patchOperations = []
        for api in apis:
            patchOperations.append({
                                    'op': op,
                                    'path': '/apiStages',
                                    'value': '{0}:{1}'.format(api['apiId'], api['stage'])
                                   })
        res = None
        if patchOperations:
            conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
            res = conn.update_usage_plan(usagePlanId=plan_id,
                                         patchOperations=patchOperations)
        return {'success': True, 'result': res}
    except ClientError as e:
        return {'error': __utils__['boto3.get_error'](e)}
    except Exception as e:
        return {'error': e}