Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Global Search): remove deprecated method getSupportedTypes #192

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ibm.cloud.platform_services.global_search.v2.model.GetSupportedTypesOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.ScanResult;
import com.ibm.cloud.platform_services.global_search.v2.model.SearchOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.SupportedTypesList;
import com.ibm.cloud.sdk.core.http.Response;
import com.ibm.cloud.sdk.core.service.exception.ServiceResponseException;

Expand Down Expand Up @@ -70,25 +68,5 @@ public static void main(String[] args) throws Exception {
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
}

try {
System.out.println("getSupportedTypes() result:");

// begin-get_supported_types

GetSupportedTypesOptions getSupportedTypesOptions = new GetSupportedTypesOptions();

Response<SupportedTypesList> response = service.getSupportedTypes(getSupportedTypesOptions).execute();
SupportedTypesList supportedTypesList = response.getResult();

System.out.println(supportedTypesList);

// end-get_supported_types

} catch (ServiceResponseException e) {
logger.error(String.format("Service returned status code %s: %s\nError details: %s",
e.getStatusCode(), e.getMessage(), e.getDebuggingInfo()), e);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.67.0-df2073a1-20230222-221157
* IBM OpenAPI SDK Code Generator Version: 3.70.0-7df966bf-20230419-195904
*/

package com.ibm.cloud.platform_services.global_search.v2;

import com.google.gson.JsonObject;
import com.ibm.cloud.platform_services.common.SdkCommon;
import com.ibm.cloud.platform_services.global_search.v2.model.GetSupportedTypesOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.ScanResult;
import com.ibm.cloud.platform_services.global_search.v2.model.SearchOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.SupportedTypesList;
import com.ibm.cloud.sdk.core.http.RequestBuilder;
import com.ibm.cloud.sdk.core.http.ResponseConverter;
import com.ibm.cloud.sdk.core.http.ServiceCall;
Expand All @@ -33,7 +31,6 @@
import com.ibm.cloud.sdk.core.util.ResponseConverterUtils;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Logger;

/**
* Search for resources with the global and shared resource properties repository that is integrated in the IBM Cloud
Expand All @@ -47,7 +44,6 @@
* API Version: 2.0.1
*/
public class GlobalSearch extends BaseService {
private static final Logger LOGGER = Logger.getLogger(GlobalSearch.class.getName());

/**
* Default service name used when configuring the `GlobalSearch` client.
Expand Down Expand Up @@ -130,9 +126,6 @@ public ServiceCall<ScanResult> search(SearchOptions searchOptions) {
if (searchOptions.accountId() != null) {
builder.query("account_id", String.valueOf(searchOptions.accountId()));
}
if (searchOptions.boundary() != null) {
builder.query("boundary", String.valueOf(searchOptions.boundary()));
}
if (searchOptions.limit() != null) {
builder.query("limit", String.valueOf(searchOptions.limit()));
}
Expand Down Expand Up @@ -196,40 +189,4 @@ public ServiceCall<ScanResult> search() {
return search(null);
}

/**
* DEPRECATED. Get all GhoST indexes.
*
* Retrieves a list of all GhoST indexes.
*
* @param getSupportedTypesOptions the {@link GetSupportedTypesOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SupportedTypesList}
* @deprecated this method is deprecated and may be removed in a future release
*/
@Deprecated
public ServiceCall<SupportedTypesList> getSupportedTypes(GetSupportedTypesOptions getSupportedTypesOptions) {
LOGGER.warning("A deprecated operation has been invoked: getSupportedTypes");
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v2/resources/supported_types"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("global_search", "v2", "getSupportedTypes");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SupportedTypesList> responseConverter =
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SupportedTypesList>() { }.getType());
return createServiceCall(builder.build(), responseConverter);
}

/**
* DEPRECATED. Get all GhoST indexes.
*
* Retrieves a list of all GhoST indexes.
*
* @return a {@link ServiceCall} with a result of type {@link SupportedTypesList}
* @deprecated this method is deprecated and may be removed in a future release
*/
@Deprecated
public ServiceCall<SupportedTypesList> getSupportedTypes() {
return getSupportedTypes(null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
*/
public class SearchOptions extends GenericModel {

/**
* The boundary where the search performs. This parameter must be set only for the cross-account searches.
*/
public interface Boundary {
/** global. */
String GLOBAL = "global";
/** us-regulated. */
String US_REGULATED = "us-regulated";
}

/**
* Determines if deleted documents should be included in result set or not. Possible values are false (default), true
* or any. If false, only existing documents are returned; if true, only deleted documents are returned; If any, both
Expand Down Expand Up @@ -91,7 +81,6 @@ public interface CanTag {
protected String searchCursor;
protected String transactionId;
protected String accountId;
protected String boundary;
protected Long limit;
protected Long timeout;
protected List<String> sort;
Expand All @@ -110,7 +99,6 @@ public static class Builder {
private String searchCursor;
private String transactionId;
private String accountId;
private String boundary;
private Long limit;
private Long timeout;
private List<String> sort;
Expand All @@ -131,7 +119,6 @@ private Builder(SearchOptions searchOptions) {
this.searchCursor = searchOptions.searchCursor;
this.transactionId = searchOptions.transactionId;
this.accountId = searchOptions.accountId;
this.boundary = searchOptions.boundary;
this.limit = searchOptions.limit;
this.timeout = searchOptions.timeout;
this.sort = searchOptions.sort;
Expand Down Expand Up @@ -245,17 +232,6 @@ public Builder accountId(String accountId) {
return this;
}

/**
* Set the boundary.
*
* @param boundary the boundary
* @return the SearchOptions builder
*/
public Builder boundary(String boundary) {
this.boundary = boundary;
return this;
}

/**
* Set the limit.
*
Expand Down Expand Up @@ -354,7 +330,6 @@ protected SearchOptions(Builder builder) {
searchCursor = builder.searchCursor;
transactionId = builder.transactionId;
accountId = builder.accountId;
boundary = builder.boundary;
limit = builder.limit;
timeout = builder.timeout;
sort = builder.sort;
Expand Down Expand Up @@ -432,17 +407,6 @@ public String accountId() {
return accountId;
}

/**
* Gets the boundary.
*
* The boundary where the search performs. This parameter must be set only for the cross-account searches.
*
* @return the boundary
*/
public String boundary() {
return boundary;
}

/**
* Gets the limit.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,6 @@ public void testSearch() throws Exception {
}
}

@Test
public void testGetSupportedTypes() throws Exception {
try {
GetSupportedTypesOptions getSupportedTypesOptions = new GetSupportedTypesOptions();

Response<SupportedTypesList> response = service.getSupportedTypes(getSupportedTypesOptions).execute();
assertNotNull(response);
assertEquals(response.getStatusCode(), 200);

SupportedTypesList supportedTypesListResult = response.getResult();
assertNotNull(supportedTypesListResult);
log(String.format("getSupportedTypes() result:\n%s\n", supportedTypesListResult.toString()));
} catch (ServiceResponseException e) {
fail(String.format("Service returned status code %d: %s\nError details: %s", e.getStatusCode(),
e.getMessage(), e.getDebuggingInfo()));
}
}

@AfterClass
public void tearDown() {
// Add any clean up logic here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
package com.ibm.cloud.platform_services.global_search.v2;

import com.ibm.cloud.platform_services.global_search.v2.GlobalSearch;
import com.ibm.cloud.platform_services.global_search.v2.model.GetSupportedTypesOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.ResultItem;
import com.ibm.cloud.platform_services.global_search.v2.model.ScanResult;
import com.ibm.cloud.platform_services.global_search.v2.model.SearchOptions;
import com.ibm.cloud.platform_services.global_search.v2.model.SupportedTypesList;
import com.ibm.cloud.platform_services.global_search.v2.utils.TestUtilities;
import com.ibm.cloud.sdk.core.http.Response;
import com.ibm.cloud.sdk.core.security.Authenticator;
Expand Down Expand Up @@ -73,7 +71,6 @@ public void testSearchWOptions() throws Throwable {
.searchCursor("testString")
.transactionId("testString")
.accountId("testString")
.boundary("global")
.limit(Long.valueOf("1"))
.timeout(Long.valueOf("0"))
.sort(java.util.Arrays.asList("testString"))
Expand Down Expand Up @@ -101,7 +98,6 @@ public void testSearchWOptions() throws Throwable {
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNotNull(query);
assertEquals(query.get("account_id"), "testString");
assertEquals(query.get("boundary"), "global");
assertEquals(Long.valueOf(query.get("limit")), Long.valueOf("1"));
assertEquals(Long.valueOf(query.get("timeout")), Long.valueOf("0"));
assertEquals(query.get("sort"), RequestUtils.join(java.util.Arrays.asList("testString"), ","));
Expand All @@ -122,48 +118,6 @@ public void testSearchWRetries() throws Throwable {
testSearchWOptions();
}

// Test the getSupportedTypes operation with a valid options model parameter
@Test
public void testGetSupportedTypesWOptions() throws Throwable {
// Register a mock response
String mockResponseBody = "{\"supported_types\": [\"supportedTypes\"]}";
String getSupportedTypesPath = "/v2/resources/supported_types";
server.enqueue(new MockResponse()
.setHeader("Content-type", "application/json")
.setResponseCode(200)
.setBody(mockResponseBody));

// Construct an instance of the GetSupportedTypesOptions model
GetSupportedTypesOptions getSupportedTypesOptionsModel = new GetSupportedTypesOptions();

// Invoke getSupportedTypes() with a valid options model and verify the result
Response<SupportedTypesList> response = globalSearchService.getSupportedTypes(getSupportedTypesOptionsModel).execute();
assertNotNull(response);
SupportedTypesList responseObj = response.getResult();
assertNotNull(responseObj);

// Verify the contents of the request sent to the mock server
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Verify request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getSupportedTypesPath);
// Verify that there is no query string
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
}

// Test the getSupportedTypes operation with and without retries enabled
@Test
public void testGetSupportedTypesWRetries() throws Throwable {
globalSearchService.enableRetries(4, 30);
testGetSupportedTypesWOptions();

globalSearchService.disableRetries();
testGetSupportedTypesWOptions();
}

// Perform setup needed before each test method
@BeforeMethod
public void beforeEachTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void testSearchOptions() throws Throwable {
.searchCursor("testString")
.transactionId("testString")
.accountId("testString")
.boundary("global")
.limit(Long.valueOf("1"))
.timeout(Long.valueOf("0"))
.sort(java.util.Arrays.asList("testString"))
Expand All @@ -52,7 +51,6 @@ public void testSearchOptions() throws Throwable {
assertEquals(searchOptionsModel.searchCursor(), "testString");
assertEquals(searchOptionsModel.transactionId(), "testString");
assertEquals(searchOptionsModel.accountId(), "testString");
assertEquals(searchOptionsModel.boundary(), "global");
assertEquals(searchOptionsModel.limit(), Long.valueOf("1"));
assertEquals(searchOptionsModel.timeout(), Long.valueOf("0"));
assertEquals(searchOptionsModel.sort(), java.util.Arrays.asList("testString"));
Expand Down