<commit_before>package cassandra

import (
	"fmt"
	"strings"
	"time"

	"github.com/gocql/gocql"
	"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
	"github.com/hashicorp/vault/helper/strutil"
	"github.com/hashicorp/vault/plugins/helper/database/connutil"
	"github.com/hashicorp/vault/plugins/helper/database/credsutil"
	"github.com/hashicorp/vault/plugins/helper/database/dbutil"
)

const (
	defaultCreationCQL = `CREATE USER '{{username}}' WITH PASSWORD '{{password}}' NOSUPERUSER;`
	defaultRollbackCQL = `DROP USER '{{username}}';`
	cassandraTypeName  = "cassandra"
)

type Cassandra struct {
	connutil.ConnectionProducer
	credsutil.CredentialsProducer
}

func New() *Cassandra {
	connProducer := &connutil.CassandraConnectionProducer{}
	connProducer.Type = cassandraTypeName

	credsProducer := &credsutil.CassandraCredentialsProducer{}

	dbType := &Cassandra{
		ConnectionProducer:  connProducer,
		CredentialsProducer: credsProducer,
	}

	return dbType
}

// Run instantiates a MySQL object, and runs the RPC server for the plugin
func Run() error {
	dbType := New()

	dbplugin.NewPluginServer(dbType)

	return nil
}

func (c *Cassandra) Type() (string, error) {
	return cassandraTypeName, nil
}

func (c *Cassandra) getConnection() (*gocql.Session, error) {
	session, err := c.Connection()
	if err != nil {
		return nil, err
	}

	return session.(*gocql.Session), nil
}

// func (c *Cassandra) CreateUser(statements dbplugin.Statements, username, password, expiration string) error {
func (c *Cassandra) CreateUser(statements dbplugin.Statements, usernamePrefix string, expiration time.Time) (username string, password string, err error) {
	// Grab the lock
	c.Lock()<commit_msg>Remove commented old method signature<commit_after>package cassandra

import (
	"fmt"
	"strings"
	"time"

	"github.com/gocql/gocql"
	"github.com/hashicorp/vault/builtin/logical/database/dbplugin"
	"github.com/hashicorp/vault/helper/strutil"
	"github.com/hashicorp/vault/plugins/helper/database/connutil"
	"github.com/hashicorp/vault/plugins/helper/database/credsutil"
	"github.com/hashicorp/vault/plugins/helper/database/dbutil"
)

const (
	defaultCreationCQL = `CREATE USER '{{username}}' WITH PASSWORD '{{password}}' NOSUPERUSER;`
	defaultRollbackCQL = `DROP USER '{{username}}';`
	cassandraTypeName  = "cassandra"
)

type Cassandra struct {
	connutil.ConnectionProducer
	credsutil.CredentialsProducer
}

func New() *Cassandra {
	connProducer := &connutil.CassandraConnectionProducer{}
	connProducer.Type = cassandraTypeName

	credsProducer := &credsutil.CassandraCredentialsProducer{}

	dbType := &Cassandra{
		ConnectionProducer:  connProducer,
		CredentialsProducer: credsProducer,
	}

	return dbType
}

// Run instantiates a MySQL object, and runs the RPC server for the plugin
func Run() error {
	dbType := New()

	dbplugin.NewPluginServer(dbType)

	return nil
}

func (c *Cassandra) Type() (string, error) {
	return cassandraTypeName, nil
}

func (c *Cassandra) getConnection() (*gocql.Session, error) {
	session, err := c.Connection()
	if err != nil {
		return nil, err
	}

	return session.(*gocql.Session), nil
}

func (c *Cassandra) CreateUser(statements dbplugin.Statements, usernamePrefix string, expiration time.Time) (username string, password string, err error) {
	// Grab the lock
	c.Lock()
{'fraction_non_alphanumeric': 0.12170753860127158, 'fraction_numerical': 0.0, 'mean_word_length': 5.329501915708812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6946276', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1134, 'n_words': 245}