// newBucket returns a new bucket associated with a transaction.
356914
func newBucket(tx *Tx) Bucket {
	var b = Bucket{tx: tx, FillPercent: DefaultFillPercent}
	if tx.writable {
		b.buckets = make(map[string]*Bucket)
		b.nodes = make(map[pgid]*node)
	}
	return b
}
1141250
func (s *BucketService) CreateBucket(ctx context.Context, b *platform.Bucket) error {
	if s.inner == nil || s.engine == nil {
		return errors.New("nil inner BucketService or Engine")
	}
	return s.inner.CreateBucket(ctx, b)
}
1004487
func (s *ListBucketAnalyticsConfigurationsInput) SetBucket(v string) *ListBucketAnalyticsConfigurationsInput {
	s.Bucket = &v
	return s
}
1117609
func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error {
	var err error
	op := getOp(platform.OpCreateBucket)
	return c.db.Update(func(tx *bolt.Tx) error {
		if b.OrganizationID.Valid() {
			_, pe := c.findOrganizationByID(ctx, tx, b.OrganizationID)
			if pe != nil {
				return &platform.Error{
					Err: pe,
					Op:  op,
				}
			}
		} else {
			o, pe := c.findOrganizationByName(ctx, tx, b.Organization)
			if pe != nil {
				return &platform.Error{
					Err: pe,
					Op:  op,
				}
			}
			b.OrganizationID = o.ID
		}

		unique := c.uniqueBucketName(ctx, tx, b)

		if !unique {
			// TODO: make standard error
			return &platform.Error{
				Code: platform.EConflict,
				Op:   op,
				Msg:  fmt.Sprintf("bucket with name %s already exists", b.Name),
			}
		}

		b.ID = c.IDGenerator.ID()

		if err = c.appendBucketEventToLog(ctx, tx, b.ID, bucketCreatedEvent); err != nil {
			return &platform.Error{
				Op:  op,
				Err: err,
			}
		}

		if pe := c.putBucket(ctx, tx, b); pe != nil {
			pe.Op = op
			err = pe
		}

		if pe := c.createBucketUserResourceMappings(ctx, tx, b); pe != nil {
			pe.Op = op
			err = pe
		}
		return nil
	})
}
653666
func (s *BucketService) CreateBucket(ctx context.Context, b *platform.Bucket) error {
	span, ctx := tracing.StartSpanFromContext(ctx)
	defer span.Finish()

	if s.inner == nil || s.engine == nil {
		return errors.New("nil inner BucketService or Engine")
	}
	return s.inner.CreateBucket(ctx, b)
}
618381
func (s *PutObjectTaggingInput) SetBucket(v string) *PutObjectTaggingInput {
	s.Bucket = &v
	return s
}
864720
func (s *PutBucketInventoryConfigurationInput) SetBucket(v string) *PutBucketInventoryConfigurationInput {
	s.Bucket = &v
	return s
}
248495
func (c *Cluster) Bucket(bucketName string, opts *BucketOptions) *Bucket {
	if opts == nil {
		opts = &BucketOptions{}
	}
	b := newBucket(&c.sb, bucketName, *opts)
	b.connect()
	return b
}
721599
func (s *GetObjectAclInput) SetBucket(v string) *GetObjectAclInput {
	s.Bucket = &v
	return s
}
617145
func NewBuckets(count uint, bucketSize uint8) *Buckets {
	return &Buckets{
		count:      count,
		data:       make([]byte, (count*uint(bucketSize)+7)/8),
		bucketSize: bucketSize,
		max:        (1 << bucketSize) - 1,
	}
}
784598
func (s *StreamingLoggingConfig) SetBucket(v string) *StreamingLoggingConfig {
	s.Bucket = &v
	return s
}
838164
func (s *GetObjectTaggingInput) SetBucket(v string) *GetObjectTaggingInput {
	s.Bucket = &v
	return s
}
388805
func (s *PutBucketWebsiteInput) SetBucket(v string) *PutBucketWebsiteInput {
	s.Bucket = &v
	return s
}
968118
func (s *UploadPartCopyInput) SetBucket(v string) *UploadPartCopyInput {
	s.Bucket = &v
	return s
}
172806
func (s *PutBucketRequestPaymentInput) SetBucket(v string) *PutBucketRequestPaymentInput {
	s.Bucket = &v
	return s
}
916064
func (s *ListPartsInput) SetBucket(v string) *ListPartsInput {
	s.Bucket = &v
	return s
}
757139
func (c *Client) SetBucket(bucket string, nval *uint32, allowmult *bool) ([]byte, error) {
	return c.setBucket(nil, bucket, nval, allowmult)
}