19 Criteria-based deletion

 

This chapter covers...

  • How the custom Purge method can be used to delete matching resources
  • Why the custom Purge method is dangerous and should be avoided if possible
  • A variety of safety precautions to avoid accidentally deleting more data than intended
  • How to address concerns about consistency in the matching result set

While batch operations we learned about in Chapter 18 (Batch operations) provide the ability to delete several resources with a single API call, there's an underlying requirement that we must know in advance the unique identifiers of the resource we want to delete. However, there are many scenarios where we're not so much interested in deleting a specific list of resources and instead are more interested in deleting any resources that happen to match a specific set of criteria. This design pattern provides a mechanism by which we can safely and atomically remove all resources matching certain criteria rather than by a list of identifiers.

19.1  Motivation

As is evident from Chapter 18 (Batch operations), it's not all that uncommon to want to operate on more than one resource at a time. More specifically, certainly might want to "clear out" a set of specific resources. However, compared to the other batch operations, deletion is by far the most straightforward, requiring no other information to perform an action: given an ID, remove the resource.

19.2  Overview

19.3  Implementation

19.3.1    Filtering results

19.3.2    Validation only by default

19.3.3    Result count

19.3.4    Result sample set

19.3.5    Consistency

19.3.6    Final API definition

19.4  Trade-offs

19.5  Exercises

19.6  Summary

19.7  References

sitemap