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

Added Dns methods, Zone and ZoneTest. Fixes #596. #606

Merged
merged 3 commits into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
194 changes: 190 additions & 4 deletions gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

import com.google.common.base.Joiner;
import com.google.common.collect.Sets;
import com.google.gcloud.Page;
import com.google.gcloud.Service;
import com.google.gcloud.spi.DnsRpc;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.Set;

import static com.google.gcloud.dns.Dns.ZoneField.selector;

/**
* An interface for the Google Cloud DNS service.
*
Expand Down Expand Up @@ -285,7 +285,7 @@ class ZoneListOption extends AbstractOption implements Serializable {
*/
public static ZoneListOption fields(ZoneField... fields) {
StringBuilder builder = new StringBuilder();
builder.append("managedZones(").append(selector(fields)).append(')');
builder.append("managedZones(").append(ZoneField.selector(fields)).append(')');
return new ZoneListOption(DnsRpc.Option.FIELDS, builder.toString());
}

Expand Down Expand Up @@ -420,5 +420,191 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) {
}
}

// TODO(mderka) Add methods. Created issue #596.
/**
* Creates a new zone.
*
* @return ZoneInfo object representing the new zone's metadata. In addition to the name, dns name
* and description (supplied by the user within the {@code zoneInfo} parameter, the returned

This comment was marked as spam.

This comment was marked as spam.

* object will include the following read-only fields supplied by the server: creation time, id,
* and list of name servers.
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/create">Cloud DNS Managed Zones:
* create</a>
*/
ZoneInfo create(ZoneInfo zoneInfo);

This comment was marked as spam.

This comment was marked as spam.


/**
* Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found.

This comment was marked as spam.

This comment was marked as spam.

* The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones:
* get</a>
*/
ZoneInfo getZone(String zoneName, ZoneOption... options);

/**
* Retrieves the zone by the specified zone name. Returns {@code null} is the zone is not found.

This comment was marked as spam.

This comment was marked as spam.

* The returned fields can be optionally restricted by specifying {@code ZoneFieldOptions}.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/get">Cloud DNS Managed Zones:
* get</a>
*/
ZoneInfo getZone(BigInteger zoneId, ZoneOption... options);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


/**
* Lists the zoned inside the project.

This comment was marked as spam.

This comment was marked as spam.

*
* <p>This method returns zone in an unspecified order. New zones do not necessarily appear at the

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* end of the list. Use {@link ZoneListOption} to restrict the listing to a domain name, set page
* size, and set page tokens.

This comment was marked as spam.

This comment was marked as spam.

*
* @return {@code Page<Zone>}, a page of zones

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/list">Cloud DNS Managed Zones:
* list</a>
*/
Page<Zone> listZones(ZoneListOption... options);

/**
* Deletes an existing zone identified by name. Returns true if the zone was successfully deleted

This comment was marked as spam.

This comment was marked as spam.

* and false otherwise.

This comment was marked as spam.

This comment was marked as spam.

*
* @return {@code true} if zone was found and deleted and false otherwise
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/delete">Cloud DNS Managed Zones:
* delete</a>
*/
boolean delete(String zoneName); // delete does not admit any options

/**
* Deletes an existing zone identified by id. Returns true if the zone was successfully deleted

This comment was marked as spam.

This comment was marked as spam.

* and false otherwise.

This comment was marked as spam.

This comment was marked as spam.

*
* @return {@code true} if zone was found and deleted and false otherwise
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/managedZones/delete">Cloud DNS Managed Zones:
* delete</a>
*/
boolean delete(BigInteger zoneId); // delete does not admit any options

/**
* Lists the DNS records in the zone identified by name.
*
* <p>The fields to be returned, page size and page tokens can be specified using {@code
* DnsRecordOptions}. Returns null if the zone cannot be found.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/resourceRecordSets/list">Cloud DNS
* ResourceRecordSets: list</a>
*/
Page<DnsRecord> listDnsRecords(String zoneName, DnsRecordListOption... options);

/**
* Lists the DNS records in the zone identified by ID.
*
* <p>The fields to be returned, page size and page tokens can be specified using {@code
* DnsRecordOptions}. Returns null if the zone cannot be found.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/resourceRecordSets/list">Cloud DNS
* ResourceRecordSets: list</a>
*/
Page<DnsRecord> listDnsRecords(BigInteger zoneId, DnsRecordListOption... options);

