Destroy IAM Resources.

    Args:
        app (str): Spinnaker Application name.
        env (str): Deployment environment, i.e. dev, stage, prod.

    Returns:
        True upon successful completion.
494196
def destroy_iam(app='', env='dev', **_):
    
    session = boto3.Session(profile_name=env)
    client = session.client('iam')

    generated = get_details(env=env, app=app)
    generated_iam = generated.iam()
    app_details = collections.namedtuple('AppDetails', generated_iam.keys())
    details = app_details(**generated_iam)

    LOG.debug('Application details: %s', details)

    resource_action(
        client,
        action='remove_user_from_group',
        log_format='Removed user from group: %(UserName)s ~> %(GroupName)s',
        GroupName=details.group,
        UserName=details.user)
    resource_action(client, action='delete_user', log_format='Destroyed user: %(UserName)s', UserName=details.user)
    resource_action(client, action='delete_group', log_format='Destroyed group: %(GroupName)s', GroupName=details.group)

    resource_action(
        client,
        action='remove_role_from_instance_profile',
        log_format='Destroyed Instance Profile from Role: '
        '%(InstanceProfileName)s ~> %(RoleName)s',
        InstanceProfileName=details.profile,
        RoleName=details.role)
    resource_action(
        client,
        action='delete_instance_profile',
        log_format='Destroyed Instance Profile: %(InstanceProfileName)s',
        InstanceProfileName=details.profile)

    role_policies = []
    try:
        role_policies = resource_action(
            client,
            action='list_role_policies',
            log_format='Found Role Policies for %(RoleName)s.',
            RoleName=details.role)['PolicyNames']
    except TypeError:
        LOG.info('Role %s not found.', details.role)

    for policy in role_policies:
        resource_action(
            client,
            action='delete_role_policy',
            log_format='Removed Inline Policy from Role: '
            '%(PolicyName)s ~> %(RoleName)s',
            RoleName=details.role,
            PolicyName=policy)

    attached_role_policies = []
    try:
        attached_role_policies = resource_action(
            client,
            action='list_attached_role_policies',
            log_format='Found attached Role Polices for %(RoleName)s.',
            RoleName=details.role)['AttachedPolicies']
    except TypeError:
        LOG.info('Role %s not found.', details.role)

    for policy in attached_role_policies:
        resource_action(
            client,
            action='detach_role_policy',
            log_format='Detached Policy from Role: '
            '%(PolicyArn)s ~> %(RoleName)s',
            RoleName=details.role,
            PolicyArn=policy['PolicyArn'])

    resource_action(client, action='delete_role', log_format='Destroyed Role: %(RoleName)s', RoleName=details.role)
230331
def close(self):
        """"""
        # make sure the environment hasn't already been closed
        if self._env is None:
            raise ValueError('env has already been closed.')
        # purge the environment from C++ memory
        _LIB.Close(self._env)
        # deallocate the object locally
        self._env = None
        # if there is an image viewer open, delete it
        if self.viewer is not None:
            self.viewer.close()
102928
def call(env)
      begin
        if running? && !path_ignored?(env)
          transaction = start_transaction(env)
        end

        resp = @app.call env
      rescue InternalError
        raise # Don't report ElasticAPM errors
      rescue ::Exception => e
        context = ElasticAPM.build_context(rack_env: env, for_type: :error)
        ElasticAPM.report(e, context: context, handled: false)
        raise
      ensure
        if resp && transaction
          status, headers, _body = resp
          transaction.add_response(status, headers: headers.dup)
        end

        ElasticAPM.end_transaction http_result(status)
      end

      resp
    end
636240
function(app, args) {
  app.set(Constants.RESERVED.ENV, args.env || process.env.NODE_ENV || Constants.RESERVED.ENV_DEV, true);
}
1226269
def destroy_sg(app='', env='', region='', **_):
    
    vpc = get_vpc_id(account=env, region=region)

    url = '{api}/securityGroups/{env}/{region}/{app}'.format(api=API_URL, env=env, region=region, app=app)
    payload = {'vpcId': vpc}
    security_group = requests.get(url, params=payload, verify=GATE_CA_BUNDLE, cert=GATE_CLIENT_CERT)

    if not security_group:
        LOG.info('Nothing to delete.')
    else:
        LOG.info('Found Security Group in %(region)s: %(name)s', security_group)

        destroy_request = get_template('destroy/destroy_sg.json.j2', app=app, env=env, region=region, vpc=vpc)
        wait_for_task(destroy_request)

    return True
