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

Usage for circular dependency and custom update endpoint #80

Open
mrhamburg opened this issue Apr 18, 2023 · 0 comments
Open

Usage for circular dependency and custom update endpoint #80

mrhamburg opened this issue Apr 18, 2023 · 0 comments

Comments

@mrhamburg
Copy link

mrhamburg commented Apr 18, 2023

Hi! Thx for creating this package for Pulumi. Since dynamic providers for .NET is not ready yet and I would like to implement a "simple" API based infra provider, I thought why not make use of Purrl instead of creating a full package. While doing so, I bumped against some limitations and questions which made me give second thoughts on my approach. I'm facing the following challenges:

I have this endpoint for managing DNS records. There is a PUT endpoint for creating a new record and a POST endpoint for updating an existing record. However, in the current implementation of Purrl I cannot change the method used for updates, can I? (see non working example below).

Second to this, the endpoint requires the ID of the DNS record when updating and removing the record. How can a property of an existing instance work for subsequent requests? In the example below, Id will be null in the constructor, so I would not be able to make use of it before instantiating the resource itself.

public class Record : BunnyCdnComponentResource
{
    [Output]
    public Output<string> Id { get; set; }

    public Record(string name, string zoneId, DnsRecordArgs args, ComponentResourceOptions? options = null) : base("", name, options)
    {
        // Cannot make use of Id as it has not been defined yet
        var recordEndpoint = Id.Apply(recordId => $"https://api.bunny.net/dnszone/{zoneId}/records/{recordId}");
        var request = new Purrl(name, new PurrlArgs
        {
            Name = name,
            Url = $"https://api.bunny.net/dnszone/{zoneId}/records",
            ResponseCodes = new List<string> { "200" },
            Method = "PUT",
            Headers = new Dictionary<string, string>
            {
                { "accept", "application/json" },
                { "content-type", "application/json" }
            },
            Body = args.ToJson(),
            UpdateMethod = "POST",          // Currently does not exist <--------!!!!
            UpdateUrl = recordEndpoint,     // Currently does not exist <--------!!!!
            DeleteMethod = "DELETE",
            DeleteUrl = recordEndpoint,
            DeleteResponseCodes = new List<string> { "200" },
        });

        Id = request.Response;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant