api

package
v0.0.0-...-1b842a1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCalendar = "Calendar"
	DefaultContacts = "Contacts"
	MailInbox       = "Inbox"
	MsgFolderRoot   = "msgfolderroot"
)

Well knwon Folder Names Mail Definitions: https://docs.microsoft.com/en-us/graph/api/resources/mailfolder?view=graph-rest-1.0

View Source
const (
	AttachmentsColumnName       = "Attachments"
	EditColumnName              = "Edit"
	ContentTypeColumnName       = "ContentType"
	CreatedColumnName           = "Created"
	ModifiedColumnName          = "Modified"
	AuthorLookupIDColumnName    = "AuthorLookupId"
	EditorLookupIDColumnName    = "EditorLookupId"
	AppAuthorLookupIDColumnName = "AppAuthorLookupId"
	TitleColumnName             = "Title"

	ContentTypeColumnDisplayName = "Content Type"

	AddressKey     = "address"
	CoordinatesKey = "coordinates"
	DisplayNameKey = "displayName"
	LocationURIKey = "locationUri"
	UniqueIDKey    = "uniqueId"

	// entries that are nested within a second layer
	CityKey       = "city"
	CountryKey    = "countryOrRegion"
	PostalCodeKey = "postalCode"
	StateKey      = "state"
	StreetKey     = "street"
	LatitudeKey   = "latitude"
	LongitudeKey  = "longitude"

	CountryOrRegionFN = "CountryOrRegion"
	StateFN           = "State"
	CityFN            = "City"
	PostalCodeFN      = "PostalCode"
	StreetFN          = "Street"
	GeoLocFN          = "GeoLoc"
	DispNameFN        = "DispName"

	HyperlinkDescriptionKey = "Description"
	HyperlinkURLKey         = "Url"

	LookupIDKey    = "LookupId"
	LookupValueKey = "LookupValue"

	PersonEmailKey = "Email"

	MetadataLabelKey    = "Label"
	MetadataTermGUIDKey = "TermGuid"
	MetadataWssIDKey    = "WssId"

	LinkTitleFieldNamePart  = "LinkTitle"
	ChildCountFieldNamePart = "ChildCount"
	LookupIDFieldNamePart   = "LookupId"

	ODataTypeFieldNamePart      = "@odata.type"
	ODataTypeFieldNameStringVal = "Collection(Edm.String)"
	ODataTypeFieldNameIntVal    = "Collection(Edm.Int32)"

	ReadOnlyOrHiddenFieldNamePrefix = "_"
	DescoratorFieldNamePrefix       = "@"

	WebTemplateExtensionsListTemplate = "webTemplateExtensionsList"
	// This issue https://github.com/alcionai/corso/issues/4932
	// tracks to backup/restore supportability of `documentLibrary` templated lists
	DocumentLibraryListTemplate = "documentLibrary"
	SharingLinksListTemplate    = "sharingLinks"
	AccessRequestsListTemplate  = "accessRequest"
)
View Source
const (
	ResourceProvisioningOptions = "resourceProvisioningOptions"
)

Variables

View Source
var (
	ErrMailBoxNotFound             = clues.New("mailbox not found")
	ErrMailBoxSettingsAccessDenied = clues.New("mailbox settings access denied")
)

Variables

View Source
var ErrFolderNotFound = clues.New("folder not found")
View Source
var ErrSkippableListTemplate = clues.New("unable to create lists with skippable templates")

Functions

func BytesToContactable

func BytesToContactable(bytes []byte) (models.Contactable, error)

func BytesToEventable

func BytesToEventable(body []byte) (models.Eventable, error)

func BytesToListable

func BytesToListable(bytes []byte) (models.Listable, error)

func BytesToMessageable

func BytesToMessageable(body []byte) (models.Messageable, error)

func BytesToPostable

func BytesToPostable(body []byte) (models.Postable, error)

func CloneListItem

func CloneListItem(orig models.ListItemable, columnNames map[string]*columnDetails) models.ListItemable

CloneListItem creates a new `SharePoint.ListItem` and stores the original item's M365 data into it set fields. - https://learn.microsoft.com/en-us/graph/api/resources/listitem?view=graph-rest-1.0

func ContactCollisionKey

func ContactCollisionKey(item models.Contactable) string

ContactCollisionKey constructs a key from the contactable's creation time and either displayName or given+surname. collision keys are used to identify duplicate item conflicts for handling advanced restoration config.

func ContactInfo

func ContactInfo(contact models.Contactable) *details.ExchangeInfo

func CreateFromBytes

func CreateFromBytes(
	bytes []byte,
	createFunc serialization.ParsableFactory,
) (serialization.Parsable, error)

CreateFromBytes generates an m365 object form bytes.

func DefaultDriveItemProps

func DefaultDriveItemProps() []string

func DriveItemCollisionKey

func DriveItemCollisionKey(item models.DriveItemable) string

DriveItemCollisionKeyy constructs a key from the item name. collision keys are used to identify duplicate item conflicts for handling advanced restoration config.

func EvaluateMailboxError

func EvaluateMailboxError(err error) error

EvaluateMailboxError checks whether the provided error can be interpreted as "user does not have a mailbox", or whether it is some other error. If the former (no mailbox), returns nil, otherwise returns an error.

func EventCollisionKey

func EventCollisionKey(item models.Eventable) string

EventCollisionKey constructs a key from the eventable's creation time, subject, and organizer. collision keys are used to identify duplicate item conflicts for handling advanced restoration config.

func EventFromMap

func EventFromMap(ev map[string]any) (models.Eventable, error)

func EventInfo

func EventInfo(evt models.Eventable) *details.ExchangeInfo

func GetAllDrives

func GetAllDrives(
	ctx context.Context,
	pager pagers.NonDeltaHandler[models.Driveable],
) ([]models.Driveable, error)

GetAllDrives fetches all drives for the given pager

func GetAttachmentContent

func GetAttachmentContent(attachment models.Attachmentable) ([]byte, error)

func GetCancelledEventDateStrings

func GetCancelledEventDateStrings(event models.Eventable) ([]string, error)

func GetChatMessageAttachmentNames

func GetChatMessageAttachmentNames(msg models.ChatMessageable) []string

func GetChatMessageFrom

func GetChatMessageFrom(msg models.ChatMessageable) string

func HasAttachments

func HasAttachments(body models.ItemBodyable) bool

func InitConcurrencyLimit

func InitConcurrencyLimit(ctx context.Context, pst path.ServiceType)

initConcurrencyLimit ensures that the graph concurrency limiter is initialized, so that calls do not step over graph api's service limits. Limits are derived from the provided servie type. Callers will need to call this func before making api calls an api client.

func IsAnyErrMailboxNotFound

func IsAnyErrMailboxNotFound(errs []error) bool

IsAnyErrMailboxNotFound inspects the secondary errors inside MailboxInfo and determines whether the resource has a mailbox.

func IsNotSystemMessage

func IsNotSystemMessage(cm models.ChatMessageable) bool

func IsTeam

func IsTeam(ctx context.Context, mg models.Groupable) bool

func ListCollisionKey

func ListCollisionKey(list models.Listable) string

Two lists with same name cannot be created, hence going by the displayName itself as the collision key. Only displayName can be set. name is system generated based on displayName.

func ListToSPInfo

func ListToSPInfo(lst models.Listable) *details.SharePointInfo

ListToSPInfo translates models.Listable metadata into searchable content List documentation: https://learn.microsoft.com/en-us/graph/api/resources/list?view=graph-rest-1.0

func MailCollisionKey

func MailCollisionKey(item models.Messageable) string

MailCollisionKey constructs a key from the messageable's subject, sender, and recipients (to, cc, bcc). collision keys are used to identify duplicate item conflicts for handling advanced restoration config.

func MailInfo

func MailInfo(msg models.Messageable, size int64) *details.ExchangeInfo

func NewDriveItem

func NewDriveItem(name string, folder bool) *models.DriveItem

NewDriveItem initializes a `models.DriveItemable` with either a folder or file entry.

func NewService

func NewService(
	creds account.M365Config,
	counter *count.Bus,
	opts ...graph.Option,
) (*graph.Service, error)

func OnlyTeams

func OnlyTeams(ctx context.Context, gs []models.Groupable) []models.Groupable

func SelectProps

func SelectProps(ss ...string) []string

func TeamsChatInfo

func TeamsChatInfo(chat models.Chatable) *details.TeamsChatsInfo

func ToListable

func ToListable(orig models.Listable, listName string) (models.Listable, map[string]*columnDetails)

ToListable utility function to encapsulate stored data for restoration. New Listable omits trackable fields such as `id` or `ETag` and other read-only objects that are prevented upon upload. Additionally, read-Only columns are not attached in this method. ListItems are not included in creation of new list, and have to be restored in separate call.

func URLCacheDriveItemProps

func URLCacheDriveItemProps() []string

URL cache only needs to fetch a small subset of item properties

Types

type Access

type Access struct {
	Client
}

Access is an interface-compliant provider of the client.

func (Access) GetToken

func (c Access) GetToken(
	ctx context.Context,
) error

GetToken retrieves a m365 application auth token using client id and secret credentials. This token is not normally needed in order for corso to function, and is implemented primarily as a way to exercise the validity of those credentials without need of specific permissions.

type AutomaticRepliesSettings

type AutomaticRepliesSettings struct {
	ExternalAudience       string
	ExternalReplyMessage   string
	InternalReplyMessage   string
	ScheduledEndDateTime   TimeInfo
	ScheduledStartDateTime TimeInfo
	Status                 string
}

type CalendarDisplayable

type CalendarDisplayable struct {
	models.Calendarable
}

CalendarDisplayable is a wrapper that complies with the models.Calendarable interface with the graph.Container interfaces. Calendars do not have a parentFolderID. Therefore, that value will always return nil.

func (CalendarDisplayable) GetDisplayName

func (c CalendarDisplayable) GetDisplayName() *string

GetDisplayName returns the *string of the models.Calendable variant: calendar.GetName()

func (CalendarDisplayable) GetParentFolderId

func (c CalendarDisplayable) GetParentFolderId() *string

GetParentFolderId returns the default calendar name address EventCalendars have a flat hierarchy and Calendars are rooted at the default

type CallConfig

type CallConfig struct {
	Expand              []string
	Select              []string
	CanMakeDeltaQueries bool
	// LimitResults limits the returned results to the given number. If 0, returns
	// all results.
	LimitResults int
}

CallConfig defines additional parameters to add to the query like field selection and limiting results.

Not all calls may support all options. Check individual implementations to see what's supported and what's not.

type Channels

type Channels struct {
	Client
}

Channels is an interface-compliant provider of the client.

func (Channels) GetChannel

func (c Channels) GetChannel(
	ctx context.Context,
	teamID, containerID string,
) (models.Channelable, error)

func (Channels) GetChannelByName

func (c Channels) GetChannelByName(
	ctx context.Context,
	teamID, containerName string,
) (models.Channelable, error)

GetChannelByName fetches a channel by name

func (Channels) GetChannelMessage

func (c Channels) GetChannelMessage(
	ctx context.Context,
	teamID, channelID, messageID string,
) (models.ChatMessageable, *details.GroupsInfo, error)

func (Channels) GetChannelMessageIDs

