// DeleteBucket deletes a bucket and prunes it from the index.
354309
func (c *Client) DeleteBucket(ctx context.Context, id platform.ID) error {
	return c.db.Update(func(tx *bolt.Tx) error {
		var err error
		if pe := c.deleteBucket(ctx, tx, id); pe != nil {
			pe.Op = getOp(platform.OpDeleteBucket)
			err = pe
		}
		return err
	})
}
407943
func (s *DeleteBucketTaggingInput) SetBucket(v string) *DeleteBucketTaggingInput {
	s.Bucket = &v
	return s
}
1080596
func (s *GetObjectRetentionInput) SetBucket(v string) *GetObjectRetentionInput {
	s.Bucket = &v
	return s
}
66879
func (s *DeleteObjectInput) SetBucket(v string) *DeleteObjectInput {
	s.Bucket = &v
	return s
}
349469
func deleteBuckets(ns walletdb.ReadWriteBucket) error {
	if err := ns.DeleteNestedBucket(bucketBlocks); err != nil {
		str := "failed to delete blocks bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketTxRecords); err != nil {
		str := "failed to delete tx records bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketCredits); err != nil {
		str := "failed to delete credits bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketDebits); err != nil {
		str := "failed to delete debits bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketUnspent); err != nil {
		str := "failed to delete unspent bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketUnmined); err != nil {
		str := "failed to delete unmined bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketUnminedCredits); err != nil {
		str := "failed to delete unmined credits bucket"
		return storeError(ErrDatabase, str, err)
	}
	if err := ns.DeleteNestedBucket(bucketUnminedInputs); err != nil {
		str := "failed to delete unmined inputs bucket"
		return storeError(ErrDatabase, str, err)
	}

	return nil
}
703883
func (s *GetBucketLifecycleConfigurationInput) SetBucket(v string) *GetBucketLifecycleConfigurationInput {
	s.Bucket = &v
	return s
}
980553
func (s *PutBucketReplicationInput) SetBucket(v string) *PutBucketReplicationInput {
	s.Bucket = &v
	return s
}
402880
func (bk *Backend) DeleteBucket(parent []string, bucket string) error {
	fullBucket := append(parent, bucket)

	err := os.Remove(bk.flatten(fullBucket))
	if err != nil {
		return trace.ConvertSystemError(err)
	}

	return nil
}
500374
func (s *GetObjectLockConfigurationInput) SetBucket(v string) *GetObjectLockConfigurationInput {
	s.Bucket = &v
	return s
}
1164985
func (s *DeleteBucketMetricsConfigurationInput) SetBucket(v string) *DeleteBucketMetricsConfigurationInput {
	s.Bucket = &v
	return s
}
635549
func (xl xlObjects) DeleteBucket(ctx context.Context, bucket string) error {
	bucketLock := xl.nsMutex.NewNSLock(bucket, "")
	if err := bucketLock.GetLock(globalObjectTimeout); err != nil {
		return err
	}
	defer bucketLock.Unlock()

	// Collect if all disks report volume not found.
	var wg = &sync.WaitGroup{}
	var dErrs = make([]error, len(xl.getDisks()))

	// Remove a volume entry on all underlying storage disks.
	storageDisks := xl.getDisks()
	for index, disk := range storageDisks {
		if disk == nil {
			dErrs[index] = errDiskNotFound
			continue
		}
		wg.Add(1)
		// Delete volume inside a go-routine.
		go func(index int, disk StorageAPI) {
			defer wg.Done()
			// Attempt to delete bucket.
			err := disk.DeleteVol(bucket)
			if err != nil {
				dErrs[index] = err
				return
			}

			// Cleanup all the previously incomplete multiparts.
			err = cleanupDir(ctx, disk, minioMetaMultipartBucket, bucket)
			if err != nil && err != errVolumeNotFound {
				dErrs[index] = err
			}
		}(index, disk)
	}

	// Wait for all the delete vols to finish.
	wg.Wait()

	writeQuorum := len(xl.getDisks())/2 + 1
	err := reduceWriteQuorumErrs(ctx, dErrs, bucketOpIgnoredErrs, writeQuorum)
	if err == errXLWriteQuorum {
		xl.undoDeleteBucket(bucket)
	}
	if err != nil {
		return toObjectErr(err, bucket)
	}

	// If we reduce quorum to nil, means we have deleted buckets properly
	// on some servers in quorum, we should look for volumeNotEmpty errors
	// and delete those buckets as well.
	deleteDanglingBucket(ctx, storageDisks, dErrs, bucket)

	return nil
}
503740
func (s *xlSets) DeleteBucket(ctx context.Context, bucket string) error {
	g := errgroup.WithNErrs(len(s.sets))

	// Delete buckets in parallel across all sets.
	for index := range s.sets {
		index := index
		g.Go(func() error {
			return s.sets[index].DeleteBucket(ctx, bucket)
		}, index)
	}

	errs := g.Wait()
	// For any write quorum failure, we undo all the delete buckets operation
	// by creating all the buckets again.
	for _, err := range errs {
		if err != nil {
			if _, ok := err.(InsufficientWriteQuorum); ok {
				undoDeleteBucketSets(bucket, s.sets, errs)
			}
			return err
		}
	}

	// Delete all bucket metadata.
	deleteBucketMetadata(ctx, bucket, s)

	// Success.
	return nil
}
247196
func (s *SelectObjectContentInput) SetBucket(v string) *SelectObjectContentInput {
	s.Bucket = &v
	return s
}
463638
func (s *PutBucketAccelerateConfigurationInput) SetBucket(v string) *PutBucketAccelerateConfigurationInput {
	s.Bucket = &v
	return s
}
898782
func (s *DeleteObjectTaggingInput) SetBucket(v string) *DeleteObjectTaggingInput {
	s.Bucket = &v
	return s
}
1355169
func (s *S3Destination) SetBucket(v string) *S3Destination {
	s.Bucket = &v
	return s
}
149088
func deleteBucket(url string) *probe.Error {
	targetAlias, targetURL, _ := mustExpandAlias(url)
	clnt, pErr := newClientFromAlias(targetAlias, targetURL)
	if pErr != nil {
		return pErr
	}
	var isIncomplete bool
	isRemoveBucket := true
	contentCh := make(chan *clientContent)
	errorCh := clnt.Remove(isIncomplete, isRemoveBucket, contentCh)

	for content := range clnt.List(true, false, DirLast) {
		if content.Err != nil {
			switch content.Err.ToGoError().(type) {
			case PathInsufficientPermission:
				errorIf(content.Err.Trace(url), "Failed to remove `"+url+"`.")
				// Ignore Permission error.
				continue
			}
			close(contentCh)
			return content.Err
		}
		urlString := content.URL.Path

		sent := false
		for !sent {
			select {
			case contentCh <- content:
				sent = true
			case pErr := <-errorCh:
				switch pErr.ToGoError().(type) {
				case PathInsufficientPermission:
					errorIf(pErr.Trace(urlString), "Failed to remove `"+urlString+"`.")
					// Ignore Permission error.
					continue
				}
				close(contentCh)
				return pErr
			}
		}
		// list internally mimics recursive directory listing of object prefixes for s3 similar to FS.
		// The rmMessage needs to be printed only for actual buckets being deleted and not objects.
		tgt := strings.TrimPrefix(urlString, string(filepath.Separator))
		if !strings.Contains(tgt, string(filepath.Separator)) && tgt != targetAlias {
			printMsg(removeBucketMessage{
				Bucket: targetAlias + urlString, Status: "success",
			})
		}
	}

	// Remove the given url since the user will always want to remove it.
	alias, _ := url2Alias(targetURL)
	if alias != "" {
		contentCh <- &clientContent{URL: *newClientURL(targetURL)}
	}

	// Finish removing and print all the remaining errors
	close(contentCh)
	for pErr := range errorCh {
		switch pErr.ToGoError().(type) {
		case PathInsufficientPermission:
			errorIf(pErr.Trace(url), "Failed to remove `"+url+"`.")
			// Ignore Permission error.
			continue
		}
		return pErr
	}
	return nil
}