chapter seventeen
17 Copy and move
This chapter covers...
- How to use the Copy and Move custom methods for rearranging resources in an API
- Choosing the right identifier (or identifier policy) for copy and move operations
- How to handle child and other related resources when copying or moving parent resources
- Dealing with external data references for copied or moved resources
- What level of atomicity should be expected from these new custom methods
While very few resources are considered immutable, there are often certain attributes of a resource that we can safely assume won't change out from under us. In particular, a resource's unique identifier is one of these attributes. But what if we want to "rename" a resource? How can we do so safely? Further, what if we want to move a resource from belonging to one parent resource to another? Or duplicate a resource? In this pattern, we'll explore a safe and stable method for these operations, covering both "copying" (duplication) and "moving" (changing a unique identifier or changing a parent) of resources in an API.