liveBook · Manning

Copy or move operation

As explained in API Design Patterns

A copy or move operation duplicates or relocates an API resource while applying the destination resource's constraints.

A copy or move operation duplicates or relocates a resource while preserving its associated data and respecting constraints inherited from the destination. Treating the operation as a single-record update can produce incomplete or surprising resources. section 17.3.2 section 17.3.5

Moving a ChatRoom with messages

Moving ChatRoom old to ChatRoom new must also update each Message path from chatRooms/old/messages/... to chatRooms/new/messages/.... If the destination ChatRoom imposes a messageLengthLimit that any message violates, reject the entire operation with clear failure reasons rather than silently truncating data. section 17.3.2 section 17.3.5

Use these rules when designing the operation:

  • Include every child resource so the destination behaves as much like the source as possible. section 17.3.2
  • Validate children against metadata inherited from the destination parent. section 17.3.5
  • Reject and abort on violations; let users correct the data or destination constraints before retrying. section 17.3.5
Table 17.1 New and old identifiers after moving (or copying) a ChatRoom resource (view table figure)

Resource type

Original identifier

New identifier

ChatRoom

chatRooms/old

chatRooms/new

Message

chatRooms/old/messages/2

chatRooms/new/messages/2

Message

chatRooms/old/messages/3

chatRooms/new/messages/3

Message

chatRooms/old/messages/4

chatRooms/new/messages/4

Compare original and new identifiers for the parent and each moved or copied child resource. section 17.3.2

How API Design Patterns covers it

How deep it goes
Explains child-resource identifier updates and validation failures, but defers handling of references beyond the stated dead-link problem.
Examples
Uses ChatRoom and Message resources, nested identifier mappings, and a message-length limit inherited by children.
What it assumes
Assumes nested resources and destination validation, while teaching their implications for copying and moving from the operation’s consequences.
What you can do after
Operate/configure copy and move workflows that preserve children, reject invalid destinations, and expose actionable failure reasons.
How it connects
Connects child resources, inherited metadata, resource identifiers, validation, and references.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.