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

Not updated example of the C# code for Azure API Management #3113

Closed
paf-dev opened this issue Feb 28, 2024 · 6 comments
Closed

Not updated example of the C# code for Azure API Management #3113

paf-dev opened this issue Feb 28, 2024 · 6 comments
Assignees
Labels
kind/question Questions about existing features resolution/wont-fix This issue won't be fixed

Comments

@paf-dev
Copy link

paf-dev commented Feb 28, 2024

What happened?

There is documentation about the class that is responsible for Azure API Management.
The link: https://www.pulumi.com/registry/packages/azure-native/api-docs/apimanagement/api/
The C# example has initialization of the Protocols property like that

    var api = new AzureNative.ApiManagement.Api("api", new()
    {
        ...
        Protocols = new[]
        {
            "https",
            "http",
        },
        ...
    });

The problem is that Protocols has type of List<Union<string, Pulumi.AzureNative.ApiManagement.Protocol>>
Also, I can't find any documentation about the usage of the Union type.

Example

No

Output of pulumi about

No

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@paf-dev paf-dev added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Feb 28, 2024
@mjeffryes mjeffryes added kind/question Questions about existing features and removed kind/bug Some behavior is incorrect or out of spec labels Feb 28, 2024
@mjeffryes
Copy link
Member

Hi @paf-dev, the Union type is defined in the shared dotnet SDK here

The reason the code example doesn't explicitly instantiate it is that Union provides implicit conversions link, so the compiler will automatically convert those Strings into Union<string, Pulumi.AzureNative.ApiManagement.Protocol>s

@mjeffryes mjeffryes added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Feb 28, 2024
@paf-dev
Copy link
Author

paf-dev commented Feb 29, 2024

The reason the code example doesn't explicitly instantiate it is that Union provides implicit conversions link, so the compiler will automatically convert those Strings into Union<string, Pulumi.AzureNative.ApiManagement.Protocol>s

I also thought about implicit conversion, but dotnet build still says the following

error CS0029: Cannot implicitly convert type 'string[]' to 'Pulumi.InputList<Pulumi.Union<string, Pulumi.AzureNative.ApiManagement.Protocol>>

@TheRubble
Copy link

TheRubble commented Mar 14, 2024

@paf-dev did you solve this? Getting the same issue. Do you really mean this Protocols = ["https"] or Protocols = new InputList<Union<string, Protocol>>() {"https"}

@paf-dev
Copy link
Author

paf-dev commented Mar 14, 2024

@TheRubble Here is what I used in my code to make it work

Protocols = new Union<string, Protocol>[]
{
   Protocol.Https
},

Probably not the best, but at least it worked and I was not blocked by the service that actually takes my company's money for that

@TheRubble
Copy link

["https"]

["https"] this will work then :-)

@mikhailshilkov mikhailshilkov added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels May 8, 2024
@thomas11 thomas11 added resolution/wont-fix This issue won't be fixed and removed needs-triage Needs attention from the triage team labels May 10, 2024
@thomas11
Copy link
Contributor

Since there seems to be a working solution, I'll close this issue, but please feel free to re-open if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Questions about existing features resolution/wont-fix This issue won't be fixed
Projects
None yet
Development

No branches or pull requests

5 participants