Skip to content

Commit 0338ead

Browse files
committed
Completes DnsRpc interface by adding methods and doc.
Closes #594.
1 parent d6daf09 commit 0338ead

1 file changed

Lines changed: 116 additions & 1 deletion

File tree

  • gcloud-java-dns/src/main/java/com/google/gcloud/spi

gcloud-java-dns/src/main/java/com/google/gcloud/spi/DnsRpc.java

Lines changed: 116 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
package com.google.gcloud.spi;
1818

19+
import com.google.api.services.dns.model.Change;
20+
import com.google.api.services.dns.model.ManagedZone;
21+
import com.google.api.services.dns.model.Project;
22+
import com.google.api.services.dns.model.ResourceRecordSet;
23+
import com.google.gcloud.dns.DnsException;
24+
1925
import java.util.Map;
2026

2127
public interface DnsRpc {
@@ -52,5 +58,114 @@ Integer getInt(Map<Option, ?> options) {
5258
}
5359
}
5460

55-
//TODO(mderka) add supported operations. Created issue #594.
61+
class Tuple<X, Y> {
62+
63+
private final X x;
64+
private final Y y;
65+
66+
private Tuple(X x, Y y) {
67+
this.x = x;
68+
this.y = y;
69+
}
70+
71+
public static <X, Y> Tuple<X, Y> of(X x, Y y) {
72+
return new Tuple<>(x, y);
73+
}
74+
75+
public X x() {
76+
return x;
77+
}
78+
79+
public Y y() {
80+
return y;
81+
}
82+
}
83+
84+
/**
85+
* Creates a new zone.
86+
*
87+
* @param zone a zone to be created
88+
* @return Updated {@link ManagedZone} object
89+
* @throws DnsException upon failure
90+
*/
91+
ManagedZone create(ManagedZone zone) throws DnsException;
92+
93+
/**
94+
* Retrieves and returns an existing zone.
95+
*
96+
* @param zoneName name of the zone to be returned
97+
* @param options a map of options for the service call
98+
* @return a zone or {@code null} if not found
99+
* @throws DnsException upon failure
100+
*/
101+
ManagedZone getZone(String zoneName, Map<Option, ?> options) throws DnsException;
102+
103+
/**
104+
* Lists the zones that exist within the project.
105+
*
106+
* @param options a map of options for the service call
107+
* @throws DnsException upon failure
108+
*/
109+
Tuple<String, Iterable<ManagedZone>> listZones(Map<Option, ?> options) throws DnsException;
110+
111+
/**
112+
* Deletes the zone identified by the name.
113+
*
114+
* @return {@code true} if the zone was deleted and {@code false} otherwise
115+
* @throws DnsException upon failure
116+
*/
117+
boolean deleteZone(String zoneName) throws DnsException;
118+
119+
/**
120+
* Lists DNS records for a given zone.
121+
*
122+
* @param zoneName name of the zone to be listed
123+
* @param options a map of options for the service call
124+
* @throws DnsException upon failure or if zone not found
125+
*/
126+
Tuple<String, Iterable<ResourceRecordSet>> listDnsRecords(String zoneName,
127+
Map<Option, ?> options) throws DnsException;
128+
129+
/**
130+
* Returns information about the current project.
131+
*
132+
* @param options a map of options for the service call
133+
* @return up-to-date project information
134+
* @throws DnsException upon failure
135+
*/
136+
Project getProject(Map<Option, ?> options) throws DnsException;
137+
138+
/**
139+
* Applies change request to a zone.
140+
*
141+
* @param zoneName the name of a zone to which the {@link Change} should be applied
142+
* @param changeRequest change to be applied
143+
* @param options a map of options for the service call
144+
* @return updated change object with server-assigned ID
145+
* @throws DnsException upon failure or if zone not found
146+
*/
147+
Change applyChangeRequest(String zoneName, Change changeRequest, Map<Option, ?> options)
148+
throws DnsException;
149+
150+
/**
151+
* Returns an existing change request.
152+
*
153+
* @param zoneName the name of a zone to which the {@link Change} was be applied
154+
* @param changeRequestId the unique id assigned to the change by the server
155+
* @param options a map of options for the service call
156+
* @return up-to-date change object
157+
* @throws DnsException upon failure or if zone not found
158+
*/
159+
Change getChangeRequest(String zoneName, String changeRequestId, Map<Option, ?> options)
160+
throws DnsException;
161+
162+
/**
163+
* List an existing change requests for a zone.
164+
*
165+
* @param zoneName the name of a zone to which the {@link Change}s were be applied
166+
* @param options a map of options for the service call
167+
* @throws DnsException upon failure or if zone not found
168+
*/
169+
Tuple<String, Iterable<Change>> listChangeRequests(String zoneName, Map<Option, ?> options)
170+
throws DnsException;
56171
}

0 commit comments

Comments
 (0)