func (c Channels) GetChannelMessageIDs(
	ctx context.Context,
	teamID, channelID, prevDeltaLink string,
	cc CallConfig,
) (pagers.AddedAndRemoved, error)

GetChannelMessageIDs fetches a delta of all messages in the channel. returns two maps: addedItems, deletedItems

func (Channels) GetChannelMessageReplies

func (c Channels) GetChannelMessageReplies(
	ctx context.Context,
	teamID, channelID, messageID string,
) ([]models.ChatMessageable, error)

GetChannels fetches the minimum valuable data from each reply in the message

func (Channels) GetChannelMessages

func (c Channels) GetChannelMessages(
	ctx context.Context,
	teamID, channelID string,
	cc CallConfig,
) ([]models.ChatMessageable, error)

GetChannelMessages fetches a delta of all messages in the channel.

func (Channels) GetChannels

func (c Channels) GetChannels(
	ctx context.Context,
	teamID string,
) ([]models.Channelable, error)

GetChannels fetches all channels in the team.

func (Channels) NewChannelMessageDeltaPager

func (c Channels) NewChannelMessageDeltaPager(
	teamID, channelID, prevDelta string,
	selectProps ...string,
) *channelMessageDeltaPageCtrl

func (Channels) NewChannelMessagePager

func (c Channels) NewChannelMessagePager(
	teamID, channelID string,
	cc CallConfig,
) *channelMessagePageCtrl

func (Channels) NewChannelMessageRepliesPager

func (c Channels) NewChannelMessageRepliesPager(
	teamID, channelID, messageID string,
	selectProps ...string,
) *channelMessageRepliesPageCtrl

func (Channels) NewChannelPager

func (c Channels) NewChannelPager(
	teamID string,
) *channelPageCtrl

type Chats

type Chats struct {
	Client
}

Chats is an interface-compliant provider of the client.

func (Chats) GetChatByID

func (c Chats) GetChatByID(
	ctx context.Context,
	chatID string,
	cc CallConfig,
) (models.Chatable, *details.TeamsChatsInfo, error)

func (Chats) GetChatMessageIDs

func (c Chats) GetChatMessageIDs(
	ctx context.Context,
	chatID string,
	cc CallConfig,
) (pagers.AddedAndRemoved, error)

GetChatMessageIDs fetches a delta of all messages in the chat. returns two maps: addedItems, deletedItems

func (Chats) GetChatMessages

func (c Chats) GetChatMessages(
	ctx context.Context,
	chatID string,
	cc CallConfig,
) ([]models.ChatMessageable, error)

GetChatMessages fetches a delta of all messages in the chat.

func (Chats) GetChats

func (c Chats) GetChats(
	ctx context.Context,
	userID string,
	cc CallConfig,
) ([]models.Chatable, error)

GetChats fetches all chats in the team.

func (Chats) NewChatMessagePager

func (c Chats) NewChatMessagePager(
	chatID string,
	cc CallConfig,
) *chatMessagePageCtrl

func (Chats) NewChatPager

func (c Chats) NewChatPager(
	userID string,
	cc CallConfig,
) *chatPageCtrl

type Client

type Client struct {
	Credentials account.M365Config

	// The Stable service is re-usable for any request.
	// This allows us to maintain performance across async requests.
	Stable graph.Servicer

	// The LargeItem graph servicer is configured specifically for
	// downloading large items such as drive item content or outlook
	// mail and event attachments.
	LargeItem graph.Servicer

	// The Requester provides a client specifically for calling
	// arbitrary urls instead of constructing queries using the
	// graph api client.
	Requester graph.Requester
	// contains filtered or unexported fields
}

Client is used to fulfill queries that are traditionally backed by GraphAPI. A struct is used in this case, instead of deferring to pure function wrappers, so that the boundary separates the granular implementation of the graphAPI and kiota away from the other packages.

func NewClient

func NewClient(
	creds account.M365Config,
	co control.Options,
	counter *count.Bus,
	opts ...graph.Option,
) (Client, error)

NewClient produces a new exchange api client. Must be used in place of creating an ad-hoc client struct.

func (Client) Access

func (c Client) Access() Access

func (Client) Channels

func (c Client) Channels() Channels

func (Client) Chats

func (c Client) Chats() Chats

func (Client) Contacts

func (c Client) Contacts() Contacts

func (Client) Conversations

func (c Client) Conversations() Conversations

func (Client) Drives

func (c Client) Drives() Drives

func (Client) Events

func (c Client) Events() Events

func (Client) Get

func (c Client) Get(
	ctx context.Context,
	url string,
	headers map[string]string,
	requireAuth bool,
) (*http.Response, error)

Get performs an ad-hoc get request using its graph.Requester

func (Client) Groups

func (c Client) Groups() Groups

func (Client) Lists

func (c Client) Lists() Lists

func (Client) Mail

func (c Client) Mail() Mail

func (Client) Post

func (c Client) Post(
	ctx context.Context,
	url string,
	headers map[string]string,
	body io.Reader,
	requireAuth bool,
) (*http.Response, error)

Get performs an ad-hoc get request using its graph.Requester

func (Client) Service

func (c Client) Service(
	counter *count.Bus,
	opts ...graph.Option,
) (graph.Servicer, error)

Service generates a new graph servicer. New servicers are used for paged and other long-running requests instead of the client's stable service, so that in-flight state within the adapter doesn't get clobbered. Most calls should use the Client.Stable property instead of calling this func, unless it is explicitly necessary.

func (Client) Sites

func (c Client) Sites() Sites

func (Client) Users

func (c Client) Users() Users

type Contacts

type Contacts struct {
	Client
}

Contacts is an interface-compliant provider of the client.

func (Contacts) CreateContainer

