sentryapi

package
v0.0.0-...-d27488d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

README

sentryapi

sentryapi is a Go library for Apache Sentry.

The library can be used to interface with non-kerberized Sentry daemon.

Installation

Standard go get:

$ go get github.com/akolb1/sentrytool/sentryapi

Usage & Example

For API usage and examples, see GoDoc

Documentation

Overview

Package sentryapi provides GO-specific client interface to Apache Sentry. It supports both Generic and legacy APIs. The interface is defined by SentryClientAPI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Err        error
	StackTrace string
}

APIError is an extension to error type that also contains source stack trace.

func (*APIError) Error

func (err *APIError) Error() string

type ClientAPI

type ClientAPI interface {
	// Close closes the client connection
	Close()
	// CreateRole creates a role with given name
	//   roleName - role name
	CreateRole(roleName string) error
	// RemoveRole removes role with given name
	//   roleName - role name
	RemoveRole(roleName string) error
	// ListRoleByGroup returns list of role names for a given group or all
	// roles if group is nil
	//   groupName - group name
	ListRoleByGroup(groupName string) ([]string, []*Role, error)
	// AddGroupsToRole adds specified groups to the role
	//   roleName - role name
	//   groups - list of group names to add
	AddGroupsToRole(roleName string, groups []string) error
	// RemoveGroupsFromRole removes specified groups from the role
	//   roleName - role name
	//   groups - list of group names to remove
	RemoveGroupsFromRole(roleName string, groups []string) error
	// GrantPrivilege grants privilege to the role
	//   roleName - role name
	//   priv - privilege to grant
	GrantPrivilege(roleName string, priv *Privilege) error
	// RevokePrivilege revokes privilege from the role
	//  roleName - role name
	//  priv - privilege to revoke
	RevokePrivilege(roleName string, priv *Privilege) error
	// ListPrivilegesByRole returns a list of privileges for the role
	// role.
	// If template is not NULL, only return privileges matching template
	ListPrivilegesByRole(roleName string, template *Privilege) ([]*Privilege, error)
}

ClientAPI is a generic Apache Sentry client interface. The API is the same for the Generic or Hive model.

func GetClient

func GetClient(protocol ProtocolType, host string, port int,
	component string, user string) (ClientAPI, error)

GetClient returns a Sentry client implementation

protocol - legacy or generic
host - server host
port - server port
component - Sentry component for generic protocol
user - Sentry authorization user

type Privilege

type Privilege struct {
	Scope            string
	Server           string
	Database         string
	Table            string
	Column           string
	URI              string
	Action           string
	Service          string
	GrantOption      bool
	UnsetGrantOption bool // True is grant option is unset
}

Privilege is the Sentry privilege representation. It comboines Generic model and legacy Hive model

type ProtocolType

type ProtocolType int

ProtocolType is enum describing available Apache Sentry protocols. Currently Sentry supports two protocols: old protocol and generic protocol.

const (
	PolicyProtocol ProtocolType = iota
	GenericPolicyProtocol
)

PolicyProtocol is the legacy Sentry protocol GenericPolicyProtocol is the generic Sentry protocol

func (ProtocolType) String

func (pt ProtocolType) String() string

type Role

type Role struct {
	Name   string
	Groups []string
}

Role is a representation of Sentry role. Each role has a name and a list of groups associated with the role. Attributes:

Name - Role name
Groups - list of groups for the role

Directories

Path Synopsis
thrift

Jump to

Keyboard shortcuts

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