Netflix/denominator — pull request #178 by adriancole (2013-06-13 20:37:04+00:00)
Title: Add full write support to AllProfileResourceRecordSetApi and Add ResourceRecordApi.put

This change aligns all mutation operations so that `AllProfileResourceRecordSetApi` can control everything regardless of profile. This deprecates "partial update" methods in `ResourceRecordSetApi` for `ResourceRecordSetApi.put()`.

Below are workarounds for the partial update commands.

#### apply ttl by name and type
```java
Optional> rrset = api.getByNameAndType(name, type);
if (rrset.isPresent() && rrset.get().ttl().or(Integer.MAX_VALUE).intValue() != ttl) {
api.put(ResourceRecordSet.builder()
.name(name)
.type(type)
.ttl(ttl)
.addAll(rrset.get().rdata()).build());
}
```
#### add an additional round-robin value
```java
Optional> rrset = api.getByNameAndType(name, type);
if (rrset.isPresent()) {
List> oldRDataAsList = ImmutableList.copyOf(rrset.get().rdata());
List> newRData = ImmutableList.copyOf(filter(rrset.get().rdata(), not(in(toAdd.rdata()))));
if (!newRData.isEmpty()) {
api.put(ResourceRecordSet.builder()
.name(name)
.type(type)
.ttl(rrset.get().ttl().orNull())
.addAll(oldRDataAsList)
.addAll(newRData).build());
}
} else {
api.put(toAdd);
}
```
#### delete one value or the rrset if that's the last one
```java
Optional> rrset = api.getByNameAndType(name, type);
if (rrset.isPresent()) {
List> oldRDataAsList = ImmutableList.copyOf(rrset.get().rdata());
List> retainedRData = ImmutableList.copyOf(filter(rrset.get().rdata(), not(in(toRemove.rdata()))));
if (retainedRData.isEmpty()) {
api.deleteByNameAndType(name, type);
} else if (!oldRDataAsList.equals(retainedRData)) {
api.put(ResourceRecordSet.builder()
.name(name)
.type(type)
.ttl(rrset.get().ttl().orNull())
.addAll(retainedRData).build());
}
}
```