Remove all foremast-* permissions from lambda.

    Args:
        app_name (str): Application name
        env (str): AWS environment
        region (str): AWS region
195704
def remove_all_lambda_permissions(app_name='', env='', region='us-east-1'):
    
    session = boto3.Session(profile_name=env, region_name=region)
    lambda_client = session.client('lambda')
    legacy_prefix = app_name + "_"

    lambda_arn = get_lambda_arn(app_name, env, region)
    lambda_alias_arn = get_lambda_alias_arn(app_name, env, region)
    arns = (lambda_arn, lambda_alias_arn)

    for arn in arns:
        try:
            response = lambda_client.get_policy(FunctionName=arn)
        except boto3.exceptions.botocore.exceptions.ClientError as error:
            LOG.info("No policy exists for function %s, skipping deletion", arn)
            LOG.debug(error)
            continue

        policy_json = json.loads(response['Policy'])
        LOG.debug("Found Policy: %s", response)
        for perm in policy_json['Statement']:
            if perm['Sid'].startswith(FOREMAST_PREFIX) or perm['Sid'].startswith(legacy_prefix):
                lambda_client.remove_permission(FunctionName=arn, StatementId=perm['Sid'])
                LOG.info('removed permission: %s', perm['Sid'])
            else:
                LOG.info('Skipping deleting permission %s - Not managed by Foremast', perm['Sid'])
457079
def strip_app_metadata(template_dict):
    
    if SERVERLESS_REPO_APPLICATION not in template_dict.get(METADATA, {}):
        return template_dict

    template_dict_copy = copy.deepcopy(template_dict)

    # strip the whole metadata section if SERVERLESS_REPO_APPLICATION is the only key in it
    if not [k for k in template_dict_copy.get(METADATA) if k != SERVERLESS_REPO_APPLICATION]:
        template_dict_copy.pop(METADATA, None)
    else:
        template_dict_copy.get(METADATA).pop(SERVERLESS_REPO_APPLICATION, None)

    return template_dict_copy
971158
def destroy_cloudwatch_event(app='', env='dev', region=''):
    

    session = boto3.Session(profile_name=env, region_name=region)
    cloudwatch_client = session.client('events')

    event_rules = get_cloudwatch_event_rule(app_name=app, account=env, region=region)

    for rule in event_rules:
        cloudwatch_client.remove_targets(Rule=rule, Ids=[app])

    return True
653331
public void removeRoleToWarningMapping(String appName) {
        Map<String, Boolean> roleToWarningMap = roleToWarningMappingPerApp.get(appName);
        if (roleToWarningMap != null) {
            roleToWarningMap.clear();
        }
        roleToWarningMappingPerApp.remove(appName);
    }
335597
def init_app(self, app):
        
        app.scoped_session = self

        @app.teardown_appcontext
        def remove_scoped_session(*args, **kwargs):
            # pylint: disable=missing-docstring,unused-argument,unused-variable
            app.scoped_session.remove()
632444
public void remove(String applicationName, Class<?> robotContext, boolean verbose) {
        logger.info("Remove application named [{}].", applicationName);
        removeApplicationPages(applicationName, robotContext, verbose);
        removeApplicationSteps(applicationName, robotContext, verbose);
        removeApplicationModel(applicationName, robotContext, verbose);
        removeApplicationContext(robotContext, applicationName, verbose);
        removeApplicationSelector(applicationName, verbose);
        removeApplicationInPropertiesFile(applicationName, robotContext.getSimpleName().replaceAll("Context", ""), verbose);
        removeApplicationInEnvPropertiesFile(applicationName, "ci", verbose);
        removeApplicationInEnvPropertiesFile(applicationName, "dev", verbose);
        removeApplicationInEnvPropertiesFile(applicationName, "prod", verbose);
    }
1008881
def delete_app_id(self, app_id, mount_point='app-id'):
        
        return self._adapter.delete('/v1/auth/{0}/map/app-id/{1}'.format(mount_point, app_id))
