code: 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
  	})
  }
docs: // CreateBucket creates a platform bucket and sets b.ID.