use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSetTable in project kylo by Teradata.
the class DataSourceController method listTables.
@GET
@Path("{id}/tables")
@ApiOperation("List tables in a data source")
@ApiResponses({ @ApiResponse(code = 200, message = "List of tables", response = DataSetTable.class, responseContainer = "List"), @ApiResponse(code = 404, message = "Data source does not exist", response = RestResponseStatus.class), @ApiResponse(code = 500, message = "Failed to list tables", response = RestResponseStatus.class) })
public Response listTables(@PathParam("id") final String dataSourceId, @QueryParam("catalog") final String catalogName, @QueryParam("schema") final String schemaName) {
log.entry(dataSourceId, catalogName, schemaName);
// read as the user to see if they can access the datasource
boolean hasAccess = metadataService.read(() -> {
return findDataSource(dataSourceId, true) != null;
});
if (hasAccess) {
return metadataService.read(() -> {
// List tables
final DataSource dataSource = findDataSource(dataSourceId, false);
final List<DataSetTable> tables = doListTables(catalogName, schemaName, dataSource);
return Response.ok(log.exit(tables)).build();
}, MetadataAccess.SERVICE);
} else {
log.debug("Access denied accessing datasource : {}", dataSourceId);
throw new ForbiddenException(getMessage("catalog.datasource.forbidden"));
}
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSetTable in project kylo by Teradata.
the class DefaultCatalogTableManager method createTable.
/**
* Converts a JDBC table to a data set model.
*/
@Nonnull
private DataSetTable createTable(@Nonnull final JdbcTable table) {
final DataSetTable entry = new DataSetTable();
entry.setCatalog(table.getCatalog());
entry.setName(table.getName());
entry.setQualifiedIdentifier(table.getQualifiedIdentifier());
entry.setRemarks(table.getRemarks());
entry.setSchema(table.getSchema());
entry.setType(table.getType());
return entry;
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSetTable in project kylo by Teradata.
the class DefaultCatalogTableManager method createCatalog.
/**
* Converts a JDBC catalog to a data set model.
*/
@Nonnull
private DataSetTable createCatalog(@Nonnull final JdbcCatalog catalog) {
final DataSetTable entry = new DataSetTable();
entry.setName(catalog.getCatalog());
entry.setType("CATALOG");
return entry;
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSetTable in project kylo by Teradata.
the class DataSourceController method doListTables.
private List<DataSetTable> doListTables(@QueryParam("catalog") String catalogName, @QueryParam("schema") String schemaName, DataSource dataSource) {
final List<DataSetTable> tables;
try {
log.debug("List tables for catalog:{} schema:{}", catalogName, schemaName);
tables = tableManager.listCatalogsOrTables(dataSource, catalogName, schemaName);
} catch (final Exception e) {
if (exceptionTransformer.causesInChain(e)) {
throw new ThriftConnectionException(e);
}
if (log.isErrorEnabled()) {
log.error("Failed to list tables for catalog [" + catalogName + "] schema [" + schemaName + "]: " + e, e);
}
final RestResponseStatus status = new RestResponseStatus.ResponseStatusBuilder().message(getMessage("catalog.datasource.listTables.error", catalogName, schemaName)).url(request.getRequestURI()).setDeveloperMessage(e).buildError();
throw new InternalServerErrorException(Response.serverError().entity(status).build());
}
return tables;
}
use of com.thinkbiganalytics.kylo.catalog.rest.model.DataSetTable in project kylo by Teradata.
the class DefaultCatalogTableManager method createSchema.
/**
* Converts a JDBC schema to a data set model.
*/
@Nonnull
private DataSetTable createSchema(@Nonnull final JdbcSchema schema) {
final DataSetTable entry = new DataSetTable();
entry.setCatalog(schema.getCatalog());
entry.setName(schema.getSchema());
entry.setType("SCHEMA");
return entry;
}
Aggregations