diff --git a/README.md b/README.md index 663bed433b..61192388cf 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ See the table below for links to README files, documentation, and source code. | Java | [README](https://github.com/vaticle/typedb-driver/tree/development/java/README.md) | [Documentation](https://typedb.com/docs/drivers/java/overview) | [`java/`](https://github.com/vaticle/typedb-driver/tree/development/java) | | C | [README](https://github.com/vaticle/typedb-driver/tree/development/c/README.md) | See C++ | [`c/`](https://github.com/vaticle/typedb-driver/tree/development/c) | | C++ | [README](https://github.com/vaticle/typedb-driver/tree/development/cpp/README.md) | [Documentation](https://typedb.com/docs/drivers/cpp/overview) | [`cpp/`](https://github.com/vaticle/typedb-driver/tree/development/cpp) | -| C# | [README](https://github.com/vaticle/typedb-driver/tree/development/csharp/README.md) | (Coming soon!) | [`csharp/`](https://github.com/vaticle/typedb-driver/tree/development/csharp) | +| C# | [README](https://github.com/vaticle/typedb-driver/tree/development/csharp/README.md) | [Documentation](https://typedb.com/docs/drivers/csharp/overview) | [`csharp/`](https://github.com/vaticle/typedb-driver/tree/development/csharp) | ### Package hosting diff --git a/WORKSPACE b/WORKSPACE index 45c1eb46e1..c3f3b93990 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,7 +20,6 @@ workspace(name = "vaticle_typedb_driver") ############################## # Load @vaticle_dependencies # ############################## - load("//dependencies/vaticle:repositories.bzl", "vaticle_dependencies") vaticle_dependencies() @@ -79,6 +78,22 @@ paket2bazel_dependencies() load("//csharp/nuget:paket.csharp_deps.bzl", csharp_deps = "csharp_deps") csharp_deps() +# Load //builder/go +load("@vaticle_dependencies//builder/go:deps.bzl", go_deps = "deps") +go_deps() +load("@io_bazel_rules_go//go:deps.bzl", "go_rules_dependencies") +go_rules_dependencies() + +load("//go:go_versions.bzl", "register_all_toolchains") +register_all_toolchains() + +# gazelle:repo bazel_gazelle <- Used to tell gazelle that it is loaded in a macro. +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("//go:deps.bzl", "go_repositories") +# gazelle:repository_macro go/deps.bzl%go_repositories +go_repositories() +gazelle_dependencies() + # Load //builder/proto_grpc load("@vaticle_dependencies//builder/proto_grpc:deps.bzl", grpc_deps = "deps") grpc_deps() @@ -246,6 +261,7 @@ vaticle_typedb_protocol_npm_repositories() # Setup rules_ts load("@aspect_rules_ts//ts:repositories.bzl", "rules_ts_dependencies") + rules_ts_dependencies( ts_version_from = "//nodejs:package.json", ) diff --git a/c/swig/typedb_driver_go.swg b/c/swig/typedb_driver_go.swg new file mode 100644 index 0000000000..f182f85a94 --- /dev/null +++ b/c/swig/typedb_driver_go.swg @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* TODO: Implement */ diff --git a/dependencies/vaticle/repositories.bzl b/dependencies/vaticle/repositories.bzl index 56f22c083f..b690b8a716 100644 --- a/dependencies/vaticle/repositories.bzl +++ b/dependencies/vaticle/repositories.bzl @@ -21,7 +21,7 @@ def vaticle_dependencies(): git_repository( name = "vaticle_dependencies", remote = "https://github.com/vaticle/dependencies", - commit = "294ef724c3853c9851e1e0c6bc04e0470c724e10", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies + commit = "0b52d5d6dc5906d6a5dd6444ad2849466363ec6b", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies ) def vaticle_typeql(): diff --git a/go/BUILD b/go/BUILD new file mode 100644 index 0000000000..aace9b7ebf --- /dev/null +++ b/go/BUILD @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("//go:rules.bzl", "swig_native_go_library") + +# TODO: Building this target doesn't put the dynamic library (libtypedb_driver_go_native.dylib for MacOS) into +# bazel-bin/go, while it's needed for the clinkopts below. +swig_native_go_library( + name = "typedb_driver_go_native", + lib = "//c:typedb_driver_clib_headers", + package_name= "typedb_driver", + interface = "//c:typedb_driver.i", + includes = ["//c:swig/typedb_driver_go.swg"], + enable_cxx = True, + visibility = ["//visibility:public"], +) + +# TODO: Cannot be built in CI because of the absolute path used in clinkopts. +# For now, requires manually running `bazel build //go:libtypedb_driver_go_native` before this building this target. +#go_library( +# name = "driver-go", +# srcs = glob(["*.go"]), +# data = ["//:LICENSE"], +# importpath = "typedb_driver/go", +# clinkopts = [ +# "-L$TYPEDB_DRIVER_PATH/typedb-driver/bazel-bin/go", # TODO: Use relative path instead of the full path (couldn't make working for now) +# "-ltypedb_driver_go_native", +# "-framework", "CoreFoundation" +# ], +# deps = [ +# "//go:typedb_driver_go_native", +# "//go/api/user:user", +# "//go/api/database:database", +# "//go/connection:connection", +# ], +# cgo = True, +# visibility = ["//visibility:public"], +#) + +# TODO: The targets below are proofs of concept and are placed here for a simpler linker debug process. +# It runs based on `driver_proof_of_concept.go` (NOTICE: this file is built inside the library, which is incorrect, +# but it was enough for a simple proof of concept. Need to verify if the dynamic library can be found by external packages. +#go_binary( +# name = "driver-temp-exe", +# embed = [":driver-go"], +# visibility = ["//visibility:public"], +#) + +# TODO: This test doesn't work because it can't find the driver's native dynamic library. +#go_test( +# name = "db-connection-test", +# srcs = ["//go/test/integration:db_connection_test.go"], +# embed = ["//go:driver-go"], +# visibility = ["//visibility:public"], +#) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + exclude = glob([ + "README.md", + "docs/**/*.adoc", + ]), + license_type = "apache-header", +) diff --git a/go/README.md b/go/README.md new file mode 100644 index 0000000000..fcbe950a01 --- /dev/null +++ b/go/README.md @@ -0,0 +1,28 @@ +# TypeDB Go Driver (WIP) + +## Current state + +`TypeDB Go Driver` is not implemented yet. This repository contains proofs of concept, including driver's library build +phase and basic database manipulation functionality. A usage example could be found +in [driver_proof_of_concept.go](driver_proof_of_concept.go) (database creation and deletion). + +### Issues + +- [BUILD](BUILD) expects manual actions to build on a specific machine and is not fully automated yet (more details + below and inside the file) +- Only basic connection and database manipulation features are implemented and not tested +- There is no resource management, exceptions handling and some of the needed Rust structs wrappers on the SWIG side + +### Run + +- Run `bazel build //go:libtypedb_driver_go_native` +- Uncomment `driver-go` (and `driver-temp-exe`) targets in [BUILD](BUILD) +- Specify your local path to the `typedb_driver_go_native` dynamic library instead + of `$TYPEDB_DRIVER_PATH/typedb-driver/bazel-bin/go` +- Run `bazel build //go:driver-go` (or `bazel run //go:driver-temp-exe`). Make sure that you have a `TypeDB` server + running to connect to it + +```bash +bazel build //go:libtypedb_driver_go_native +bazel build //go:driver-go +``` diff --git a/go/api/BUILD b/go/api/BUILD new file mode 100644 index 0000000000..7060530647 --- /dev/null +++ b/go/api/BUILD @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +package(default_visibility = ["//visibility:public"]) + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +#go_library( +# name = "api", +# srcs = glob(["*.go", "*/*.go"]), +# deps = [ +# "//go/api/database:database", +# "//go/api/user:user", +# "//go:typedb_driver_go_native", +# ], +# importpath = "typedb_driver/go/api", +# visibility = ["//visibility:public"], +# cgo = True +#) + +checkstyle_test( + name = "checkstyle", + include = glob(["*", "*/*"]), + license_type = "apache-header", + size = "small", +) diff --git a/go/api/TypeDBDriver.go b/go/api/TypeDBDriver.go new file mode 100644 index 0000000000..a16ee62db9 --- /dev/null +++ b/go/api/TypeDBDriver.go @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package api + +import ( + "typedb_driver/go/api/database" + "typedb_driver/go/api/user" + "typedb_driver/go_wrapper" +) + +type Driver interface { + IsOpen() bool + Databases() database.DatabaseManager + Session() typedb_driver.Session // TODO: Implement sessions and return it instead of the native one + Close() + User() user.User + Users() user.UserManager +} diff --git a/go/api/database/BUILD b/go/api/database/BUILD new file mode 100644 index 0000000000..548cc76593 --- /dev/null +++ b/go/api/database/BUILD @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +# TODO: Consider merging everything into api/BUILD +#go_library( +# name = "database", +# srcs = [ +# "DatabaseManager.go", +# "Database.go" +# ], +# importpath = "typedb_driver/go/api/database", +# visibility = ["//visibility:public"], +#) + +checkstyle_test( + name = "checkstyle", + include = glob(["*"]), + license_type = "apache-header", + size = "small", +) diff --git a/go/api/database/Database.go b/go/api/database/Database.go new file mode 100644 index 0000000000..c8b19ef1bb --- /dev/null +++ b/go/api/database/Database.go @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package database + +type Database interface { + Name() string + Schema() string + TypeSchema() string + RuleSchema() string + Delete() + Replicas() []Replica + PrimaryReplica() Replica + PreferredReplica() Replica +} + +type Replica interface { + Server() string + IsPrimary() bool + IsPreferred() bool + Term() int64 +} diff --git a/go/api/database/DatabaseManager.go b/go/api/database/DatabaseManager.go new file mode 100644 index 0000000000..90145ca7bf --- /dev/null +++ b/go/api/database/DatabaseManager.go @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package database + +type DatabaseManager interface { + Get(name string) Database + Contains(name string) bool + Create(name string) + All() []Database +} diff --git a/go/api/user/BUILD b/go/api/user/BUILD new file mode 100644 index 0000000000..c2563d906b --- /dev/null +++ b/go/api/user/BUILD @@ -0,0 +1,38 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +# TODO: Consider merging everything into api/BUILD +#go_library( +# name = "user", +# srcs = [ +# "User.go", +# "UserManager.go", +# ], +# importpath = "typedb_driver/go/api/user", +# visibility = ["//visibility:public"], +# cgo = True +#) + +checkstyle_test( + name = "checkstyle", + include = glob(["*"]), + license_type = "apache-header", + size = "small", +) diff --git a/go/api/user/User.go b/go/api/user/User.go new file mode 100644 index 0000000000..3d31e47e86 --- /dev/null +++ b/go/api/user/User.go @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package user + +type User interface { + Username() string + PasswordExpirySeconds() (int64, bool) + PasswordUpdate() (string, string) +} diff --git a/go/api/user/UserManager.go b/go/api/user/UserManager.go new file mode 100644 index 0000000000..508f166f70 --- /dev/null +++ b/go/api/user/UserManager.go @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package user + +type UserManager interface { + Contains(username string) bool + Create(username, password string) + Delete(username string) + Get(username string) User + All() map[string]User + PasswordSet(username, password string) +} diff --git a/go/connection/BUILD b/go/connection/BUILD new file mode 100644 index 0000000000..9afa005f1d --- /dev/null +++ b/go/connection/BUILD @@ -0,0 +1,41 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +package(default_visibility = ["//visibility:public"]) + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +#go_library( +# name = "connection", +# srcs = glob(["*.go"], +# ), +# deps = [ +# "//go/api/database:database", +# "//go:typedb_driver_go_native", +# "//go/api/user:user" +# ], +# importpath = "typedb_driver/go/connection", +# cgo = True +#) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "apache-header", +) diff --git a/go/connection/TypeDBDatabaseImpl.go b/go/connection/TypeDBDatabaseImpl.go new file mode 100644 index 0000000000..da01760ee8 --- /dev/null +++ b/go/connection/TypeDBDatabaseImpl.go @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package connection + +import ( + "typedb_driver/go/api/database" + "typedb_driver/go_wrapper" +) + +type TypeDBDatabaseImpl struct { + nativeObject typedb_driver.Database +} + +func NewTypeDBDatabaseImpl(database typedb_driver.Database) *TypeDBDatabaseImpl { + return &TypeDBDatabaseImpl{ + nativeObject: database, + } +} + +// todo add error checks, for all functions. check if nativeObject.isOwned() before + +func (db *TypeDBDatabaseImpl) Name() string { + return typedb_driver.Database_get_name(db.nativeObject) +} + +func (db *TypeDBDatabaseImpl) Schema() string { + return typedb_driver.Database_schema(db.nativeObject) +} + +func (db *TypeDBDatabaseImpl) TypeSchema() string { + return typedb_driver.Database_type_schema(db.nativeObject) +} + +func (db *TypeDBDatabaseImpl) RuleSchema() string { + return typedb_driver.Database_rule_schema(db.nativeObject) +} + +func (db *TypeDBDatabaseImpl) Delete() { + typedb_driver.Database_delete(db.nativeObject) // TODO should be object.released() +} + +// String representation +func (db *TypeDBDatabaseImpl) String() string { + return db.Name() +} + +func (db *TypeDBDatabaseImpl) Replicas() []database.Replica { + return nil + // TODO iterate through 'Database_get_replicas_info' and return a set of all replicas using the iterator. + // replicaIterator:= typedb_driver.Database_get_replicas_info(db.nativeObject) +} + +func (db *TypeDBDatabaseImpl) PrimaryReplica() database.Replica { + res := typedb_driver.Database_get_primary_replica_info(db.nativeObject) + return NewReplica(res) +} + +func (db *TypeDBDatabaseImpl) PreferredReplica() database.Replica { + res := typedb_driver.Database_get_preferred_replica_info(db.nativeObject) + return NewReplica(res) +} + +type Replica struct { + nativeObject typedb_driver.ReplicaInfo +} + +func NewReplica(replicaInfo typedb_driver.ReplicaInfo) *Replica { + return &Replica{ + nativeObject: replicaInfo, + } +} + +func (r *Replica) Server() string { + return typedb_driver.Replica_info_get_server(r.nativeObject) +} + +func (r *Replica) IsPrimary() bool { + return typedb_driver.Replica_info_is_primary(r.nativeObject) +} + +func (r *Replica) IsPreferred() bool { + return typedb_driver.Replica_info_is_preferred(r.nativeObject) +} + +func (r *Replica) Term() int64 { + return typedb_driver.Replica_info_get_term(r.nativeObject) +} diff --git a/go/connection/TypeDBDatabaseManagerImpl.go b/go/connection/TypeDBDatabaseManagerImpl.go new file mode 100644 index 0000000000..3b961888eb --- /dev/null +++ b/go/connection/TypeDBDatabaseManagerImpl.go @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package connection + +import "C" +import ( + "typedb_driver/go/api/database" + "typedb_driver/go_wrapper" +) + +type TypeDBDatabaseManagerImpl struct { + nativeConnection typedb_driver.Connection + nativeObject typedb_driver.DatabaseManager +} + +func NewTypeDBDatabaseManagerImpl(nativeConnection typedb_driver.Connection) *TypeDBDatabaseManagerImpl { + return &TypeDBDatabaseManagerImpl{ + nativeConnection: nativeConnection, + nativeObject: typedb_driver.Database_manager_new(nativeConnection), + } +} + +func (dbManager *TypeDBDatabaseManagerImpl) Get(name string) database.Database { + // TODO deal with errors + return NewTypeDBDatabaseImpl(typedb_driver.Databases_get(dbManager.nativeObject, name)) +} + +func (dbManager *TypeDBDatabaseManagerImpl) Contains(name string) bool { + return typedb_driver.Databases_contains(dbManager.nativeObject, name) +} + +func (dbManager *TypeDBDatabaseManagerImpl) Create(name string) { + typedb_driver.Databases_create(dbManager.nativeObject, name) +} + +func (dbManager *TypeDBDatabaseManagerImpl) All() []database.Database { + //return new NativeIterator<>(databases_all(nativeObject)).stream().map(TypeDBDatabaseImpl::new).collect(toList()); + //TODO implement - dealing with iterator + return nil +} diff --git a/go/connection/TypeDBDriverImpl.go b/go/connection/TypeDBDriverImpl.go new file mode 100644 index 0000000000..a5284be12c --- /dev/null +++ b/go/connection/TypeDBDriverImpl.go @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package connection + +import "C" +import ( + "typedb_driver/go/api/database" + "typedb_driver/go/api/user" + "typedb_driver/go_wrapper" +) + +type TypeDBDriver struct { + nativeObject typedb_driver.Connection + databaseMgr database.DatabaseManager + userMgr user.UserManager +} + +func NewTypeDBDriver(address string) *TypeDBDriver { + core_conn := openCore(address) + databaseMgr := NewTypeDBDatabaseManagerImpl(core_conn) + //userMgr := NewUserManagerImpl(core_conn) + + return &TypeDBDriver{ + nativeObject: openCore(address), + databaseMgr: databaseMgr, + //userMgr: userMgr, + } +} + +func openCore(address string) typedb_driver.Connection { + return typedb_driver.Connection_open_core(address) +} + +func (d *TypeDBDriver) IsOpen() bool { + return typedb_driver.Connection_is_open(d.nativeObject) +} + +func (d *TypeDBDriver) User() user.User { + // TODO implement users + // return d.userMgr.GetCurrentUser() + return nil +} + +func (d *TypeDBDriver) Databases() database.DatabaseManager { + return d.databaseMgr +} + +func (d *TypeDBDriver) Session(database string, typ typedb_driver.SessionType) typedb_driver.Session { + // return NewTypeDBSessionImpl + // TODO implement sessions + return nil +} + +func (d *TypeDBDriver) Close() { + if !d.IsOpen() { + return + } + typedb_driver.Connection_force_close(d.nativeObject) +} diff --git a/go/deps.bzl b/go/deps.bzl new file mode 100644 index 0000000000..bc53823c80 --- /dev/null +++ b/go/deps.bzl @@ -0,0 +1,112 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@bazel_gazelle//:deps.bzl", "go_repository") + +# These are auto-generated by gazelle when we run update-dependencies. +def go_repositories(): + go_repository( + name = "com_github_cucumber_gherkin_go_v26", + build_file_proto_mode = "disable_global", + importpath = "github.com/cucumber/gherkin/go/v26", + sum = "h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI=", + version = "v26.2.0", + ) + go_repository( + name = "com_github_cucumber_messages_go_v21", + build_file_proto_mode = "disable_global", + importpath = "github.com/cucumber/messages/go/v21", + sum = "h1:wzA0LxwjlWQYZd32VTlAVDTkW6inOFmSM+RuOwHZiMI=", + version = "v21.0.1", + ) + go_repository( + name = "com_github_cucumber_messages_go_v22", + build_file_proto_mode = "disable_global", + importpath = "github.com/cucumber/messages/go/v22", + sum = "h1:hk3ITpEWQ+KWDe619zYcqtaLOfcu9jgClSeps3DlNWI=", + version = "v22.0.0", + ) + go_repository( + name = "com_github_davecgh_go_spew", + build_file_proto_mode = "disable_global", + importpath = "github.com/davecgh/go-spew", + sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", + version = "v1.1.1", + ) + go_repository( + name = "com_github_gofrs_uuid", + build_file_proto_mode = "disable_global", + importpath = "github.com/gofrs/uuid", + sum = "h1:0/KbAdpx3UXAx1kEOWHJeOkpbgRFGHVgv+CFIY7dBJI=", + version = "v4.3.1+incompatible", + ) + go_repository( + name = "com_github_hashicorp_go_immutable_radix", + build_file_proto_mode = "disable_global", + importpath = "github.com/hashicorp/go-immutable-radix", + sum = "h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc=", + version = "v1.3.1", + ) + go_repository( + name = "com_github_hashicorp_go_memdb", + build_file_proto_mode = "disable_global", + importpath = "github.com/hashicorp/go-memdb", + sum = "h1:XSL3NR682X/cVk2IeV0d70N4DZ9ljI885xAEU8IoK3c=", + version = "v1.3.4", + ) + go_repository( + name = "com_github_hashicorp_go_uuid", + build_file_proto_mode = "disable_global", + importpath = "github.com/hashicorp/go-uuid", + sum = "h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=", + version = "v1.0.0", + ) + go_repository( + name = "com_github_hashicorp_golang_lru", + build_file_proto_mode = "disable_global", + importpath = "github.com/hashicorp/golang-lru", + sum = "h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=", + version = "v0.5.4", + ) + go_repository( + name = "com_github_pmezard_go_difflib", + build_file_proto_mode = "disable_global", + importpath = "github.com/pmezard/go-difflib", + sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", + version = "v1.0.0", + ) + go_repository( + name = "com_github_spf13_pflag", + build_file_proto_mode = "disable_global", + importpath = "github.com/spf13/pflag", + sum = "h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=", + version = "v1.0.5", + ) + go_repository( + name = "com_github_stretchr_testify", + build_file_proto_mode = "disable_global", + importpath = "github.com/stretchr/testify", + sum = "h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=", + version = "v1.8.2", + ) + go_repository( + name = "in_gopkg_yaml_v3", + build_file_proto_mode = "disable_global", + importpath = "gopkg.in/yaml.v3", + sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", + version = "v3.0.1", + ) diff --git a/go/driver_proof_of_concept.go b/go/driver_proof_of_concept.go new file mode 100644 index 0000000000..a8d737ba32 --- /dev/null +++ b/go/driver_proof_of_concept.go @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package main + +import "C" +import ( + "fmt" + "typedb_driver/go/connection" +) + +func openCoreFunc() { + dbName := "access-management-db" + fmt.Println(dbName) + serverAddr := "127.0.0.1:1729" + + driver := connection.NewTypeDBDriver(serverAddr) + fmt.Println("hello") + + driver.Databases().Create(dbName) + fmt.Println("db created") + + database := driver.Databases().Get(dbName) + // TODO not stable, occasional runtime error: slice bounds out of range. + fmt.Println(database) + + database.Delete() + + fmt.Println(driver.Databases().Contains(dbName)) + + driver.Close() + +} + +func main() { + openCoreFunc() +} diff --git a/go/gazelle/BUILD b/go/gazelle/BUILD new file mode 100644 index 0000000000..4649aa2f7d --- /dev/null +++ b/go/gazelle/BUILD @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@bazel_gazelle//:def.bzl", "gazelle") + +gazelle( + name = "update-dependencies", + args = [ + "-from_file=go/go.mod", + "-to_macro=go/deps.bzl%go_repositories", + "-prune", + "-build_file_proto_mode=disable_global", + ], + command = "update-repos", +) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "apache-header", +) diff --git a/go/gazelle/add_dep.sh b/go/gazelle/add_dep.sh new file mode 100644 index 0000000000..a10c5ff321 --- /dev/null +++ b/go/gazelle/add_dep.sh @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# To update external required dependencies with gazelle, follow these steps: +# 1. Specify the desired packages to your go.mod file manually OR with go get (requires installing Go on your local) +# 2. Run this shell script to add the dependencies in go/deps.bzl with bazel go_repositories. +# 3. Add the import to the go file it will be used in +# - (import_path is declared in deps.bzl, where the repositories are defined). + +# go get PACKAGE NAME, eg: +# go get github.com/cucumber/godog + +bazel run //go/gazelle:update-dependencies diff --git a/go/go.mod b/go/go.mod new file mode 100644 index 0000000000..c83a8eea92 --- /dev/null +++ b/go/go.mod @@ -0,0 +1,30 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +module typedb-driver + +go 1.21.10 + +require ( + github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect + github.com/cucumber/messages/go/v21 v21.0.1 // indirect + github.com/gofrs/uuid v4.3.1+incompatible // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-memdb v1.3.4 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/go/go_versions.bzl b/go/go_versions.bzl new file mode 100644 index 0000000000..ddc4185d53 --- /dev/null +++ b/go/go_versions.bzl @@ -0,0 +1,26 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains") + +go_versions = [ + "1.21.10", +] + +def register_all_toolchains(): + for version in go_versions: + go_register_toolchains(version=version) diff --git a/go/rules.bzl b/go/rules.bzl new file mode 100644 index 0000000000..4e5965c574 --- /dev/null +++ b/go/rules.bzl @@ -0,0 +1,33 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//builder/swig:go.bzl", "swig_go") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +def swig_native_go_library(name, visibility, tags=[], **kwargs): + swig_go( + name = "__" + name, + shared_lib_name = name, + tags = tags, + **kwargs, + ) + + native.alias( + name = name, + actual = "__" + name, + visibility = visibility + ) diff --git a/go/test/integration/BUILD b/go/test/integration/BUILD new file mode 100644 index 0000000000..24abeac32e --- /dev/null +++ b/go/test/integration/BUILD @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_test") + +exports_files( + ["db_connection_test.go"] +) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "apache-header", +) diff --git a/go/test/integration/db_connection_test.go b/go/test/integration/db_connection_test.go new file mode 100644 index 0000000000..35ccf2ad40 --- /dev/null +++ b/go/test/integration/db_connection_test.go @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package main + +import ( + "testing" + "typedb_driver/go/connection" +) + +func TestDBConnection(t *testing.T) { + dbName := "test-db" + serverAddr := "127.0.0.1:1729" + + driver := connection.NewTypeDBDriver(serverAddr) + + driver.Databases().Create(dbName) + if !driver.Databases().Contains(dbName) { + t.Errorf("Expected driver.Databases to contain '%s'", dbName) + } + + database := driver.Databases().Get(dbName) + if database.Name() != "dbName" { + t.Errorf("Expected databaseName to be '%s', got '%s", dbName, database.Name()) + } + + database.Delete() + + if driver.Databases().Contains(dbName) { + t.Errorf("Expected database to be deleted, but exists as: '%s'", dbName) + } + + driver.Close() +} diff --git a/go/user/BUILD b/go/user/BUILD new file mode 100644 index 0000000000..f6c073280c --- /dev/null +++ b/go/user/BUILD @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +package(default_visibility = ["//visibility:public"]) + +load("@vaticle_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "apache-header", +) diff --git a/go/user/UserImpl.go b/go/user/UserImpl.go new file mode 100644 index 0000000000..b4e29060e2 --- /dev/null +++ b/go/user/UserImpl.go @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package user + +import ( + "typedb_driver/go_wrapper" +) + +type UserImpl struct { + users UserManagerImpl + nativeObject typedb_driver.User +} + +func NewUserImpl(user typedb_driver.User, users UserManagerImpl, ) *UserImpl { + return &UserImpl{ + users: users, + nativeObject: user, + } +} + +func (u *UserImpl) Username() string { + return typedb_driver.User_get_username(u.nativeObject) +} + +func (u *UserImpl) PasswordExpirySeconds() int64 { + return typedb_driver.User_get_password_expiry_seconds(u.nativeObject) +} + +func (u *UserImpl) PasswordUpdate(passwordOld string, passwordNew string) { + typedb_driver.User_password_update(u.nativeObject, u.users.nativeObject, passwordOld, passwordNew) +} diff --git a/go/user/UserManagerImpl.go b/go/user/UserManagerImpl.go new file mode 100644 index 0000000000..67d8dff154 --- /dev/null +++ b/go/user/UserManagerImpl.go @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package user + +import "C" +import ( + "typedb_driver/go/api/user" + "typedb_driver/go_wrapper" +) + +type UserManagerImpl struct { + nativeConnection typedb_driver.Connection + nativeObject typedb_driver.UserManager +} + +func NewUserManagerImpl(nativeConnection typedb_driver.Connection) *UserManagerImpl { + return &UserManagerImpl{ + nativeConnection: nativeConnection, + nativeObject: typedb_driver.User_manager_new(nativeConnection), + } +} + +func (userMngr *UserManagerImpl) Contains(username string) bool { + return typedb_driver.Users_contains(userMngr.nativeObject, username) +} + +func (userMngr *UserManagerImpl) Create(username, password string) { + typedb_driver.Users_create(userMngr.nativeObject, username, password) +} + +func (userMngr *UserManagerImpl) Delete(username string) { + typedb_driver.Users_delete(userMngr.nativeObject, username) +} + +func (userMngr *UserManagerImpl) Get(username string) typedb_driver.User { + user_fetched := typedb_driver.Users_get(userMngr.nativeObject, username) + if user_fetched != nil { + return NewUserImpl(user_fetched, *userMngr).nativeObject + } else { + return nil + } +} + +func (userMngr *UserManagerImpl) PasswordSet(username, password string) { + typedb_driver.Users_set_password(userMngr.nativeObject, username, password) +} + +func (userMngr *UserManagerImpl) GetCurrentUser() user.User { + return nil + // TODO implement +} + +func (userMngr *UserManagerImpl) All() map[string]user.User { + userSet := make(map[string]user.User) + // TODO implement - iterator + return userSet +}