1162849
def security_cleanup(app, appbuilder):
    
    _appbuilder = import_application(app, appbuilder)
    _appbuilder.security_cleanup()
    click.echo(click.style("Finished security cleanup", fg="green"))
200096
def remove_supervisor_app(app_name):
    """"""

    app = u'/etc/supervisor/conf.d/%s.conf' % app_name
    if files.exists(app):
        sudo(u'rm %s' % app)
        supervisor_command(u'update')
1369621
def gpg_unstash_key( appname, key_id, config_dir=None, gpghome=None ):
    

    assert is_valid_appname(appname)
    if gpghome is None:
        config_dir = get_config_dir( config_dir )
        keydir = get_gpg_home( appname, config_dir=config_dir )
    else:
        keydir = gpghome

    gpg = gnupg.GPG( homedir=keydir )
    res = gpg.delete_keys( [key_id] )
    if res.status == 'Must delete secret key first':
        # this is a private key 
        res = gpg.delete_keys( [key_id], secret=True )

    try:
        assert res.status == 'ok', "Failed to delete key (%s)" % res
    except AssertionError, e:
        log.exception(e)
        log.error("Failed to delete key '%s'" % key_id)
        log.debug("res: %s" % res.__dict__)
        return False

    return True
353114
def find_applications_by_app_name(app_name)
      pids = []

      begin
        x = `ps auxw | grep -v grep | awk '{print $2, $11, $12}' | grep #{app_name}`
        if x && x.chomp!
          processes = x.split(/\n/).compact
          processes = processes.delete_if do |p|
            _pid, name, add = p.split(/\s/)
            # We want to make sure that the first part of the process name matches
            # so that app_name matches app_name_22

            app_name != name[0..(app_name.length - 1)] and not add.include?(app_name)
          end
          pids = processes.map { |p| p.split(/\s/)[0].to_i }
        end
        rescue ::Exception
      end

      pids.map do |f|
        app = Application.new(self, {}, PidMem.existing(f))
        setup_app(app)
        app
      end
    end
777468
function() {
								jQuery.each(req.apps, function(idx, item) {
									item.name = item.name || item.appId;
									F2.log('Removed failed ' + item.name + ' app', item);
									F2.AppHandlers.__trigger(
										_sAppHandlerToken,
										F2.Constants.AppHandlers.APP_MANIFEST_REQUEST_FAIL,
										item // the app config
									);
									F2.removeApp(item.instanceId);
								});
							}
774246
def secured_apps_copy(self, apps):
        
        return [[app_name, path] for app_name, path in apps if
                app_name not in (self.LETSENCRYPT_VERIFY_APP_NAME,)]
645614
def _can_process_application(self, app):
        
        return (self.LOCATION_KEY in app.properties and
                isinstance(app.properties[self.LOCATION_KEY], dict) and
                self.APPLICATION_ID_KEY in app.properties[self.LOCATION_KEY] and
                self.SEMANTIC_VERSION_KEY in app.properties[self.LOCATION_KEY])
40663
function foward(app, options) {
  if (typeof options.name === 'string') {
    app.name = options.name;
    delete options.name;
  }
  Scaffold.emit('scaffold', app);
  emit('target', app, Scaffold);
  emit('files', app, Scaffold);
}
525349
def remove_environment(self, name=None, path=None, **kwargs):
        
        return self.remove(name=name, path=path, all=True, **kwargs)
1133569
def delete_app_info(app_id):
    
    try:
        conn = get_conn()
        c = conn.cursor()
        c.execute("DELETE FROM container WHERE app_id='{0}'".format(app_id))
        c.execute("DELETE FROM app WHERE id='{0}'".format(app_id))
        conn.commit()
        #print 'clear old app %s in db succeed!' % app_id
    except Exception, e:
        raise RuntimeError('clear old app %s in db failed! %s' % (app_id,e))