details

package
v0.0.0-...-4fc5b5b Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewChatsLocationIDer

func NewChatsLocationIDer(
	category path.CategoryType,
	escapedFolders ...string,
) (uniqueLoc, error)

NewChatsLocationIDer builds a LocationIDer for the chats.

func NewExchangeLocationIDer

func NewExchangeLocationIDer(
	category path.CategoryType,
	escapedFolders ...string,
) (uniqueLoc, error)

NewExchangeLocationIDer builds a LocationIDer for the given category and folder path. The path denoted by the folders should be unique within the category.

func NewGroupsLocationIDer

func NewGroupsLocationIDer(
	category path.CategoryType,
	driveID string,
	escapedFolders ...string,
) (uniqueLoc, error)

NewGroupsLocationIDer builds a LocationIDer for the groups.

func NewOneDriveLocationIDer

func NewOneDriveLocationIDer(
	driveID string,
	escapedFolders ...string,
) uniqueLoc

NewOneDriveLocationIDer builds a LocationIDer for the drive and folder path. The path denoted by the folders should be unique within the drive.

func NewSharePointLocationIDer

func NewSharePointLocationIDer(
	category path.CategoryType,
	driveID string,
	escapedFolders ...string,
) uniqueLoc

NewSharePointLocationIDer builds a LocationIDer for the drive and folder path. The path denoted by the folders should be unique within the drive.

func UnmarshalTo

func UnmarshalTo(d *Details) func(io.ReadCloser) error

UnmarshalTo produces a func that complies with the unmarshaller type in streamStore.

func UpdateItem

func UpdateItem(item *ItemInfo, newLocPath *path.Builder)

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder should be used to create a details model.

func (*Builder) Add

func (b *Builder) Add(
	repoRef path.Path,
	locationRef *path.Builder,
	info ItemInfo,
) error

func (*Builder) Details

func (b *Builder) Details() *Details

func (*Builder) Empty

func (b *Builder) Empty() bool

type ChannelMessageInfo

type ChannelMessageInfo struct {
	AttachmentNames []string  `json:"attachmentNames,omitempty"`
	CreatedAt       time.Time `json:"createdAt,omitempty"`
	Creator         string    `json:"creator,omitempty"`
	Preview         string    `json:"preview,omitempty"`
	ReplyCount      int       `json:"replyCount"`
	Size            int64     `json:"size,omitempty"`
	Subject         string    `json:"subject,omitempty"`
}

type ChatInfo

type ChatInfo struct {
	CreatedAt          time.Time `json:"createdAt,omitempty"`
	HasExternalMembers bool      `json:"hasExternalMembers,omitempty"`
	LastMessageAt      time.Time `json:"lastMessageAt,omitempty"`
	LastMessagePreview string    `json:"preview,omitempty"`
	Members            []string  `json:"members,omitempty"`
	MessageCount       int       `json:"messageCount,omitempty"`
	Name               string    `json:"name,omitempty"`
}

type ConversationPostInfo

type ConversationPostInfo struct {
	CreatedAt  time.Time `json:"createdAt,omitempty"`
	Creator    string    `json:"creator,omitempty"`
	Preview    string    `json:"preview,omitempty"`
	Recipients []string  `json:"recipients,omitempty"`
	Size       int64     `json:"size,omitempty"`
	Topic      string    `json:"topic,omitempty"`
}

type Details

type Details struct {
	DetailsModel
}

Details augments the core with a mutex for processing. Should be sliced back to d.DetailsModel for storage and printing.

func (*Details) Marshal

func (d *Details) Marshal() ([]byte, error)

Marshal complies with the marshaller interface in streamStore.

type DetailsModel

type DetailsModel struct {
	Entries []Entry `json:"entries"`
}

DetailsModel describes what was stored in a Backup

func (DetailsModel) FilterMetaFiles

func (dm DetailsModel) FilterMetaFiles() DetailsModel

FilterMetaFiles returns a copy of the Details with all of the .meta files removed from the entries.

func (DetailsModel) Items

func (dm DetailsModel) Items() entrySet

Items returns a slice of *ItemInfo that does not contain any FolderInfo entries. Required because not all folders in the details are valid resource paths, and we want to slice out metadata.

func (DetailsModel) Paths

func (dm DetailsModel) Paths() []string

Paths returns the list of Paths for non-folder and non-meta items extracted from the Entries slice.

func (DetailsModel) PrintEntries

func (dm DetailsModel) PrintEntries(ctx context.Context)

Print writes the DetailModel Entries to StdOut, in the format requested by the caller.

func (DetailsModel) SumNonMetaFileSizes

func (dm DetailsModel) SumNonMetaFileSizes() int64

SumNonMetaFileSizes returns the total size of items excluding all the .meta files from the items.

type Entry

type Entry struct {
	// RepoRef is the full storage path of the item in Kopia
	RepoRef   string `json:"repoRef"`
	ShortRef  string `json:"shortRef"`
	ParentRef string `json:"parentRef,omitempty"`

	// LocationRef contains the logical path structure by its human-readable
	// display names.  IE:  If an item is located at "/Inbox/Important", we
	// hold that string in the LocationRef, while the actual IDs of each
	// container are used for the RepoRef.
	// LocationRef only holds the container values, and does not include
	// the metadata prefixes (tenant, service, owner, etc) found in the
	// repoRef.
	// Currently only implemented for Exchange Calendars.
	LocationRef string `json:"locationRef,omitempty"`

	// ItemRef contains the stable id of the item itself.  ItemRef is not
	// guaranteed to be unique within a repository.  Uniqueness guarantees
	// maximally inherit from the source item. Eg: Entries for m365 mail items
	// are only as unique as m365 mail item IDs themselves.
	ItemRef string `json:"itemRef,omitempty"`

	ItemInfo
}

Entry describes a single item stored in a Backup

func (Entry) Headers

func (de Entry) Headers(skipID bool) []string

Headers returns the human-readable names of properties in a DetailsEntry for printing out to a terminal in a columnar display.

func (Entry) MinimumPrintable

func (de Entry) MinimumPrintable() any

MinimumPrintable DetailsEntries is a passthrough func, because no reduction is needed for the json output.

func (Entry) ToLocationIDer

func (de Entry) ToLocationIDer(backupVersion int) (LocationIDer, error)

ToLocationIDer takes a backup version and produces the unique location for this entry if possible. Reasons it may not be possible to produce the unique location include an unsupported backup version or missing information.

TODO(ashmrtn): Remove this function completely if we ever decide to sunset older corso versions that didn't populate LocationRef.

func (Entry) Values

func (de Entry) Values(skipID bool) []string

Values returns the values matching the Headers list.

type ExchangeInfo

type ExchangeInfo struct {
	ItemType    ItemType  `json:"itemType,omitempty"`
	Sender      string    `json:"sender,omitempty"`
	Subject     string    `json:"subject,omitempty"`
	Recipient   []string  `json:"recipient,omitempty"`
	ParentPath  string    `json:"parentPath,omitempty"`
	Received    time.Time `json:"received,omitempty"`
	EventStart  time.Time `json:"eventStart,omitempty"`
	EventEnd    time.Time `json:"eventEnd,omitempty"`
	Organizer   string    `json:"organizer,omitempty"`
	ContactName string    `json:"contactName,omitempty"`
	EventRecurs bool      `json:"eventRecurs,omitempty"`
	Created     time.Time `json:"created,omitempty"`
	Modified    time.Time `json:"modified,omitempty"`
	Size        int64     `json:"size,omitempty"`
}

ExchangeInfo describes an exchange item

func (ExchangeInfo) Headers

func (i ExchangeInfo) Headers() []string

Headers returns the human-readable names of properties in an ExchangeInfo for printing out to a terminal in a columnar display.

func (*ExchangeInfo) UpdateParentPath

func (i *ExchangeInfo) UpdateParentPath(newLocPath *path.Builder)

func (ExchangeInfo) Values

func (i ExchangeInfo) Values() []string

