Documentation
¶
Index ¶
- Variables
- type AddDirectShareRecipientsOptions
- type CreateDirectShareRequest
- type CreateEnvironmentShareRequest
- type CreateRequest
- type DeletionInfo
- type DirectShare
- type DirectShareList
- type Document
- type DocumentFilters
- type DocumentList
- type DocumentMetadata
- type EnvironmentShare
- type EnvironmentShareClaimResult
- type EnvironmentShareList
- type Handler
- func (h *Handler) AddDirectShareRecipients(ctx context.Context, shareID string, recipients []SsoEntity) error
- func (h *Handler) AddDirectShareRecipientsWithOptions(ctx context.Context, shareID string, recipients []SsoEntity, ...) error
- func (h *Handler) ClaimEnvironmentShare(ctx context.Context, shareID string) (*EnvironmentShareClaimResult, error)
- func (h *Handler) Create(ctx context.Context, req CreateRequest) (*Document, error)
- func (h *Handler) CreateDirectShare(ctx context.Context, req CreateDirectShareRequest) (*DirectShare, error)
- func (h *Handler) CreateEnvironmentShare(ctx context.Context, req CreateEnvironmentShareRequest) (*EnvironmentShare, error)
- func (h *Handler) Delete(ctx context.Context, id string, version int) error
- func (h *Handler) DeleteDirectShare(ctx context.Context, shareID string) error
- func (h *Handler) DeleteEnvironmentShare(ctx context.Context, shareID string) error
- func (h *Handler) DeleteSnapshot(ctx context.Context, documentID string, version int) error
- func (h *Handler) Get(ctx context.Context, id string) (*Document, error)
- func (h *Handler) GetAtVersion(ctx context.Context, id string, version int) (*Document, error)
- func (h *Handler) GetEnvironmentShare(ctx context.Context, shareID string) (*EnvironmentShare, error)
- func (h *Handler) GetMetadata(ctx context.Context, id string) (*DocumentMetadata, error)
- func (h *Handler) GetSnapshot(ctx context.Context, documentID string, version int) (*Snapshot, error)
- func (h *Handler) List(ctx context.Context, filters DocumentFilters) (*DocumentList, error)
- func (h *Handler) ListDirectShares(ctx context.Context, documentID string) (*DirectShareList, error)
- func (h *Handler) ListEnvironmentShares(ctx context.Context, documentID string) (*EnvironmentShareList, error)
- func (h *Handler) ListSnapshots(ctx context.Context, documentID string) (*SnapshotList, error)
- func (h *Handler) RemoveDirectShareRecipients(ctx context.Context, shareID string, recipientIDs []string) error
- func (h *Handler) RestoreSnapshot(ctx context.Context, documentID string, version int) (*DocumentMetadata, error)
- func (h *Handler) SetDocumentPublic(ctx context.Context, id string, version int) error
- func (h *Handler) Update(ctx context.Context, id string, version int, content []byte, ...) (*Document, error)
- func (h *Handler) UpdateDocument(ctx context.Context, id string, version int, req UpdateRequest) (*Document, error)
- func (h *Handler) UpdateWithMetadata(ctx context.Context, id string, version int, content []byte, ...) (*Document, error)
- type ModificationInfo
- type RestoreOptions
- type ShareInfo
- type Snapshot
- type SnapshotList
- type SnapshotModInfo
- type SsoEntity
- type TrashDocumentListEntry
- type TrashHandler
- func (h *TrashHandler) Delete(ctx context.Context, id string) error
- func (h *TrashHandler) Get(ctx context.Context, id string) (*TrashedDocument, error)
- func (h *TrashHandler) List(ctx context.Context, opts TrashListOptions) ([]TrashDocumentListEntry, error)
- func (h *TrashHandler) Restore(ctx context.Context, id string, opts RestoreOptions) error
- type TrashList
- type TrashListOptions
- type TrashedDocument
- type UpdateRequest
- type UserContext
Constants ¶
This section is empty.
Variables ¶
ErrShareConflict is returned when creating an environment share fails because one already exists for the document (HTTP 409). Callers can use errors.Is to detect this case without fragile string matching.
var ErrVersionConflict = fmt.Errorf("document version conflict")
ErrVersionConflict is returned when a document PATCH fails due to optimistic locking (HTTP 409). Callers can use errors.Is to detect this without string matching.
Functions ¶
This section is empty.
Types ¶
type AddDirectShareRecipientsOptions ¶
type AddDirectShareRecipientsOptions struct {
SuppressNotification bool
}
AddDirectShareRecipientsOptions controls side effects of adding recipients.
type CreateDirectShareRequest ¶
type CreateDirectShareRequest struct {
// sent as a query parameter, not in the body. The API notifies by default,
// and a group recipient means every member of the group.
SuppressNotification bool `json:"-"`
}
CreateDirectShareRequest contains the data needed to create a direct share
type CreateEnvironmentShareRequest ¶
type CreateEnvironmentShareRequest struct {
}
CreateEnvironmentShareRequest contains the data needed to create an environment share. The Document Service API schema is asymmetric: GET returns access as an array (e.g. ["read"] or ["read","write"]), but POST accepts a single level string ("read" or "read-write") and the server expands it server-side into the array.
type CreateRequest ¶
type CreateRequest struct {
ID string // Optional - if not provided, system generates one
Name string // Required
Type string // Required - e.g., "dashboard", "notebook"
Description string // Optional
Content []byte // Required - the document content
Labels []string // Optional - classification labels stored in document metadata
}
CreateRequest contains the data needed to create a new document
type DeletionInfo ¶
type DeletionInfo struct {
DeletedBy string `json:"deletedBy" yaml:"deletedBy"`
DeletedTime time.Time `json:"deletedTime" yaml:"deletedTime"`
}
DeletionInfo contains deletion metadata
type DirectShare ¶
type DirectShare struct {
}
DirectShare represents a direct share for a document
func (DirectShare) ExactAccess ¶
func (s DirectShare) ExactAccess(level string) bool
ExactAccess reports whether the share grants exactly the given access level.
type DirectShareList ¶
type DirectShareList struct {
}
DirectShareList represents a list of direct shares
type Document ¶
type Document struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Owner string `json:"owner"`
IsPrivate bool `json:"isPrivate"`
Created time.Time `json:"-"`
Description string `json:"description,omitempty"`
Version int `json:"version"`
Modified time.Time `json:"-"`
Content []byte `json:"-"`
OriginAppID string `json:"originAppId,omitempty" yaml:"originAppId,omitempty"`
OriginExtensionID string `json:"originExtensionId,omitempty" yaml:"originExtensionId,omitempty"`
Labels []string `json:"labels,omitempty" yaml:"labels,omitempty"`
UserContext *UserContext `json:"userContext,omitempty" yaml:"userContext,omitempty"`
}
Document represents a document resource.
The trailing optional fields (OriginAppID, OriginExtensionID, Labels, ShareInfo, UserContext) are populated only when requested via DocumentFilters.AddFields. They are tagged `omitempty` so default JSON/YAML output stays minimal.
func ParseMultipartDocument ¶
ParseMultipartDocument parses a multipart response into a Document
func (Document) MarshalJSON ¶
MarshalJSON custom marshaler for Document to include content when present
func (Document) MarshalYAML ¶
MarshalYAML custom marshaler for Document to include content for YAML output
func (*Document) UnmarshalJSON ¶
UnmarshalJSON custom unmarshaler for Document to handle nested modificationInfo and version as string or int.
type DocumentFilters ¶
type DocumentFilters struct {
Type string // e.g., "dashboard", "notebook"
Name string // Filter by name
Owner string // Filter by owner ID
Filter string // Raw filter string, sent verbatim (overrides Type/Name/Owner)
ChunkSize int64 // Page size for pagination (0 = no chunking, use API default)
Sort string // Sort fields, comma-separated, prefix with "-" for descending
AddFields []string // Fields the API omits by default (e.g. "originExtensionId", "labels")
AdminAccess bool // List as effective owner; requires document:documents:admin
}
DocumentFilters contains filter options for listing documents. When Filter is non-empty it is sent verbatim and overrides Type/Name/Owner.
type DocumentList ¶
type DocumentList struct {
Documents []DocumentMetadata `json:"documents"`
TotalCount int `json:"totalCount"`
NextPageKey string `json:"nextPageKey,omitempty"`
}
DocumentList represents a list of documents
type DocumentMetadata ¶
type DocumentMetadata struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description,omitempty"`
Version int `json:"version"`
Owner string `json:"owner"`
IsPrivate bool `json:"isPrivate"`
ModificationInfo ModificationInfo `json:"modificationInfo"`
Access []string `json:"access,omitempty"`
OriginAppID string `json:"originAppId,omitempty" yaml:"originAppId,omitempty"`
OriginExtensionID string `json:"originExtensionId,omitempty" yaml:"originExtensionId,omitempty"`
Labels []string `json:"labels,omitempty" yaml:"labels,omitempty"`
UserContext *UserContext `json:"userContext,omitempty" yaml:"userContext,omitempty"`
}
DocumentMetadata represents detailed document metadata. Fields after Access are only populated when requested via DocumentFilters.AddFields.
func (*DocumentMetadata) UnmarshalJSON ¶
func (m *DocumentMetadata) UnmarshalJSON(data []byte) error
UnmarshalJSON custom unmarshaler for DocumentMetadata to handle version as string or int.
type EnvironmentShare ¶
type EnvironmentShare struct {
// share exists on the server but doesn't flip the document's isPrivate flag.
ClaimCount int `json:"claimCount"`
}
EnvironmentShare represents an environment-wide share for a document (a document shared with everyone in the environment, reflected as isPrivate=false on the document). The Document Service API returns `access` as a string array (e.g. ["read"] or ["read","write"]), not a single string. The create endpoint accepts either form and normalises server-side.
func (EnvironmentShare) ExactAccess ¶
func (s EnvironmentShare) ExactAccess(level string) bool
ExactAccess reports whether the share grants exactly the given access level (no more, no less). Use this when deciding whether to replace a share: a "read-write" share is NOT an exact match for "read".
func (EnvironmentShare) HasAccess ¶
func (s EnvironmentShare) HasAccess(level string) bool
HasAccess reports whether the share grants the given access level. Accepts "read" (present if "read" or "write" is in Access) or "read-write" (present if "write" is in Access).
type EnvironmentShareClaimResult ¶
type EnvironmentShareClaimResult struct {
}
EnvironmentShareClaimResult is what claiming an environment share returns: the document the share points to and the access the caller now holds on it.
type EnvironmentShareList ¶
type EnvironmentShareList struct {
}
EnvironmentShareList represents a list of environment shares. The API's JSON key is kebab-case: "environment-shares".
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles document resources (dashboards, notebooks, etc.)
func NewHandler ¶
func NewHandler(c *httpclient.Client) *Handler
NewHandler creates a new document handler
func (*Handler) AddDirectShareRecipients ¶
func (h *Handler) AddDirectShareRecipients(ctx context.Context, shareID string, recipients []SsoEntity) error
AddDirectShareRecipients adds recipients to a direct share
func (*Handler) AddDirectShareRecipientsWithOptions ¶
func (h *Handler) AddDirectShareRecipientsWithOptions(ctx context.Context, shareID string, recipients []SsoEntity, opts AddDirectShareRecipientsOptions) error
AddDirectShareRecipientsWithOptions adds recipients to a direct share, honoring opts (for example, suppressing recipient notifications).
func (*Handler) ClaimEnvironmentShare ¶
func (h *Handler) ClaimEnvironmentShare(ctx context.Context, shareID string) (*EnvironmentShareClaimResult, error)
ClaimEnvironmentShare claims an environment share, mirroring the browser's "Copy link to share" -> open flow. Claiming is how a recipient resolves a share link: GetEnvironmentShare only answers for the share's owner, so the claim response is the one place the recipient learns the document.
func (*Handler) CreateDirectShare ¶
func (h *Handler) CreateDirectShare(ctx context.Context, req CreateDirectShareRequest) (*DirectShare, error)
CreateDirectShare creates a direct share for a document
func (*Handler) CreateEnvironmentShare ¶
func (h *Handler) CreateEnvironmentShare(ctx context.Context, req CreateEnvironmentShareRequest) (*EnvironmentShare, error)
CreateEnvironmentShare creates an environment-wide share for a document
func (*Handler) DeleteDirectShare ¶
DeleteDirectShare deletes a direct share
func (*Handler) DeleteEnvironmentShare ¶
DeleteEnvironmentShare deletes an environment share
func (*Handler) DeleteSnapshot ¶
DeleteSnapshot deletes a specific snapshot
func (*Handler) GetAtVersion ¶
GetAtVersion retrieves a document's content at a specific snapshot version
func (*Handler) GetEnvironmentShare ¶
func (h *Handler) GetEnvironmentShare(ctx context.Context, shareID string) (*EnvironmentShare, error)
GetEnvironmentShare retrieves an environment share by ID, resolving it to the document it points to. Environment share URLs (`.../document/v0/#share=<id>`) carry only the share ID, not the document ID, so this is how a share link gets resolved.
func (*Handler) GetMetadata ¶
GetMetadata retrieves only the metadata for a document
func (*Handler) GetSnapshot ¶
func (h *Handler) GetSnapshot(ctx context.Context, documentID string, version int) (*Snapshot, error)
GetSnapshot retrieves metadata for a specific snapshot
func (*Handler) List ¶
func (h *Handler) List(ctx context.Context, filters DocumentFilters) (*DocumentList, error)
List retrieves documents matching the provided filters with automatic pagination
func (*Handler) ListDirectShares ¶
func (h *Handler) ListDirectShares(ctx context.Context, documentID string) (*DirectShareList, error)
ListDirectShares lists direct shares for a document. Paginates automatically using the Document API style (page-size sent on every request).
func (*Handler) ListEnvironmentShares ¶
func (h *Handler) ListEnvironmentShares(ctx context.Context, documentID string) (*EnvironmentShareList, error)
ListEnvironmentShares lists environment shares for a document (or all if documentID is empty). Paginates automatically using the Document API style (page-size sent on every request).
func (*Handler) ListSnapshots ¶
ListSnapshots retrieves all snapshots for a document
func (*Handler) RemoveDirectShareRecipients ¶
func (h *Handler) RemoveDirectShareRecipients(ctx context.Context, shareID string, recipientIDs []string) error
RemoveDirectShareRecipients removes recipients from a direct share
func (*Handler) RestoreSnapshot ¶
func (h *Handler) RestoreSnapshot(ctx context.Context, documentID string, version int) (*DocumentMetadata, error)
RestoreSnapshot restores a document to a specific snapshot version
func (*Handler) SetDocumentPublic ¶
SetDocumentPublic flips a document's isPrivate flag to false, making it discoverable to everyone in the environment via the Notebooks/Dashboards app's listing. Requires the current document version for optimistic-locking. Uses the documents PATCH endpoint with a multipart form body (the same shape content updates use).
This is the half of the "Share with environment" UI action that the environment-share API does not cover: the env-share creates a claimable grant, but isPrivate=false is a separate owner-settable metadata flag.
func (*Handler) Update ¶
func (h *Handler) Update(ctx context.Context, id string, version int, content []byte, contentType string) (*Document, error)
Update updates a document's content.
func (*Handler) UpdateDocument ¶
func (h *Handler) UpdateDocument(ctx context.Context, id string, version int, req UpdateRequest) (*Document, error)
UpdateDocument performs a partial update of a document via the updateDocument endpoint. It is the general form behind Update / UpdateWithMetadata and is the only write path that can set labels (the create endpoint cannot).
func (*Handler) UpdateWithMetadata ¶
func (h *Handler) UpdateWithMetadata(ctx context.Context, id string, version int, content []byte, contentType string, name string, description string) (*Document, error)
UpdateWithMetadata updates a document's content and optionally its metadata (name, description).
type ModificationInfo ¶
type ModificationInfo struct {
CreatedBy string `json:"createdBy"`
CreatedTime time.Time `json:"createdTime"`
LastModifiedBy string `json:"lastModifiedBy"`
LastModifiedTime time.Time `json:"lastModifiedTime"`
}
ModificationInfo contains creation and modification timestamps
type RestoreOptions ¶
type RestoreOptions struct {
Force bool // Restore even if name conflicts exist (not supported by API yet)
NewName string // Restore with a new name (not supported by API yet)
}
RestoreOptions contains options for restoring a document
type Snapshot ¶
type Snapshot struct {
SnapshotVersion int `json:"snapshotVersion"`
DocumentVersion int `json:"documentVersion"`
Description string `json:"description,omitempty"`
ModificationInfo SnapshotModInfo `json:"modificationInfo"`
CreatedBy string `json:"-"`
CreatedTime time.Time `json:"-"`
}
Snapshot represents a document snapshot (version)
func (*Snapshot) UnmarshalJSON ¶
UnmarshalJSON custom unmarshaler for Snapshot to flatten modificationInfo and handle version fields as string or int.
type SnapshotList ¶
type SnapshotList struct {
Snapshots []Snapshot `json:"snapshots"`
TotalCount int `json:"totalCount"`
NextPageKey string `json:"nextPageKey,omitempty"`
}
SnapshotList represents a list of snapshots
type SnapshotModInfo ¶
type SnapshotModInfo struct {
CreatedBy string `json:"createdBy"`
CreatedTime time.Time `json:"createdTime"`
}
SnapshotModInfo contains creation info for a snapshot
type TrashDocumentListEntry ¶
type TrashDocumentListEntry struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
DeletionInfo DeletionInfo `json:"deletionInfo" yaml:"deletionInfo"`
// Computed fields for display
DeletedBy string `json:"-" yaml:"-"`
DeletedAt time.Time `json:"-" yaml:"-"`
}
TrashDocumentListEntry represents a document in the trash list (from GET /trash/documents)
type TrashHandler ¶
type TrashHandler struct {
// contains filtered or unexported fields
}
TrashHandler handles trash operations for documents
func NewTrashHandler ¶
func NewTrashHandler(c *httpclient.Client) *TrashHandler
NewTrashHandler creates a new trash handler
func (*TrashHandler) Delete ¶
func (h *TrashHandler) Delete(ctx context.Context, id string) error
Delete permanently deletes a document from trash
func (*TrashHandler) Get ¶
func (h *TrashHandler) Get(ctx context.Context, id string) (*TrashedDocument, error)
Get retrieves a specific trashed document by ID
func (*TrashHandler) List ¶
func (h *TrashHandler) List(ctx context.Context, opts TrashListOptions) ([]TrashDocumentListEntry, error)
List retrieves trashed documents matching the provided filters
func (*TrashHandler) Restore ¶
func (h *TrashHandler) Restore(ctx context.Context, id string, opts RestoreOptions) error
Restore restores a document from trash
type TrashList ¶
type TrashList struct {
Documents []TrashDocumentListEntry `json:"documents"`
TotalCount int `json:"totalCount"`
NextPageKey string `json:"nextPageKey,omitempty"`
}
TrashList represents a list of trashed documents
type TrashListOptions ¶
type TrashListOptions struct {
Type string // Filter by type: "dashboard", "notebook"
DeletedBy string // Filter by who deleted it
DeletedAfter time.Time // Show documents deleted after date
DeletedBefore time.Time // Show documents deleted before date
ChunkSize int64 // Page size for pagination (0 = no chunking)
}
TrashListOptions contains filter options for listing trashed documents
type TrashedDocument ¶
type TrashedDocument struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Version int `json:"version" yaml:"version"`
Owner string `json:"owner" yaml:"owner"`
DeletionInfo DeletionInfo `json:"deletionInfo" yaml:"deletionInfo"`
ModificationInfo ModificationInfo `json:"modificationInfo,omitempty" yaml:"modificationInfo,omitempty"`
// Computed fields for display
DeletedBy string `json:"-" yaml:"-"`
DeletedAt time.Time `json:"-" yaml:"-"`
}
TrashedDocument represents a document in the trash (from GET /trash/documents/{id})
func (*TrashedDocument) UnmarshalJSON ¶
func (t *TrashedDocument) UnmarshalJSON(data []byte) error
UnmarshalJSON custom unmarshaler for TrashedDocument to handle version as string or int.
type UpdateRequest ¶
type UpdateRequest struct {
Content []byte // Document content; omitted when empty (content unchanged)
ContentType string // Content-Type for Content; defaults to application/json
Name string // New name; omitted when empty
Description string // New description; omitted when empty
Labels []string // Replacement label set; omitted when empty
// CreateSnapshot asks the API to snapshot the document's current state
// before applying this update, so the pre-update content stays retrievable
// via ListSnapshots / RestoreSnapshot. Defaults to false: updates overwrite
// without keeping history unless this is set.
//
// The API caps snapshot creation at 5 per document per 60 seconds and keeps
// at most 50 snapshots per document (creating the 51st deletes the oldest).
CreateSnapshot bool
// SnapshotDescription labels the snapshot created by CreateSnapshot (max
// 128 characters). Ignored when CreateSnapshot is false.
SnapshotDescription string
}
UpdateRequest contains the (all optional) fields that can be changed on an existing document via updateDocument. Any zero-valued field is omitted from the request and the API leaves the corresponding attribute unchanged. A non-empty Labels slice replaces the document's entire label set; an empty or nil slice sends no labels, which the API also treats as "no change" (this endpoint offers no way to clear labels).
type UserContext ¶
type UserContext struct {
LastAccessedTime time.Time `json:"lastAccessedTime" yaml:"lastAccessedTime"`
}
UserContext describes per-user metadata for a document.