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

API Documentation is out-of-date or misleading #1037

Open
mentallabyrinth opened this issue May 3, 2024 · 1 comment
Open

API Documentation is out-of-date or misleading #1037

mentallabyrinth opened this issue May 3, 2024 · 1 comment
Labels
area/docs Improvements or additions to documentation awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features

Comments

@mentallabyrinth
Copy link

mentallabyrinth commented May 3, 2024

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

It appears the documentation for https://www.pulumi.com/registry/packages/azuread/api-docs/applicationapiaccess is out-of-date. Following the examples directly leads to code that cannot compile. In the first example the following code is provided:

var wellKnown = AzureAD.GetApplicationPublishedAppIds.Invoke();
var msGraph = AzureAD.GetServicePrincipal.Invoke(new()
{
    ClientId = wellKnown.Apply(getApplicationPublishedAppIdsResult => 
        getApplicationPublishedAppIdsResult.Result?.MicrosoftGraph),
});

However, MicrosoftGraph property doesn't exist. The Result property is a ImmutableDictionary<string, string> so the access path should be:

var wellKnown = AzureAD.GetApplicationPublishedAppIds.Invoke();
var msGraph = AzureAD.GetServicePrincipal.Invoke(new()
{
    ClientId = wellKnown.Apply(getApplicationPublishedAppIdsResult => 
        getApplicationPublishedAppIdsResult.Result["MicrosoftGraph"]),
});

Next, if the developer tries to implement this segment of code in the first example:

var exampleMsgraph = new AzureAD.ApplicationApiAccess("example_msgraph", new()
    {
        ApplicationId = example.Id,
        ApiClientId = wellKnown.Apply(getApplicationPublishedAppIdsResult => getApplicationPublishedAppIdsResult.Result?.MicrosoftGraph),
        RoleIds = new[]
        {
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.AppRoleIds?.Group_Read_All),
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.AppRoleIds?.User_Read_All),
        },
        ScopeIds = new[]
        {
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.Oauth2PermissionScopeIds?.User_ReadWrite),
        },
    });

It fails because both AppRoleIds and Oauth2PermissionScopeIds are type ImmutableDictionary<string, string>. With the fixed code it should be:

var exampleMsgraph = new AzureAD.ApplicationApiAccess("example_msgraph", new()
    {
        ApplicationId = example.Id,
        ApiClientId = wellKnown.Apply(getApplicationPublishedAppIdsResult => getApplicationPublishedAppIdsResult.Result["MicrosoftGraph"]),
        RoleIds = new[]
        {
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.AppRoleIds["Group.Read.All"]),
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.AppRoleIds["User.Read.All"]),
        },
        ScopeIds = new[]
        {
            msgraph.Apply(getServicePrincipalResult => getServicePrincipalResult.Oauth2PermissionScopeIds["User.ReadWrite"]),
        },
    });

Note: I'm using the latest stable version v5.48.0 as mentioned in the documentation.

Thank you for your time.

Affected area/feature

Looking a the https://www.pulumi.com/registry/packages/azuread/api-docs/ documentation this is a wide spread issue. Multiple update will be required.

@mentallabyrinth mentallabyrinth added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels May 3, 2024
@thomas11
Copy link
Contributor

thomas11 commented May 8, 2024

Thank you for reporting this, @mentallabyrinth! This might be a bug in our code generation. I've filed an issue with that team.

@thomas11 thomas11 added awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). area/docs Improvements or additions to documentation and removed needs-triage Needs attention from the triage team labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Improvements or additions to documentation awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants