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

Support for generic directory objects and improved odata field handling #86

Merged
merged 10 commits into from
Aug 17, 2021

Conversation

manicminer
Copy link
Owner

  • Adds a top level model struct for the directoryObject API base class
  • Embed this struct into other models to inherit the ID and odata fields
  • Support operations via the /directoryObjects endpoint
  • Improved handling of @odata.bind fields so that the tenant ID isn't needed to build odata URIs for objects

Amongst other benefits, this should enable us to determine the type of an object given its UUID.

- Adds a top level model struct for the directoryObject API base class
- Embed this struct into other models to inherit the ID and odata fields
- Support operations via the /directoryObjects endpoint
- Improved handling of @odata.bind fields so that the tenant ID isn't
  needed to build odata URIs for objects
@manicminer manicminer added the enhancement New feature or request label Aug 12, 2021
@manicminer manicminer added this to the v0.24.0 milestone Aug 12, 2021
Copy link
Collaborator

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

a few minor comments but this otherwise LGTM 👍

msgraph/models.go Outdated Show resolved Hide resolved
msgraph/models.go Show resolved Hide resolved
Comment on lines +22 to +41
c := DirectoryObjectsClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
c.client = msgraph.NewDirectoryObjectsClient(c.connection.AuthConfig.TenantID)
c.client.BaseClient.Authorizer = c.connection.Authorizer

g := GroupsClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
g.client = msgraph.NewGroupsClient(c.connection.AuthConfig.TenantID)
g.client.BaseClient.Authorizer = c.connection.Authorizer

u := UsersClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
u.client = msgraph.NewUsersClient(c.connection.AuthConfig.TenantID)
u.client.BaseClient.Authorizer = c.connection.Authorizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

it might be worth adding some test-wrappers here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Comment on lines +74 to +79
testDirectoryObjectsClient_Get(t, c, *user.ID)
testDirectoryObjectsClient_Get(t, c, *group1.ID)
testDirectoryObjectsClient_GetMemberGroups(t, c, *user.ID, true, []string{*group1.ID, *group2.ID})
testDirectoryObjectsClient_GetMemberObjects(t, c, *group1.ID, true, []string{*group2.ID})
testDirectoryObjectsClient_GetByIds(t, c, []string{*group1.ID, *group2.ID, *user.ID}, []string{odata.ShortTypeGroup})
testDirectoryObjectsClient_Delete(t, c, *group1.ID)
Copy link
Collaborator

Choose a reason for hiding this comment

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

using something like Testify's suite package would make this easier fwiw (since these'd be methods hanging off of that struct with a Setup, as your doing here?)

Copy link
Owner Author

Choose a reason for hiding this comment

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

cool, will take a look at that and improving the test setup sprawl 👍

msgraph/directory_objects_test.go Outdated Show resolved Hide resolved
msgraph/models.go Outdated Show resolved Hide resolved
odata/odata.go Show resolved Hide resolved
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

aside from a couple mindor comments LGTM 👍

msgraph/directory_objects.go Outdated Show resolved Hide resolved
msgraph/directory_objects.go Outdated Show resolved Hide resolved
Comment on lines +22 to +41
c := DirectoryObjectsClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
c.client = msgraph.NewDirectoryObjectsClient(c.connection.AuthConfig.TenantID)
c.client.BaseClient.Authorizer = c.connection.Authorizer

g := GroupsClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
g.client = msgraph.NewGroupsClient(c.connection.AuthConfig.TenantID)
g.client.BaseClient.Authorizer = c.connection.Authorizer

u := UsersClientTest{
connection: test.NewConnection(auth.MsGraph, auth.TokenVersion2),
randomString: rs,
}
u.client = msgraph.NewUsersClient(c.connection.AuthConfig.TenantID)
u.client.BaseClient.Authorizer = c.connection.Authorizer
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

@manicminer manicminer merged commit d503035 into main Aug 17, 2021
@manicminer manicminer deleted the f/directory-objects branch August 17, 2021 12:50
manicminer added a commit that referenced this pull request Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants