Destroys given bucket. Raises an S3::Error::BucketNotEmpty
 exception if the bucket is not empty. You can destroy non-empty
 bucket passing true (to force destroy)
179852
def destroy(force = false)
      delete_bucket
      true
    rescue Error::BucketNotEmpty
      if force
        objects.destroy_all
        retry
      else
        raise
      end
    end
398170
def destroy_key attribute, key
      raise "invalid attribute #{attribute}" unless self.class.column_names.include?(attribute.to_s)
      new_value = send(attribute)
      new_value.delete(key.to_s)
      send("#{attribute}=", new_value)
      self
    end
852658
function (req, res) {
                var s3 = new AWS.S3(),
                    bucket = req.params.name,
                    key = getFullKeyParam(req.params, req.route),
                    params = {
                        Bucket: bucket,
                        Delete: {
                            Objects: [{
                                Key: key
                            }]
                        }
                    },
                    
                    handleDeleteObjects = function (err, data) {
                        if (err) {
                            res.status(500).send(err);
                        } else {
                            res.json(data);
                        }
                    };
                s3.deleteObjects(params, handleDeleteObjects);
            }
401622
public static void closeBucket(Bucket bucket)
    {
        if (bucket != null)
        {
            if (!bucket.close())
            {
                LOGGER.error("Not able to close bucket [" + bucket.name() + "].");
                throw new KunderaException("Not able to close bucket [" + bucket.name() + "].");
            }
            else
            {
                LOGGER.debug("Bucket [" + bucket.name() + "] is closed!");
            }
        }
    }
333120
def remove(self):
        
        ''' 
            
        '''
    
        title = '%s.remove' % self.__class__.__name__
    
    # request bucket delete 
        self.s3.delete_bucket(self.bucket_name)

    # return confirmation
        exit_msg = '%s collection has been removed from S3.' % self.bucket_name
        return exit_msg
258568
def destroy(name, conn=None, call=None):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    if not conn:
        conn = get_conn()
    node = show_instance(name, conn=conn, call='action')
    log.info('Destroying VM: %s', name)
    ret = conn.delete_server(name)
    if ret:
        log.info('Destroyed VM: %s', name)
        # Fire destroy action
        __utils__['cloud.fire_event'](
            'event',
            'destroyed instance',
            'salt/cloud/{0}/destroyed'.format(name),
            args={'name': name},
            sock_dir=__opts__['sock_dir'],
            transport=__opts__['transport']
        )
        if __opts__.get('delete_sshkeys', False) is True:
            __utils__['cloud.remove_sshkey'](getattr(node, __opts__.get('ssh_interface', 'public_ips'))[0])
        if __opts__.get('update_cachedir', False) is True:
            __utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)
        __utils__['cloud.cachedir_index_del'](name)
        return True

    log.error('Failed to Destroy VM: %s', name)
    return False
1083182
def delete(bucket, path=None, action=None, key=None, keyid=None,
           service_url=None, verify_ssl=None, kms_keyid=None, location=None,
           role_arn=None, path_style=None, https_enable=None):
    '''
    
    '''
    key, keyid, service_url, verify_ssl, kms_keyid, location, role_arn, path_style, https_enable = _get_key(
        key,
        keyid,
        service_url,
        verify_ssl,
        kms_keyid,
        location,
        role_arn,
        path_style,
        https_enable,
    )

    return __utils__['s3.query'](method='DELETE',
                                 bucket=bucket,
                                 path=path,
                                 action=action,
                                 key=key,
                                 keyid=keyid,
                                 kms_keyid=kms_keyid,
                                 service_url=service_url,
                                 verify_ssl=verify_ssl,
                                 location=location,
                                 role_arn=role_arn,
                                 path_style=path_style,
                                 https_enable=https_enable)
1208610
def destroy(name, call=None):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    response = _query('grid', 'server/delete', args={'name': name})

    __utils__['cloud.fire_event'](
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    if __opts__.get('update_cachedir', False) is True:
        __utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)

    return response
1254774
def reset(self, force):
        """"""
        client = self.create_client()
        bucket = client.lookup_bucket(self.bucket_name)
        if bucket is not None:
            if not force:
                self._log.error("Bucket already exists, aborting.")
                raise ExistingBackendError
            self._log.info("Bucket already exists, deleting all content.")
            for blob in bucket.list_blobs():
                self._log.info("Deleting %s ..." % blob.name)
                bucket.delete_blob(blob.name)
        else:
            client.create_bucket(self.bucket_name)
5600
def destroy(name, call=None):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    vm_properties = [
        "name",
        "summary.runtime.powerState"
    ]

    vm_list = salt.utils.vmware.get_mors_with_properties(_get_si(), vim.VirtualMachine, vm_properties)

    for vm in vm_list:
        if vm["name"] == name:
            if vm["summary.runtime.powerState"] != "poweredOff":
                # Power off the vm first
                try:
                    log.info('Powering Off VM %s', name)
                    task = vm["object"].PowerOff()
                    salt.utils.vmware.wait_for_task(task, name, 'power off')
                except Exception as exc:
                    log.error(
                        'Error while powering off VM %s: %s',
                        name, exc,
                        # Show the traceback if the debug logging level is enabled
                        exc_info_on_loglevel=logging.DEBUG
                    )
                    return 'failed to destroy'
            try:
                log.info('Destroying VM %s', name)
                task = vm["object"].Destroy_Task()
                salt.utils.vmware.wait_for_task(task, name, 'destroy')
            except Exception as exc:
                log.error(
                    'Error while destroying VM %s: %s',
                    name, exc,
                    # Show the traceback if the debug logging level is enabled
                    exc_info_on_loglevel=logging.DEBUG
                )
                return 'failed to destroy'

    __utils__['cloud.fire_event'](
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )
    if __opts__.get('update_cachedir', False) is True:
        __utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)

    return True