func (c Contacts) CreateContainer(
	ctx context.Context,

	userID, _, containerName string,
) (graph.Container, error)

CreateContainer makes a contact folder with the displayName of folderName. If successful, returns the created folder object.

func (Contacts) DeleteContainer

func (c Contacts) DeleteContainer(
	ctx context.Context,
	userID, containerID string,
) error

DeleteContainer deletes the ContactFolder associated with the M365 ID if permissions are valid.

func (Contacts) DeleteItem

func (c Contacts) DeleteItem(
	ctx context.Context,
	userID, itemID string,
) error

func (Contacts) EnumerateContainers

func (c Contacts) EnumerateContainers(
	ctx context.Context,
	userID, baseContainerID string,
) ([]models.ContactFolderable, error)

EnumerateContainers retrieves all of the user's current contact folders.

func (Contacts) GetAddedAndRemovedItemIDs

func (c Contacts) GetAddedAndRemovedItemIDs(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	config CallConfig,
) (pagers.AddedAndRemoved, error)

func (Contacts) GetContainerByID

func (c Contacts) GetContainerByID(
	ctx context.Context,
	userID, containerID string,
) (graph.Container, error)

func (Contacts) GetContainerByName

func (c Contacts) GetContainerByName(
	ctx context.Context,

	userID, _, containerName string,
) (graph.Container, error)

GetContainerByName fetches a folder by name

func (Contacts) GetItem

func (c Contacts) GetItem(
	ctx context.Context,
	userID, itemID string,
	_ *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error)

GetItem retrieves a Contactable item.

func (Contacts) GetItemIDsInContainer

func (c Contacts) GetItemIDsInContainer(
	ctx context.Context,
	userID, containerID string,
) (map[string]struct{}, error)

func (Contacts) GetItemsInContainerByCollisionKey

func (c Contacts) GetItemsInContainerByCollisionKey(
	ctx context.Context,
	userID, containerID string,
) (map[string]string, error)

func (Contacts) NewContactFoldersPager

func (c Contacts) NewContactFoldersPager(
	userID, baseContainerID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.ContactFolderable]

func (Contacts) NewContactsDeltaPager

func (c Contacts) NewContactsDeltaPager(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	selectProps ...string,
) pagers.DeltaHandler[models.Contactable]

func (Contacts) NewContactsPager

func (c Contacts) NewContactsPager(
	userID, containerID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.Contactable]

func (Contacts) PatchFolder

func (c Contacts) PatchFolder(
	ctx context.Context,
	userID, containerID string,
	body models.ContactFolderable,
) error

func (Contacts) PostItem

func (c Contacts) PostItem(
	ctx context.Context,
	userID, containerID string,
	body models.Contactable,
) (models.Contactable, error)

func (Contacts) Serialize

func (c Contacts) Serialize(
	ctx context.Context,
	item serialization.Parsable,
	userID, itemID string,
) ([]byte, error)

type Conversations

type Conversations struct {
	Client
}

Conversations is an interface-compliant provider of the client.

func (Conversations) GetConversationPost

func (c Conversations) GetConversationPost(
	ctx context.Context,
	groupID, conversationID, threadID, postID string,
) (models.Postable, *details.GroupsInfo, error)

func (Conversations) GetConversationThreadPostIDs

func (c Conversations) GetConversationThreadPostIDs(
	ctx context.Context,
	groupID, conversationID, threadID string,
	cc CallConfig,
) (pagers.AddedAndRemoved, error)

GetConversations fetches all added and deleted conversation posts in the group.

func (Conversations) GetConversationThreadPosts

func (c Conversations) GetConversationThreadPosts(
	ctx context.Context,
	groupID, conversationID, threadID string,
	cc CallConfig,
) ([]models.Postable, error)

GetConversations fetches all conversation posts in the group.

func (Conversations) GetConversationThreads

func (c Conversations) GetConversationThreads(
	ctx context.Context,
	groupID, conversationID string,
	cc CallConfig,
) ([]models.ConversationThreadable, error)

GetConversations fetches all conversation threads in the group.

func (Conversations) GetConversations

func (c Conversations) GetConversations(
	ctx context.Context,
	groupID string,
	cc CallConfig,
) ([]models.Conversationable, error)

GetConversations fetches all conversations in the group.

func (Conversations) NewConversationThreadPostsPager

func (c Conversations) NewConversationThreadPostsPager(
	groupID, conversationID, threadID string,
	cc CallConfig,
) *conversationThreadPostsPageCtrl

func (Conversations) NewConversationThreadsPager

func (c Conversations) NewConversationThreadsPager(
	groupID, conversationID string,
	cc CallConfig,
) *conversationThreadsPageCtrl

func (Conversations) NewConversationsPager

func (c Conversations) NewConversationsPager(
	groupID string,
	cc CallConfig,
) *conversationsPageCtrl

type DriveItemDeltaPageCtrl

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

func (*DriveItemDeltaPageCtrl) GetPage

func (*DriveItemDeltaPageCtrl) Reset

func (p *DriveItemDeltaPageCtrl) SetNextLink(link string)

func (*DriveItemDeltaPageCtrl) ValidModTimes

func (p *DriveItemDeltaPageCtrl) ValidModTimes() bool

type DriveItemIDType

type DriveItemIDType struct {
	ItemID   string
	IsFolder bool
}

type Drives

type Drives struct {
	Client
}

Drives is an interface-compliant provider of the client.

func (Drives) DeleteItem

func (c Drives) DeleteItem(
	ctx context.Context,
	driveID, itemID string,
) error

deletes require unique http clients https://github.com/alcionai/corso/issues/2707

func (Drives) DeleteItemPermission

