| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | import static com.google.common.base.Preconditions.checkNotNull; | |
| 20 | 20 | ||
| 21 | - import com.google.api.services.dns.model.ResourceRecordSet; | ||
| 21 | + import com.google.api.services.dns.model.Change; | ||
| 22 | 22 | import com.google.common.base.Function; | |
| 23 | 23 | import com.google.common.base.MoreObjects; | |
| 24 | 24 | import com.google.common.collect.ImmutableList; | |
@@ -40,21 +40,14 @@ | |||
| 40 | 40 | */ | |
| 41 | 41 | public class ChangeRequest implements Serializable { | |
| 42 | 42 | ||
| 43 | - private static final Function<ResourceRecordSet, DnsRecord> FROM_PB_FUNCTION = | ||
| 44 | - new Function<com.google.api.services.dns.model.ResourceRecordSet, DnsRecord>() { | ||
| 43 | + static final Function<Change, ChangeRequest> FROM_PB_FUNCTION = | ||
| 44 | + new Function<Change, ChangeRequest>() { | ||
| 45 | 45 | @Override | |
| 46 | - public DnsRecord apply(com.google.api.services.dns.model.ResourceRecordSet pb) { | ||
| 47 | - return DnsRecord.fromPb(pb); | ||
| 46 | + public ChangeRequest apply(com.google.api.services.dns.model.Change pb) { | ||
| 47 | + return ChangeRequest.fromPb(pb); | ||
| 48 | 48 | } | |
| 49 | 49 | }; | |
| 50 | - private static final Function<DnsRecord, ResourceRecordSet> TO_PB_FUNCTION = | ||
| 51 | - new Function<DnsRecord, ResourceRecordSet>() { | ||
| 52 | - @Override | ||
| 53 | - public com.google.api.services.dns.model.ResourceRecordSet apply(DnsRecord error) { | ||
| 54 | - return error.toPb(); | ||
| 55 | - } | ||
| 56 | - }; | ||
| 57 | - private static final long serialVersionUID = -8703939628990291682L; | ||
| 50 | + private static final long serialVersionUID = -9027378042756366333L; | ||
| 58 | 51 | private final List<DnsRecord> additions; | |
| 59 | 52 | private final List<DnsRecord> deletions; | |
| 60 | 53 | private final String id; | |
@@ -274,9 +267,9 @@ com.google.api.services.dns.model.Change toPb() { | |||
| 274 | 267 | pb.setStatus(status().name().toLowerCase()); | |
| 275 | 268 | } | |
| 276 | 269 | // set a list of additions | |
| 277 | - pb.setAdditions(Lists.transform(additions(), TO_PB_FUNCTION)); | ||
| 270 | + pb.setAdditions(Lists.transform(additions(), DnsRecord.TO_PB_FUNCTION)); | ||
| 278 | 271 | // set a list of deletions | |
| 279 | - pb.setDeletions(Lists.transform(deletions(), TO_PB_FUNCTION)); | ||
| 272 | + pb.setDeletions(Lists.transform(deletions(), DnsRecord.TO_PB_FUNCTION)); | ||
| 280 | 273 | return pb; | |
| 281 | 274 | } | |
| 282 | 275 | ||
@@ -293,10 +286,10 @@ static ChangeRequest fromPb(com.google.api.services.dns.model.Change pb) { | |||
| 293 | 286 | builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); | |
| 294 | 287 | } | |
| 295 | 288 | if (pb.getDeletions() != null) { | |
| 296 | - builder.deletions(Lists.transform(pb.getDeletions(), FROM_PB_FUNCTION)); | ||
| 289 | + builder.deletions(Lists.transform(pb.getDeletions(), DnsRecord.FROM_PB_FUNCTION)); | ||
| 297 | 290 | } | |
| 298 | 291 | if (pb.getAdditions() != null) { | |
| 299 | - builder.additions(Lists.transform(pb.getAdditions(), FROM_PB_FUNCTION)); | ||
| 292 | + builder.additions(Lists.transform(pb.getAdditions(), DnsRecord.FROM_PB_FUNCTION)); | ||
| 300 | 293 | } | |
| 301 | 294 | return builder.build(); | |
| 302 | 295 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ public interface Dns extends Service<DnsOptions> { | |||
| 36 | 36 | * The fields of a project. | |
| 37 | 37 | * | |
| 38 | 38 | * <p>These values can be used to specify the fields to include in a partial response when calling | |
| 39 | - * {@link Dns#getProjectInfo(ProjectOption...)}. Project ID is always returned, even if not | ||
| 39 | + * {@link Dns#getProject(ProjectOption...)}. Project ID is always returned, even if not | ||
| 40 | 40 | * specified. | |
| 41 | 41 | */ | |
| 42 | 42 | enum ProjectField { | |
@@ -419,7 +419,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { | |||
| 419 | 419 | /** | |
| 420 | 420 | * Creates a new zone. | |
| 421 | 421 | * | |
| 422 | - * <p>Returns {@link ZoneInfo} object representing the new zone's information. In addition to the | ||
| 422 | + * <p>Returns {@link Zone} object representing the new zone's information. In addition to the | ||
| 423 | 423 | * name, dns name and description (supplied by the user within the {@code zoneInfo} parameter), | |
| 424 | 424 | * the returned object can include the following read-only fields supplied by the server: creation | |
| 425 | 425 | * time, id, and list of name servers. The returned fields can be optionally restricted by | |
@@ -429,7 +429,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { | |||
| 429 | 429 | * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/create">Cloud DNS Managed Zones: | |
| 430 | 430 | * create</a> | |
| 431 | 431 | */ | |
| 432 | - ZoneInfo create(ZoneInfo zoneInfo, ZoneOption... options); | ||
| 432 | + Zone create(ZoneInfo zoneInfo, ZoneOption... options); | ||
| 433 | 433 | ||
| 434 | 434 | /** | |
| 435 | 435 | * Returns the zone by the specified zone name. Returns {@code null} if the zone is not found. The | |
@@ -439,7 +439,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { | |||
| 439 | 439 | * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones: | |
| 440 | 440 | * get</a> | |
| 441 | 441 | */ | |
| 442 | - ZoneInfo getZone(String zoneName, ZoneOption... options); | ||
| 442 | + Zone getZone(String zoneName, ZoneOption... options); | ||
| 443 | 443 | ||
| 444 | 444 | /** | |
| 445 | 445 | * Lists the zones inside the project. | |
@@ -485,7 +485,7 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) { | |||
| 485 | 485 | * @throws DnsException upon failure | |
| 486 | 486 | * @see <a href="https://cloud.google.com/dns/api/v1/projects/get">Cloud DNS Projects: get</a> | |
| 487 | 487 | */ | |
| 488 | - ProjectInfo getProjectInfo(ProjectOption... fields); | ||
| 488 | + ProjectInfo getProject(ProjectOption... fields); | ||
| 489 | 489 | ||
| 490 | 490 | /** | |
| 491 | 491 | * Submits a change request for the specified zone. The returned object contains the following | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,6 +17,8 @@ | |||
| 17 | 17 | package com.google.gcloud.dns; | |
| 18 | 18 | ||
| 19 | 19 | import com.google.gcloud.BaseServiceException; | |
| 20 | + import com.google.gcloud.RetryHelper.RetryHelperException; | ||
| 21 | + import com.google.gcloud.RetryHelper.RetryInterruptedException; | ||
| 20 | 22 | ||
| 21 | 23 | import java.io.IOException; | |
| 22 | 24 | ||
@@ -31,5 +33,21 @@ public DnsException(IOException exception) { | |||
| 31 | 33 | super(exception, true); | |
| 32 | 34 | } | |
| 33 | 35 | ||
| 36 | + public DnsException(int code, String message) { | ||
| 37 | + super(code, message, null, true); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * Translate RetryHelperException to the DnsException that caused the error. This method will | ||
| 42 | + * always throw an exception. | ||
| 43 | + * | ||
| 44 | + * @throws DnsException when {@code ex} was caused by a {@code DnsException} | ||
| 45 | + * @throws RetryInterruptedException when {@code ex} is a {@code RetryInterruptedException} | ||
| 46 | + */ | ||
| 47 | + static DnsException translateAndThrow(RetryHelperException ex) { | ||
| 48 | + BaseServiceException.translateAndPropagateIfPossible(ex); | ||
| 49 | + throw new DnsException(UNKNOWN_CODE, ex.getMessage()); | ||
| 50 | + } | ||
| 51 | + | ||
| 34 | 52 | //TODO(mderka) Add translation and retry functionality. Created issue #593. | |
| 35 | 53 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments