Skip to content

Commit

Permalink
Client implementation for creating a skillset (Azure#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Humoiz authored Nov 7, 2019
1 parent 978b95e commit f385821
Show file tree
Hide file tree
Showing 5 changed files with 336 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1079,19 +1079,48 @@ Mono<PagedResponse<TokenInfo>> analyzeIndexWithResponse(String indexName,
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @return the created Skillset.
* @throws NotImplementedException not implemented
*/
public Mono<Skillset> createSkillset() {
throw logger.logExceptionAsError(new NotImplementedException("not implemented."));
public Mono<Skillset> createSkillset(Skillset skillset) {
return this.createSkillsetWithResponse(skillset, null)
.map(Response::getValue);
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @param requestOptions additional parameters for the operation.
* Contains the tracking ID sent with the request to help with debugging
* @return the created Skillset.
*/
public Mono<Skillset> createSkillset(Skillset skillset, RequestOptions requestOptions) {
return this.createSkillsetWithResponse(skillset, requestOptions)
.map(Response::getValue);
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @param requestOptions additional parameters for the operation.
* Contains the tracking ID sent with the request to help with debugging
* @return a response containing the created Skillset.
* @throws NotImplementedException not implemented
*/
public Mono<Response<Skillset>> createSkillsetWithResponse() {
throw logger.logExceptionAsError(new NotImplementedException("not implemented."));
public Mono<Response<Skillset>> createSkillsetWithResponse(Skillset skillset, RequestOptions requestOptions) {
return withContext(context -> createSkillsetWithResponse(skillset, requestOptions, context));
}

Mono<Response<Skillset>> createSkillsetWithResponse(Skillset skillset,
RequestOptions requestOptions,
Context context) {
return restClient
.skillsets()
.createWithRestResponseAsync(skillset, requestOptions, context)
.map(Function.identity());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,19 +946,54 @@ public PagedIterable<TokenInfo> analyzeIndex(String indexName,
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
*
* @return the created Skillset.
* @throws NotImplementedException not implemented
*/
public Skillset createSkillset() {
throw logger.logExceptionAsError(new NotImplementedException("not implemented."));
public Skillset createSkillset(Skillset skillset) {
return asyncClient.createSkillset(skillset).block();
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @param requestOptions additional parameters for the operation.
* Contains the tracking ID sent with the request to help with debugging
* @return the created Skillset.
*/
public Skillset createSkillset(Skillset skillset, RequestOptions requestOptions) {
return asyncClient.createSkillset(skillset, requestOptions).block();
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @param requestOptions additional parameters for the operation.
* Contains the tracking ID sent with the request to help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return the created Skillset.
*/
public Skillset createSkillset(Skillset skillset, RequestOptions requestOptions, Context context) {
return this.createSkillsetWithResponse(skillset, requestOptions, context).getValue();
}

/**
* Creates a new skillset in an Azure Cognitive Search service.
*
* @param skillset definition of the skillset containing one or more cognitive skills
* @param requestOptions additional parameters for the operation.
* Contains the tracking ID sent with the request to help with debugging
* @param context additional context that is passed through the HTTP pipeline during the service call
* @return a response containing the created Skillset.
* @throws NotImplementedException not implemented
*/
public Response<Skillset> createSkillsetWithResponse() {
throw logger.logExceptionAsError(new NotImplementedException("not implemented."));
public Response<Skillset> createSkillsetWithResponse(Skillset skillset,
RequestOptions requestOptions,
Context context) {
return asyncClient.createSkillsetWithResponse(skillset, requestOptions, context).block();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.search;

public class SkillsetManagementAsyncTests extends SkillsetManagementTestBase {
private SearchServiceAsyncClient client;

@Override
protected void beforeTest() {
super.beforeTest();
client = getSearchServiceClientBuilder().buildAsyncClient();
}

@Override
public void createSkillsetReturnsCorrectDefinitionImageAnalysisKeyPhrase() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionLanguageDetection() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionMergeText() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrEntity() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrHandwritingSentiment() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrKeyPhrase() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrShaper() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrSplitText() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionWithCognitiveServicesDefault() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionWithDefaultSettings() {

}

@Override
public void createSkillsetThrowsExceptionWithInvalidLanguageSelection() {

}

@Override
public void createSkillsetWithCognitiveServicesKey() {

}

@Override
public void createSkillsetWithEntityRecognitionDefaultSettings() {

}

@Override
public void createSkillsetWithImageAnalysisDefaultSettings() {

}

@Override
public void createSkillsetWithKeyPhraseExtractionDefaultSettings() {

}

@Override
public void createSkillsetWithMergeDefaultSettings() {

}

@Override
public void createSkillsetWithOcrDefaultSettings() {

}

@Override
public void createSkillsetWithSentimentDefaultSettings() {

}

@Override
public void createSkillsetWithSplitDefaultSettings() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.search;

public class SkillsetManagementSyncTests extends SkillsetManagementTestBase {
private SearchServiceClient client;

@Override
protected void beforeTest() {
super.beforeTest();
client = getSearchServiceClientBuilder().buildClient();
}

@Override
public void createSkillsetReturnsCorrectDefinitionImageAnalysisKeyPhrase() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionLanguageDetection() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionMergeText() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrEntity() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrHandwritingSentiment() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrKeyPhrase() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrShaper() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionOcrSplitText() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionWithCognitiveServicesDefault() {

}

@Override
public void createSkillsetReturnsCorrectDefinitionWithDefaultSettings() {

}

@Override
public void createSkillsetThrowsExceptionWithInvalidLanguageSelection() {

}

@Override
public void createSkillsetWithCognitiveServicesKey() {

}

@Override
public void createSkillsetWithEntityRecognitionDefaultSettings() {

}

@Override
public void createSkillsetWithImageAnalysisDefaultSettings() {

}

@Override
public void createSkillsetWithKeyPhraseExtractionDefaultSettings() {

}

@Override
public void createSkillsetWithMergeDefaultSettings() {

}

@Override
public void createSkillsetWithOcrDefaultSettings() {

}

@Override
public void createSkillsetWithSentimentDefaultSettings() {

}

@Override
public void createSkillsetWithSplitDefaultSettings() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.search;

public abstract class SkillsetManagementTestBase extends SearchServiceTestBase {

public abstract void createSkillsetReturnsCorrectDefinitionImageAnalysisKeyPhrase();

public abstract void createSkillsetReturnsCorrectDefinitionLanguageDetection();

public abstract void createSkillsetReturnsCorrectDefinitionMergeText();

public abstract void createSkillsetReturnsCorrectDefinitionOcrEntity();

public abstract void createSkillsetReturnsCorrectDefinitionOcrHandwritingSentiment();

public abstract void createSkillsetReturnsCorrectDefinitionOcrKeyPhrase();

public abstract void createSkillsetReturnsCorrectDefinitionOcrShaper();

public abstract void createSkillsetReturnsCorrectDefinitionOcrSplitText();

public abstract void createSkillsetReturnsCorrectDefinitionWithCognitiveServicesDefault();

public abstract void createSkillsetReturnsCorrectDefinitionWithDefaultSettings();

public abstract void createSkillsetThrowsExceptionWithInvalidLanguageSelection();

public abstract void createSkillsetWithCognitiveServicesKey();

public abstract void createSkillsetWithEntityRecognitionDefaultSettings();

public abstract void createSkillsetWithImageAnalysisDefaultSettings();

public abstract void createSkillsetWithKeyPhraseExtractionDefaultSettings();

public abstract void createSkillsetWithMergeDefaultSettings();

public abstract void createSkillsetWithOcrDefaultSettings();

public abstract void createSkillsetWithSentimentDefaultSettings();

public abstract void createSkillsetWithSplitDefaultSettings();
}

0 comments on commit f385821

Please sign in to comment.