func (c Drives) DeleteItemPermission(
	ctx context.Context,
	driveID, itemID, permissionID string,
) error

func (Drives) EnumerateDriveItemsDelta

func (c Drives) EnumerateDriveItemsDelta(
	ctx context.Context,
	driveID string,
	prevDeltaLink string,
	cc CallConfig,
) pagers.NextPageResulter[models.DriveItemable]

EnumerateDriveItems will enumerate all items in the specified drive and stream them page by page, along with the delta update and any errors, to the provided channel.

func (Drives) GetFolderByName

func (c Drives) GetFolderByName(
	ctx context.Context,
	driveID, parentFolderID, folderName string,
) (models.DriveItemable, error)

GetFolderByName will lookup the specified folder by name within the parentFolderID folder.

func (Drives) GetFolderChildren

func (c Drives) GetFolderChildren(
	ctx context.Context,
	driveID, folderID string,
) ([]models.DriveItemable, error)

TODO: pagination controller needed for completion.

func (Drives) GetItem

func (c Drives) GetItem(
	ctx context.Context,
	driveID, itemID string,
) (models.DriveItemable, error)

generic drive item getter

func (Drives) GetItemIDsInContainer

func (c Drives) GetItemIDsInContainer(
	ctx context.Context,
	driveID, containerID string,
) (map[string]DriveItemIDType, error)

func (Drives) GetItemPermission

func (c Drives) GetItemPermission(
	ctx context.Context,
	driveID, itemID string,
) (models.PermissionCollectionResponseable, error)

func (Drives) GetItemsInContainerByCollisionKey

func (c Drives) GetItemsInContainerByCollisionKey(
	ctx context.Context,
	driveID, containerID string,
) (map[string]DriveItemIDType, error)

func (Drives) GetRootFolder

func (c Drives) GetRootFolder(
	ctx context.Context,
	driveID string,
) (models.DriveItemable, error)

func (Drives) NewDriveItemPager

func (c Drives) NewDriveItemPager(
	driveID, containerID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.DriveItemable]

func (Drives) NewItemContentUpload

func (c Drives) NewItemContentUpload(
	ctx context.Context,
	driveID, itemID string,
) (models.UploadSessionable, error)

func (Drives) NewSiteDrivePager

func (c Drives) NewSiteDrivePager(
	siteID string,
	fields []string,
) *siteDrivePager

NewSiteDrivePager is a constructor for creating a siteDrivePager fields are the associated site drive fields that are desired to be returned in a query. NOTE: Fields are case-sensitive. Incorrect field settings will cause errors during later paging. Available fields: https://learn.microsoft.com/en-us/graph/api/resources/drive?view=graph-rest-1.0

func (Drives) NewUserDrivePager

func (c Drives) NewUserDrivePager(
	userID string,
	fields []string,
) *userDrivePager

func (Drives) PatchItem

func (c Drives) PatchItem(
	ctx context.Context,
	driveID, itemID string,
	item models.DriveItemable,
) error

func (Drives) PostItemInContainer

func (c Drives) PostItemInContainer(
	ctx context.Context,
	driveID, parentFolderID string,
	newItem models.DriveItemable,
	onCollision control.CollisionPolicy,
) (models.DriveItemable, error)

PostItemInContainer creates a new item in the specified folder

func (Drives) PostItemLinkShareUpdate

func (c Drives) PostItemLinkShareUpdate(
	ctx context.Context,
	driveID, itemID string,
	body *drives.ItemItemsItemCreateLinkPostRequestBody,
) (models.Permissionable, error)

func (Drives) PostItemPermissionUpdate

func (c Drives) PostItemPermissionUpdate(
	ctx context.Context,
	driveID, itemID string,
	body *drives.ItemItemsItemInvitePostRequestBody,
) (drives.ItemItemsItemInviteResponseable, error)

func (Drives) PutItemContent

func (c Drives) PutItemContent(
	ctx context.Context,
	driveID, itemID string,
	content []byte,
) error

type Events

type Events struct {
	Client
}

Events is an interface-compliant provider of the client.

func (Events) CreateContainer

func (c Events) CreateContainer(
	ctx context.Context,

	userID, _, containerName string,
) (graph.Container, error)

CreateContainer makes an event Calendar with the name in the user's M365 exchange account Reference: https://docs.microsoft.com/en-us/graph/api/user-post-calendars?view=graph-rest-1.0&tabs=go

func (Events) DeleteAttachment

func (c Events) DeleteAttachment(
	ctx context.Context,
	userID, calendarID, eventID, attachmentID string,
) error

func (Events) DeleteContainer

func (c Events) DeleteContainer(
	ctx context.Context,
	userID, containerID string,
) error

DeleteContainer removes a calendar from user's M365 account Reference: https://docs.microsoft.com/en-us/graph/api/calendar-delete?view=graph-rest-1.0&tabs=go

func (Events) DeleteItem

func (c Events) DeleteItem(
	ctx context.Context,
	userID, itemID string,
) error

func (Events) EnumerateContainers

func (c Events) EnumerateContainers(
	ctx context.Context,
	userID, _ string,
) ([]models.Calendarable, error)

EnumerateContainers retrieves all of the user's current mail folders.

func (Events) GetAddedAndRemovedItemIDs

func (c Events) GetAddedAndRemovedItemIDs(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	config CallConfig,
) (pagers.AddedAndRemoved, error)

func (Events) GetAttachments

func (c Events) GetAttachments(
	ctx context.Context,
	userID, itemID string,
) ([]models.Attachmentable, error)

func (Events) GetContainerByID

func (c Events) GetContainerByID(
	ctx context.Context,
	userID, containerID string,
) (graph.Container, error)

func (Events) GetContainerByName