/**
* Retrieves the metadata about the current project. The returned fields can be optionally
* restricted by specifying {@code ProjectOptions}.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/projects/get">Cloud DNS Projects: get</a>
*/
ProjectInfo getProjectInfo(ProjectGetOption... fields);

/**
* Returns the current project id.
*/
String getProjectId();

This comment was marked as spam.

This comment was marked as spam.


/**
* Returns the current project number.
*/
BigInteger getProjectNumber();

/**
* Submits a change requests for applying to the zone identified by ID to the service. The

This comment was marked as spam.

This comment was marked as spam.

* returned object contains the following read-only fields supplied by the server: id, start time
* and status. time, id, and list of name servers. The returned fields can be modified by {@code

This comment was marked as spam.

This comment was marked as spam.

* ChangeRequestFieldOptions}. Returns null if the zone is not found.

This comment was marked as spam.

This comment was marked as spam.

*
* @return ChangeRequest object representing the new change request or null if zone is not found

This comment was marked as spam.

This comment was marked as spam.

* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/create">Cloud DNS Changes: create</a>
*/
ChangeRequest applyChangeRequest(ChangeRequest changeRequest, BigInteger zoneId,

This comment was marked as spam.

This comment was marked as spam.

ChangeRequestOption... options);

This comment was marked as spam.

This comment was marked as spam.


/**
* Submits a change requests for applying to the zone identified by name to the service. The
* returned object contains the following read-only fields supplied by the server: id, start time
* and status. time, id, and list of name servers. The returned fields can be modified by {@code
* ChangeRequestFieldOptions}. Returns null if the zone is not found.
*
* @return ChangeRequest object representing the new change request or null if zone is not found
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/create">Cloud DNS Changes: create</a>
*/
ChangeRequest applyChangeRequest(ChangeRequest changeRequest, String zoneName,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

ChangeRequestOption... options);

/**
* Retrieves updated information about a change request previously submitted for a zone identified
* by ID. Returns null if the zone or request cannot be found.

This comment was marked as spam.

This comment was marked as spam.

*
* <p>The fields to be returned using {@code ChangeRequestFieldOptions}.

This comment was marked as spam.

This comment was marked as spam.

*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
*/
ChangeRequest getChangeRequest(ChangeRequest changeRequest, BigInteger zoneId,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

ChangeRequestOption... options);

This comment was marked as spam.

This comment was marked as spam.


/**
* Retrieves updated information about a change request previously submitted for a zone identified
* by name. Returns null if the zone or request cannot be found.
*
* <p>The fields to be returned using {@code ChangeRequestFieldOptions}.
*
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
*/
ChangeRequest getChangeRequest(ChangeRequest changeRequest, String zoneName,

This comment was marked as spam.

ChangeRequestOption... options);

/**
* Lists the change requests for the zone identified by ID that were submitted to the service.
*
* <p>The sorting key for changes, fields to be returned, page and page tokens can be specified

This comment was marked as spam.

This comment was marked as spam.

* using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is

This comment was marked as spam.

This comment was marked as spam.

* the timestamp of submitting the change request to the service.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

*
* @return {@code Page<ChangeRequest>}, a page of change requests

This comment was marked as spam.

This comment was marked as spam.

* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/list">Cloud DNS Chages: list</a>
*/
Page<ChangeRequest> listChangeRequests(BigInteger zoneId, ChangeRequestListOption... options);

/**
* Lists the change requests for the zone identified by name that were submitted to the service.
*
* <p>The sorting key for changes, fields to be returned, page and page tokens can be specified
* using {@code ChangeRequestListOptions}. Note that the only sorting key currently supported is
* the timestamp of submitting the change request to the service.
*
* @return {@code Page<ChangeRequest>}, a page of change requests
* @throws DnsException upon failure
* @see <a href="https://cloud.google.com/dns/api/v1/changes/list">Cloud DNS Chages: list</a>
*/
Page<ChangeRequest> listChangeRequests(String zoneName, ChangeRequestListOption... options);

This comment was marked as spam.

This comment was marked as spam.

}
Loading