IPA-127: Declarative-Friendly Interfaces
Following declarative-friendly standards is essential for ensuring reliable,
consistent, automated, and low-latency integrations with consumers,
such as Infrastructure as Code (IaC) tools, which many customers heavily
depend on for their DevOps workflows.
An interface is considered "declarative-friendly" when resources can be managed
by specifying their desired final state, rather than outlining a series of
steps or actions. In this approach, a user defines what the resource should
look like via an IaC tool, while the tool and underlying API take care of the
how.
With the wide range of popular IaC tools and the constant demand to integrate diverse resource types across multiple platforms, uniformity is critical to fully automating these integrations.\
In addition to the existing guidelines, declarative-friendly interfaces require extra, stricter guidance to support IaC tooling automation.
Guidance
A resource must be strongly consistent with the Resource-Oriented Design (IPA-101).
paths:
/projects:
get:
operationId: listProjects
post:
operationId: createProject
/projects/{projectId}:
get:
operationId: getProject
delete:
operationId: deleteProjectWhy:Paths form a noun hierarchy and each verb maps to a standard method on the resource, so the resource can be expressed as a desired state rather than a sequence of actions.
paths:
/createProject:
post:
operationId: createProject
/deleteProjectById:
post:
operationId: deleteProjectByIdWhy:The paths name actions instead of a resource. An action-shaped interface cannot be reconciled to a desired state, which is what IaC tooling depends on.
Enumerate every entry under
pathsand group the paths by their resource segment.Confirm each path alternates collection nouns and resource identifiers rather than encoding a verb or action.
Confirm each operation maps to a standard method on its resource (the verb matches the resource semantics, not an arbitrary RPC).
Report any path or operation that models an action instead of a resource as a deviation from Resource-Oriented Design.
A resource must have
CREATE,DELETE,GET, andLISTmethods.paths:
/orders:
get:
operationId: listOrders
post:
operationId: createOrder
/orders/{orderId}:
get:
operationId: getOrder
delete:
operationId: deleteOrderWhy:The collection exposes
LISTandCREATEand the item exposesGETandDELETE, so the full lifecycle of the resource can be driven declaratively.paths:
/orders:
post:
operationId: createOrder
/orders/{orderId}:
get:
operationId: getOrderWhy:LISTandDELETEare missing. WithoutLIST, an IaC tool cannot discover existing resources to reconcile; withoutDELETE, removed configuration cannot be applied.Group the paths by resource: a collection path and its corresponding item path with a path parameter.
For each resource, collect the operations on the collection path (
getforLIST,postforCREATE) and on the item path (getforGET,deleteforDELETE).Confirm all four standard methods are present for the resource.
Report any resource that is missing one or more of
CREATE,DELETE,GET, orLIST, unless it qualifies as a singleton or read-only resource.
Singleton resources and read-only resources must have
GETandLISTmethods.paths:
/audit-events:
get:
operationId: listAuditEvents
/audit-events/{eventId}:
get:
operationId: getAuditEventWhy:Audit events are read-only, so the resource correctly exposes only
GETandLISTand omits the mutating methods that do not apply.paths:
/audit-events:
post:
operationId: createAuditEvent
/audit-events/{eventId}:
delete:
operationId: deleteAuditEventWhy:A read-only resource exposes mutating methods and omits
GETandLIST. The required read methods are absent, and the mutating methods imply a lifecycle the resource does not have.Identify resources that are singletons (no collection path with a list operation, accessed at a fixed path) or read-only (state is server-owned and not client-mutable).
For each such resource, confirm a
GETmethod is present (geton the item path) and aLISTmethod is present (geton the collection path).Confirm no mutating methods (
CREATE,DELETE) are exposed where the resource cannot be created or removed by the client.Report any singleton or read-only resource that is missing
GETorLIST.
Depends onA resource should not have custom methods (IPA-109). Any complementary functionality of a resource exposed through custom methods will not be supported through automation.
Deviation from this guidance requires a strong justification and review by the governing API body.
paths:
/jobs:
post:
operationId: createJob
/jobs/{jobId}:
get:
operationId: getJob
patch:
operationId: updateJobWhy:State that would otherwise be set by a custom action is modeled as a standard update, so the resource can be reconciled to a desired state by an IaC tool.
paths:
/jobs/{jobId}:
get:
operationId: getJob
"/jobs/{jobId}:cancel":
post:
operationId: cancelJobWhy:cancelis a custom method expressing an action rather than a state. IaC tooling cannot represent invoking an action, so this behavior falls outside automation.Enumerate the operations under
pathsand identify any custom methods, such as a path segment of the form:verbor an operation that does not map to a standardCREATE,READ,UPDATE,DELETE, orLISTmethod.For each custom method, determine whether the same outcome could be expressed as a state change on a standard method (for example, a status field updated via
PATCH).Flag every custom method on a resource. Each occurrence is a deviation that requires explicit justification and review by the governing API body.
Motivation and Strategic Goals
Our engineering teams and customers rely on IaC tools to manage infrastructure repeatably and reliably. APIs that don't follow a declarative model require complex and brittle integration work, creating a poor experience for all consumers.
The primary strategic benefit of adopting a consistent declarative model is the ability to automate the generation of IaC provider resources. When our APIs are predictably declarative, we can build automations that create and maintain tools such as our Terraform and CloudFormation providers. This will dramatically accelerate the availability of IaC support for our products and reduce manual, error-prone development.