1818
1919import com .google .common .base .Joiner ;
2020import com .google .common .collect .Sets ;
21+ import com .google .gcloud .Page ;
2122import com .google .gcloud .Service ;
2223import com .google .gcloud .spi .DnsRpc ;
2324
2425import java .io .Serializable ;
26+ import java .math .BigInteger ;
2527import java .util .Set ;
2628
27- import static com .google .gcloud .dns .Dns .ZoneField .selector ;
28-
2929/**
3030 * An interface for the Google Cloud DNS service.
3131 *
@@ -37,7 +37,7 @@ public interface Dns extends Service<DnsOptions> {
3737 * The fields of a project.
3838 *
3939 * <p>These values can be used to specify the fields to include in a partial response when calling
40- * {@code Dns#getProjectInfo(ProjectGetOption ...)}. Project ID is always returned, even if not
40+ * {@link Dns#getProjectInfo(ProjectOption ...)}. Project ID is always returned, even if not
4141 * specified.
4242 */
4343 enum ProjectField {
@@ -69,7 +69,7 @@ static String selector(ProjectField... fields) {
6969 * The fields of a zone.
7070 *
7171 * <p>These values can be used to specify the fields to include in a partial response when calling
72- * {@code Dns#getZone(BigInteger, ZoneOption...)} or {@code Dns#getZone(String, ZoneOption...)}.
72+ * {@link Dns#getZone(BigInteger, ZoneOption...)} or {@link Dns#getZone(String, ZoneOption...)}.
7373 * The ID is always returned, even if not specified.
7474 */
7575 enum ZoneField {
@@ -105,7 +105,7 @@ static String selector(ZoneField... fields) {
105105 * The fields of a DNS record.
106106 *
107107 * <p>These values can be used to specify the fields to include in a partial response when calling
108- * {@code Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@code
108+ * {@link Dns#listDnsRecords(BigInteger, DnsRecordListOption...)} or {@link
109109 * Dns#listDnsRecords(String, DnsRecordListOption...)}. The name is always returned even if not
110110 * selected.
111111 */
@@ -139,8 +139,8 @@ static String selector(DnsRecordField... fields) {
139139 * The fields of a change request.
140140 *
141141 * <p>These values can be used to specify the fields to include in a partial response when calling
142- * {@code Dns#applyChangeRequest(ChangeRequest, BigInteger , ChangeRequestOption...)} or {@code
143- * Dns#applyChangeRequest(ChangeRequest, String , ChangeRequestOption...)} The ID is always
142+ * {@link Dns#applyChangeRequest(BigInteger, ChangeRequest , ChangeRequestOption...)} or {@link
143+ * Dns#applyChangeRequest(String, ChangeRequest , ChangeRequestOption...)} The ID is always
144144 * returned even if not selected.
145145 */
146146 enum ChangeRequestField {
@@ -285,7 +285,7 @@ class ZoneListOption extends AbstractOption implements Serializable {
285285 */
286286 public static ZoneListOption fields (ZoneField ... fields ) {
287287 StringBuilder builder = new StringBuilder ();
288- builder .append ("managedZones(" ).append (selector (fields )).append (')' );
288+ builder .append ("managedZones(" ).append (ZoneField . selector (fields )).append (')' );
289289 return new ZoneListOption (DnsRpc .Option .FIELDS , builder .toString ());
290290 }
291291
@@ -313,24 +313,24 @@ public static ZoneListOption pageSize(int pageSize) {
313313 /**
314314 * Class for specifying project options.
315315 */
316- class ProjectGetOption extends AbstractOption implements Serializable {
316+ class ProjectOption extends AbstractOption implements Serializable {
317317
318318 private static final long serialVersionUID = 6817937338218847748L ;
319319
320- ProjectGetOption (DnsRpc .Option option , Object value ) {
320+ ProjectOption (DnsRpc .Option option , Object value ) {
321321 super (option , value );
322322 }
323323
324324 /**
325325 * Returns an option to specify the project's fields to be returned by the RPC call.
326326 *
327327 * <p>If this option is not provided all project fields are returned. {@code
328- * ProjectGetOption .fields} can be used to specify only the fields of interest. Project ID is
328+ * ProjectOption .fields} can be used to specify only the fields of interest. Project ID is
329329 * always returned, even if not specified. {@link ProjectField} provides a list of fields that
330330 * can be used.
331331 */
332- public static ProjectGetOption fields (ProjectField ... fields ) {
333- return new ProjectGetOption (DnsRpc .Option .FIELDS , ProjectField .selector (fields ));
332+ public static ProjectOption fields (ProjectField ... fields ) {
333+ return new ProjectOption (DnsRpc .Option .FIELDS , ProjectField .selector (fields ));
334334 }
335335 }
336336
@@ -420,5 +420,178 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) {
420420 }
421421 }
422422
423- // TODO(mderka) Add methods. Created issue #596.
423+ /**
424+ * Creates a new zone.
425+ *
426+ * <p>Returns {@link ZoneInfo} object representing the new zone's information. In addition to the
427+ * name, dns name and description (supplied by the user within the {@code zoneInfo} parameter),
428+ * the returned object will include the following read-only fields supplied by the server:
429+ * creation time, id, and list of name servers.
430+ *
431+ * @throws DnsException upon failure
432+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/create">Cloud DNS Managed Zones:
433+ * create</a>
434+ */
435+ ZoneInfo create (ZoneInfo zoneInfo );
436+
437+ /**
438+ * Returns the zone by the specified zone name. Returns {@code null} if the zone is not found. The
439+ * returned fields can be optionally restricted by specifying {@link ZoneOption}s.
440+ *
441+ * @throws DnsException upon failure
442+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones:
443+ * get</a>
444+ */
445+ ZoneInfo getZone (String zoneName , ZoneOption ... options );
446+
447+ /**
448+ * Returns the zone by the specified zone id. Returns {@code null} if the zone is not found. The
449+ * returned fields can be optionally restricted by specifying {@link ZoneOption}s.
450+ *
451+ * @throws DnsException upon failure
452+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones:
453+ * get</a>
454+ */
455+ ZoneInfo getZone (BigInteger zoneId , ZoneOption ... options );
456+
457+ /**
458+ * Lists the zones inside the project.
459+ *
460+ * <p>This method returns zones in an unspecified order. New zones do not necessarily appear at
461+ * the end of the list. Use {@link ZoneListOption} to restrict the listing to a domain name, set
462+ * page size, and set page token.
463+ *
464+ * @return a page of zones
465+ * @throws DnsException upon failure
466+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/list">Cloud DNS Managed Zones:
467+ * list</a>
468+ */
469+ Page <Zone > listZones (ZoneListOption ... options );
470+
471+ /**
472+ * Deletes an existing zone identified by name. Returns {@code true} if the zone was successfully
473+ * deleted and {@code false} otherwise.
474+ *
475+ * @return {@code true} if zone was found and deleted and {@code false} otherwise
476+ * @throws DnsException upon failure
477+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/delete">Cloud DNS Managed Zones:
478+ * delete</a>
479+ */
480+ boolean delete (String zoneName ); // delete does not admit any options
481+
482+ /**
483+ * Deletes an existing zone identified by id. Returns {@code true} if the zone was successfully
484+ * deleted and {@code false} otherwise.
485+ *
486+ * @return {@code true} if zone was found and deleted and {@code false} otherwise
487+ * @throws DnsException upon failure
488+ * @see <a href="https://cloud.google.com/dns/api/v1/managedZones/delete">Cloud DNS Managed Zones:
489+ * delete</a>
490+ */
491+ boolean delete (BigInteger zoneId ); // delete does not admit any options
492+
493+ /**
494+ * Lists the DNS records in the zone identified by name.
495+ *
496+ * <p>The fields to be returned, page size and page tokens can be specified using {@link
497+ * DnsRecordListOption}s.
498+ *
499+ * @throws DnsException upon failure or if the zone cannot be found
500+ * @see <a href="https://cloud.google.com/dns/api/v1/resourceRecordSets/list">Cloud DNS
501+ * ResourceRecordSets: list</a>
502+ */
503+ Page <DnsRecord > listDnsRecords (String zoneName , DnsRecordListOption ... options );
504+
505+ /**
506+ * Lists the DNS records in the zone identified by ID.
507+ *
508+ * <p>The fields to be returned, page size and page tokens can be specified using {@link
509+ * DnsRecordListOption}s.
510+ *
511+ * @throws DnsException upon failure or if the zone cannot be found
512+ * @see <a href="https://cloud.google.com/dns/api/v1/resourceRecordSets/list">Cloud DNS
513+ * ResourceRecordSets: list</a>
514+ */
515+ Page <DnsRecord > listDnsRecords (BigInteger zoneId , DnsRecordListOption ... options );
516+
517+ /**
518+ * Retrieves the information about the current project. The returned fields can be optionally
519+ * restricted by specifying {@link ProjectOption}s.
520+ *
521+ * @throws DnsException upon failure
522+ * @see <a href="https://cloud.google.com/dns/api/v1/projects/get">Cloud DNS Projects: get</a>
523+ */
524+ ProjectInfo getProjectInfo (ProjectOption ... fields );
525+
526+ /**
527+ * Submits a change request for the specified zone. The returned object contains the following
528+ * read-only fields supplied by the server: id, start time and status. time, id, and list of name
529+ * servers. The fields to be returned can be selected by {@link ChangeRequestOption}s.
530+ *
531+ * @return the new {@link ChangeRequest} or {@code null} if zone is not found
532+ * @throws DnsException upon failure
533+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/create">Cloud DNS Changes: create</a>
534+ */
535+ ChangeRequest applyChangeRequest (BigInteger zoneId , ChangeRequest changeRequest ,
536+ ChangeRequestOption ... options );
537+
538+ /**
539+ * Submits a change request for the specified zone. The returned object contains the following
540+ * read-only fields supplied by the server: id, start time and status. time, id, and list of name
541+ * servers. The fields to be returned can be selected by {@link ChangeRequestOption}s.
542+ *
543+ * @return the new {@link ChangeRequest}
544+ * @throws DnsException upon failure if zone is not found
545+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/create">Cloud DNS Changes: create</a>
546+ */
547+ ChangeRequest applyChangeRequest (String zoneName , ChangeRequest changeRequest ,
548+ ChangeRequestOption ... options );
549+
550+ /**
551+ * Retrieves updated information about a change request previously submitted for a zone identified
552+ * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone
553+ * does not exist. The fields to be returned using can be specified using {@link
554+ * ChangeRequestOption}s.
555+ *
556+ * @throws DnsException upon failure or if the zone cannot be found
557+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
558+ */
559+ ChangeRequest getChangeRequest (BigInteger zoneId , String changeRequestId ,
560+ ChangeRequestOption ... options );
561+
562+ /**
563+ * Retrieves updated information about a change request previously submitted for a zone identified
564+ * by ID. Returns {@code null} if the request cannot be found and throws an exception if the zone
565+ * does not exist. The fields to be returned using can be specified using {@link
566+ * ChangeRequestOption}s.
567+ *
568+ * @throws DnsException upon failure or if the zone cannot be found
569+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
570+ */
571+ ChangeRequest getChangeRequest (String zoneName , String changeRequestId ,
572+ ChangeRequestOption ... options );
573+
574+ /**
575+ * Lists the change requests for the zone identified by ID that were submitted to the service.
576+ *
577+ * <p>The sorting order for changes (based on when they were received by the server), fields to be
578+ * returned, page size and page token can be specified using {@link ChangeRequestListOption}s.
579+ *
580+ * @return A page of change requests
581+ * @throws DnsException upon failure or if the zone cannot be found
582+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/list">Cloud DNS Chages: list</a>
583+ */
584+ Page <ChangeRequest > listChangeRequests (BigInteger zoneId , ChangeRequestListOption ... options );
585+
586+ /**
587+ * Lists the change requests for the zone identified by name that were submitted to the service.
588+ *
589+ * <p>The sorting order for changes (based on when they were received by the server), fields to be
590+ * returned, page size and page token can be specified using {@link ChangeRequestListOption}s.
591+ *
592+ * @return A page of change requests
593+ * @throws DnsException upon failure or if the zone cannot be found
594+ * @see <a href="https://cloud.google.com/dns/api/v1/changes/list">Cloud DNS Chages: list</a>
595+ */
596+ Page <ChangeRequest > listChangeRequests (String zoneName , ChangeRequestListOption ... options );
424597}
0 commit comments