1 /* 2 * Copyright 2016 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.google.cloud.dns.spi.v1; 18 19 import com.google.api.client.googleapis.json.GoogleJsonError; 20 import com.google.api.services.dns.model.Change; 21 import com.google.api.services.dns.model.ChangesListResponse; 22 import com.google.api.services.dns.model.ManagedZone; 23 import com.google.api.services.dns.model.ManagedZonesListResponse; 24 import com.google.api.services.dns.model.Project; 25 import com.google.api.services.dns.model.ResourceRecordSetsListResponse; 26 import java.util.Map; 27 28 /** An interface for the collection of batch operations. */ 29 public interface RpcBatch { 30 31 /** An interface for batch callbacks. */ 32 interface Callback<T> { 33 34 /** This method will be called upon success of the batch operation. */ onSuccess(T response)35 void onSuccess(T response); 36 37 /** This method will be called upon failure of the batch operation. */ onFailure(GoogleJsonError googleJsonError)38 void onFailure(GoogleJsonError googleJsonError); 39 } 40 41 /** 42 * Adds a call to "list zones" to the batch with the provided {@code callback} and {@code 43 * options}. 44 */ addListZones(Callback<ManagedZonesListResponse> callback, Map<DnsRpc.Option, ?> options)45 void addListZones(Callback<ManagedZonesListResponse> callback, Map<DnsRpc.Option, ?> options); 46 47 /** 48 * Adds a call to "create zone" to the batch with the provided {@code callback} and {@code 49 * options}. 50 */ addCreateZone( ManagedZone zone, Callback<ManagedZone> callback, Map<DnsRpc.Option, ?> options)51 void addCreateZone( 52 ManagedZone zone, Callback<ManagedZone> callback, Map<DnsRpc.Option, ?> options); 53 54 /** 55 * Adds a call to "get zone" to the batch with the provided {@code callback} and {@code options}. 56 * The zone to be retrieved is identified by {@code zoneName}. 57 */ addGetZone(String zoneName, Callback<ManagedZone> callback, Map<DnsRpc.Option, ?> options)58 void addGetZone(String zoneName, Callback<ManagedZone> callback, Map<DnsRpc.Option, ?> options); 59 60 /** 61 * Adds a call to "get project" to the batch with the provided {@code callback} and {@code 62 * options}. 63 */ addGetProject(Callback<Project> callback, Map<DnsRpc.Option, ?> options)64 void addGetProject(Callback<Project> callback, Map<DnsRpc.Option, ?> options); 65 66 /** 67 * Adds a call to "delete zone" to the batch with the provided {@code callback}. The zone to be 68 * deleted is identified by {@code zoneName}. 69 */ addDeleteZone(String zoneName, Callback<Void> callback)70 void addDeleteZone(String zoneName, Callback<Void> callback); 71 72 /** 73 * Adds a call to "list record sets" to the batch with the provided {@code callback} and {@code 74 * options}. The zone whose record sets are to be listed is identified by {@code zoneName}. 75 */ addListRecordSets( String zoneName, Callback<ResourceRecordSetsListResponse> callback, Map<DnsRpc.Option, ?> options)76 void addListRecordSets( 77 String zoneName, 78 Callback<ResourceRecordSetsListResponse> callback, 79 Map<DnsRpc.Option, ?> options); 80 81 /** 82 * Adds a call to "list change requests" to the batch with the provided {@code callback} and 83 * {@code options}. The zone whose change requests are to be listed is identified by {@code 84 * zoneName}. 85 */ addListChangeRequests( String zoneName, Callback<ChangesListResponse> callback, Map<DnsRpc.Option, ?> options)86 void addListChangeRequests( 87 String zoneName, Callback<ChangesListResponse> callback, Map<DnsRpc.Option, ?> options); 88 89 /** 90 * Adds a call to "get change request" to the batch with the provided {@code callback} and {@code 91 * options}. The change request to be retrieved is identified by {@code changeRequestId}. The zone 92 * to which the change request was applied is identified by {@code zoneName}. 93 */ addGetChangeRequest( String zoneName, String changeRequestId, Callback<Change> callback, Map<DnsRpc.Option, ?> options)94 void addGetChangeRequest( 95 String zoneName, 96 String changeRequestId, 97 Callback<Change> callback, 98 Map<DnsRpc.Option, ?> options); 99 100 /** 101 * Adds a call to "apply change request" to the batch with the provided {@code callback} and 102 * {@code options}. The parameter {@code change} is the change request to be applied. The zone to 103 * which the change request should be applied is identified by {@code zoneName}. 104 */ addApplyChangeRequest( String zoneName, Change change, Callback<Change> callback, Map<DnsRpc.Option, ?> options)105 void addApplyChangeRequest( 106 String zoneName, Change change, Callback<Change> callback, Map<DnsRpc.Option, ?> options); 107 108 /** Submits a batch of requests for processing using a single RPC request to Cloud DNS. */ submit()109 void submit(); 110 } 111