use of com.google.api.Service in project toolkit by googleapis.
the class ProductServiceConfig method getAuthScopes.
/**
* Return a list of scopes for authentication.
*/
public List<String> getAuthScopes(Model model) {
Set<String> result = new TreeSet<>();
Service config = model.getServiceConfig();
Authentication auth = config.getAuthentication();
for (AuthenticationRule rule : auth.getRulesList()) {
// Scopes form a union and the union is used for down-scoping, so adding more scopes that
// are subsets of the others already in the union essentially has no effect.
// We are doing this for implementation simplicity so we don't have to compute which scopes
// are subsets of the others.
String scopesString = rule.getOauth().getCanonicalScopes();
for (String scope : scopesString.split(",")) {
result.add(scope.trim());
}
}
return new ArrayList<>(result);
}
use of com.google.api.Service in project toolkit by googleapis.
the class PhpGapicSurfaceTransformer method generateRestInterfaceConfigViews.
private List<RestInterfaceConfigView> generateRestInterfaceConfigViews(GapicInterfaceContext context) {
List<RestInterfaceConfigView> configViews = new ArrayList<>();
GapicInterfaceConfig interfaceConfig = context.getInterfaceConfig();
SurfaceNamer namer = context.getNamer();
Map<String, List<HttpRule>> interfaces = new TreeMap<>();
Service serviceConfig = serviceModel.getServiceConfig();
for (MethodModel methodModel : context.getSupportedMethods()) {
GapicMethodContext methodContext = context.asDynamicMethodContext(methodModel);
MethodConfig methodConfig = methodContext.getMethodConfig();
Method method = methodContext.getMethod();
// REST does not support streaming methods
if (methodConfig.isGrpcStreaming()) {
continue;
}
String interfaceName = methodConfig.getRerouteToGrpcInterface() == null ? context.getInterface().getFullName() : methodConfig.getRerouteToGrpcInterface();
HttpRule httpRule = getHttpRule(method.getOptionFields()).toBuilder().setSelector(String.format("%s.%s", interfaceName, method.getSimpleName())).build();
addHttpRuleToMap(interfaces, interfaceName, httpRule);
}
for (HttpRule httpRule : serviceConfig.getHttp().getRulesList()) {
String selector = httpRule.getSelector();
String interfaceName = selector.substring(0, selector.lastIndexOf("."));
addHttpRuleToMap(interfaces, interfaceName, httpRule);
}
for (Map.Entry<String, List<HttpRule>> entry : interfaces.entrySet()) {
configViews.add(generateRestInterfaceConfigView(entry.getKey(), entry.getValue(), namer));
}
return configViews;
}
use of com.google.api.Service in project toolkit by googleapis.
the class ProtoApiModel method getAuthScopes.
@Override
public List<String> getAuthScopes() {
Set<String> result = new TreeSet<>();
Service config = protoModel.getServiceConfig();
Authentication auth = config.getAuthentication();
for (AuthenticationRule rule : auth.getRulesList()) {
// Scopes form a union and the union is used for down-scoping, so adding more scopes that
// are subsets of the others already in the union essentially has no effect.
// We are doing this for implementation simplicity so we don't have to compute which scopes
// are subsets of the others.
String scopesString = rule.getOauth().getCanonicalScopes();
for (String scope : scopesString.split(",")) {
result.add(scope.trim());
}
}
return new ArrayList<>(result);
}
Aggregations