def _update_usage_plan_apis(plan_id, apis, op, region=None, key=None, keyid=None, profile=None):
 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': salt.utils.boto3.get_error(e)}
 except Exception as e:
  return {'error': e}

def _update_usage_plan_apis ( plan_id , apis , op , region = None , key = None , keyid = None , profile = None ) : 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' : salt . utils . boto3 . get_error ( e ) } except Exception as e : return { 'error' : e }
helper function that updates the usage plan identified by plan_id by adding or removing it to each of the stages .