func (c Events) GetContainerByName(
	ctx context.Context,

	userID, _, containerName string,
) (graph.Container, error)

GetContainerByName fetches a calendar by name

func (Events) GetItem

func (c Events) GetItem(
	ctx context.Context,
	userID, itemID string,
	errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error)

GetItem retrieves an Eventable item.

func (Events) GetItemIDsInContainer

func (c Events) GetItemIDsInContainer(
	ctx context.Context,
	userID, containerID string,
) (map[string]struct{}, error)

func (Events) GetItemInstances

func (c Events) GetItemInstances(
	ctx context.Context,
	userID, itemID, startDate, endDate string,
) ([]models.Eventable, error)

func (Events) GetItemsInContainerByCollisionKey

func (c Events) GetItemsInContainerByCollisionKey(
	ctx context.Context,
	userID, containerID string,
) (map[string]string, error)

func (Events) NewEventCalendarsPager

func (c Events) NewEventCalendarsPager(
	userID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.Calendarable]

func (Events) NewEventsDeltaPager

func (c Events) NewEventsDeltaPager(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	selectProps ...string,
) pagers.DeltaHandler[models.Eventable]

func (Events) NewEventsPager

func (c Events) NewEventsPager(
	userID, containerID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.Eventable]

func (Events) PatchCalendar

func (c Events) PatchCalendar(
	ctx context.Context,
	userID, containerID string,
	body models.Calendarable,
) error

func (Events) PatchItem

func (c Events) PatchItem(
	ctx context.Context,
	userID, eventID string,
	body models.Eventable,
) (models.Eventable, error)

func (Events) PostItem

func (c Events) PostItem(
	ctx context.Context,
	userID, containerID string,
	body models.Eventable,
) (models.Eventable, error)

func (Events) PostLargeAttachment

func (c Events) PostLargeAttachment(
	ctx context.Context,
	userID, containerID, parentItemID, itemName string,
	content []byte,
) (string, error)

func (Events) PostSmallAttachment

func (c Events) PostSmallAttachment(
	ctx context.Context,
	userID, containerID, parentItemID string,
	body models.Attachmentable,
) error

func (Events) Serialize

func (c Events) Serialize(
	ctx context.Context,
	item serialization.Parsable,
	userID, itemID string,
) ([]byte, error)

type GetAndSerializeItemer

type GetAndSerializeItemer[INFO any] interface {
	GetItemer[INFO]
	Serializer
}

type GetByIDer

type GetByIDer[T any] interface {
	GetByID(
		ctx context.Context,
		identifier string,
		cc CallConfig,
	) (T, error)
}

type GetItemer

type GetItemer[INFO any] interface {
	GetItem(
		ctx context.Context,
		user, itemID string,
		errs *fault.Bus,
	) (serialization.Parsable, *INFO, error)
}

type Getter

type Getter interface {
	Get(
		ctx context.Context,
		url string,
		headers map[string]string,
		requireAuth bool,
	) (*http.Response, error)
}

type Groups

type Groups struct {
	Client
}

Groups is an interface-compliant provider of the client.

func (Groups) GetAll

func (c Groups) GetAll(
	ctx context.Context,
	errs *fault.Bus,
) ([]models.Groupable, error)

func (Groups) GetAllIDsAndNames

func (c Groups) GetAllIDsAndNames(ctx context.Context, errs *fault.Bus) (idname.Cacher, error)

GetAllIDsAndNames retrieves all groups in the tenant and returns them in an idname.Cacher

func (Groups) GetAllSites

func (c Groups) GetAllSites(
	ctx context.Context,
	identifier string,
	errs *fault.Bus,
) ([]models.Siteable, error)

GetAllSites gets all the sites that belong to a group. This is necessary as private and shared channels gets their on individual sites. All the other channels make use of the root site.

func (Groups) GetByID

func (c Groups) GetByID(
	ctx context.Context,
	identifier string,
	_ CallConfig,
) (models.Groupable, error)

GetID can look up a group by either its canonical id (a uuid) or by the group's display name. If looking up the display name an error will be returned if more than one group gets returned in the results.

func (Groups) GetIDAndName

func (c Groups) GetIDAndName(
	ctx context.Context,
	groupID string,
	cc CallConfig,
) (string, string, error)

GetIDAndName looks up the group matching the given ID, and returns its canonical ID and the name.

func (Groups) GetRootSite

func (c Groups) GetRootSite(
	ctx context.Context,
	identifier string,
) (models.Siteable, error)

func (Groups) GetTeamByID

func (c Groups) GetTeamByID(
	ctx context.Context,
	identifier string,
	_ CallConfig,
) (models.Teamable, error)

GetTeamByID can lookup a team by its group id. It will fail if the group is not a Team.

type Language

type Language struct {
	Locale      string
	DisplayName string
}

type Lists

type Lists struct {
	Client
}

Lists is an interface-compliant provider of the client.

func (Lists) DeleteList

func (c Lists) DeleteList(
	ctx context.Context,
	siteID, listID string,
) error

func (Lists) GetCTypesColumns

func (c Lists) GetCTypesColumns(
	ctx context.Context,
	siteID string,
	listID string,
	contentTypeID string,
	cc CallConfig,
) ([]models.ColumnDefinitionable, error)

GetCTypesColumns fetches all columns in the content type.

func (c Lists) GetColumnLinks(
	ctx context.Context,
	siteID string,
	listID string,
	contentTypeID string,
	cc CallConfig,
) ([]models.ColumnLinkable, error)

GetColumnLinks fetches all column links in the content type.

func (Lists) GetContentTypes

func (c Lists) GetContentTypes(
	ctx context.Context,
	siteID string,
	listID string,
	cc CallConfig,
) ([]models.ContentTypeable, error)

