• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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  *      https://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.aiplatform.v1beta1;
18 
19 import com.google.api.core.BetaApi;
20 import com.google.cloud.aiplatform.v1beta1.JobServiceGrpc.JobServiceImplBase;
21 import com.google.longrunning.Operation;
22 import com.google.protobuf.AbstractMessage;
23 import com.google.protobuf.Empty;
24 import io.grpc.stub.StreamObserver;
25 import java.util.ArrayList;
26 import java.util.LinkedList;
27 import java.util.List;
28 import java.util.Queue;
29 import javax.annotation.Generated;
30 
31 @BetaApi
32 @Generated("by gapic-generator-java")
33 public class MockJobServiceImpl extends JobServiceImplBase {
34   private List<AbstractMessage> requests;
35   private Queue<Object> responses;
36 
MockJobServiceImpl()37   public MockJobServiceImpl() {
38     requests = new ArrayList<>();
39     responses = new LinkedList<>();
40   }
41 
getRequests()42   public List<AbstractMessage> getRequests() {
43     return requests;
44   }
45 
addResponse(AbstractMessage response)46   public void addResponse(AbstractMessage response) {
47     responses.add(response);
48   }
49 
setResponses(List<AbstractMessage> responses)50   public void setResponses(List<AbstractMessage> responses) {
51     this.responses = new LinkedList<Object>(responses);
52   }
53 
addException(Exception exception)54   public void addException(Exception exception) {
55     responses.add(exception);
56   }
57 
reset()58   public void reset() {
59     requests = new ArrayList<>();
60     responses = new LinkedList<>();
61   }
62 
63   @Override
createCustomJob( CreateCustomJobRequest request, StreamObserver<CustomJob> responseObserver)64   public void createCustomJob(
65       CreateCustomJobRequest request, StreamObserver<CustomJob> responseObserver) {
66     Object response = responses.poll();
67     if (response instanceof CustomJob) {
68       requests.add(request);
69       responseObserver.onNext(((CustomJob) response));
70       responseObserver.onCompleted();
71     } else if (response instanceof Exception) {
72       responseObserver.onError(((Exception) response));
73     } else {
74       responseObserver.onError(
75           new IllegalArgumentException(
76               String.format(
77                   "Unrecognized response type %s for method CreateCustomJob, expected %s or %s",
78                   response == null ? "null" : response.getClass().getName(),
79                   CustomJob.class.getName(),
80                   Exception.class.getName())));
81     }
82   }
83 
84   @Override
getCustomJob( GetCustomJobRequest request, StreamObserver<CustomJob> responseObserver)85   public void getCustomJob(
86       GetCustomJobRequest request, StreamObserver<CustomJob> responseObserver) {
87     Object response = responses.poll();
88     if (response instanceof CustomJob) {
89       requests.add(request);
90       responseObserver.onNext(((CustomJob) response));
91       responseObserver.onCompleted();
92     } else if (response instanceof Exception) {
93       responseObserver.onError(((Exception) response));
94     } else {
95       responseObserver.onError(
96           new IllegalArgumentException(
97               String.format(
98                   "Unrecognized response type %s for method GetCustomJob, expected %s or %s",
99                   response == null ? "null" : response.getClass().getName(),
100                   CustomJob.class.getName(),
101                   Exception.class.getName())));
102     }
103   }
104 
105   @Override
listCustomJobs( ListCustomJobsRequest request, StreamObserver<ListCustomJobsResponse> responseObserver)106   public void listCustomJobs(
107       ListCustomJobsRequest request, StreamObserver<ListCustomJobsResponse> responseObserver) {
108     Object response = responses.poll();
109     if (response instanceof ListCustomJobsResponse) {
110       requests.add(request);
111       responseObserver.onNext(((ListCustomJobsResponse) response));
112       responseObserver.onCompleted();
113     } else if (response instanceof Exception) {
114       responseObserver.onError(((Exception) response));
115     } else {
116       responseObserver.onError(
117           new IllegalArgumentException(
118               String.format(
119                   "Unrecognized response type %s for method ListCustomJobs, expected %s or %s",
120                   response == null ? "null" : response.getClass().getName(),
121                   ListCustomJobsResponse.class.getName(),
122                   Exception.class.getName())));
123     }
124   }
125 
126   @Override
deleteCustomJob( DeleteCustomJobRequest request, StreamObserver<Operation> responseObserver)127   public void deleteCustomJob(
128       DeleteCustomJobRequest request, StreamObserver<Operation> responseObserver) {
129     Object response = responses.poll();
130     if (response instanceof Operation) {
131       requests.add(request);
132       responseObserver.onNext(((Operation) response));
133       responseObserver.onCompleted();
134     } else if (response instanceof Exception) {
135       responseObserver.onError(((Exception) response));
136     } else {
137       responseObserver.onError(
138           new IllegalArgumentException(
139               String.format(
140                   "Unrecognized response type %s for method DeleteCustomJob, expected %s or %s",
141                   response == null ? "null" : response.getClass().getName(),
142                   Operation.class.getName(),
143                   Exception.class.getName())));
144     }
145   }
146 
147   @Override
cancelCustomJob( CancelCustomJobRequest request, StreamObserver<Empty> responseObserver)148   public void cancelCustomJob(
149       CancelCustomJobRequest request, StreamObserver<Empty> responseObserver) {
150     Object response = responses.poll();
151     if (response instanceof Empty) {
152       requests.add(request);
153       responseObserver.onNext(((Empty) response));
154       responseObserver.onCompleted();
155     } else if (response instanceof Exception) {
156       responseObserver.onError(((Exception) response));
157     } else {
158       responseObserver.onError(
159           new IllegalArgumentException(
160               String.format(
161                   "Unrecognized response type %s for method CancelCustomJob, expected %s or %s",
162                   response == null ? "null" : response.getClass().getName(),
163                   Empty.class.getName(),
164                   Exception.class.getName())));
165     }
166   }
167 
168   @Override
createDataLabelingJob( CreateDataLabelingJobRequest request, StreamObserver<DataLabelingJob> responseObserver)169   public void createDataLabelingJob(
170       CreateDataLabelingJobRequest request, StreamObserver<DataLabelingJob> responseObserver) {
171     Object response = responses.poll();
172     if (response instanceof DataLabelingJob) {
173       requests.add(request);
174       responseObserver.onNext(((DataLabelingJob) response));
175       responseObserver.onCompleted();
176     } else if (response instanceof Exception) {
177       responseObserver.onError(((Exception) response));
178     } else {
179       responseObserver.onError(
180           new IllegalArgumentException(
181               String.format(
182                   "Unrecognized response type %s for method CreateDataLabelingJob, expected %s or %s",
183                   response == null ? "null" : response.getClass().getName(),
184                   DataLabelingJob.class.getName(),
185                   Exception.class.getName())));
186     }
187   }
188 
189   @Override
getDataLabelingJob( GetDataLabelingJobRequest request, StreamObserver<DataLabelingJob> responseObserver)190   public void getDataLabelingJob(
191       GetDataLabelingJobRequest request, StreamObserver<DataLabelingJob> responseObserver) {
192     Object response = responses.poll();
193     if (response instanceof DataLabelingJob) {
194       requests.add(request);
195       responseObserver.onNext(((DataLabelingJob) response));
196       responseObserver.onCompleted();
197     } else if (response instanceof Exception) {
198       responseObserver.onError(((Exception) response));
199     } else {
200       responseObserver.onError(
201           new IllegalArgumentException(
202               String.format(
203                   "Unrecognized response type %s for method GetDataLabelingJob, expected %s or %s",
204                   response == null ? "null" : response.getClass().getName(),
205                   DataLabelingJob.class.getName(),
206                   Exception.class.getName())));
207     }
208   }
209 
210   @Override
listDataLabelingJobs( ListDataLabelingJobsRequest request, StreamObserver<ListDataLabelingJobsResponse> responseObserver)211   public void listDataLabelingJobs(
212       ListDataLabelingJobsRequest request,
213       StreamObserver<ListDataLabelingJobsResponse> responseObserver) {
214     Object response = responses.poll();
215     if (response instanceof ListDataLabelingJobsResponse) {
216       requests.add(request);
217       responseObserver.onNext(((ListDataLabelingJobsResponse) response));
218       responseObserver.onCompleted();
219     } else if (response instanceof Exception) {
220       responseObserver.onError(((Exception) response));
221     } else {
222       responseObserver.onError(
223           new IllegalArgumentException(
224               String.format(
225                   "Unrecognized response type %s for method ListDataLabelingJobs, expected %s or %s",
226                   response == null ? "null" : response.getClass().getName(),
227                   ListDataLabelingJobsResponse.class.getName(),
228                   Exception.class.getName())));
229     }
230   }
231 
232   @Override
deleteDataLabelingJob( DeleteDataLabelingJobRequest request, StreamObserver<Operation> responseObserver)233   public void deleteDataLabelingJob(
234       DeleteDataLabelingJobRequest request, StreamObserver<Operation> responseObserver) {
235     Object response = responses.poll();
236     if (response instanceof Operation) {
237       requests.add(request);
238       responseObserver.onNext(((Operation) response));
239       responseObserver.onCompleted();
240     } else if (response instanceof Exception) {
241       responseObserver.onError(((Exception) response));
242     } else {
243       responseObserver.onError(
244           new IllegalArgumentException(
245               String.format(
246                   "Unrecognized response type %s for method DeleteDataLabelingJob, expected %s or %s",
247                   response == null ? "null" : response.getClass().getName(),
248                   Operation.class.getName(),
249                   Exception.class.getName())));
250     }
251   }
252 
253   @Override
cancelDataLabelingJob( CancelDataLabelingJobRequest request, StreamObserver<Empty> responseObserver)254   public void cancelDataLabelingJob(
255       CancelDataLabelingJobRequest request, StreamObserver<Empty> responseObserver) {
256     Object response = responses.poll();
257     if (response instanceof Empty) {
258       requests.add(request);
259       responseObserver.onNext(((Empty) response));
260       responseObserver.onCompleted();
261     } else if (response instanceof Exception) {
262       responseObserver.onError(((Exception) response));
263     } else {
264       responseObserver.onError(
265           new IllegalArgumentException(
266               String.format(
267                   "Unrecognized response type %s for method CancelDataLabelingJob, expected %s or %s",
268                   response == null ? "null" : response.getClass().getName(),
269                   Empty.class.getName(),
270                   Exception.class.getName())));
271     }
272   }
273 
274   @Override
createHyperparameterTuningJob( CreateHyperparameterTuningJobRequest request, StreamObserver<HyperparameterTuningJob> responseObserver)275   public void createHyperparameterTuningJob(
276       CreateHyperparameterTuningJobRequest request,
277       StreamObserver<HyperparameterTuningJob> responseObserver) {
278     Object response = responses.poll();
279     if (response instanceof HyperparameterTuningJob) {
280       requests.add(request);
281       responseObserver.onNext(((HyperparameterTuningJob) response));
282       responseObserver.onCompleted();
283     } else if (response instanceof Exception) {
284       responseObserver.onError(((Exception) response));
285     } else {
286       responseObserver.onError(
287           new IllegalArgumentException(
288               String.format(
289                   "Unrecognized response type %s for method CreateHyperparameterTuningJob, expected %s or %s",
290                   response == null ? "null" : response.getClass().getName(),
291                   HyperparameterTuningJob.class.getName(),
292                   Exception.class.getName())));
293     }
294   }
295 
296   @Override
getHyperparameterTuningJob( GetHyperparameterTuningJobRequest request, StreamObserver<HyperparameterTuningJob> responseObserver)297   public void getHyperparameterTuningJob(
298       GetHyperparameterTuningJobRequest request,
299       StreamObserver<HyperparameterTuningJob> responseObserver) {
300     Object response = responses.poll();
301     if (response instanceof HyperparameterTuningJob) {
302       requests.add(request);
303       responseObserver.onNext(((HyperparameterTuningJob) response));
304       responseObserver.onCompleted();
305     } else if (response instanceof Exception) {
306       responseObserver.onError(((Exception) response));
307     } else {
308       responseObserver.onError(
309           new IllegalArgumentException(
310               String.format(
311                   "Unrecognized response type %s for method GetHyperparameterTuningJob, expected %s or %s",
312                   response == null ? "null" : response.getClass().getName(),
313                   HyperparameterTuningJob.class.getName(),
314                   Exception.class.getName())));
315     }
316   }
317 
318   @Override
listHyperparameterTuningJobs( ListHyperparameterTuningJobsRequest request, StreamObserver<ListHyperparameterTuningJobsResponse> responseObserver)319   public void listHyperparameterTuningJobs(
320       ListHyperparameterTuningJobsRequest request,
321       StreamObserver<ListHyperparameterTuningJobsResponse> responseObserver) {
322     Object response = responses.poll();
323     if (response instanceof ListHyperparameterTuningJobsResponse) {
324       requests.add(request);
325       responseObserver.onNext(((ListHyperparameterTuningJobsResponse) response));
326       responseObserver.onCompleted();
327     } else if (response instanceof Exception) {
328       responseObserver.onError(((Exception) response));
329     } else {
330       responseObserver.onError(
331           new IllegalArgumentException(
332               String.format(
333                   "Unrecognized response type %s for method ListHyperparameterTuningJobs, expected %s or %s",
334                   response == null ? "null" : response.getClass().getName(),
335                   ListHyperparameterTuningJobsResponse.class.getName(),
336                   Exception.class.getName())));
337     }
338   }
339 
340   @Override
deleteHyperparameterTuningJob( DeleteHyperparameterTuningJobRequest request, StreamObserver<Operation> responseObserver)341   public void deleteHyperparameterTuningJob(
342       DeleteHyperparameterTuningJobRequest request, StreamObserver<Operation> responseObserver) {
343     Object response = responses.poll();
344     if (response instanceof Operation) {
345       requests.add(request);
346       responseObserver.onNext(((Operation) response));
347       responseObserver.onCompleted();
348     } else if (response instanceof Exception) {
349       responseObserver.onError(((Exception) response));
350     } else {
351       responseObserver.onError(
352           new IllegalArgumentException(
353               String.format(
354                   "Unrecognized response type %s for method DeleteHyperparameterTuningJob, expected %s or %s",
355                   response == null ? "null" : response.getClass().getName(),
356                   Operation.class.getName(),
357                   Exception.class.getName())));
358     }
359   }
360 
361   @Override
cancelHyperparameterTuningJob( CancelHyperparameterTuningJobRequest request, StreamObserver<Empty> responseObserver)362   public void cancelHyperparameterTuningJob(
363       CancelHyperparameterTuningJobRequest request, StreamObserver<Empty> responseObserver) {
364     Object response = responses.poll();
365     if (response instanceof Empty) {
366       requests.add(request);
367       responseObserver.onNext(((Empty) response));
368       responseObserver.onCompleted();
369     } else if (response instanceof Exception) {
370       responseObserver.onError(((Exception) response));
371     } else {
372       responseObserver.onError(
373           new IllegalArgumentException(
374               String.format(
375                   "Unrecognized response type %s for method CancelHyperparameterTuningJob, expected %s or %s",
376                   response == null ? "null" : response.getClass().getName(),
377                   Empty.class.getName(),
378                   Exception.class.getName())));
379     }
380   }
381 
382   @Override
createNasJob(CreateNasJobRequest request, StreamObserver<NasJob> responseObserver)383   public void createNasJob(CreateNasJobRequest request, StreamObserver<NasJob> responseObserver) {
384     Object response = responses.poll();
385     if (response instanceof NasJob) {
386       requests.add(request);
387       responseObserver.onNext(((NasJob) response));
388       responseObserver.onCompleted();
389     } else if (response instanceof Exception) {
390       responseObserver.onError(((Exception) response));
391     } else {
392       responseObserver.onError(
393           new IllegalArgumentException(
394               String.format(
395                   "Unrecognized response type %s for method CreateNasJob, expected %s or %s",
396                   response == null ? "null" : response.getClass().getName(),
397                   NasJob.class.getName(),
398                   Exception.class.getName())));
399     }
400   }
401 
402   @Override
getNasJob(GetNasJobRequest request, StreamObserver<NasJob> responseObserver)403   public void getNasJob(GetNasJobRequest request, StreamObserver<NasJob> responseObserver) {
404     Object response = responses.poll();
405     if (response instanceof NasJob) {
406       requests.add(request);
407       responseObserver.onNext(((NasJob) response));
408       responseObserver.onCompleted();
409     } else if (response instanceof Exception) {
410       responseObserver.onError(((Exception) response));
411     } else {
412       responseObserver.onError(
413           new IllegalArgumentException(
414               String.format(
415                   "Unrecognized response type %s for method GetNasJob, expected %s or %s",
416                   response == null ? "null" : response.getClass().getName(),
417                   NasJob.class.getName(),
418                   Exception.class.getName())));
419     }
420   }
421 
422   @Override
listNasJobs( ListNasJobsRequest request, StreamObserver<ListNasJobsResponse> responseObserver)423   public void listNasJobs(
424       ListNasJobsRequest request, StreamObserver<ListNasJobsResponse> responseObserver) {
425     Object response = responses.poll();
426     if (response instanceof ListNasJobsResponse) {
427       requests.add(request);
428       responseObserver.onNext(((ListNasJobsResponse) response));
429       responseObserver.onCompleted();
430     } else if (response instanceof Exception) {
431       responseObserver.onError(((Exception) response));
432     } else {
433       responseObserver.onError(
434           new IllegalArgumentException(
435               String.format(
436                   "Unrecognized response type %s for method ListNasJobs, expected %s or %s",
437                   response == null ? "null" : response.getClass().getName(),
438                   ListNasJobsResponse.class.getName(),
439                   Exception.class.getName())));
440     }
441   }
442 
443   @Override
deleteNasJob( DeleteNasJobRequest request, StreamObserver<Operation> responseObserver)444   public void deleteNasJob(
445       DeleteNasJobRequest request, StreamObserver<Operation> responseObserver) {
446     Object response = responses.poll();
447     if (response instanceof Operation) {
448       requests.add(request);
449       responseObserver.onNext(((Operation) response));
450       responseObserver.onCompleted();
451     } else if (response instanceof Exception) {
452       responseObserver.onError(((Exception) response));
453     } else {
454       responseObserver.onError(
455           new IllegalArgumentException(
456               String.format(
457                   "Unrecognized response type %s for method DeleteNasJob, expected %s or %s",
458                   response == null ? "null" : response.getClass().getName(),
459                   Operation.class.getName(),
460                   Exception.class.getName())));
461     }
462   }
463 
464   @Override
cancelNasJob(CancelNasJobRequest request, StreamObserver<Empty> responseObserver)465   public void cancelNasJob(CancelNasJobRequest request, StreamObserver<Empty> responseObserver) {
466     Object response = responses.poll();
467     if (response instanceof Empty) {
468       requests.add(request);
469       responseObserver.onNext(((Empty) response));
470       responseObserver.onCompleted();
471     } else if (response instanceof Exception) {
472       responseObserver.onError(((Exception) response));
473     } else {
474       responseObserver.onError(
475           new IllegalArgumentException(
476               String.format(
477                   "Unrecognized response type %s for method CancelNasJob, expected %s or %s",
478                   response == null ? "null" : response.getClass().getName(),
479                   Empty.class.getName(),
480                   Exception.class.getName())));
481     }
482   }
483 
484   @Override
getNasTrialDetail( GetNasTrialDetailRequest request, StreamObserver<NasTrialDetail> responseObserver)485   public void getNasTrialDetail(
486       GetNasTrialDetailRequest request, StreamObserver<NasTrialDetail> responseObserver) {
487     Object response = responses.poll();
488     if (response instanceof NasTrialDetail) {
489       requests.add(request);
490       responseObserver.onNext(((NasTrialDetail) response));
491       responseObserver.onCompleted();
492     } else if (response instanceof Exception) {
493       responseObserver.onError(((Exception) response));
494     } else {
495       responseObserver.onError(
496           new IllegalArgumentException(
497               String.format(
498                   "Unrecognized response type %s for method GetNasTrialDetail, expected %s or %s",
499                   response == null ? "null" : response.getClass().getName(),
500                   NasTrialDetail.class.getName(),
501                   Exception.class.getName())));
502     }
503   }
504 
505   @Override
listNasTrialDetails( ListNasTrialDetailsRequest request, StreamObserver<ListNasTrialDetailsResponse> responseObserver)506   public void listNasTrialDetails(
507       ListNasTrialDetailsRequest request,
508       StreamObserver<ListNasTrialDetailsResponse> responseObserver) {
509     Object response = responses.poll();
510     if (response instanceof ListNasTrialDetailsResponse) {
511       requests.add(request);
512       responseObserver.onNext(((ListNasTrialDetailsResponse) response));
513       responseObserver.onCompleted();
514     } else if (response instanceof Exception) {
515       responseObserver.onError(((Exception) response));
516     } else {
517       responseObserver.onError(
518           new IllegalArgumentException(
519               String.format(
520                   "Unrecognized response type %s for method ListNasTrialDetails, expected %s or %s",
521                   response == null ? "null" : response.getClass().getName(),
522                   ListNasTrialDetailsResponse.class.getName(),
523                   Exception.class.getName())));
524     }
525   }
526 
527   @Override
createBatchPredictionJob( CreateBatchPredictionJobRequest request, StreamObserver<BatchPredictionJob> responseObserver)528   public void createBatchPredictionJob(
529       CreateBatchPredictionJobRequest request,
530       StreamObserver<BatchPredictionJob> responseObserver) {
531     Object response = responses.poll();
532     if (response instanceof BatchPredictionJob) {
533       requests.add(request);
534       responseObserver.onNext(((BatchPredictionJob) response));
535       responseObserver.onCompleted();
536     } else if (response instanceof Exception) {
537       responseObserver.onError(((Exception) response));
538     } else {
539       responseObserver.onError(
540           new IllegalArgumentException(
541               String.format(
542                   "Unrecognized response type %s for method CreateBatchPredictionJob, expected %s or %s",
543                   response == null ? "null" : response.getClass().getName(),
544                   BatchPredictionJob.class.getName(),
545                   Exception.class.getName())));
546     }
547   }
548 
549   @Override
getBatchPredictionJob( GetBatchPredictionJobRequest request, StreamObserver<BatchPredictionJob> responseObserver)550   public void getBatchPredictionJob(
551       GetBatchPredictionJobRequest request, StreamObserver<BatchPredictionJob> responseObserver) {
552     Object response = responses.poll();
553     if (response instanceof BatchPredictionJob) {
554       requests.add(request);
555       responseObserver.onNext(((BatchPredictionJob) response));
556       responseObserver.onCompleted();
557     } else if (response instanceof Exception) {
558       responseObserver.onError(((Exception) response));
559     } else {
560       responseObserver.onError(
561           new IllegalArgumentException(
562               String.format(
563                   "Unrecognized response type %s for method GetBatchPredictionJob, expected %s or %s",
564                   response == null ? "null" : response.getClass().getName(),
565                   BatchPredictionJob.class.getName(),
566                   Exception.class.getName())));
567     }
568   }
569 
570   @Override
listBatchPredictionJobs( ListBatchPredictionJobsRequest request, StreamObserver<ListBatchPredictionJobsResponse> responseObserver)571   public void listBatchPredictionJobs(
572       ListBatchPredictionJobsRequest request,
573       StreamObserver<ListBatchPredictionJobsResponse> responseObserver) {
574     Object response = responses.poll();
575     if (response instanceof ListBatchPredictionJobsResponse) {
576       requests.add(request);
577       responseObserver.onNext(((ListBatchPredictionJobsResponse) response));
578       responseObserver.onCompleted();
579     } else if (response instanceof Exception) {
580       responseObserver.onError(((Exception) response));
581     } else {
582       responseObserver.onError(
583           new IllegalArgumentException(
584               String.format(
585                   "Unrecognized response type %s for method ListBatchPredictionJobs, expected %s or %s",
586                   response == null ? "null" : response.getClass().getName(),
587                   ListBatchPredictionJobsResponse.class.getName(),
588                   Exception.class.getName())));
589     }
590   }
591 
592   @Override
deleteBatchPredictionJob( DeleteBatchPredictionJobRequest request, StreamObserver<Operation> responseObserver)593   public void deleteBatchPredictionJob(
594       DeleteBatchPredictionJobRequest request, StreamObserver<Operation> responseObserver) {
595     Object response = responses.poll();
596     if (response instanceof Operation) {
597       requests.add(request);
598       responseObserver.onNext(((Operation) response));
599       responseObserver.onCompleted();
600     } else if (response instanceof Exception) {
601       responseObserver.onError(((Exception) response));
602     } else {
603       responseObserver.onError(
604           new IllegalArgumentException(
605               String.format(
606                   "Unrecognized response type %s for method DeleteBatchPredictionJob, expected %s or %s",
607                   response == null ? "null" : response.getClass().getName(),
608                   Operation.class.getName(),
609                   Exception.class.getName())));
610     }
611   }
612 
613   @Override
cancelBatchPredictionJob( CancelBatchPredictionJobRequest request, StreamObserver<Empty> responseObserver)614   public void cancelBatchPredictionJob(
615       CancelBatchPredictionJobRequest request, StreamObserver<Empty> responseObserver) {
616     Object response = responses.poll();
617     if (response instanceof Empty) {
618       requests.add(request);
619       responseObserver.onNext(((Empty) response));
620       responseObserver.onCompleted();
621     } else if (response instanceof Exception) {
622       responseObserver.onError(((Exception) response));
623     } else {
624       responseObserver.onError(
625           new IllegalArgumentException(
626               String.format(
627                   "Unrecognized response type %s for method CancelBatchPredictionJob, expected %s or %s",
628                   response == null ? "null" : response.getClass().getName(),
629                   Empty.class.getName(),
630                   Exception.class.getName())));
631     }
632   }
633 
634   @Override
createModelDeploymentMonitoringJob( CreateModelDeploymentMonitoringJobRequest request, StreamObserver<ModelDeploymentMonitoringJob> responseObserver)635   public void createModelDeploymentMonitoringJob(
636       CreateModelDeploymentMonitoringJobRequest request,
637       StreamObserver<ModelDeploymentMonitoringJob> responseObserver) {
638     Object response = responses.poll();
639     if (response instanceof ModelDeploymentMonitoringJob) {
640       requests.add(request);
641       responseObserver.onNext(((ModelDeploymentMonitoringJob) response));
642       responseObserver.onCompleted();
643     } else if (response instanceof Exception) {
644       responseObserver.onError(((Exception) response));
645     } else {
646       responseObserver.onError(
647           new IllegalArgumentException(
648               String.format(
649                   "Unrecognized response type %s for method CreateModelDeploymentMonitoringJob, expected %s or %s",
650                   response == null ? "null" : response.getClass().getName(),
651                   ModelDeploymentMonitoringJob.class.getName(),
652                   Exception.class.getName())));
653     }
654   }
655 
656   @Override
searchModelDeploymentMonitoringStatsAnomalies( SearchModelDeploymentMonitoringStatsAnomaliesRequest request, StreamObserver<SearchModelDeploymentMonitoringStatsAnomaliesResponse> responseObserver)657   public void searchModelDeploymentMonitoringStatsAnomalies(
658       SearchModelDeploymentMonitoringStatsAnomaliesRequest request,
659       StreamObserver<SearchModelDeploymentMonitoringStatsAnomaliesResponse> responseObserver) {
660     Object response = responses.poll();
661     if (response instanceof SearchModelDeploymentMonitoringStatsAnomaliesResponse) {
662       requests.add(request);
663       responseObserver.onNext(((SearchModelDeploymentMonitoringStatsAnomaliesResponse) response));
664       responseObserver.onCompleted();
665     } else if (response instanceof Exception) {
666       responseObserver.onError(((Exception) response));
667     } else {
668       responseObserver.onError(
669           new IllegalArgumentException(
670               String.format(
671                   "Unrecognized response type %s for method SearchModelDeploymentMonitoringStatsAnomalies, expected %s or %s",
672                   response == null ? "null" : response.getClass().getName(),
673                   SearchModelDeploymentMonitoringStatsAnomaliesResponse.class.getName(),
674                   Exception.class.getName())));
675     }
676   }
677 
678   @Override
getModelDeploymentMonitoringJob( GetModelDeploymentMonitoringJobRequest request, StreamObserver<ModelDeploymentMonitoringJob> responseObserver)679   public void getModelDeploymentMonitoringJob(
680       GetModelDeploymentMonitoringJobRequest request,
681       StreamObserver<ModelDeploymentMonitoringJob> responseObserver) {
682     Object response = responses.poll();
683     if (response instanceof ModelDeploymentMonitoringJob) {
684       requests.add(request);
685       responseObserver.onNext(((ModelDeploymentMonitoringJob) response));
686       responseObserver.onCompleted();
687     } else if (response instanceof Exception) {
688       responseObserver.onError(((Exception) response));
689     } else {
690       responseObserver.onError(
691           new IllegalArgumentException(
692               String.format(
693                   "Unrecognized response type %s for method GetModelDeploymentMonitoringJob, expected %s or %s",
694                   response == null ? "null" : response.getClass().getName(),
695                   ModelDeploymentMonitoringJob.class.getName(),
696                   Exception.class.getName())));
697     }
698   }
699 
700   @Override
listModelDeploymentMonitoringJobs( ListModelDeploymentMonitoringJobsRequest request, StreamObserver<ListModelDeploymentMonitoringJobsResponse> responseObserver)701   public void listModelDeploymentMonitoringJobs(
702       ListModelDeploymentMonitoringJobsRequest request,
703       StreamObserver<ListModelDeploymentMonitoringJobsResponse> responseObserver) {
704     Object response = responses.poll();
705     if (response instanceof ListModelDeploymentMonitoringJobsResponse) {
706       requests.add(request);
707       responseObserver.onNext(((ListModelDeploymentMonitoringJobsResponse) response));
708       responseObserver.onCompleted();
709     } else if (response instanceof Exception) {
710       responseObserver.onError(((Exception) response));
711     } else {
712       responseObserver.onError(
713           new IllegalArgumentException(
714               String.format(
715                   "Unrecognized response type %s for method ListModelDeploymentMonitoringJobs, expected %s or %s",
716                   response == null ? "null" : response.getClass().getName(),
717                   ListModelDeploymentMonitoringJobsResponse.class.getName(),
718                   Exception.class.getName())));
719     }
720   }
721 
722   @Override
updateModelDeploymentMonitoringJob( UpdateModelDeploymentMonitoringJobRequest request, StreamObserver<Operation> responseObserver)723   public void updateModelDeploymentMonitoringJob(
724       UpdateModelDeploymentMonitoringJobRequest request,
725       StreamObserver<Operation> responseObserver) {
726     Object response = responses.poll();
727     if (response instanceof Operation) {
728       requests.add(request);
729       responseObserver.onNext(((Operation) response));
730       responseObserver.onCompleted();
731     } else if (response instanceof Exception) {
732       responseObserver.onError(((Exception) response));
733     } else {
734       responseObserver.onError(
735           new IllegalArgumentException(
736               String.format(
737                   "Unrecognized response type %s for method UpdateModelDeploymentMonitoringJob, expected %s or %s",
738                   response == null ? "null" : response.getClass().getName(),
739                   Operation.class.getName(),
740                   Exception.class.getName())));
741     }
742   }
743 
744   @Override
deleteModelDeploymentMonitoringJob( DeleteModelDeploymentMonitoringJobRequest request, StreamObserver<Operation> responseObserver)745   public void deleteModelDeploymentMonitoringJob(
746       DeleteModelDeploymentMonitoringJobRequest request,
747       StreamObserver<Operation> responseObserver) {
748     Object response = responses.poll();
749     if (response instanceof Operation) {
750       requests.add(request);
751       responseObserver.onNext(((Operation) response));
752       responseObserver.onCompleted();
753     } else if (response instanceof Exception) {
754       responseObserver.onError(((Exception) response));
755     } else {
756       responseObserver.onError(
757           new IllegalArgumentException(
758               String.format(
759                   "Unrecognized response type %s for method DeleteModelDeploymentMonitoringJob, expected %s or %s",
760                   response == null ? "null" : response.getClass().getName(),
761                   Operation.class.getName(),
762                   Exception.class.getName())));
763     }
764   }
765 
766   @Override
pauseModelDeploymentMonitoringJob( PauseModelDeploymentMonitoringJobRequest request, StreamObserver<Empty> responseObserver)767   public void pauseModelDeploymentMonitoringJob(
768       PauseModelDeploymentMonitoringJobRequest request, StreamObserver<Empty> responseObserver) {
769     Object response = responses.poll();
770     if (response instanceof Empty) {
771       requests.add(request);
772       responseObserver.onNext(((Empty) response));
773       responseObserver.onCompleted();
774     } else if (response instanceof Exception) {
775       responseObserver.onError(((Exception) response));
776     } else {
777       responseObserver.onError(
778           new IllegalArgumentException(
779               String.format(
780                   "Unrecognized response type %s for method PauseModelDeploymentMonitoringJob, expected %s or %s",
781                   response == null ? "null" : response.getClass().getName(),
782                   Empty.class.getName(),
783                   Exception.class.getName())));
784     }
785   }
786 
787   @Override
resumeModelDeploymentMonitoringJob( ResumeModelDeploymentMonitoringJobRequest request, StreamObserver<Empty> responseObserver)788   public void resumeModelDeploymentMonitoringJob(
789       ResumeModelDeploymentMonitoringJobRequest request, StreamObserver<Empty> responseObserver) {
790     Object response = responses.poll();
791     if (response instanceof Empty) {
792       requests.add(request);
793       responseObserver.onNext(((Empty) response));
794       responseObserver.onCompleted();
795     } else if (response instanceof Exception) {
796       responseObserver.onError(((Exception) response));
797     } else {
798       responseObserver.onError(
799           new IllegalArgumentException(
800               String.format(
801                   "Unrecognized response type %s for method ResumeModelDeploymentMonitoringJob, expected %s or %s",
802                   response == null ? "null" : response.getClass().getName(),
803                   Empty.class.getName(),
804                   Exception.class.getName())));
805     }
806   }
807 }
808