onedrive

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	DisplayName string `json:"displayName"`
	ID          string `json:"id"`
}

type Client

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

func NewClient

func NewClient(clientID, clientSecret, redirectURL string, opt ...ClientOption) *Client

func (*Client) AuthCodeURL

func (c *Client) AuthCodeURL(state string) string

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) DriveList

func (c *Client) DriveList() (*DriveListResp, error)

func (*Client) FsDownload

func (c *Client) FsDownload(path string, opt ...FsOptionFunc) (string, error)

func (*Client) FsGet

func (c *Client) FsGet(path string, opt ...FsOptionFunc) (*FsGetResp, error)

func (*Client) FsList

func (c *Client) FsList(path string, opt ...FsOptionFunc) (*FsListResp, error)

func (*Client) GetToken

func (c *Client) GetToken(code string) (*oauth2.Token, error)

func (*Client) GetUserInfo

func (c *Client) GetUserInfo() (*microsoftUserInfo, error)

func (*Client) HttpClient

func (c *Client) HttpClient() (*http.Client, error)

func (*Client) Login

func (c *Client) Login(code string) error

func (*Client) NewRequest

func (c *Client) NewRequest(method, relative string, data any) (req *http.Request, err error)

func (*Client) RefreshToken

func (c *Client) RefreshToken(refresh string) (*oauth2.Token, error)

func (*Client) SetToken

func (c *Client) SetToken(tk oauth2.Token)

func (*Client) Token

func (c *Client) Token() (*oauth2.Token, error)

type ClientOption

type ClientOption func(*Client)

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

func WithContext

func WithContext(ctx context.Context) ClientOption

func WithToken

func WithToken(tk oauth2.Token) ClientOption

type CreatedBy

type CreatedBy struct {
	Application  Application  `json:"application"`
	Device       Device       `json:"device"`
	User         User         `json:"user"`
	OneDriveSync OneDriveSync `json:"oneDriveSync"`
}

type Device

type Device struct {
	ID string `json:"id"`
}

type DriveListResp

type DriveListResp struct {
	Value []struct {
		ID        string `json:"id"`
		DriveType string `json:"driveType"`
		Name      string `json:"name"`
		Owner     struct {
			User struct {
				ID          string `json:"id"`
				DisplayName string `json:"displayName"`
			} `json:"user"`
		} `json:"owner"`
	} `json:"value"`
}

type File

type File struct {
	MimeType string `json:"mimeType"`
	Hashes   Hashes `json:"hashes"`
}

type FileSystemInfo

type FileSystemInfo struct {
	CreatedDateTime      time.Time `json:"createdDateTime"`
	LastModifiedDateTime time.Time `json:"lastModifiedDateTime"`
}

type Folder

type Folder struct {
	ChildCount int  `json:"childCount"`
	View       View `json:"view"`
}

type FsGetResp

type FsGetResp struct {
	CreatedBy struct {
		User struct {
			ID          string `json:"id"`
			DisplayName string `json:"displayName"`
		} `json:"user"`
	} `json:"createdBy"`
	CreatedDateTime time.Time `json:"createdDateTime"`
	CTag            string    `json:"cTag"`
	ETag            string    `json:"eTag"`
	Folder          struct {
		ChildCount int `json:"childCount"`
	} `json:"folder"`
	ID             string `json:"id"`
	LastModifiedBy struct {
		User struct {
			ID          string `json:"id"`
			DisplayName string `json:"displayName"`
		} `json:"user"`
	} `json:"lastModifiedBy"`
	LastModifiedDateTime time.Time `json:"lastModifiedDateTime"`
	Name                 string    `json:"name"`
	Root                 struct {
	} `json:"root"`
	Size   int    `json:"size"`
	WebURL string `json:"webUrl"`
}

type FsListResp

type FsListResp struct {
	OdataContext string  `json:"@odata.context"`
	OdataCount   int     `json:"@odata.count"`
	Value        []Value `json:"value"`
}

type FsOption

type FsOption struct {
	DriveID string
}

type FsOptionFunc

type FsOptionFunc func(*FsOption)

func WithDriveID

func WithDriveID(driveID string) FsOptionFunc

type Hashes

type Hashes struct {
	QuickXorHash string `json:"quickXorHash"`
	Sha1Hash     string `json:"sha1Hash"`
	Sha256Hash   string `json:"sha256Hash"`
}

type LastModifiedBy

type LastModifiedBy struct {
	Application  Application  `json:"application"`
	Device       Device       `json:"device"`
	User         User         `json:"user"`
	OneDriveSync OneDriveSync `json:"oneDriveSync"`
}

type OneDriveSync

type OneDriveSync struct {
	OdataType string `json:"@odata.type"`
	ID        string `json:"id"`
}

type ParentReference

type ParentReference struct {
	DriveID   string `json:"driveId"`
	DriveType string `json:"driveType"`
	ID        string `json:"id"`
	Path      string `json:"path"`
}

type Reactions

type Reactions struct {
	CommentCount int `json:"commentCount"`
}

type SpecialFolder

type SpecialFolder struct {
	Name string `json:"name"`
}

type User

type User struct {
	DisplayName string `json:"displayName"`
	ID          string `json:"id"`
}

type Value

type Value struct {
	CreatedDateTime           time.Time       `json:"createdDateTime"`
	CTag                      string          `json:"cTag"`
	ETag                      string          `json:"eTag"`
	ID                        string          `json:"id"`
	LastModifiedDateTime      time.Time       `json:"lastModifiedDateTime"`
	Name                      string          `json:"name"`
	Size                      int             `json:"size"`
	WebURL                    string          `json:"webUrl"`
	Reactions                 Reactions       `json:"reactions"`
	CreatedBy                 CreatedBy       `json:"createdBy,omitempty"`
	LastModifiedBy            LastModifiedBy  `json:"lastModifiedBy,omitempty"`
	ParentReference           ParentReference `json:"parentReference"`
	FileSystemInfo            FileSystemInfo  `json:"fileSystemInfo"`
	Folder                    Folder          `json:"folder,omitempty"`
	SpecialFolder             SpecialFolder   `json:"specialFolder,omitempty"`
	MicrosoftGraphDownloadURL string          `json:"@microsoft.graph.downloadUrl,omitempty"`
	File                      File            `json:"file,omitempty"`
}

type View

type View struct {
	ViewType  string `json:"viewType"`
	SortBy    string `json:"sortBy"`
	SortOrder string `json:"sortOrder"`
}

Jump to

Keyboard shortcuts

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