90
90
import java .util .Arrays ;
91
91
import java .util .Collections ;
92
92
import java .util .HashMap ;
93
- import java .util .HashSet ;
94
93
import java .util .Iterator ;
95
94
import java .util .LinkedHashMap ;
96
95
import java .util .List ;
97
96
import java .util .Map ;
98
97
import java .util .Objects ;
99
98
import java .util .Optional ;
100
- import java .util .Set ;
101
99
import java .util .concurrent .TimeUnit ;
102
100
import java .util .function .BiFunction ;
103
101
import java .util .function .Function ;
@@ -507,17 +505,23 @@ private List<MethodDefinition> createGetterMethods(
507
505
"getSettings" , typeStore .get (ClassNames .getServiceSettingsClassName (service )));
508
506
methodNameToTypes .put ("getStub" , typeStore .get (ClassNames .getServiceStubClassName (service )));
509
507
510
- Set <String > getOperationsClientMethodNames = new HashSet <>();
508
+ Map <String , List <AnnotationNode >> getOperationsClientMethod = new HashMap <>();
509
+ AnnotationNode betaAnnotation =
510
+ AnnotationNode .builder ().setType (typeStore .get ("BetaApi" )).build ();
511
511
512
512
if (hasLroClient ) {
513
513
Iterator <String > opClientNamesIt = getTransportContext ().operationsClientNames ().iterator ();
514
514
Iterator <TypeNode > opClientTypesIt = getTransportContext ().operationsClientTypes ().iterator ();
515
-
515
+ List < AnnotationNode > operationClientGetterAnnotations = new ArrayList <>();
516
516
while (opClientNamesIt .hasNext () && opClientTypesIt .hasNext ()) {
517
517
String opClientMethodName =
518
518
String .format ("get%s" , JavaStyle .toUpperCamelCase (opClientNamesIt .next ()));
519
- getOperationsClientMethodNames . add (opClientMethodName );
519
+ getOperationsClientMethod . put (opClientMethodName , operationClientGetterAnnotations );
520
520
methodNameToTypes .put (opClientMethodName , opClientTypesIt .next ());
521
+ // Only first (default transport) getter is non-beta, all others are
522
+ if (operationClientGetterAnnotations .isEmpty ()) {
523
+ operationClientGetterAnnotations = Collections .singletonList (betaAnnotation );
524
+ }
521
525
}
522
526
}
523
527
@@ -528,10 +532,12 @@ private List<MethodDefinition> createGetterMethods(
528
532
TypeNode methodReturnType = e .getValue ();
529
533
String returnVariableName = JavaStyle .toLowerCamelCase (methodName .substring (3 ));
530
534
MethodDefinition .Builder methodBuilder = MethodDefinition .builder ();
531
- if (getOperationsClientMethodNames .contains (methodName )) {
535
+ List <AnnotationNode > annotations = getOperationsClientMethod .get (methodName );
536
+ if (annotations != null ) {
532
537
methodBuilder =
533
538
methodBuilder .setHeaderCommentStatements (
534
539
ServiceClientCommentComposer .GET_OPERATIONS_CLIENT_METHOD_COMMENT );
540
+ methodBuilder .setAnnotations (annotations );
535
541
}
536
542
return methodBuilder
537
543
.setScope (ScopeNode .PUBLIC )
0 commit comments