Values returns the values matching the Headers list for printing out to a terminal in a columnar display.

type ExtensionData

type ExtensionData struct {
	Data map[string]any `json:"data,omitempty"`
}

ExtensionData stores extension data associated with an item

type FolderInfo

type FolderInfo struct {
	ItemType    ItemType  `json:"itemType,omitempty"`
	DisplayName string    `json:"displayName"`
	Modified    time.Time `json:"modified,omitempty"`
	Size        int64     `json:"size,omitempty"`
	DataType    ItemType  `json:"dataType,omitempty"`
	DriveName   string    `json:"driveName,omitempty"`
	DriveID     string    `json:"driveID,omitempty"`
}

func (FolderInfo) Headers

func (i FolderInfo) Headers() []string

func (FolderInfo) Values

func (i FolderInfo) Values() []string

type GroupsInfo

type GroupsInfo struct {
	ItemType ItemType  `json:"itemType,omitempty"`
	Modified time.Time `json:"modified,omitempty"`

	// Channels Specific
	Message   ChannelMessageInfo `json:"message,omitempty"`
	LastReply ChannelMessageInfo `json:"lastReply,omitempty"`

	// Conversations Specific
	Post ConversationPostInfo `json:"post,omitempty"`

	// SharePoint specific
	Created    time.Time `json:"created,omitempty"`
	DriveName  string    `json:"driveName,omitempty"`
	DriveID    string    `json:"driveID,omitempty"`
	ItemName   string    `json:"itemName,omitempty"`
	Owner      string    `json:"owner,omitempty"`
	ParentPath string    `json:"parentPath,omitempty"`
	SiteID     string    `json:"siteID,omitempty"`
	Size       int64     `json:"size,omitempty"`
	WebURL     string    `json:"webURL,omitempty"`
}

GroupsInfo describes a groups item

func (GroupsInfo) Headers

func (i GroupsInfo) Headers() []string

Headers returns the human-readable names of properties in a groupsInfo for printing out to a terminal in a columnar display.

func (*GroupsInfo) UpdateParentPath

func (i *GroupsInfo) UpdateParentPath(newLocPath *path.Builder)

func (GroupsInfo) Values

func (i GroupsInfo) Values() []string

Values returns the values matching the Headers list for printing out to a terminal in a columnar display.

type ItemInfo

type ItemInfo struct {
	Folder     *FolderInfo     `json:"folder,omitempty"`
	Exchange   *ExchangeInfo   `json:"exchange,omitempty"`
	SharePoint *SharePointInfo `json:"sharePoint,omitempty"`
	OneDrive   *OneDriveInfo   `json:"oneDrive,omitempty"`
	Groups     *GroupsInfo     `json:"groups,omitempty"`
	TeamsChats *TeamsChatsInfo `json:"teamsChats,omitempty"`
	// Optional item extension data
	Extension *ExtensionData `json:"extension,omitempty"`
}

ItemInfo is a oneOf that contains service specific information about the item it tracks

func (ItemInfo) Modified

func (i ItemInfo) Modified() time.Time

type ItemType

type ItemType int
const (
	UnknownType ItemType = 0

	// Exchange (00x)
	ExchangeContact ItemType = 1
	ExchangeEvent   ItemType = 2
	ExchangeMail    ItemType = 3

	// SharePoint (10x)
	SharePointLibrary ItemType = 101 // also used for groups
	SharePointList    ItemType = 102
	SharePointPage    ItemType = 103

	// OneDrive (20x)
	OneDriveItem ItemType = 205

	// Folder Management(30x)
	FolderItem ItemType = 306

	// Groups/Teams(40x)
	GroupsChannelMessage   ItemType = 401
	GroupsConversationPost ItemType = 402

	// Teams Chat
	TeamsChat ItemType = 501
)

ItemTypes are enumerated by service (hundredth digit) and data type (ones digit). Ex: exchange is 00x where x is the data type. Sharepoint is 10x, and etc. Every item info struct should get its own hundredth enumeration entry. Every item category for that service should get its own entry (even if differences between types aren't apparent on initial implementation, this future-proofs against breaking changes). Entries should not be rearranged. Additionally, any itemType directly assigned a number should not be altered. This applies to OneDriveItem and FolderItem

type ListInfo

type ListInfo struct {
	Name      string `json:"name,omitempty"`
	ItemCount int64  `json:"itemCount,omitempty"`
	Template  string `json:"template,omitempty"`
}

type LocationIDer

type LocationIDer interface {
	ID() *path.Builder
	InDetails() *path.Builder
}

LocationIDer provides access to location information but guarantees that it can also generate a unique location (among items in the same service but possibly across data types within the service) that can be used as a key in maps and other structures. The unique location may be different than InDetails, the location used in backup details.

type OneDriveInfo

type OneDriveInfo struct {
	Created    time.Time `json:"created,omitempty"`
	DriveID    string    `json:"driveID,omitempty"`
	DriveName  string    `json:"driveName,omitempty"`
	IsMeta     bool      `json:"isMeta,omitempty"`
	ItemName   string    `json:"itemName,omitempty"`
	ItemType   ItemType  `json:"itemType,omitempty"`
	Modified   time.Time `json:"modified,omitempty"`
	Owner      string    `json:"owner,omitempty"`
	ParentPath string    `json:"parentPath"`
	Size       int64     `json:"size,omitempty"`
}

OneDriveInfo describes a oneDrive item

func (OneDriveInfo) Headers

func (i OneDriveInfo) Headers() []string

Headers returns the human-readable names of properties in a OneDriveInfo for printing out to a terminal in a columnar display.

func (*OneDriveInfo) UpdateParentPath

func (i *OneDriveInfo) UpdateParentPath(newLocPath *path.Builder)

func (OneDriveInfo) Values

func (i OneDriveInfo) Values() []string

Values returns the values matching the Headers list for printing out to a terminal in a columnar display.

type SharePointInfo

type SharePointInfo struct {
	Created    time.Time `json:"created,omitempty"`
	DriveName  string    `json:"driveName,omitempty"`
	DriveID    string    `json:"driveID,omitempty"`
	ItemName   string    `json:"itemName,omitempty"`
	ItemType   ItemType  `json:"itemType,omitempty"`
	Modified   time.Time `json:"modified,omitempty"`
	Owner      string    `json:"owner,omitempty"`
	ParentPath string    `json:"parentPath,omitempty"`
	Size       int64     `json:"size,omitempty"`
	WebURL     string    `json:"webUrl,omitempty"`
	SiteID     string    `json:"siteID,omitempty"`
	List       *ListInfo `json:"list,omitempty"`
}

SharePointInfo describes a sharepoint item

func (SharePointInfo) Headers

func (i SharePointInfo) Headers() []string

Headers returns the human-readable names of properties in a SharePointInfo for printing out to a terminal in a columnar display.

func (*SharePointInfo) UpdateParentPath

func (i *SharePointInfo) UpdateParentPath(newLocPath *path.Builder)

func (SharePointInfo) Values

func (i SharePointInfo) Values() []string

Values returns the values matching the Headers list for printing out to a terminal in a columnar display.

type TeamsChatsInfo

type TeamsChatsInfo struct {
	ItemType   ItemType  `json:"itemType,omitempty"`
	Modified   time.Time `json:"modified,omitempty"`
	ParentPath string    `json:"parentPath,omitempty"`

	Chat ChatInfo `json:"chat,omitempty"`
}

TeamsChatsInfo describes a chat within teams chats.

func (TeamsChatsInfo) Headers

func (i TeamsChatsInfo) Headers() []string

Headers returns the human-readable names of properties in a ChatsInfo for printing out to a terminal in a columnar display.

func (*TeamsChatsInfo) UpdateParentPath

func (i *TeamsChatsInfo) UpdateParentPath(newLocPath *path.Builder)

func (TeamsChatsInfo) Values

func (i TeamsChatsInfo) Values() []string

Values returns the values matching the Headers list for printing out to a terminal in a columnar display.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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