use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class Discovery method deleteConfiguration.
/**
* Delete a configuration.
*
* <p>The deletion is performed unconditionally. A configuration deletion request succeeds even if
* the configuration is referenced by a collection or document ingestion. However, documents that
* have already been submitted for processing continue to use the deleted configuration. Documents
* are always processed with a snapshot of the configuration as it existed at the time the
* document was submitted.
*
* @param deleteConfigurationOptions the {@link DeleteConfigurationOptions} containing the options
* for the call
* @return a {@link ServiceCall} with a result of type {@link DeleteConfigurationResponse}
*/
public ServiceCall<DeleteConfigurationResponse> deleteConfiguration(DeleteConfigurationOptions deleteConfigurationOptions) {
com.ibm.cloud.sdk.core.util.Validator.notNull(deleteConfigurationOptions, "deleteConfigurationOptions cannot be null");
Map<String, String> pathParamsMap = new HashMap<String, String>();
pathParamsMap.put("environment_id", deleteConfigurationOptions.environmentId());
pathParamsMap.put("configuration_id", deleteConfigurationOptions.configurationId());
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/environments/{environment_id}/configurations/{configuration_id}", pathParamsMap));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("version", String.valueOf(this.version));
ResponseConverter<DeleteConfigurationResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<DeleteConfigurationResponse>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.watson.discovery.v1.model.Collection in project bgg-api by tnaskali.
the class ThingsService method getPrivateThings.
public Mono<Collection> getPrivateThings(String username, String cookie, CollectionParams params) {
BggCollectionQueryParams queryParams = collectionParamsMapper.toBggModel(params);
queryParams.setUsername(username);
// handle subtype bug in the BBG XML API
if (queryParams.getSubtype() == null || queryParams.getSubtype().equals(CollectionItemSubtype.boardgame.value())) {
queryParams.setExcludesubtype(CollectionItemSubtype.boardgameexpansion.value());
}
queryParams.setShowprivate(1);
return collectionRepository.getCollection(cookie, queryParams).map(xml -> xmlProcessor.toJavaObject(xml, com.boardgamegeek.collection.Collection.class)).map(collectionMapper::fromBggModel);
}
use of com.ibm.watson.discovery.v1.model.Collection in project bgg-api by tnaskali.
the class ThingsService method getThings.
public Mono<Collection> getThings(String username, CollectionParams params) {
BggCollectionQueryParams queryParams = collectionParamsMapper.toBggModel(params);
queryParams.setUsername(username);
// handle subtype bug in the BBG XML API
if (queryParams.getSubtype() == null || queryParams.getSubtype().equals(CollectionItemSubtype.boardgame.value())) {
queryParams.setExcludesubtype(CollectionItemSubtype.boardgameexpansion.value());
}
return collectionRepository.getCollection(null, queryParams).map(xml -> xmlProcessor.toJavaObject(xml, com.boardgamegeek.collection.Collection.class)).map(collectionMapper::fromBggModel);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testCreateCollectionWOptions.
@Test
public void testCreateCollectionWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}";
String createCollectionPath = "/v4/collections";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the CreateCollectionOptions model
CreateCollectionOptions createCollectionOptionsModel = new CreateCollectionOptions.Builder().name("testString").description("testString").build();
// Invoke operation with valid options model (positive test)
Response<Collection> response = visualRecognitionService.createCollection(createCollectionOptionsModel).execute();
assertNotNull(response);
Collection responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("version"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, createCollectionPath);
}
use of com.ibm.watson.discovery.v1.model.Collection in project java-sdk by watson-developer-cloud.
the class VisualRecognitionTest method testTrainWOptions.
@Test
public void testTrainWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"collection_id\": \"collectionId\", \"name\": \"name\", \"description\": \"description\", \"created\": \"2019-01-01T12:00:00.000Z\", \"updated\": \"2019-01-01T12:00:00.000Z\", \"image_count\": 10, \"training_status\": {\"objects\": {\"ready\": false, \"in_progress\": true, \"data_changed\": false, \"latest_failed\": true, \"rscnn_ready\": true, \"description\": \"description\"}}}";
String trainPath = "/v4/collections/testString/train";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(202).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the TrainOptions model
TrainOptions trainOptionsModel = new TrainOptions.Builder().collectionId("testString").build();
// Invoke operation with valid options model (positive test)
Response<Collection> response = visualRecognitionService.train(trainOptionsModel).execute();
assertNotNull(response);
Collection responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "POST");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
// Get query params
assertEquals(query.get("version"), "testString");
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, trainPath);
}
Aggregations