Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add graph beta sharedWithMe API #7633

Merged
merged 1 commit into from Nov 8, 2023

Conversation

fschade
Copy link
Contributor

@fschade fschade commented Oct 31, 2023

Description

Add graph beta api implementation for the sharedWithMe endpoint.
The implementation is a logical replication of the existing OCS API.

Related Issue

Motivation and Context

part of the OCS api to graph api ADR

How Has This Been Tested?

  • unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

MS Graph (oneDrive) share livecycle

Process

  • User A has 2 resources
    • Test (folder)
    • Card.pdf (file)
  • User A shares
    • Test (folder), Card.pdf (file) TO User B
    • Card.pdf (file) TO User C
  • User B shares
    • Test (folder) TO User C

Result /v1.0/me/drive/root/children for User A

{
	"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('f.schade%40foo.com')/drive/root/children",
	"@odata.count": 2,
	"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/root/children?$select=audio,bundle",
	"value": [
		{
			"createdDateTime": "2023-11-05T07:33:16.767Z",
			"cTag": "adDo0MjQ4RDA4MkIxOEY1NkYzITEwNS42MzgzNDc3MDkxOTcxMDAwMDA",
			"eTag": "aNDI0OEQwODJCMThGNTZGMyExMDUuMg",
			"id": "4248D082B18F56F3!105",
			"lastModifiedDateTime": "2023-11-05T08:48:39.71Z",
			"name": "test",
			"size": 0,
			"webUrl": "https://1drv.ms/f/s!APNWj7GC0EhCaQ",
			"reactions": {
				"commentCount": 0
			},
			"createdBy": {
				"application": {
					"displayName": "OneDrive",
					"id": "481710a4"
				},
				"user": {
					"displayName": "Florian Schade",
					"id": "4248d082b18f56f3"
				}
			},
			"lastModifiedBy": {
				"application": {
					"displayName": "OneDrive",
					"id": "481710a4"
				},
				"user": {
					"displayName": "Florian Schade",
					"id": "4248d082b18f56f3"
				}
			},
			"parentReference": {
				"driveId": "4248d082b18f56f3",
				"driveType": "personal",
				"id": "4248D082B18F56F3!101",
				"path": "/drive/root:"
			},
			"fileSystemInfo": {
				"createdDateTime": "2023-11-05T07:33:16.766Z",
				"lastModifiedDateTime": "2023-11-05T07:33:16.766Z"
			},
			"folder": {
				"childCount": 0,
				"view": {
					"viewType": "thumbnails",
					"sortBy": "name",
					"sortOrder": "ascending"
				}
			},
			"shared": {
				"scope": "users",
				"sharedDateTime": "2023-11-05T08:48:08.0061935Z",
				"owner": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				}
			}
		},
		{
			"@microsoft.graph.downloadUrl": "https://public.db.files.1drv.com/y4mdJmpXzVykKLjSml4Qdsu2vAJMPpW1qw-J730KpbNB0YMyjr9xa84rYmdsO8uAVOlARMIgf8DfqEYFZqUrn6wf3yLtPwuNW6qH3wpOMfKDaWn6JhYyLyl5cC0yAnX2kTjAdzSTXhYs9bPcTxSwdWD54TB2VIR43XPN-LpLXgvH1dDCYQX478P4DrT81Uw9anwOSWLwYLyzdhykPAgZUGD1T0bTmkBnvMZi7cDpv0jB4VJFEkpYpFEXbnao5q9Y-pE9_5y_TCte5b-l3889v7VCcR4_UwPBpdu0f7S_8eC_wg",
			"createdDateTime": "2023-11-05T12:12:00.44Z",
			"cTag": "aYzo0MjQ4RDA4MkIxOEY1NkYzITEwOC4yNTc",
			"eTag": "aNDI0OEQwODJCMThGNTZGMyExMDguNg",
			"id": "4248D082B18F56F3!108",
			"lastModifiedDateTime": "2023-11-05T12:16:37.733Z",
			"name": "card.pdf",
			"size": 5333805,
			"webUrl": "https://1drv.ms/b/s!APNWj7GC0EhCbA",
			"reactions": {
				"commentCount": 0
			},
			"createdBy": {
				"application": {
					"displayName": "OneDrive",
					"id": "481710a4"
				},
				"user": {
					"displayName": "Florian Schade",
					"id": "4248d082b18f56f3"
				}
			},
			"lastModifiedBy": {
				"application": {
					"displayName": "OneDrive",
					"id": "481710a4"
				},
				"user": {
					"displayName": "Florian Schade",
					"id": "4248d082b18f56f3"
				}
			},
			"parentReference": {
				"driveId": "4248d082b18f56f3",
				"driveType": "personal",
				"id": "4248D082B18F56F3!101",
				"path": "/drive/root:"
			},
			"file": {
				"mimeType": "application/pdf",
				"hashes": {
					"quickXorHash": "fLXOC13mFvBf2YZJBnBMNMwie+s=",
					"sha1Hash": "8FE5FAFF1515FC55AAC59F6483AC1FDC3EE0F799",
					"sha256Hash": "28F9182C9F1FA4BA1ADFEB5CDD9210FF85D3D3B6FA8C8D156BA09602E9F57190"
				}
			},
			"fileSystemInfo": {
				"createdDateTime": "2023-11-05T12:12:00.44Z",
				"lastModifiedDateTime": "2023-11-05T12:12:00.44Z"
			},
			"shared": {
				"scope": "users",
				"sharedDateTime": "2023-11-05T12:16:19.3612484Z",
				"owner": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				}
			}
		}
	]
}

