use of io.cdap.cdap.proto.DatasetTypeMeta in project cdap by caskdata.
the class DatasetAdminOpHTTPHandler method update.
@POST
@Path("/data/datasets/{name}/admin/update")
public void update(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String name) throws Exception {
propagateUserId(request);
InternalDatasetUpdateParams params = GSON.fromJson(request.content().toString(StandardCharsets.UTF_8), InternalDatasetUpdateParams.class);
Preconditions.checkArgument(params.getProperties() != null, "Missing required 'instanceProps' parameter.");
Preconditions.checkArgument(params.getTypeMeta() != null, "Missing required 'typeMeta' parameter.");
Preconditions.checkArgument(params.getExistingSpec() != null, "Missing required 'existingSpec' parameter.");
DatasetProperties props = params.getProperties();
DatasetSpecification existing = params.getExistingSpec();
DatasetTypeMeta typeMeta = params.getTypeMeta();
try {
DatasetId instanceId = new DatasetId(namespaceId, name);
DatasetCreationResponse response = datasetAdminService.createOrUpdate(instanceId, typeMeta, props, existing);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(response));
} catch (IncompatibleUpdateException e) {
throw new ConflictException(e.getMessage());
}
}
use of io.cdap.cdap.proto.DatasetTypeMeta in project cdap by caskdata.
the class DatasetAdminOpHTTPHandler method drop.
@POST
@Path("/data/datasets/{name}/admin/drop")
public void drop(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("name") String instanceName) throws Exception {
propagateUserId(request);
InternalDatasetDropParams params = GSON.fromJson(request.content().toString(StandardCharsets.UTF_8), InternalDatasetDropParams.class);
Preconditions.checkArgument(params.getInstanceSpec() != null, "Missing required 'instanceSpec' parameter.");
Preconditions.checkArgument(params.getTypeMeta() != null, "Missing required 'typeMeta' parameter.");
DatasetSpecification spec = params.getInstanceSpec();
DatasetTypeMeta typeMeta = params.getTypeMeta();
datasetAdminService.drop(new DatasetId(namespaceId, instanceName), typeMeta, spec);
responder.sendJson(HttpResponseStatus.OK, GSON.toJson(spec));
}
use of io.cdap.cdap.proto.DatasetTypeMeta in project cdap by caskdata.
the class DatasetTypeTable method getTypes.
public Collection<DatasetTypeMeta> getTypes(NamespaceId namespaceId) throws IOException {
List<DatasetTypeMeta> types = Lists.newArrayList();
try (CloseableIterator<StructuredRow> iterator = getTypeTable().scan(Range.singleton(getModulePrefix(namespaceId.getEntityName())), Integer.MAX_VALUE)) {
while (iterator.hasNext()) {
StructuredRow row = iterator.next();
String typeName = row.getString(StoreDefinition.DatasetTypeStore.TYPE_NAME_FIELD);
DatasetModuleId moduleId = GSON.fromJson(row.getString(StoreDefinition.DatasetTypeStore.DATASET_METADATA_FIELD), DatasetModuleId.class);
types.add(getTypeMeta(namespaceId, typeName, moduleId));
}
}
return types;
}
use of io.cdap.cdap.proto.DatasetTypeMeta in project cdap by caskdata.
the class DatasetTypeClient method get.
/**
* Gets information about a dataset type.
*
* @param type the dataset type
* @return {@link DatasetTypeMeta} of the dataset type
* @throws DatasetTypeNotFoundException if the dataset type could not be found
* @throws IOException if a network error occurred
* @throws UnauthenticatedException if the request is not authorized successfully in the gateway server
*/
public DatasetTypeMeta get(DatasetTypeId type) throws DatasetTypeNotFoundException, IOException, UnauthenticatedException, UnauthorizedException {
URL url = config.resolveNamespacedURLV3(type.getParent(), String.format("data/types/%s", type.getType()));
HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new DatasetTypeNotFoundException(type);
}
return ObjectResponse.fromJsonBody(response, DatasetTypeMeta.class).getResponseObject();
}
use of io.cdap.cdap.proto.DatasetTypeMeta in project cdap by caskdata.
the class GenerateClientUsageExample method datasetTypeClient.
public void datasetTypeClient() throws Exception {
// Construct the client used to interact with CDAP
DatasetTypeClient datasetTypeClient = new DatasetTypeClient(clientConfig);
// Fetch the dataset type information using the type name
DatasetTypeMeta datasetTypeMeta = datasetTypeClient.get(NamespaceId.DEFAULT.datasetType("someDatasetType"));
// Fetch the dataset type information using the classname
datasetTypeClient.get(NamespaceId.DEFAULT.datasetType(SomeDataset.class.getName()));
}
Aggregations