1143508
def delete(self, **params):
        
        self.clear()
        self._context = None
        self._set_value(self._default_value())
        self.bucket._client.delete(self, **params)
        return self
310098
def destroy(self):
        

        # if this unit didn't come from fleet, we can't destroy it
        if not self._is_live():
            raise RuntimeError('A unit must be submitted to fleet before it can destroyed.')

        return self._client.destroy_unit(self.name)
242475
def delete_object(self, bucket, object_name):
        
        details = self._details(
            method=b"DELETE",
            url_context=self._url_context(bucket=bucket, object_name=object_name),
        )
        d = self._submit(self._query_factory(details))
        return d
636241
def destroy_all
      if defined?(ActiveRecord)
        if params[:app]
          RailsExceptionHandler::ActiveRecord::ErrorMessage.destroy_all(app_name: params[:app])
        else
          RailsExceptionHandler::ActiveRecord::ErrorMessage.destroy_all
        end
      end
      if defined?(Mongoid)
        if params[:app]
          RailsExceptionHandler::Mongoid::ErrorMessage.where(app_name: params[:app]).destroy
        else
          RailsExceptionHandler::Mongoid::ErrorMessage.all.destroy
        end
      end

      respond_to do |format|
        format.html { redirect_to error_messages_url }
        format.json { head :no_content }
      end
    end
1341007
def destroy(name, call=None):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    data = show_instance(name, call='action')
    node = query(method='droplets', droplet_id=data['id'], http_method='delete')

    ## This is all terribly optomistic:
    # vm_ = get_vm_config(name=name)
    # delete_dns_record = config.get_cloud_config_value(
    #     'delete_dns_record', vm_, __opts__, search_global=False, default=None,
    # )
    # TODO: when _vm config data can be made available, we should honor the configuration settings,
    # but until then, we should assume stale DNS records are bad, and default behavior should be to
    # delete them if we can. When this is resolved, also resolve the comments a couple of lines below.
    delete_dns_record = True

    if not isinstance(delete_dns_record, bool):
        raise SaltCloudConfigError(
            '\'delete_dns_record\' should be a boolean value.'
        )
    # When the "to do" a few lines up is resolved, remove these lines and use the if/else logic below.
    log.debug('Deleting DNS records for %s.', name)
    destroy_dns_records(name)

    # Until the "to do" from line 754 is taken care of, we don't need this logic.
    # if delete_dns_record:
    #    log.debug('Deleting DNS records for %s.', name)
    #    destroy_dns_records(name)
    # else:
    #    log.debug('delete_dns_record : %s', delete_dns_record)
    #    for line in pprint.pformat(dir()).splitlines():
    #       log.debug('delete context: %s', line)

    __utils__['cloud.fire_event'](
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    if __opts__.get('update_cachedir', False) is True:
        __utils__['cloud.delete_minion_cachedir'](name, __active_provider_name__.split(':')[0], __opts__)

    return node
1074946
def empty(Bucket, MFA=None, RequestPayer=None, region=None, key=None,
          keyid=None, profile=None):
    '''
    

    '''

    stuff = list_object_versions(Bucket, region=region, key=key, keyid=keyid,
                                 profile=profile)
    Delete = {}
    Delete['Objects'] = [{'Key': v['Key'], 'VersionId': v['VersionId']} for v in stuff.get('Versions', [])]
    Delete['Objects'] += [{'Key': v['Key'], 'VersionId': v['VersionId']} for v in stuff.get('DeleteMarkers', [])]
    if Delete['Objects']:
        ret = delete_objects(Bucket, Delete, MFA=MFA, RequestPayer=RequestPayer,
                             region=region, key=key, keyid=keyid, profile=profile)
        failed = ret.get('failed', [])
        if failed:
            return {'deleted': False, 'failed': ret[failed]}
    return {'deleted': True}
562100
def remove_s3_bucket():
    """"""
    logger.debug("[#] Removing S3 bucket")
    client = boto3.client("s3", region_name=PRIMARY_REGION)
    buckets = client.list_buckets()
    matches = [x for x in buckets.get('Buckets', list())
               if x['Name'].startswith(S3_BUCKET_NAME)]
    if len(matches) == 0:
        return
    match = matches.pop()['Name']
    try:
        response = client.list_objects_v2(
            Bucket=match,
        )
    except client.exceptions.NoSuchBucket:
        logger.info("[!] S3 bucket already deleted")
        return True

    while response['KeyCount'] > 0:
        logger.debug('[*] Deleting %d objects from bucket %s'
                     % (len(response['Contents']), match))
        response = client.delete_objects(
            Bucket=match,
            Delete={
                'Objects': [{'Key': obj['Key']} for obj in response['Contents']]
            }
        )
        response = client.list_objects_v2(
            Bucket=match,
        )

    logger.debug('[#] Deleting bucket %s' % match)
    response = client.delete_bucket(
        Bucket=match
    )
    logger.info("[#] Successfully deleted the S3 bucket")

    return response