forked from TrueCloudLab/rclone
onedrive: factor API types back into correct file
This commit is contained in:
parent
cb43e86d16
commit
ecb09badba
2 changed files with 32 additions and 30 deletions
|
@ -185,8 +185,8 @@ type Item struct {
|
||||||
Deleted *DeletedFacet `json:"deleted"` // Information about the deleted state of the item. Read-only.
|
Deleted *DeletedFacet `json:"deleted"` // Information about the deleted state of the item. Read-only.
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewDeltaResponse is the response to the view delta method
|
// DeltaResponse is the response to the view delta method
|
||||||
type ViewDeltaResponse struct {
|
type DeltaResponse struct {
|
||||||
Value []Item `json:"value"` // An array of Item objects which have been created, modified, or deleted.
|
Value []Item `json:"value"` // An array of Item objects which have been created, modified, or deleted.
|
||||||
NextLink string `json:"@odata.nextLink"` // A URL to retrieve the next available page of changes.
|
NextLink string `json:"@odata.nextLink"` // A URL to retrieve the next available page of changes.
|
||||||
DeltaLink string `json:"@odata.deltaLink"` // A URL returned instead of @odata.nextLink after all current changes have been returned. Used to read the next set of changes in the future.
|
DeltaLink string `json:"@odata.deltaLink"` // A URL returned instead of @odata.nextLink after all current changes have been returned. Used to read the next set of changes in the future.
|
||||||
|
@ -438,3 +438,27 @@ type Version struct {
|
||||||
type VersionsResponse struct {
|
type VersionsResponse struct {
|
||||||
Versions []Version `json:"value"`
|
Versions []Version `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DriveResource is returned from /me/drive
|
||||||
|
type DriveResource struct {
|
||||||
|
DriveID string `json:"id"`
|
||||||
|
DriveName string `json:"name"`
|
||||||
|
DriveType string `json:"driveType"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DrivesResponse is returned from /sites/{siteID}/drives",
|
||||||
|
type DrivesResponse struct {
|
||||||
|
Drives []DriveResource `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SiteResource is part of the response from from "/sites/root:"
|
||||||
|
type SiteResource struct {
|
||||||
|
SiteID string `json:"id"`
|
||||||
|
SiteName string `json:"displayName"`
|
||||||
|
SiteURL string `json:"webUrl"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// SiteResponse is returned from "/sites/root:"
|
||||||
|
type SiteResponse struct {
|
||||||
|
Sites []SiteResource `json:"value"`
|
||||||
|
}
|
||||||
|
|
|
@ -371,28 +371,6 @@ file.
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type driveResource struct {
|
|
||||||
DriveID string `json:"id"`
|
|
||||||
DriveName string `json:"name"`
|
|
||||||
DriveType string `json:"driveType"`
|
|
||||||
}
|
|
||||||
type drivesResponse struct {
|
|
||||||
Drives []driveResource `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type siteResource struct {
|
|
||||||
SiteID string `json:"id"`
|
|
||||||
SiteName string `json:"displayName"`
|
|
||||||
SiteURL string `json:"webUrl"`
|
|
||||||
}
|
|
||||||
type siteResponse struct {
|
|
||||||
Sites []siteResource `json:"value"`
|
|
||||||
}
|
|
||||||
type deltaResponse struct {
|
|
||||||
DeltaLink string `json:"@odata.deltaLink"`
|
|
||||||
Value []api.Item `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the region and graphURL from the config
|
// Get the region and graphURL from the config
|
||||||
func getRegionURL(m configmap.Mapper) (region, graphURL string) {
|
func getRegionURL(m configmap.Mapper) (region, graphURL string) {
|
||||||
region, _ = m.Get("region")
|
region, _ = m.Get("region")
|
||||||
|
@ -419,7 +397,7 @@ func chooseDrive(ctx context.Context, name string, m configmap.Mapper, srv *rest
|
||||||
RootURL: graphURL,
|
RootURL: graphURL,
|
||||||
Path: "/sites/root:" + opt.relativePath,
|
Path: "/sites/root:" + opt.relativePath,
|
||||||
}
|
}
|
||||||
site := siteResource{}
|
site := api.SiteResource{}
|
||||||
_, err := srv.CallJSON(ctx, &opt.opts, nil, &site)
|
_, err := srv.CallJSON(ctx, &opt.opts, nil, &site)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available site by relative path: %v", err))
|
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available site by relative path: %v", err))
|
||||||
|
@ -436,7 +414,7 @@ func chooseDrive(ctx context.Context, name string, m configmap.Mapper, srv *rest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drives := drivesResponse{}
|
drives := api.DrivesResponse{}
|
||||||
|
|
||||||
// We don't have the final ID yet?
|
// We don't have the final ID yet?
|
||||||
// query Microsoft Graph
|
// query Microsoft Graph
|
||||||
|
@ -449,7 +427,7 @@ func chooseDrive(ctx context.Context, name string, m configmap.Mapper, srv *rest
|
||||||
// Also call /me/drive as sometimes /me/drives doesn't return it #4068
|
// Also call /me/drive as sometimes /me/drives doesn't return it #4068
|
||||||
if opt.opts.Path == "/me/drives" {
|
if opt.opts.Path == "/me/drives" {
|
||||||
opt.opts.Path = "/me/drive"
|
opt.opts.Path = "/me/drive"
|
||||||
meDrive := driveResource{}
|
meDrive := api.DriveResource{}
|
||||||
_, err := srv.CallJSON(ctx, &opt.opts, nil, &meDrive)
|
_, err := srv.CallJSON(ctx, &opt.opts, nil, &meDrive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available drives: %v", err))
|
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available drives: %v", err))
|
||||||
|
@ -468,7 +446,7 @@ func chooseDrive(ctx context.Context, name string, m configmap.Mapper, srv *rest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
drives.Drives = append(drives.Drives, driveResource{
|
drives.Drives = append(drives.Drives, api.DriveResource{
|
||||||
DriveID: opt.finalDriveID,
|
DriveID: opt.finalDriveID,
|
||||||
DriveName: "Chosen Drive ID",
|
DriveName: "Chosen Drive ID",
|
||||||
DriveType: "drive",
|
DriveType: "drive",
|
||||||
|
@ -605,7 +583,7 @@ Examples:
|
||||||
Path: "/sites?search=" + searchTerm,
|
Path: "/sites?search=" + searchTerm,
|
||||||
}
|
}
|
||||||
|
|
||||||
sites := siteResponse{}
|
sites := api.SiteResponse{}
|
||||||
_, err := srv.CallJSON(ctx, &opts, nil, &sites)
|
_, err := srv.CallJSON(ctx, &opts, nil, &sites)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available sites: %v", err))
|
return fs.ConfigError("choose_type", fmt.Sprintf("Failed to query available sites: %v", err))
|
||||||
|
@ -2481,7 +2459,7 @@ func (f *Fs) changeNotifyStartPageToken(ctx context.Context) (nextDeltaToken str
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fs) changeNotifyNextChange(ctx context.Context, token string) (delta deltaResponse, err error) {
|
func (f *Fs) changeNotifyNextChange(ctx context.Context, token string) (delta api.DeltaResponse, err error) {
|
||||||
opts := f.buildDriveDeltaOpts(token)
|
opts := f.buildDriveDeltaOpts(token)
|
||||||
|
|
||||||
_, err = f.srv.CallJSON(ctx, &opts, nil, &delta)
|
_, err = f.srv.CallJSON(ctx, &opts, nil, &delta)
|
||||||
|
|
Loading…
Reference in a new issue