CLI: Adds to the displayable headers for OneDrive and SharePoint. (#2090)
## Description The update adds `DriveName` to SharePoint details. Values are currently the M365ID ## Does this PR need a docs update or release note? - [x] ⛔ No ## Type of change <!--- Please check the type of change your PR introduces: ---> - [x] 🌻 Feature ## Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * related to #1938<issue> * related to #2064 ## Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
3869baac64
commit
9f05e83d43
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
msdrives "github.com/microsoftgraph/msgraph-sdk-go/drives"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
@ -128,10 +129,11 @@ func oneDriveItemInfo(di models.DriveItemable, itemSize int64) *details.OneDrive
|
|||||||
// separately for restore processes because the local itemable
|
// separately for restore processes because the local itemable
|
||||||
// doesn't have its size value updated as a side effect of creation,
|
// doesn't have its size value updated as a side effect of creation,
|
||||||
// and kiota drops any SetSize update.
|
// and kiota drops any SetSize update.
|
||||||
|
// TODO: Update drive name during Issue #2071
|
||||||
func sharePointItemInfo(di models.DriveItemable, itemSize int64) *details.SharePointInfo {
|
func sharePointItemInfo(di models.DriveItemable, itemSize int64) *details.SharePointInfo {
|
||||||
var (
|
var (
|
||||||
id string
|
id, parent, url string
|
||||||
url string
|
reference = di.GetParentReference()
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: we rely on this info for details/restore lookups,
|
// TODO: we rely on this info for details/restore lookups,
|
||||||
@ -148,14 +150,29 @@ func sharePointItemInfo(di models.DriveItemable, itemSize int64) *details.ShareP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if reference != nil {
|
||||||
|
parent = *reference.GetDriveId()
|
||||||
|
|
||||||
|
if reference.GetName() != nil {
|
||||||
|
// EndPoint is not always populated from external apps
|
||||||
|
temp := *reference.GetName()
|
||||||
|
temp = strings.TrimSpace(temp)
|
||||||
|
|
||||||
|
if temp != "" {
|
||||||
|
parent = temp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &details.SharePointInfo{
|
return &details.SharePointInfo{
|
||||||
ItemType: details.OneDriveItem,
|
ItemType: details.OneDriveItem,
|
||||||
ItemName: *di.GetName(),
|
ItemName: *di.GetName(),
|
||||||
Created: *di.GetCreatedDateTime(),
|
Created: *di.GetCreatedDateTime(),
|
||||||
Modified: *di.GetLastModifiedDateTime(),
|
Modified: *di.GetLastModifiedDateTime(),
|
||||||
Size: itemSize,
|
DriveName: parent,
|
||||||
Owner: id,
|
Size: itemSize,
|
||||||
WebURL: url,
|
Owner: id,
|
||||||
|
WebURL: url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -477,6 +477,7 @@ func (i ExchangeInfo) Values() []string {
|
|||||||
type SharePointInfo struct {
|
type SharePointInfo struct {
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
ItemName string `json:"itemName,omitempty"`
|
ItemName string `json:"itemName,omitempty"`
|
||||||
|
DriveName string `json:"driveName,omitempty"`
|
||||||
ItemType ItemType `json:"itemType,omitempty"`
|
ItemType ItemType `json:"itemType,omitempty"`
|
||||||
Modified time.Time `josn:"modified,omitempty"`
|
Modified time.Time `josn:"modified,omitempty"`
|
||||||
Owner string `json:"owner,omitempty"`
|
Owner string `json:"owner,omitempty"`
|
||||||
@ -488,7 +489,7 @@ type SharePointInfo struct {
|
|||||||
// Headers returns the human-readable names of properties in a SharePointInfo
|
// Headers returns the human-readable names of properties in a SharePointInfo
|
||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (i SharePointInfo) Headers() []string {
|
func (i SharePointInfo) Headers() []string {
|
||||||
return []string{"ItemName", "ParentPath", "Size", "WebURL", "Created", "Modified"}
|
return []string{"ItemName", "Drive", "ParentPath", "Size", "WebURL", "Created", "Modified"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the values matching the Headers list for printing
|
// Values returns the values matching the Headers list for printing
|
||||||
@ -496,6 +497,7 @@ func (i SharePointInfo) Headers() []string {
|
|||||||
func (i SharePointInfo) Values() []string {
|
func (i SharePointInfo) Values() []string {
|
||||||
return []string{
|
return []string{
|
||||||
i.ItemName,
|
i.ItemName,
|
||||||
|
i.DriveName,
|
||||||
i.ParentPath,
|
i.ParentPath,
|
||||||
humanize.Bytes(uint64(i.Size)),
|
humanize.Bytes(uint64(i.Size)),
|
||||||
i.WebURL,
|
i.WebURL,
|
||||||
@ -518,8 +520,8 @@ func (i *SharePointInfo) UpdateParentPath(newPath path.Path) error {
|
|||||||
// OneDriveInfo describes a oneDrive item
|
// OneDriveInfo describes a oneDrive item
|
||||||
type OneDriveInfo struct {
|
type OneDriveInfo struct {
|
||||||
Created time.Time `json:"created,omitempty"`
|
Created time.Time `json:"created,omitempty"`
|
||||||
ItemName string `json:"itemName"`
|
ItemName string `json:"itemName,omitempty"`
|
||||||
DriveName string `json:"driveName"`
|
DriveName string `json:"driveName,omitempty"`
|
||||||
ItemType ItemType `json:"itemType,omitempty"`
|
ItemType ItemType `json:"itemType,omitempty"`
|
||||||
Modified time.Time `json:"modified,omitempty"`
|
Modified time.Time `json:"modified,omitempty"`
|
||||||
Owner string `json:"owner,omitempty"`
|
Owner string `json:"owner,omitempty"`
|
||||||
|
|||||||
@ -107,13 +107,23 @@ func (suite *DetailsUnitSuite) TestDetailsEntry_HeadersValues() {
|
|||||||
ParentPath: "parentPath",
|
ParentPath: "parentPath",
|
||||||
Size: 1000,
|
Size: 1000,
|
||||||
WebURL: "https://not.a.real/url",
|
WebURL: "https://not.a.real/url",
|
||||||
|
DriveName: "aDrive",
|
||||||
Created: now,
|
Created: now,
|
||||||
Modified: now,
|
Modified: now,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectHs: []string{"ID", "ItemName", "ParentPath", "Size", "WebURL", "Created", "Modified"},
|
expectHs: []string{"ID", "ItemName", "Drive", "ParentPath", "Size", "WebURL", "Created", "Modified"},
|
||||||
expectVs: []string{"deadbeef", "itemName", "parentPath", "1.0 kB", "https://not.a.real/url", nowStr, nowStr},
|
expectVs: []string{
|
||||||
|
"deadbeef",
|
||||||
|
"itemName",
|
||||||
|
"aDrive",
|
||||||
|
"parentPath",
|
||||||
|
"1.0 kB",
|
||||||
|
"https://not.a.real/url",
|
||||||
|
nowStr,
|
||||||
|
nowStr,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "oneDrive info",
|
name: "oneDrive info",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user