Skip to content

Usage for circular dependency and custom update endpoint #80

Description

@mrhamburg

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;
    }
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions