use of co.cask.cdap.common.StreamNotFoundException in project cdap by caskdata.
the class StreamClient method setDescription.
/**
* Sets the description of a stream.
*
* @param stream ID of the stream
* @param description description of the stream
* @throws IOException if a network error occurred
* @throws StreamNotFoundException if the stream with the specified ID was not found
*/
public void setDescription(StreamId stream, String description) throws IOException, StreamNotFoundException, UnauthenticatedException, UnauthorizedException {
URL url = config.resolveNamespacedURLV3(stream.getParent(), String.format("streams/%s/properties", stream.getStream()));
HttpRequest request = HttpRequest.put(url).withBody(GSON.toJson(ImmutableMap.of("description", description))).build();
HttpResponse response = restClient.execute(request, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND);
if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new StreamNotFoundException(stream);
}
}
Aggregations