GetContentTypes fetches all content types in the list.

func (Lists) GetListByID

func (c Lists) GetListByID(ctx context.Context,
	siteID, listID string,
) (models.Listable, *details.SharePointInfo, error)

GetListById is a utility function to populate a SharePoint.List with objects associated with a given siteID. @param siteID the M365 ID that represents the SharePoint Site Makes additional calls to retrieve the following relationships: - Columns - ContentTypes - List Items

func (Lists) GetListColumns

func (c Lists) GetListColumns(
	ctx context.Context,
	siteID string,
	listID string,
	cc CallConfig,
) ([]models.ColumnDefinitionable, error)

GetListColumns fetches all list columns in the list.

func (Lists) GetListItems

func (c Lists) GetListItems(
	ctx context.Context,
	siteID string,
	listID string,
	cc CallConfig,
) ([]models.ListItemable, error)

GetListItems fetches all list items in the list.

func (Lists) GetLists

func (c Lists) GetLists(
	ctx context.Context,
	siteID string,
	cc CallConfig,
) ([]models.Listable, error)

GetLists fetches all lists in the site.

func (Lists) GetListsByCollisionKey

func (c Lists) GetListsByCollisionKey(
	ctx context.Context,
	siteID string,
) (map[string]string, error)

func (Lists) NewCTypesColumnsPager

func (c Lists) NewCTypesColumnsPager(
	siteID string,
	listID string,
	contentTypeID string,
	cc CallConfig,
) *cTypesColumnsPageCtrl

func (Lists) NewColumnLinksPager

func (c Lists) NewColumnLinksPager(
	siteID string,
	listID string,
	contentTypeID string,
	cc CallConfig,
) *columnLinksPageCtrl

func (Lists) NewColumnsPager

func (c Lists) NewColumnsPager(
	siteID string,
	listID string,
	cc CallConfig,
) *columnsPageCtrl

func (Lists) NewContentTypesPager

func (c Lists) NewContentTypesPager(
	siteID string,
	listID string,
	cc CallConfig,
) *contentTypesPageCtrl

func (Lists) NewListItemsPager

func (c Lists) NewListItemsPager(
	siteID string,
	listID string,
	cc CallConfig,
) *listItemsPageCtrl

func (Lists) NewListsPager

func (c Lists) NewListsPager(
	siteID string,
	cc CallConfig,
) *listsPageCtrl

func (Lists) PatchList

func (c Lists) PatchList(
	ctx context.Context,
	siteID, listID string,
	list models.Listable,
) (models.Listable, error)

func (Lists) PostDrive

func (c Lists) PostDrive(
	ctx context.Context,
	siteID, driveName string,
) (models.Driveable, error)

PostDrive creates a new list of type drive. Specifically used to create documentLibraries for SharePoint Sites.

func (Lists) PostList

func (c Lists) PostList(
	ctx context.Context,
	siteID string,
	listName string,
	storedList models.Listable,
	errs *fault.Bus,
) (models.Listable, error)

func (Lists) PostListItems

func (c Lists) PostListItems(
	ctx context.Context,
	siteID, listID string,
	listItems []models.ListItemable,
) error

type Mail

type Mail struct {
	Client
}

Mail is an interface-compliant provider of the client.

func (Mail) CreateContainer

func (c Mail) CreateContainer(
	ctx context.Context,
	userID, parentContainerID, containerName string,
) (graph.Container, error)

func (Mail) DeleteContainer

func (c Mail) DeleteContainer(
	ctx context.Context,
	userID, containerID string,
) error

DeleteContainer removes a mail folder with the corresponding M365 ID from the user's M365 Exchange account Reference: https://docs.microsoft.com/en-us/graph/api/mailfolder-delete?view=graph-rest-1.0&tabs=http

func (Mail) DeleteItem

func (c Mail) DeleteItem(
	ctx context.Context,
	userID, itemID string,
) error

func (Mail) EnumerateContainers

func (c Mail) EnumerateContainers(
	ctx context.Context,
	userID, _ string,
) ([]models.MailFolderable, error)

EnumerateContainers retrieves all of the user's current mail folders.

func (Mail) GetAddedAndRemovedItemIDs

func (c Mail) GetAddedAndRemovedItemIDs(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	config CallConfig,
) (pagers.AddedAndRemoved, error)

func (Mail) GetContainerByID

func (c Mail) GetContainerByID(
	ctx context.Context,
	userID, containerID string,
) (graph.Container, error)

func (Mail) GetContainerByName

func (c Mail) GetContainerByName(
	ctx context.Context,
	userID, parentContainerID, containerName string,
) (graph.Container, error)

GetContainerByName fetches a folder by name

func (Mail) GetContainerChildren

func (c Mail) GetContainerChildren(
	ctx context.Context,
	userID, containerID string,
) ([]models.MailFolderable, error)

TODO: needs pager implementation for completion

func (Mail) GetItem

func (c Mail) GetItem(
	ctx context.Context,
	userID, mailID string,
	errs *fault.Bus,
) (serialization.Parsable, *details.ExchangeInfo, error)

GetItem retrieves a Messageable item. If the item contains an attachment, that attachment is also downloaded.

func (Mail) GetItemIDsInContainer

func (c Mail) GetItemIDsInContainer(
	ctx context.Context,
	userID, containerID string,
) (map[string]struct{}, error)

func (Mail) GetItemsInContainer

func (c Mail) GetItemsInContainer(
	ctx context.Context,
	userID, containerID string,
) ([]models.Messageable, error)

func (Mail) GetItemsInContainerByCollisionKey

func (c Mail) GetItemsInContainerByCollisionKey(
	ctx context.Context,
	userID, containerID string,
) (map[string]string, error)

func (Mail) MoveContainer

func (c Mail) MoveContainer(
	ctx context.Context,
	userID, containerID string,
	body users.ItemMailFoldersItemMovePostRequestBodyable,
) error

func (Mail) MoveItem

func (c Mail) MoveItem(
	ctx context.Context,
	userID, oldContainerID, newContainerID, itemID string,
) (string, error)

func (Mail) NewMailDeltaPager

func (c Mail) NewMailDeltaPager(
	ctx context.Context,
	userID, containerID, prevDeltaLink string,
	selectProps ...string,
) pagers.DeltaHandler[models.Messageable]

func (Mail) NewMailFoldersPager

func (c Mail) NewMailFoldersPager(
	userID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.MailFolderable]

func (Mail) NewMailPager

func (c Mail) NewMailPager(
	userID, containerID string,
	selectProps ...string,
) pagers.NonDeltaHandler[models.Messageable]

func (Mail) PatchFolder

func (c Mail) PatchFolder(
	ctx context.Context,
	userID, containerID string,
	body models.MailFolderable,
) error

func (Mail) PostItem

func (c Mail) PostItem(
	ctx context.Context,
	userID, containerID string,
	body models.Messageable,
) (models.Messageable, error)

func (Mail) PostLargeAttachment

func (c Mail) PostLargeAttachment(
	ctx context.Context,
	userID, containerID, parentItemID, itemName string,
	content []byte,
) (string, error)

func (Mail) PostSmallAttachment

func (c Mail) PostSmallAttachment(
	ctx context.Context,
	userID, containerID, parentItemID string,
	body models.Attachmentable,
) error

func (Mail) Serialize

func (c Mail) Serialize(
	ctx context.Context,
	item serialization.Parsable,
	user, itemID string,
) ([]byte, error)

type MailboxInfo

type MailboxInfo struct {
	Purpose                    string
	ArchiveFolder              string
	DateFormat                 string
	TimeFormat                 string
	DelegateMeetMsgDeliveryOpt string
	Timezone                   string
	AutomaticRepliesSetting    AutomaticRepliesSettings
	Language                   Language
	WorkingHours               WorkingHours
	ErrGetMailBoxSetting       []error
	QuotaExceeded              bool
}

func ParseMailboxSettings

func ParseMailboxSettings(
	settings models.Userable,
	mi MailboxInfo,
) MailboxInfo

type Serializer

type Serializer interface {
	Serialize(
		ctx context.Context,
		item serialization.Parsable,
		protectedResource, itemID string,
	) ([]byte, error)
}

type Sites

type Sites struct {
	Client
}

Sites is an interface-compliant provider of the client.

func (Sites) GetAll

func (c Sites) GetAll(ctx context.Context, errs *fault.Bus) ([]models.Siteable, error)

GetAll retrieves all sites.

func (Sites) GetByID

func (c Sites) GetByID(
	ctx context.Context,
	identifier string,
	cc CallConfig,
) (models.Siteable, error)

GetByID looks up the site matching the given identifier. The identifier can be either a canonical site id or a webURL. Assumes the webURL is complete and well formed; eg: https://10rqc2.sharepoint.com/sites/Example

func (Sites) GetDefaultDrive

func (c Sites) GetDefaultDrive(
	ctx context.Context,
	site string,
) (models.Driveable, error)

func (Sites) GetIDAndName

func (c Sites) GetIDAndName(
	ctx context.Context,
	siteID string,
	cc CallConfig,
) (string, string, error)

GetIDAndName looks up the site matching the given ID, and returns its canonical ID and the webURL as the name. Accepts an ID or a WebURL as an ID.

func (Sites) GetRoot

func (c Sites) GetRoot(
	ctx context.Context,
	cc CallConfig,
) (models.Siteable, error)

type TimeInfo

type TimeInfo struct {
	DateTime string
	Timezone string
}

type Users

type Users struct {
	Client
}

Users is an interface-compliant provider of the client.

func (Users) GetAll

func (c Users) GetAll(
	ctx context.Context,
	errs *fault.Bus,
) ([]models.Userable, error)

GetAll retrieves all users.

func (Users) GetAllIDsAndNames

func (c Users) GetAllIDsAndNames(ctx context.Context, errs *fault.Bus) (idname.Cacher, error)

GetAllIDsAndNames retrieves all users in the tenant and returns them in an idname.Cacher

func (Users) GetByID

func (c Users) GetByID(
	ctx context.Context,
	identifier string,
	cc CallConfig,
) (models.Userable, error)

func (Users) GetDefaultDrive

func (c Users) GetDefaultDrive(
	ctx context.Context,
	userID string,
) (models.Driveable, error)

func (Users) GetFirstInboxMessage

func (c Users) GetFirstInboxMessage(
	ctx context.Context,
	userID, inboxID string,
) error

TODO: This tries to determine if the user has hit their mailbox limit by trying to fetch an item and seeing if we get the quota exceeded error. Ideally(if available) we should convert this to pull the user's usage via an api and compare if they have used up their quota.

func (Users) GetIDAndName

func (c Users) GetIDAndName(
	ctx context.Context,
	userID string,
	cc CallConfig,
) (string, string, error)

GetIDAndName looks up the user matching the given ID, and returns its canonical ID and the PrincipalName as the name.

func (Users) GetMailInbox

func (c Users) GetMailInbox(
	ctx context.Context,
	userID string,
) (models.MailFolderable, error)

func (Users) GetMailboxSettings

func (c Users) GetMailboxSettings(
	ctx context.Context,
	userID string,
) (models.Userable, error)

type WorkingHours

type WorkingHours struct {
	DaysOfWeek []string
	StartTime  string
	EndTime    string
	TimeZone   struct {
		Name string
	}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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