stardogapi

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	Username   string
	Password   string
	HTTPClient *http.Client
}

Client holds an HTTPClient and connectivity information

func NewClient

func NewClient(username, password, baseURL string) *Client

Create a new API Client

func (*Client) AddRole

func (c *Client) AddRole(ctx context.Context, name string) (err error)

Add a new role

func (*Client) AddRolePermission

func (c *Client) AddRolePermission(ctx context.Context, name string, permission Permission) (err error)

Add the Permission to a role

func (*Client) AddUser

func (c *Client) AddUser(ctx context.Context, name, password string) (err error)

Add a new user

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, name string, options map[string]string) (err error)

Creates a database with the given name and options

func (*Client) DeleteRole

func (c *Client) DeleteRole(ctx context.Context, name string) (err error)

Delete a role

func (*Client) DeleteRolePermission

func (c *Client) DeleteRolePermission(ctx context.Context, name string, permission Permission) (err error)

Delete the Permission from a role

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, name string) (err error)

Delete a user

func (*Client) DropDatabase

func (c *Client) DropDatabase(ctx context.Context, name string) (err error)

Drops the given database

func (*Client) GetRolePermissions

func (c *Client) GetRolePermissions(ctx context.Context, name string) ([]Permission, error)

Get Permissions of a role

func (*Client) GetRoles

func (c *Client) GetRoles(ctx context.Context) ([]string, error)

Get the available roles

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, name string) (user User, err error)

Get a user

func (*Client) GetUserRoles

func (c *Client) GetUserRoles(ctx context.Context, name string) (roles []string, err error)

Get the roles of a user

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context) (databases []string, err error)

Returns the list of databases

func (*Client) SetUserRoles

func (c *Client) SetUserRoles(ctx context.Context, name string, roles []string) (err error)

Set the roles of a user

type Permission

type Permission struct {
	Action       string   `json:"action"`
	ResourceType string   `json:"resource_type"`
	Resources    []string `json:"resource"`
}

Permission reflects the content returned and required by the Stardog API.

type StardogAPI

type StardogAPI interface {
	// DB
	CreateDatabase(ctx context.Context, name string, options map[string]string) (err error)
	DropDatabase(ctx context.Context, name string) (err error)
	ListDatabases(ctx context.Context) (databases []string, err error)

	// User
	AddUser(ctx context.Context, name, password string) (err error)
	DeleteUser(ctx context.Context, name string) (err error)
	GetUser(ctx context.Context, name string) (user User, err error)
	SetUserRoles(ctx context.Context, name string, roles []string) (err error)
	GetUserRoles(ctx context.Context, name string) (roles []string, err error)

	// Roles
	AddRole(ctx context.Context, name string) (err error)
	DeleteRole(ctx context.Context, name string) (err error)
	GetRoles(ctx context.Context) (roles []string, err error)

	// Permissions
	AddRolePermission(ctx context.Context, name string, permission Permission) (err error)
	DeleteRolePermission(ctx context.Context, name string, permission Permission) (err error)
	GetRolePermissions(ctx context.Context, name string) (permissions []Permission, err error)
}

StardogAPI provides an interface to interact with a subset of the Stardog API

type User

type User struct {
	Name        string
	Enabled     bool         `json:"enabled"`
	Superuser   bool         `json:"superuser"`
	Roles       []string     `json:"roles"`
	Permissions []Permission `json:"permissions"`
}

User reflects the content returned by the Stardog API.

type UserCredentials

type UserCredentials struct {
	Name     string
	Password string
}

UserCredentials is a helper for CreateUser()

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL