Documentation
¶
Index ¶
- Constants
- func CompareJSON(want, got string) error
- func DoReq(req *http.Request) ([]byte, error)
- func GenerateRandomVector(size int) []float32
- func GenerateRandomVectors(lowerLimit, uppermLimit, vectorSize int, label string) (string, [][]float32)
- func GetFullSchemaHTTPResponse(opts SchemaOptions) string
- func GetFullSchemaJSON(opts SchemaOptions) string
- func GetInternalPreds(excludeAclPreds bool) string
- func GetInternalTypes(excludeAclTypes bool) string
- func IsHigherVersion(higher, lower, repoDir string) (bool, error)
- func PollTillPassOrTimeout(gcli *GrpcClient, query, want string, timeout time.Duration) error
- func UnmarshalVectorResp(resp *api.Response) ([][]float32, error)
- func WaitForRestore(c Cluster) error
- type AclGroup
- type AclRule
- type Cluster
- type GraphQLParams
- type GraphQLResponse
- type GrpcClient
- func (gc *GrpcClient) DropAll() error
- func (gc *GrpcClient) DropPredicate(pred string) error
- func (gc *GrpcClient) Mutate(mu *api.Mutation) (*api.Response, error)
- func (gc *GrpcClient) Query(query string) (*api.Response, error)
- func (gc *GrpcClient) QueryMultipleVectorsUsingSimilarTo(vector []float32, pred string, topK int) ([][]float32, error)
- func (gc *GrpcClient) QuerySingleVectorsUsingUid(uid, pred string) ([][]float32, error)
- func (gc *GrpcClient) SetupSchema(dbSchema string) error
- func (gc *GrpcClient) Upsert(query string, mu *api.Mutation) (*api.Response, error)
- type HTTPClient
- func (hc *HTTPClient) AddNamespace() (uint64, error)
- func (hc *HTTPClient) AddRulesToGroup(group string, rules []AclRule, newGroup bool) error
- func (hc *HTTPClient) AddUserToGroup(userName, group string) error
- func (hc *HTTPClient) Backup(c Cluster, forceFull bool, backupPath string) error
- func (hc *HTTPClient) CreateGroup(name string) (string, error)
- func (hc *HTTPClient) CreateGroupWithRules(name string, rules []AclRule) (*AclGroup, error)
- func (hc *HTTPClient) CreateUser(username, password string) (string, error)
- func (hc *HTTPClient) DeleteGroup(name string) error
- func (hc *HTTPClient) DeleteNamespace(nsID uint64) (uint64, error)
- func (hc *HTTPClient) DeleteUser(username string) error
- func (hc *HTTPClient) Export(dest, format string, namespace int) error
- func (hc *HTTPClient) GetAlphaState() ([]byte, error)
- func (hc *HTTPClient) GetCurrentSnapshotTs(group uint64) (uint64, error)
- func (hc *HTTPClient) GetCurrentUser() (string, error)
- func (hc *HTTPClient) GetZeroState() (*LicenseResponse, error)
- func (hc *HTTPClient) HealthForInstance() ([]byte, error)
- func (hc *HTTPClient) ListNamespaces() ([]uint64, error)
- func (hc *HTTPClient) LoginIntoNamespace(user, password string, ns uint64) error
- func (hc *HTTPClient) LoginIntoNamespaceV20(user, password string) error
- func (hc *HTTPClient) LoginUsingToken(ns uint64) error
- func (hc *HTTPClient) Mutate(mutation string, commitNow bool) ([]byte, error)
- func (hc *HTTPClient) PostDqlQuery(query string) ([]byte, error)
- func (hc *HTTPClient) PostPersistentQuery(query, sha string) ([]byte, error)
- func (hc *HTTPClient) RemovePredicateFromGroup(group, predicate string) error
- func (hc *HTTPClient) RemoveUserFromGroup(userName, groupName string) error
- func (hc *HTTPClient) ResetPassword(userID, newPass string, nsID uint64) (string, error)
- func (hc *HTTPClient) Restore(c Cluster, backupPath string, backupId string, incrFrom, backupNum int) error
- func (hc *HTTPClient) RestoreTenant(c Cluster, backupPath string, backupId string, incrFrom, backupNum int, ...) error
- func (hc *HTTPClient) RunGraphqlQuery(params GraphQLParams, admin bool) ([]byte, error)
- func (hc *HTTPClient) UpdateGQLSchema(sch string) error
- func (hc *HTTPClient) UpdateGroup(name string, setRules []AclRule, removeRules []string) (*AclGroup, error)
- func (hc *HTTPClient) WaitForSnapshot(group, prevSnapshotTs uint64) (uint64, error)
- func (hc *HTTPClient) WaitForTask(taskId string) error
- type HttpToken
- type LicenseResponse
- type SchemaOptions
Constants ¶
const ( DefaultUser = "groot" DefaultPassword = "password" )
Variables ¶
This section is empty.
Functions ¶
func CompareJSON ¶
CompareJSON compares two JSON objects (passed as strings).
func GenerateRandomVector ¶
func GenerateRandomVectors ¶
func GetFullSchemaHTTPResponse ¶
func GetFullSchemaHTTPResponse(opts SchemaOptions) string
GetFullSchemaHTTPResponse returns a string representation of the HTTP response returned by the full schema{} query. It uses the user provided predicates and types along with the initial internal schema to generate the string. Example response looks like:
{ "data": { "schema": [ ... ], "types": [ ... ] } }
func GetFullSchemaJSON ¶
func GetFullSchemaJSON(opts SchemaOptions) string
GetFullSchemaJSON returns a string representation of the JSON object returned by the full schema{} query. It uses the user provided predicates and types along with the initial internal schema to generate the string. Example response looks like:
{ "schema": [ ... ], "types": [ ... ] }
func GetInternalPreds ¶
func GetInternalTypes ¶
func IsHigherVersion ¶
IsHigherVersion checks whether "higher" is the higher version compared to "lower"
func PollTillPassOrTimeout ¶
func PollTillPassOrTimeout(gcli *GrpcClient, query, want string, timeout time.Duration) error
func WaitForRestore ¶
WaitForRestore waits for restore to complete on all alphas
Types ¶
type GraphQLParams ¶
type GraphQLParams struct { Query string `json:"query"` Variables map[string]interface{} `json:"variables"` Extensions *schema.RequestExtensions `json:"extensions,omitempty"` }
GraphQLParams are used for making graphql requests to dgraph
type GraphQLResponse ¶
type GraphQLResponse struct { Data json.RawMessage `json:"data,omitempty"` Errors x.GqlErrorList `json:"errors,omitempty"` Code string `json:"code"` Extensions map[string]interface{} `json:"extensions,omitempty"` }
type GrpcClient ¶
type GrpcClient struct {
*dgo.Dgraph
}
func (*GrpcClient) DropAll ¶
func (gc *GrpcClient) DropAll() error
DropAll drops all the data in the db
func (*GrpcClient) DropPredicate ¶
func (gc *GrpcClient) DropPredicate(pred string) error
DropPredicate drops the predicate from the data in the db
func (*GrpcClient) Query ¶
func (gc *GrpcClient) Query(query string) (*api.Response, error)
Query performa a given query in a new txn
func (*GrpcClient) QueryMultipleVectorsUsingSimilarTo ¶
func (*GrpcClient) QuerySingleVectorsUsingUid ¶
func (gc *GrpcClient) QuerySingleVectorsUsingUid(uid, pred string) ([][]float32, error)
func (*GrpcClient) SetupSchema ¶
func (gc *GrpcClient) SetupSchema(dbSchema string) error
SetupSchema sets up DQL schema
type HTTPClient ¶
type HTTPClient struct { *HttpToken // contains filtered or unexported fields }
HTTPClient allows doing operations on Dgraph over http
func GetHttpClient ¶
func GetHttpClient(alphaUrl, zeroUrl string) (*HTTPClient, error)
func (*HTTPClient) AddNamespace ¶
func (hc *HTTPClient) AddNamespace() (uint64, error)
func (*HTTPClient) AddRulesToGroup ¶
func (hc *HTTPClient) AddRulesToGroup(group string, rules []AclRule, newGroup bool) error
func (*HTTPClient) AddUserToGroup ¶
func (hc *HTTPClient) AddUserToGroup(userName, group string) error
func (*HTTPClient) Backup ¶
func (hc *HTTPClient) Backup(c Cluster, forceFull bool, backupPath string) error
Backup creates a backup of dgraph at a given path
func (*HTTPClient) CreateGroup ¶
func (hc *HTTPClient) CreateGroup(name string) (string, error)
func (*HTTPClient) CreateGroupWithRules ¶
func (hc *HTTPClient) CreateGroupWithRules(name string, rules []AclRule) (*AclGroup, error)
func (*HTTPClient) CreateUser ¶
func (hc *HTTPClient) CreateUser(username, password string) (string, error)
func (*HTTPClient) DeleteGroup ¶
func (hc *HTTPClient) DeleteGroup(name string) error
func (*HTTPClient) DeleteNamespace ¶
func (hc *HTTPClient) DeleteNamespace(nsID uint64) (uint64, error)
func (*HTTPClient) DeleteUser ¶
func (hc *HTTPClient) DeleteUser(username string) error
func (*HTTPClient) GetAlphaState ¶
func (hc *HTTPClient) GetAlphaState() ([]byte, error)
func (*HTTPClient) GetCurrentSnapshotTs ¶
func (hc *HTTPClient) GetCurrentSnapshotTs(group uint64) (uint64, error)
func (*HTTPClient) GetCurrentUser ¶
func (hc *HTTPClient) GetCurrentUser() (string, error)
func (*HTTPClient) GetZeroState ¶
func (hc *HTTPClient) GetZeroState() (*LicenseResponse, error)
func (*HTTPClient) HealthForInstance ¶
func (hc *HTTPClient) HealthForInstance() ([]byte, error)
func (*HTTPClient) ListNamespaces ¶
func (hc *HTTPClient) ListNamespaces() ([]uint64, error)
func (*HTTPClient) LoginIntoNamespace ¶
func (hc *HTTPClient) LoginIntoNamespace(user, password string, ns uint64) error
func (*HTTPClient) LoginIntoNamespaceV20 ¶
func (hc *HTTPClient) LoginIntoNamespaceV20(user, password string) error
func (*HTTPClient) LoginUsingToken ¶
func (hc *HTTPClient) LoginUsingToken(ns uint64) error
func (*HTTPClient) Mutate ¶
func (hc *HTTPClient) Mutate(mutation string, commitNow bool) ([]byte, error)
func (*HTTPClient) PostDqlQuery ¶
func (hc *HTTPClient) PostDqlQuery(query string) ([]byte, error)
func (*HTTPClient) PostPersistentQuery ¶
func (hc *HTTPClient) PostPersistentQuery(query, sha string) ([]byte, error)
PostPersistentQuery stores a persisted query
func (*HTTPClient) RemovePredicateFromGroup ¶
func (hc *HTTPClient) RemovePredicateFromGroup(group, predicate string) error
func (*HTTPClient) RemoveUserFromGroup ¶
func (hc *HTTPClient) RemoveUserFromGroup(userName, groupName string) error
func (*HTTPClient) ResetPassword ¶
func (hc *HTTPClient) ResetPassword(userID, newPass string, nsID uint64) (string, error)
func (*HTTPClient) Restore ¶
func (hc *HTTPClient) Restore(c Cluster, backupPath string, backupId string, incrFrom, backupNum int) error
Restore performs restore on Dgraph cluster from the given path to backup
func (*HTTPClient) RestoreTenant ¶
func (hc *HTTPClient) RestoreTenant(c Cluster, backupPath string, backupId string, incrFrom, backupNum int, fromNamespace uint64) error
RestoreTenant restore specific namespace
func (*HTTPClient) RunGraphqlQuery ¶
func (hc *HTTPClient) RunGraphqlQuery(params GraphQLParams, admin bool) ([]byte, error)
RunGraphqlQuery makes a query to graphql (or admin) endpoint
func (*HTTPClient) UpdateGQLSchema ¶
func (hc *HTTPClient) UpdateGQLSchema(sch string) error
UpdateGQLSchema updates graphql schema for a given HTTP client
func (*HTTPClient) UpdateGroup ¶
func (*HTTPClient) WaitForSnapshot ¶
func (hc *HTTPClient) WaitForSnapshot(group, prevSnapshotTs uint64) (uint64, error)
func (*HTTPClient) WaitForTask ¶
func (hc *HTTPClient) WaitForTask(taskId string) error
WaitForTask waits for the task to finish
type LicenseResponse ¶
type LicenseResponse struct { Data json.RawMessage `json:"data,omitempty"` Errors x.GqlErrorList `json:"errors,omitempty"` Code string `json:"code"` Extensions map[string]interface{} `json:"license,omitempty"` }