289040
def destroy(self):
        
        # if this is the main_app - set the _main_app class variable to `None`.
        if self == App._main_app:
            App._main_app = None
        self.tk.destroy()
959035
def app_delete(self, id, **kwargs):
        ""
        api_path = "/api/v2/apps/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, method="DELETE", **kwargs)
55799
def init_app(self, app, env_file=None, verbose_mode=False):
        """"""
        if self.app is None:
            self.app = app
        self.verbose_mode = verbose_mode

        if env_file is None:
            env_file = os.path.join(os.getcwd(), ".env")
        if not os.path.exists(env_file):
            warnings.warn("can't read {0} - it doesn't exist".format(env_file))
        else:
            self.__import_vars(env_file)
833242
def remove_environment(project_root, environment_name)
      # Check if the environment exist
      return error(_('wizard.environment.name_not_exist')%{environment: environment_name}) unless Bebox::Environment.environment_exists?(project_root, environment_name)
      # Confirm deletion
      return warn(_('wizard.no_changes')) unless confirm_action?(_('wizard.environment.confirm_deletion'))
      # Environment deletion
      environment = Bebox::Environment.new(environment_name, project_root)
      output = environment.remove
      ok _('wizard.environment.deletion_success')
      return output
    end
770627
def deactivate(self):
        
        try:
            self.phase = PHASE.DEACTIVATE
            self.logger.info("Deactivating environment %s..." % self.namespace)
            self.directory.rewrite_config = False
            self.instantiate_features()
            self._specialize()
            for feature in self.features.run_order:
                self.logger.info("Deactivating %s..." % feature[0])
                self.run_action(feature, 'deactivate')
            self.clear_all()
            self._finalize()
        except Exception:
            self.logger.debug("", exc_info=sys.exc_info())
            et, ei, tb = sys.exc_info()
            reraise(et, ei, tb)
1332276
def reset_env(exclude=[]):
    """"""
    if os.getenv(env.INITED):
        wandb_keys = [key for key in os.environ.keys() if key.startswith(
            'WANDB_') and key not in exclude]
        for key in wandb_keys:
            del os.environ[key]
        return True
    else:
        return False
970279
def call(env)
      result = @app.call(env)

      if result.first == 404 &&
          env['REQUEST_METHOD'] == 'GET' &&
          env['PATH_INFO'] == logout_path(env)
        ::Rack::Response.new('You have been logged out.', 200).finish
      else
        result
      end
    end
381390
def remove(self):
        
        try:
            self.phase = PHASE.REMOVE
            self.logger.info("Removing environment %s..." % self.namespace)
            self.instantiate_features()
            self._specialize()
            for feature in self.features.run_order:
                try:
                    self.run_action(feature, 'sync')
                except FormulaException:
                    # continue trying to remove any remaining features.
                    pass
            self.clear_all()
            self.directory.remove()
            self.injections.commit()
            if self.error_occured:
                self.logger.error(warning_template)
                self.logger.error(REMOVE_WARNING)
        except Exception:
            self.logger.debug("", exc_info=sys.exc_info())
            et, ei, tb = sys.exc_info()
            reraise(et, ei, tb)
650409
def environment_failure(self, error):
        '''
        
        '''
        log.exception(
            'Failed to create environment for %s: %s',
            self.__class__.__name__, get_error_message(error)
        )
        self.shutdown(error)
595017
public void destroyingApplication(JPAApplInfo applInfo)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "destroyingApplication : " + applInfo.getApplName());

        applInfo.closeAllScopeModules();
        applList.remove(applInfo.getApplName()); // d643462

        if (isTraceOn && tc.isDebugEnabled())
            Tr.debug(tc, "Current application list : " + getSortedAppNames());

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "destroyingApplication : " + applInfo.getApplName());
    }
928402
async def destroy_unit(self, *unit_names):
        
        connection = self.connection()
        app_facade = client.ApplicationFacade.from_connection(connection)

        log.debug(
            'Destroying unit%s %s',
            's' if len(unit_names) == 1 else '',
            ' '.join(unit_names))

        return await app_facade.DestroyUnits(list(unit_names))
1147240
public function bootstrap(Application $app)
    {
        try
        {
            Dotenv::makeMutable();
            Dotenv::load($app->environmentPath(), $app->environmentFile());
            Dotenv::makeImmutable();
        } catch (InvalidArgumentException $e)
        {
            //
        }

        $app->detectEnvironment(
            function ()
            {
                return env('APP_ENV', 'production');
            }
        );
    }