Documentation
¶
Index ¶
- type Client
- func (c *Client) GetDelta(ctx context.Context, deltaLink string) (*DeltaResponse, error)
- func (c *Client) GetDriveItem(ctx context.Context, itemID string) (*DriveItem, error)
- func (c *Client) GetDriveItemContent(ctx context.Context, itemID string) ([]byte, error)
- func (c *Client) GetDriveItems(ctx context.Context, itemID string) (*DriveItemsResponse, error)
- func (c *Client) GetMe(ctx context.Context) (*User, error)
- func (c *Client) GetNextPage(ctx context.Context, nextLink string, result interface{}) error
- type ClientConfig
- type DeletedFacet
- type DeltaResponse
- type DriveItem
- type DriveItemsResponse
- type ErrorDetail
- type ErrorResponse
- type FileFacet
- type FolderFacet
- type HashesType
- type ItemReference
- type OAuthHandler
- func (h *OAuthHandler) BuildAuthURL(clientID, redirectURI, state, codeChallenge string, scopes []string) string
- func (h *OAuthHandler) DefaultConfig() connectors.OAuthDefaults
- func (h *OAuthHandler) ExchangeCode(ctx context.Context, ...) (*driven.OAuthToken, error)
- func (h *OAuthHandler) GetUserInfo(ctx context.Context, accessToken string) (*driven.OAuthUserInfo, error)
- func (h *OAuthHandler) RefreshToken(ctx context.Context, clientID, clientSecret, refreshToken string) (*driven.OAuthToken, error)
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides Microsoft Graph API operations.
func NewClient ¶
func NewClient(tokenProvider driven.TokenProvider, config *ClientConfig) *Client
NewClient creates a new Microsoft Graph API client.
func (*Client) GetDelta ¶
GetDelta retrieves changes in a drive using delta queries. If deltaLink is empty, starts a new delta query. Otherwise, uses the provided delta link.
func (*Client) GetDriveItem ¶
GetDriveItem retrieves a specific drive item.
func (*Client) GetDriveItemContent ¶
GetDriveItemContent downloads the content of a file. Returns the content as a byte slice.
func (*Client) GetDriveItems ¶
GetDriveItems retrieves items from a drive or folder.
type ClientConfig ¶
type ClientConfig struct {
// BaseURL is the base URL for Microsoft Graph API.
// Defaults to https://graph.microsoft.com/v1.0
BaseURL string
// RateLimitRPS is the rate limit in requests per second.
// Microsoft Graph has different rate limits per endpoint, but we use a conservative default.
RateLimitRPS float64
// RequestTimeout is the timeout for API requests.
RequestTimeout time.Duration
// MaxRetries is the maximum number of retry attempts for failed requests.
MaxRetries int
}
ClientConfig contains configuration for the Microsoft Graph client.
func DefaultClientConfig ¶
func DefaultClientConfig() *ClientConfig
DefaultClientConfig returns the default Microsoft Graph client configuration.
type DeletedFacet ¶
type DeletedFacet struct {
State string `json:"state,omitempty"`
}
DeletedFacet indicates an item has been deleted.
type DeltaResponse ¶
type DeltaResponse struct {
Value []DriveItem `json:"value"`
NextLink string `json:"@odata.nextLink,omitempty"`
DeltaLink string `json:"@odata.deltaLink,omitempty"`
}
DeltaResponse represents a response from a delta query.
type DriveItem ¶
type DriveItem struct {
ID string `json:"id"`
Name string `json:"name"`
Size int64 `json:"size,omitempty"`
WebURL string `json:"webUrl"`
CreatedDateTime time.Time `json:"createdDateTime"`
LastModifiedDateTime time.Time `json:"lastModifiedDateTime"`
Deleted *DeletedFacet `json:"deleted,omitempty"`
File *FileFacet `json:"file,omitempty"`
Folder *FolderFacet `json:"folder,omitempty"`
ParentReference *ItemReference `json:"parentReference,omitempty"`
CTag string `json:"cTag,omitempty"` // Change tag
ETag string `json:"eTag,omitempty"` // Entity tag
DownloadURL string `json:"@microsoft.graph.downloadUrl,omitempty"`
}
DriveItem represents a file or folder in OneDrive.
type DriveItemsResponse ¶
type DriveItemsResponse struct {
Value []DriveItem `json:"value"`
NextLink string `json:"@odata.nextLink,omitempty"`
}
DriveItemsResponse represents a response when listing drive items.
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
InnerError *struct {
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
} `json:"innerError,omitempty"`
}
ErrorDetail contains error details.
type ErrorResponse ¶
type ErrorResponse struct {
Error *ErrorDetail `json:"error,omitempty"`
}
ErrorResponse represents a Microsoft Graph API error.
type FileFacet ¶
type FileFacet struct {
MimeType string `json:"mimeType,omitempty"`
Hashes *HashesType `json:"hashes,omitempty"`
}
FileFacet represents file-specific metadata.
type FolderFacet ¶
type FolderFacet struct {
ChildCount int `json:"childCount,omitempty"`
}
FolderFacet represents folder-specific metadata.
type HashesType ¶
type HashesType struct {
QuickXorHash string `json:"quickXorHash,omitempty"`
SHA1Hash string `json:"sha1Hash,omitempty"`
SHA256Hash string `json:"sha256Hash,omitempty"`
}
HashesType contains file hashes.
type ItemReference ¶
type ItemReference struct {
DriveID string `json:"driveId,omitempty"`
DriveType string `json:"driveType,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
}
ItemReference represents a reference to a parent item.
type OAuthHandler ¶
type OAuthHandler struct {
// contains filtered or unexported fields
}
OAuthHandler handles OAuth operations for Microsoft Azure AD / Microsoft Graph. This handler is shared across all Microsoft services (OneDrive, SharePoint, Teams, etc.).
func NewOAuthHandler ¶
func NewOAuthHandler() *OAuthHandler
NewOAuthHandler creates a new Microsoft OAuth handler.
func (*OAuthHandler) BuildAuthURL ¶
func (h *OAuthHandler) BuildAuthURL(clientID, redirectURI, state, codeChallenge string, scopes []string) string
BuildAuthURL constructs the Microsoft Azure AD OAuth authorization URL. Microsoft OAuth uses the v2.0 endpoint with PKCE support.
func (*OAuthHandler) DefaultConfig ¶
func (h *OAuthHandler) DefaultConfig() connectors.OAuthDefaults
DefaultConfig returns Microsoft's default OAuth configuration.
func (*OAuthHandler) ExchangeCode ¶
func (h *OAuthHandler) ExchangeCode(ctx context.Context, clientID, clientSecret, code, redirectURI, codeVerifier string) (*driven.OAuthToken, error)
ExchangeCode exchanges an authorization code for tokens. Microsoft OAuth tokens expire in 1 hour and require refresh.
func (*OAuthHandler) GetUserInfo ¶
func (h *OAuthHandler) GetUserInfo(ctx context.Context, accessToken string) (*driven.OAuthUserInfo, error)
GetUserInfo fetches the authenticated user's information from Microsoft Graph.
func (*OAuthHandler) RefreshToken ¶
func (h *OAuthHandler) RefreshToken(ctx context.Context, clientID, clientSecret, refreshToken string) (*driven.OAuthToken, error)
RefreshToken refreshes an expired access token. Microsoft access tokens expire in 1 hour, so refresh is essential.