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

Introduce util for retrieving graph site id from webUrl #4316

Closed
MathijsVerbeeck opened this issue Jan 7, 2023 · 4 comments
Closed

Introduce util for retrieving graph site id from webUrl #4316

MathijsVerbeeck opened this issue Jan 7, 2023 · 4 comments

Comments

@MathijsVerbeeck
Copy link
Contributor

Currently, we have multiple commands using the method getSpoSiteId. These methods all have the same functionallty. The code is the following:

private async getSpoSiteId(args: CommandArgs): Promise<string> {
    const url = new URL(args.options.webUrl!);
    const requestOptions: CliRequestOptions= {
      url: `${this.resource}/v1.0/sites/${url.hostname}:${url.pathname}`,
      headers: {
        accept: 'application/json;odata.metadata=none'
      },
      responseType: 'json'
    };

    const site = await request.get<{ id: string }>(requestOptions)
    return site.id!
}

As this code is reused multiple times, it would be handy if this code is added to a util such as aadGroup.

This method is currently used in the following commands:

  • onenote notebook list
  • onenote page list (new command, still to be merged)
  • spo site apppermission add
  • spo site apppermission get
  • spo site apppermission list
  • spo site apppermission remove
  • spo site apppermission set
@Jwaegebaert
Copy link
Contributor

Great suggestion @MathijsVerbeeck! It's always a good idea to move duplicate code to a single location. Are you interested to work on this one?

@MathijsVerbeeck
Copy link
Contributor Author

Sure, go ahead and assign me.

@Jwaegebaert
Copy link
Contributor

Awesome, all yours!

@MathijsVerbeeck
Copy link
Contributor Author

FYI: I'm currently waiting for PR #4312 to be completed so that I can immediately add this to all the commands.

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

Successfully merging a pull request may close this issue.

3 participants