Skip to content

Change template_links() API to return links _and_ template ID #548

@mwhicks1

Description

@mwhicks1

Category

User level API changes

Describe the feature you'd like to request

Currently we have two APIs for getting information from a template-linked api::Policy:

  • template_id() returns Some(tid) if the policy is template-linked, where tid is the ID of the template
  • template_links() (added by API for extracting values from template-linked policy #515) returns Some(vals) if the policy is template-linked, where vals are the values linked into the template's slots.

An invariant is that if template_id() returns Some(_) then template_links() should return Some(_) as well. Client code still has to deal with the possibility of failure, though, by using expect() on the second call. They could avoid that step if template_links() returned both tid and vals.

Changing the API to do this would be a breaking change, but not for any released version of Cedar.

Describe alternatives you've considered

One alternative would be to add a third API, e.g., template_id_and_links that returns both. But that would only be useful if we imagined scenarios in which you'd want to know the links but not know the template ID. I can't think of reasonable (non corner-case) scenarios for that.

Another alternative would be to do nothing, and ask the client to use expect() as discussed above.

Additional context

No response

Is this something that you'd be interested in working on?

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestThis issue requets a substantial new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions