Search in sources :

Example 1 with CredentialsClassView

use of com.google.api.codegen.viewmodel.CredentialsClassView in project toolkit by googleapis.

the class RubyGapicSurfaceTransformer method generateCredentialsView.

private ViewModel generateCredentialsView(ApiModel model, GapicProductConfig productConfig) {
    SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
    CredentialsClassView credentialsClass = generateCredentialsClass(model, productConfig);
    ImportSectionView importSection = ImportSectionView.newBuilder().externalImports(ImmutableList.of(ImportFileView.newBuilder().moduleName("googleauth").types(ImmutableList.<ImportTypeView>of()).build())).build();
    List<String> modules = namer.getApiModules();
    InterfaceModel apiInterface = model.getInterfaces(productConfig).stream().filter(productConfig::hasInterfaceConfig).findFirst().orElseThrow(() -> new NoSuchElementException("reachable API interfaces"));
    GapicInterfaceContext context = createContext(apiInterface, productConfig);
    String subPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
    return CredentialsClassFileView.newBuilder().outputPath(namer.getSourceFilePath(subPath, "Credentials")).templateFileName(CREDENTIALS_CLASS_TEMPLATE_FILE).credentialsClass(credentialsClass).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer, ImmutableList.copyOf(modules))).build();
}
Also used : InterfaceModel(com.google.api.codegen.config.InterfaceModel) GapicInterfaceContext(com.google.api.codegen.config.GapicInterfaceContext) CredentialsClassView(com.google.api.codegen.viewmodel.CredentialsClassView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) NoSuchElementException(java.util.NoSuchElementException) ImportSectionView(com.google.api.codegen.viewmodel.ImportSectionView)

Aggregations

GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)1 InterfaceModel (com.google.api.codegen.config.InterfaceModel)1 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 CredentialsClassView (com.google.api.codegen.viewmodel.CredentialsClassView)1 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)1 NoSuchElementException (java.util.NoSuchElementException)1