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 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? 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.

17.1 Motivation

17.2 Overview

17.3 Implementation

17.3.1 Identifiers

17.3.2 Child resources

17.3.3 Related resources

17.3.4 External data

17.3.5 Inherited metadata

17.3.6 Atomicity

17.3.7 Final API definition

17.4 Trade-offs

17.5 Exercises

Summary