Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@ def cf_network(cli_ctx, aux_subscriptions=None, **_):


def cf_graph(cli_ctx, **_):
from azure.cli.core._profile import Profile
from azure.cli.core.commands.client_factory import configure_common_settings
from azure.graphrbac import GraphRbacManagementClient
profile = Profile(cli_ctx=cli_ctx)
cred, _, tenant_id = profile.get_login_credentials(
resource=cli_ctx.cloud.endpoints.active_directory_graph_resource_id)
client = GraphRbacManagementClient(cred, tenant_id,
base_url=cli_ctx.cloud.endpoints.active_directory_graph_resource_id)
configure_common_settings(cli_ctx, client)
from azure.cli.command_modules.role import graph_client_factory
client = graph_client_factory(cli_ctx)
Comment on lines +28 to +29
Copy link
Member

Choose a reason for hiding this comment

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

I am glad to see the new azure.cli.command_modules.role.graph_client_factory interface significantly reduces the effort to build a Graph client. 😊

Copy link
Member Author

Choose a reason for hiding this comment

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

I am glad to see the new azure.cli.command_modules.role.graph_client_factory interface significantly reduces the effort to build a Graph client. 😊

learnt this from key vault PR 😁

return client


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def worker(cmd, prefix, namespace): # pylint: disable=unused-argument
client = cf_graph(cmd.cli_ctx)
filter_str = "startswith(userPrincipalName, '{0}') or startswith(mail, '{0}')" \
.format(prefix) if prefix else None
users = client.users.list(filter=filter_str).advance_page()
users = client.user_list(filter=filter_str).advance_page()
return [user.mail if ("#EXT#" in user.user_principal_name) else user.user_principal_name for user in users]

return HDInsightCompleter(worker=worker).complete(cmd, prefix, namespace)
Expand All @@ -54,7 +54,7 @@ def cluster_user_group_completion_list(cmd, prefix, namespace, **kwargs): # pyl
def worker(cmd, prefix, namespace): # pylint: disable=unused-argument
client = cf_graph(cmd.cli_ctx)
filter_str = "startswith(displayName, '{}')".format(prefix) if prefix else None
groups = client.groups.list(filter=filter_str).advance_page()
groups = client.group_list(filter=filter_str).advance_page()
return [group.display_name for group in groups]

return HDInsightCompleter(worker=worker).complete(cmd, prefix, namespace)
Expand Down