Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ResourceRecordSet.getQualifier() #173

Merged
merged 5 commits into from
Jun 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### Version 1.3.0
* Deprecated remaining naming conventions that use syntax like `getUrl` or `listByName` to `url` or `iterateByName` to support migration to denominator 2.0.
* ResourceRecordSet no longer implements `List<D>`. Please access rdata via the `rdata()` accessor.
* Added `ResourceRecordSet.getQualifier()`, `ReadOnlyResourceRecordSetApi.getByNameTypeAndQualifier()`
* Deprecated `Geo.getGroup()` for `ResourceRecordSet.getQualifier()`
* Deprecated `GeoResourceRecordSetApi.getByNameTypeAndGroup()` for `ReadOnlyResourceRecordSetApi.getByNameTypeAndQualifier()`
* Deprecated `GeoResourceRecordSetApi.applyRegionsToNameTypeAndGroup()` for `GeoResourceRecordSetApi.applyRegionsToNameTypeAndQualifier()`
* Deprecated `GeoResourceRecordSetApi.applyTTLToNameTypeAndGroup()` for `GeoResourceRecordSetApi.applyTTLToNameTypeAndQualifier()`
* Add `-t/--type` to list, and `-q/--qualifier` to get record cli commands.

### Version 1.2.1
* remove strict zone name checks on deprecated `DNSApi.get..Api` methods as often the backend will accept zone names with or without a trailing dot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static class GeoResourceRecordSetGet extends GeoResourceRecordSetCommand

public Iterator<String> doRun(DNSApiManager mgr) {
GeoResourceRecordSetApi api = mgr.api().geoRecordSetsInZone(idOrName(mgr, zoneIdOrName)).get();
Optional<ResourceRecordSet<?>> result = api.getByNameTypeAndGroup(name, type, group);
Optional<ResourceRecordSet<?>> result = api.getByNameTypeAndQualifier(name, type, group);
return forArray(result.transform(GeoResourceRecordSetToString.INSTANCE).or(""));
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public boolean hasNext() {
@Override
public String next() {
GeoResourceRecordSetApi api = mgr.api().geoRecordSetsInZone(idOrName(mgr, zoneIdOrName)).get();
api.applyTTLToNameTypeAndGroup(ttl, name, type, group);
api.applyTTLToNameTypeAndQualifier(ttl, name, type, group);
done = true;
return ";; ok";
}
Expand All @@ -144,14 +144,11 @@ static enum GeoResourceRecordSetToString implements Function<ResourceRecordSet<?
@Override
public String apply(ResourceRecordSet<?> geoRRS) {
Geo geo = toProfile(Geo.class).apply(geoRRS);
StringBuilder suffix = new StringBuilder().append(geo.group()).append(' ')
.append(geo.regions());
ImmutableList.Builder<String> lines = ImmutableList.<String> builder();
for (String line : Splitter.on('\n').split(ResourceRecordSetToString.INSTANCE.apply(geoRRS))) {
lines.add(new StringBuilder().append(line).append(' ').append(suffix).toString());
lines.add(new StringBuilder().append(line).append(' ').append(geo.regions()).toString());
}
return Joiner.on('\n').join(lines.build());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,41 @@ public static class ResourceRecordSetList extends ResourceRecordSetCommand {
@Option(type = OptionType.COMMAND, name = { "-n", "--name" }, description = "name of the record sets. ex. www.denominator.io.")
public String name;

@Option(type = OptionType.COMMAND, name = { "-t", "--type" }, description = "type of the record set. ex. CNAME")
public String type;

public Iterator<String> doRun(DNSApiManager mgr) {
Iterator<ResourceRecordSet<?>> iterator;
if (name != null && type != null)
iterator = mgr.api().recordSetsInZone(idOrName(mgr, zoneIdOrName)).iterateByNameAndType(name, type);
if (name != null)
iterator = mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName)).iterateByName(name);
else
iterator = mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName)).iterator();
iterator = mgr.api().recordSetsInZone(idOrName(mgr, zoneIdOrName)).iterator();
return transform(iterator, ResourceRecordSetToString.INSTANCE);
}
}

@Command(name = "get", description = "gets a record record set by name and type, if present in this zone")
@Command(name = "get", description = "gets a record record set by name and type (optionally by qualifier), if present in this zone")
public static class ResourceRecordSetGet extends ResourceRecordSetCommand {
@Option(type = OptionType.COMMAND, required = true, name = { "-n", "--name" }, description = "name of the record set. ex. www.denominator.io.")
public String name;

@Option(type = OptionType.COMMAND, required = true, name = { "-t", "--type" }, description = "type of the record set. ex. CNAME")
public String type;

@Option(type = OptionType.COMMAND, name = { "-q", "--qualifier" }, description = "qualifier of the record set (if applicable). ex. US")
public String qualifier;

public Iterator<String> doRun(DNSApiManager mgr) {
return forArray(mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName)).getByNameAndType(name, type)
.transform(ResourceRecordSetToString.INSTANCE).or(""));
Optional<ResourceRecordSet<?>> result;
if (qualifier != null) {
result = mgr.api().recordSetsInZone(idOrName(mgr, zoneIdOrName))
.getByNameTypeAndQualifier(name, type, qualifier);
} else {
result = mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName)).getByNameAndType(name, type);
}
return forArray(result.transform(ResourceRecordSetToString.INSTANCE).or(""));
}
}

Expand All @@ -98,8 +112,7 @@ public boolean hasNext() {

@Override
public String next() {
mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName))
.applyTTLToNameAndType(ttl, name, type);
mgr.api().basicRecordSetsInZone(idOrName(mgr, zoneIdOrName)).applyTTLToNameAndType(ttl, name, type);
done = true;
return ";; ok";
}
Expand Down Expand Up @@ -320,8 +333,8 @@ static enum ResourceRecordSetToString implements Function<ResourceRecordSet<?>,
public String apply(ResourceRecordSet<?> input) {
ImmutableList.Builder<String> lines = ImmutableList.<String> builder();
for (Map<String, Object> rdata : input) {
lines.add(format("%-50s%-7s%-6s%s", input.name(), input.type(), input.ttl().orNull(),
flatten(rdata)));
lines.add(format("%-50s%-7s%-20s%-6s%s", input.name(), input.type(), input.qualifier().or(""),
input.ttl().orNull(), flatten(rdata)));
}
return Joiner.on('\n').join(lines.build());
}
Expand Down
Loading