Result /v1.0/me/drive/sharedWithMe for User B

{
	"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
	"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/microsoft.graph.sharedWithMe?$select=audio,bundle",
	"value": [
		{
			"@odata.type": "#microsoft.graph.driveItem",
			"@microsoft.graph.downloadUrl": "https://fnnw7q.db.files.1drv.com/y4metUELTbmKxTPBy6GO4d9ZolLegCvYtBKnGYZgMBiye0S2gKaxuUEIDP8MFK4KfB8fEbLmj1cUKYThy2mgAYeQKGOGfHX_TCxgLP2IXZasGO_iDkKJYpDjFZ99n2dkn442rULQEkf0_S6mi3XhPBgFjgSllJ5Z_c03jxgKfZ-Y6asWne2FRHzuOqT-L7IEBIOU_4Hu3gZm7L9hIyUr7JVGcxq_d_5erZQpHprFqTtVZ8",
			"createdDateTime": "2023-11-05T12:12:39.753Z",
			"cTag": "aYzozQUUxRDc2NEI3MEIyNUIzITEwOC4yNTc",
			"eTag": "aM0FFMUQ3NjRCNzBCMjVCMyExMDguMTA",
			"id": "3AE1D764B70B25B3!108",
			"lastModifiedDateTime": "2023-11-05T12:17:29.853Z",
			"name": "card.pdf",
			"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCbA",
			"parentReference": {
				"driveId": "3ae1d764b70b25b3",
				"driveType": "personal"
			},
			"remoteItem": {
				"id": "4248D082B18F56F3!108",
				"lastModifiedDateTime": "2023-11-05T12:16:37.733Z",
				"name": "card.pdf",
				"size": 5333805,
				"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCbA",
				"createdBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"fileSystemInfo": {
					"createdDateTime": "2023-11-05T12:12:00.44Z",
					"lastModifiedDateTime": "2023-11-05T12:12:00.44Z"
				},
				"file": {
					"mimeType": "application/pdf",
					"hashes": {
						"sha1Hash": "8FE5FAFF1515FC55AAC59F6483AC1FDC3EE0F799"
					}
				},
				"lastModifiedBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"parentReference": {
					"driveId": "4248d082b18f56f3",
					"driveType": "personal"
				},
				"shared": {
					"sharedDateTime": "2023-11-05T12:12:39.753Z",
					"owner": {
						"user": {
							"displayName": "Florian Schade",
							"id": "4248d082b18f56f3"
						}
					}
				}
			}
		},
		{
			"@odata.type": "#microsoft.graph.driveItem",
			"createdDateTime": "2023-11-05T07:36:51.77Z",
			"cTag": "adDozQUUxRDc2NEI3MEIyNUIzITEwNy42MzgzNDc3MTAwMDU1MzAwMDA",
			"eTag": "aM0FFMUQ3NjRCNzBCMjVCMyExMDcuMg",
			"id": "3AE1D764B70B25B3!107",
			"lastModifiedDateTime": "2023-11-05T08:50:00.553Z",
			"name": "test",
			"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCaQ",
			"parentReference": {
				"driveId": "3ae1d764b70b25b3",
				"driveType": "personal"
			},
			"remoteItem": {
				"id": "4248D082B18F56F3!105",
				"lastModifiedDateTime": "2023-11-05T08:48:39.71Z",
				"name": "test",
				"size": 0,
				"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCaQ",
				"createdBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"fileSystemInfo": {
					"createdDateTime": "2023-11-05T07:33:16.7666667Z",
					"lastModifiedDateTime": "2023-11-05T07:33:16.7666667Z"
				},
				"folder": {
					"childCount": 0,
					"view": {
						"viewType": "thumbnails",
						"sortBy": "name",
						"sortOrder": "ascending"
					}
				},
				"lastModifiedBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"parentReference": {
					"driveId": "4248d082b18f56f3",
					"driveType": "personal"
				},
				"shared": {
					"sharedDateTime": "2023-11-05T07:36:51.77Z",
					"owner": {
						"user": {
							"displayName": "Florian Schade",
							"id": "4248d082b18f56f3"
						}
					}
				}
			}
		}
	]
}

