use of com.google.api.codegen.IamResourceProto in project toolkit by googleapis.
the class GapicInterfaceConfig method createIamResources.
/**
* Creates a list of fields that can be turned into IAM resources
*/
private static ImmutableList<FieldModel> createIamResources(Model model, List<IamResourceProto> resources) {
ImmutableList.Builder<FieldModel> fields = ImmutableList.builder();
for (IamResourceProto resource : resources) {
TypeRef type = model.getSymbolTable().lookupType(resource.getType());
if (type == null) {
throw new IllegalArgumentException("type not found: " + resource.getType());
}
if (!type.isMessage()) {
throw new IllegalArgumentException("type must be a message: " + type);
}
Field field = type.getMessageType().lookupField(resource.getField());
if (field == null) {
throw new IllegalArgumentException(String.format("type %s does not have field %s", resource.getType(), resource.getField()));
}
fields.add(new ProtoField(field));
}
return fields.build();
}
Aggregations