diff --git a/src/internal/connector/exchange_data_collection.go b/src/internal/connector/exchange_data_collection.go index 7985abc31..7ce5170bf 100644 --- a/src/internal/connector/exchange_data_collection.go +++ b/src/internal/connector/exchange_data_collection.go @@ -11,6 +11,11 @@ type DataCollection interface { // Returns either the next item in the collection or an error if one occurred. // If not more items are available in the collection, returns (nil, nil). NextItem() (DataStream, error) + // FullPath returns a slice of strings that act as metadata tags for this + // DataCollection. Returned items should be ordered from most generic to least + // generic. For example, a DataCollection for emails from a specific user + // would be {"", "", "emails"}. + FullPath() []string } // DataStream represents a single item within a DataCollection @@ -32,9 +37,9 @@ type ExchangeDataCollection struct { // TODO: We would want to replace this with a channel so that we // don't need to wait for all data to be retrieved before reading it out data []ExchangeData - // FullPath is the slice representation of the action context passed down through the hierarchy. + // fullPath is the slice representation of the action context passed down through the hierarchy. //The original request can be gleaned from the slice. (e.g. {, , "emails"}) - FullPath []string + fullPath []string } // NewExchangeDataCollection creates an ExchangeDataCollection where @@ -43,7 +48,7 @@ func NewExchangeDataCollection(aUser string, pathRepresentation []string) Exchan collection := ExchangeDataCollection{ user: aUser, data: make([]ExchangeData, 0), - FullPath: pathRepresentation, + fullPath: pathRepresentation, } return collection } @@ -63,6 +68,10 @@ func (*ExchangeDataCollection) NextItem() (DataStream, error) { return nil, nil } +func (ec *ExchangeDataCollection) FullPath() []string { + return append([]string{}, ec.fullPath...) +} + // ExchangeData represents a single item retrieved from exchange type ExchangeData struct { id string diff --git a/src/internal/connector/exchange_data_collection_test.go b/src/internal/connector/exchange_data_collection_test.go index bd5a43979..c8d22ac76 100644 --- a/src/internal/connector/exchange_data_collection_test.go +++ b/src/internal/connector/exchange_data_collection_test.go @@ -25,3 +25,11 @@ func (suite *ExchangeDataCollectionSuite) TestExchangeDataReader() { buf.ReadFrom(ed.ToReader()) assert.Equal(suite.T(), buf.Bytes(), m) } + +func (suite *ExchangeDataCollectionSuite) TestExchangeData_FullPath() { + user := "a-user" + fullPath := []string{"a-tenant", user, "emails"} + edc := NewExchangeDataCollection(user, fullPath) + + assert.Equal(suite.T(), edc.FullPath(), fullPath) +}