Result /v1.0/me/drive/sharedWithMe for User C

{
	"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
	"@microsoft.graph.tips": "Use $select to choose only the properties your app needs, as this can lead to performance improvements. For example: GET me/drive/microsoft.graph.sharedWithMe?$select=audio,bundle",
	"value": [
		{
			"@odata.type": "#microsoft.graph.driveItem",
			"@microsoft.graph.downloadUrl": "https://gljo7a.bn.files.1drv.com/y4mwBO3qDYmDJeYx4a6egHpFQHb00JvRF_T0k2Dy1sufJRAeFXgO0tZL20iyMIuf1-2cAg649PHaTlokMSXBvWVqr-xhE0REl36u3T5tjAdLSuSGrdVPiimCoXn_m6eu5FIWD42ktiWCv5QCe6ypUPJCZfMMV9Z4exFXJIePMJAgir0JdNqvaM5NR4eec5KEeIxFCJmKTXGSThP9Q7nQnzU_g",
			"createdDateTime": "2023-11-05T12:16:36.013Z",
			"cTag": "aYzo4MEJGNjY0QzNEREIxRUIhMTA3LjI1Nw",
			"eTag": "aODBCRjY2NEMzRERCMUVCITEwNy40",
			"id": "80BF664C3DDB1EB!107",
			"lastModifiedDateTime": "2023-11-05T12:16:59.743Z",
			"name": "card.pdf",
			"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCbA",
			"parentReference": {
				"driveId": "80bf664c3ddb1eb",
				"driveType": "personal"
			},
			"remoteItem": {
				"id": "4248D082B18F56F3!108",
				"lastModifiedDateTime": "2023-11-05T12:16:37.733Z",
				"name": "card.pdf",
				"size": 5333805,
				"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCbA",
				"createdBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"fileSystemInfo": {
					"createdDateTime": "2023-11-05T12:12:00.44Z",
					"lastModifiedDateTime": "2023-11-05T12:12:00.44Z"
				},
				"file": {
					"mimeType": "application/pdf",
					"hashes": {
						"sha1Hash": "8FE5FAFF1515FC55AAC59F6483AC1FDC3EE0F799"
					}
				},
				"lastModifiedBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"parentReference": {
					"driveId": "4248d082b18f56f3",
					"driveType": "personal"
				},
				"shared": {
					"sharedDateTime": "2023-11-05T12:16:36.013Z",
					"owner": {
						"user": {
							"displayName": "Florian Schade",
							"id": "4248d082b18f56f3"
						}
					}
				}
			}
		},
		{
			"@odata.type": "#microsoft.graph.driveItem",
			"createdDateTime": "2023-11-05T08:48:19Z",
			"cTag": "adDo4MEJGNjY0QzNEREIxRUIhMTA2LjYzODM0NzcwOTMwMDgwMDAwMA",
			"eTag": "aODBCRjY2NEMzRERCMUVCITEwNi4w",
			"id": "80BF664C3DDB1EB!106",
			"lastModifiedDateTime": "2023-11-05T08:48:50.08Z",
			"name": "test",
			"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCaQ",
			"parentReference": {
				"driveId": "80bf664c3ddb1eb",
				"driveType": "personal"
			},
			"remoteItem": {
				"id": "4248D082B18F56F3!105",
				"lastModifiedDateTime": "2023-11-05T08:48:39.71Z",
				"name": "test",
				"size": 0,
				"webUrl": "https://1drv.ms/u/s!APNWj7GC0EhCaQ",
				"createdBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"fileSystemInfo": {
					"createdDateTime": "2023-11-05T07:33:16.7666667Z",
					"lastModifiedDateTime": "2023-11-05T07:33:16.7666667Z"
				},
				"folder": {
					"childCount": 0,
					"view": {
						"viewType": "thumbnails",
						"sortBy": "name",
						"sortOrder": "ascending"
					}
				},
				"lastModifiedBy": {
					"user": {
						"displayName": "Florian Schade",
						"id": "4248d082b18f56f3"
					}
				},
				"parentReference": {
					"driveId": "4248d082b18f56f3",
					"driveType": "personal"
				},
				"shared": {
					"sharedDateTime": "2023-11-05T08:48:19Z",
					"owner": {
						"user": {
							"displayName": "Florian Schade",
							"id": "4248d082b18f56f3"
						}
					}
				}
			}
		}
	]
}

