Documentation ¶
Overview ¶
Package egnyte provides an API interface to Egnyte APIs
Index ¶
- Constants
- Variables
- func Execute()
- func GetAccessToken(ctx context.Context, config map[string]string) (*oauth2.Token, error)
- func OAuthEndpoint(domain string) oauth2.Endpoint
- func SHA512Digest(buf []byte) string
- type ChunkUploadInfo
- func (c *ChunkUploadInfo) GetChunk() ([]byte, int64, int, error)
- func (c *ChunkUploadInfo) GetLastChunk() ([]byte, int)
- func (c *ChunkUploadInfo) GetRemainingBytes() int64
- func (c *ChunkUploadInfo) GetResultCsum() string
- func (c *ChunkUploadInfo) Init(data io.Reader, size int64, chunkSize int64)
- func (c *ChunkUploadInfo) SetChunkCheckSum(chunkNum int, csum string)
- type Client
- func (c *Client) CreateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
- func (c *Client) CreateUser(ctx context.Context, user *User, sendInvite bool) (*User, error)
- func (c *Client) DeleteGroup(ctx context.Context, groupId string) error
- func (c *Client) DeleteUser(ctx context.Context, userId int) error
- func (c *Client) EventCursor(ctx context.Context) (*EventID, error)
- func (c *Client) GetGroup(ctx context.Context, groupId string) (*Group, error)
- func (c *Client) GetUser(ctx context.Context, userId int) (*User, error)
- func (c *Client) ListGroups(ctx context.Context) ([]*Group, error)
- func (c *Client) ListUsers(ctx context.Context) ([]*User, error)
- func (c *Client) Object(path string) *Object
- func (c *Client) PartialUpdateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
- func (c *Client) UpdateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
- func (c *Client) UpdateUser(ctx context.Context, user *User) error
- func (c *Client) Userinfo(ctx context.Context) (*userInfoResponse, error)
- type Error
- type EventID
- type FolderPermission
- type Group
- type GroupMember
- type MultiPutFileContent
- type Object
- func (o *Object) ChunkUpload(ctx context.Context, uploadInfo *UploadInfo, extraHeaders map[string]string) error
- func (o *Object) Copy(ctx context.Context, newPath string) error
- func (o *Object) Create(ctx context.Context) (*Object, error)
- func (o *Object) Delete(ctx context.Context) error
- func (o *Object) Get(ctx context.Context) (io.ReadCloser, error)
- func (o *Object) GetPermissions(ctx context.Context) (*FolderPermission, error)
- func (o *Object) List(ctx context.Context) (*Object, error)
- func (o *Object) Lock(ctx context.Context) error
- func (o *Object) Move(ctx context.Context, newPath string) error
- func (o *Object) RemoveGroupPermission(ctx context.Context, groupName string) error
- func (o *Object) RemoveUserPermission(ctx context.Context, userName string) error
- func (o *Object) SetGroupPermission(ctx context.Context, groupName string, permString string) error
- func (o *Object) SetPermissions(ctx context.Context, perms FolderPermission) error
- func (o *Object) SetUserPermission(ctx context.Context, userName string, permString string) error
- func (o *Object) Stats(ctx context.Context) error
- func (o *Object) Unlock(ctx context.Context) error
- type UploadInfo
- type User
- type UserName
Constants ¶
const ( FilesystemScope = "Egnyte.filesystem" UserScope = "Egnyte.user" GroupScope = "Egnyte.group" PermissionScope = "Egnyte.permission" LaunchWebSessionScope = "Egnyte.launchwebsession" )
OAuth Scopes
const ( TimeFormat = "Mon, 02 Jan 2006 15:04:05" LetterAndNumberPattern = `^[a-zA-Z0-9]*$` CheckSumResponseVersion = "2" ModTimeLayout = "Mon, 02 Jan 2006 15:04:05 MST" Version = "v0.1.0" SourceName = "go-sdk" )
const ( // Filesystem URIS URI_LIST = URI_PREFIX_V1 + "fs%s" URI_DELETE_OBJECT = URI_PREFIX_V1 + "fs%s" URI_GET_FILE = URI_PREFIX_V1 + "fs-content%s" URI_CREATE_FOLDER = URI_PREFIX_V1 + "fs%s" URI_CHUNKED_UPLOAD = URI_PREFIX_V1 + "fs-content-chunked%s" // Auth URI_OAUTH = "/puboauth/token" // Event URIS URI_FETCH_EVENT_ID = URI_PREFIX_V1 + "events/cursor" // Group Management URIs URI_GROUPS = URI_PREFIX_V2 + "groups" // User Management URIs URI_USERS = URI_PREFIX_V2 + "users" URI_USERINFO = URI_PREFIX_V1 + "userinfo" // Permission URIs URI_PERMISSIONS = URI_PREFIX_V2 + "perms" )
const URI_PREFIX_V1 = "/pubapi/v1/"
const URI_PREFIX_V2 = "/pubapi/v2/"
Variables ¶
var ClientId string
var Domain string
var FolderRequired = errors.New("object must be a folder")
var Password string
var Username string
Functions ¶
func GetAccessToken ¶
GetAccessToken return auth token with grant type password This returns err if invalid details is provided else return auth token
func OAuthEndpoint ¶
OAuthEndpoint constructs an `oauth2.Endpoint` for the given domain This returns nil if invalid domain is provided
Types ¶
type ChunkUploadInfo ¶
type ChunkUploadInfo struct {
// contains filtered or unexported fields
}
func (*ChunkUploadInfo) GetChunk ¶
func (c *ChunkUploadInfo) GetChunk() ([]byte, int64, int, error)
GetChunk returns chunk
func (*ChunkUploadInfo) GetLastChunk ¶
func (c *ChunkUploadInfo) GetLastChunk() ([]byte, int)
func (*ChunkUploadInfo) GetRemainingBytes ¶
func (c *ChunkUploadInfo) GetRemainingBytes() int64
func (*ChunkUploadInfo) GetResultCsum ¶
func (c *ChunkUploadInfo) GetResultCsum() string
GetResultCsum return final check sum of all chunks
func (*ChunkUploadInfo) Init ¶
func (c *ChunkUploadInfo) Init(data io.Reader, size int64, chunkSize int64)
func (*ChunkUploadInfo) SetChunkCheckSum ¶
func (c *ChunkUploadInfo) SetChunkCheckSum(chunkNum int, csum string)
type Client ¶
type Client struct { http.Client Username string Email string WebAppURL string // contains filtered or unexported fields }
Custom Client with extra metadata
func NewClient ¶
func NewClient(ctx context.Context, rootUrl, token string, baseClient *http.Client) (*Client, error)
NewClient takes a http.Client, a root URL, and an auth token as input and returns a custom client.
func (*Client) CreateGroup ¶
func (c *Client) CreateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
CreateGroup creates a group
func (*Client) CreateUser ¶
CreateUser creates a user using the provided User object
func (*Client) DeleteGroup ¶
DeleteGroup deletes the group
func (*Client) DeleteUser ¶
DeleteUser deletes an user
func (*Client) EventCursor ¶
Our Events API supports polling for changes based on a cursor which indicates a position in the sequence of events that have occurred on your domain
func (*Client) GetGroup ¶
GetGroup returns the group attributes along with the list of users which are in the group for the provided group ID
func (*Client) ListGroups ¶
ListGroups lists all the groups in the domain. Note that this returns only custom groups. Egnyte default groups (i.e. 'All Power Users', 'All Standard Users and Power Users', and 'All Standard Users') are not returned. Returns all groups for this domain by iterating through all available pages
func (*Client) ListUsers ¶
ListUsers retrieves all, or a chosen subset of users Returns all users for this domain by iterating through all available pages
func (*Client) PartialUpdateGroup ¶
func (c *Client) PartialUpdateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
TODO: UpdateGroup
func (*Client) UpdateGroup ¶
func (c *Client) UpdateGroup(ctx context.Context, name string, members []*GroupMember) (*Group, error)
TODO: UpdateGroup
func (*Client) UpdateUser ¶
UpdateUser updates an user
type Error ¶
type Error struct { // StatusCode is the HTTP response status code and will always be populated StatusCode int `json:"status_code"` // ErrorCode is the Egnyte error code as returned in the response ErrorCode string Message string // Body is the raw response returned by the server. // It is often but not always JSON, depending on how the request fails. Body string // Header contains the response header fields from the server. Header http.Header }
type EventID ¶
type EventID struct { Timestamp string `json:"timestamp"` LatestEventID int64 `json:"latest_event_id"` OldestEventID int64 `json:"oldest_event_id"` }
Event is the latest build ID
type FolderPermission ¶
type FolderPermission struct { UserPerms map[string]string `json:"userPerms"` GroupPerms map[string]string `json:"groupPerms"` InheritsPermissions bool `json:"inheritsPermissions"` KeepParentPermissions bool `json:"keepParentPermissions"` }
FolderPermission represents the permissions of a folder in Egnyte
type Group ¶
type Group struct { ID string `json:"id"` // The globally unique group ID. DisplayName string `json:"displayName"` // The name of the group. Members []*GroupMember `json:"members"` // A JSON array containing all users in the group. }
Group represents an Egnyte group
type GroupMember ¶
type GroupMember struct { Username string `json:"username"` // The username of a group member ID int64 `json:"value"` // The globally unique id of a group member Display string `json:"display"` // The display name of a group member }
GroupMember represents a member of an Egnyte group
type MultiPutFileContent ¶
type Object ¶
type Object struct { Client *Client Body io.Reader Etag string ModTime time.Time Uploaded int64 `json:"uploaded"` Checksum string `json:"checksum"` Size int `json:"size"` Path string `json:"path"` Name string `json:"name"` Locked bool `json:"locked"` IsFolder bool `json:"is_folder"` EntryID string `json:"entry_id"` GroupID string `json:"group_id"` LastModifiedStr string `json:"last_modified"` LastModifiedEpoch int64 `json:"lastModified"` UploadedBy string `json:"uploaded_by"` NumVersions int `json:"num_versions"` ParentID string `json:"parent_id"` FolderID string `json:"folder_id"` Count int `json:"count"` Offset int `json:"offset"` TotalCount int `json:"total_count"` RestrictMoveDelete bool `json:"restrict_move_delete"` PublicLinks string `json:"public_links"` AllowLinks bool `json:"allow_links"` Folders []*Object `json:"folders"` Files []*Object `json:"files"` Versions []*Object `json:"versions"` Err error // This is used to store the error for this file in case of batch upload }
Object represents a file or a folder object
func (*Object) ChunkUpload ¶
func (*Object) GetPermissions ¶
func (o *Object) GetPermissions(ctx context.Context) (*FolderPermission, error)
GetPermissions fetches the permissions for the object
func (*Object) RemoveGroupPermission ¶
RemoveGroupPermission removes permissions for the given group on the object
func (*Object) RemoveUserPermission ¶
RemoveUserPermission removes permissions for the given user on the object
func (*Object) SetGroupPermission ¶
SetGroupPermission sets a permission for a single group on the object
func (*Object) SetPermissions ¶
func (o *Object) SetPermissions(ctx context.Context, perms FolderPermission) error
SetPermissions sets the provided permissions on the object
func (*Object) SetUserPermission ¶
SetUserPermission sets a permission for a single user on the object
type UploadInfo ¶
type User ¶
type User struct { ID int `json:"id"` UserName string `json:"userName"` // The Egnyte username for the user ExternalID string `json:"externalId"` // This is an immutable unique identifier provided by the API consumer Email string `json:"email"` // The email address of the user Name UserName `json:"name"` // First and last name of the user Active bool `json:"active"` // Whether the user is active or inactive CreatedDate string `json:"createdDate"` LastModificationDate string `json:"lastModificationDate"` LastActiveDate string `json:"lastActiveDate"` Locked bool `json:"locked"` AuthType string `json:"authType"` // The authentication type for the user UserType string `json:"userType"` // The type of the user // This is the way the user is identified within the SAML Response from an // SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith) IdpUserID string `json:"idpUserId"` IsServiceAccount bool `json:"isServiceAccount"` // Whether user is a service account or not Language string `json:"language"` DeleteOnExpiry interface{} `json:"deleteOnExpiry"` EmailChangePending bool `json:"emailChangePending"` ExpiryDate string `json:"expiryDate"` Role string `json:"role"` // The role assigned to the user. Only applicable for Power Users // Used to bind child authentication policies to a user when using Active // Directory authentication in a multi-domain setup (e.g. jmiller@example.com) UserPrincipalName string `json:"userPrincipalName"` Groups []struct { DisplayName string `json:"displayName"` Value string `json:"value"` } `json:"groups"` }
User represents an Egnyte user