@fschade fschade self-assigned this Oct 31, 2023
@fschade fschade force-pushed the graph-beta-sharedWithMe-api branch 2 times, most recently from bf2d0ef to ad146ff Compare October 31, 2023 16:30
@fschade
Copy link
Contributor Author

fschade commented Nov 2, 2023

CI will fail for the moment, its expected, .... somehow my locally generated swagger api uses UPPERCase letters for api, e.g. UserApi => UserAPI, UsersApi => UsersAPI, i'll investigate later why thats the case....

@fschade
Copy link
Contributor Author

fschade commented Nov 2, 2023

i could need a second pair of eyes (web :)) to see what else is needed, cc.: @kulmann

@fschade fschade force-pushed the graph-beta-sharedWithMe-api branch 2 times, most recently from 0c80c9e to e44bc2a Compare November 5, 2023 12:11
@micbar micbar mentioned this pull request Nov 6, 2023
22 tasks
@rhafer
Copy link
Contributor

rhafer commented Nov 6, 2023

CI will fail for the moment, its expected, .... somehow my locally generated swagger api uses UPPERCase letters for api, e.g. UserApi => UserAPI, UsersApi => UsersAPI, i'll investigate later why thats the case....

@fschade Yeah, that's a changed default in the go-generator. since version 6 (IIRC) You need to call it with --api-name-suffix Api now to be backwards compatible. See: owncloud/libre-graph-api@eb7bb4e

@fschade
Copy link
Contributor Author

fschade commented Nov 6, 2023

CI will fail for the moment, its expected, .... somehow my locally generated swagger api uses UPPERCase letters for api, e.g. UserApi => UserAPI, UsersApi => UsersAPI, i'll investigate later why thats the case....

@fschade Yeah, that's a changed default in the go-generator. since version 6 (IIRC) You need to call it with --api-name-suffix Api now to be backwards compatible. See: owncloud/libre-graph-api@eb7bb4e

😮 THX

@fschade fschade force-pushed the graph-beta-sharedWithMe-api branch 2 times, most recently from 7f8bc15 to 120fbba Compare November 7, 2023 15:10
@fschade fschade marked this pull request as ready for review November 7, 2023 15:10
@fschade fschade force-pushed the graph-beta-sharedWithMe-api branch 3 times, most recently from e61c482 to 634bc29 Compare November 8, 2023 11:27
services/proxy/pkg/user/backend/cs3.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rhafer rhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me in general. Commented on just a few minor things.

One question though. owncloud/libre-graph-api#112 talked about the permissions property on sharedWithMe. You code currently doesn't populate that. Is that no longer needed? If yes, how does a user figure out its own permissions (and expiry) on a share?

@fschade fschade force-pushed the graph-beta-sharedWithMe-api branch 2 times, most recently from d411d4f to 7b63628 Compare November 8, 2023 16:19
@fschade
Copy link
Contributor Author

fschade commented Nov 8, 2023

looks good to me in general. Commented on just a few minor things.

One question though. owncloud/libre-graph-api#112 talked about the permissions property on sharedWithMe. You code currently doesn't populate that. Is that no longer needed? If yes, how does a user figure out its own permissions (and expiry) on a share?

i want to wait for the Role <-> Permissions Conversion, once these are settled i planned to add them in a separate pr

Copy link
Contributor

@rhafer rhafer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me. Let's to the rest in followup PRs.

(btw, I'd prefer if stuff like the libregraph-api bump would be in separate commits, IMO that simplifies review a bit. Just as a side-note for the future)

Copy link

sonarcloud bot commented Nov 8, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 7 Code Smells

88.5% 88.5% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ocis] implement /me/drives/sharedWithMe
2 participants