use of com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions in project cloudant-java-sdk by IBM.
the class Cloudant method getCorsInformation.
/**
* Retrieve CORS configuration information.
*
* Lists all Cross-origin resource sharing (CORS) configuration. CORS defines a way in which the browser and the
* server interact to determine whether or not to allow the request.
*
* @param getCorsInformationOptions the {@link GetCorsInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link CorsInformation}
*/
public ServiceCall<CorsInformation> getCorsInformation(GetCorsInformationOptions getCorsInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_api/v2/user/config/cors"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getCorsInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<CorsInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<CorsInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions in project cloudant-java-sdk by IBM.
the class GetCorsInformationOptionsTest method testGetCorsInformationOptions.
@Test
public void testGetCorsInformationOptions() throws Throwable {
GetCorsInformationOptions getCorsInformationOptionsModel = new GetCorsInformationOptions();
assertNotNull(getCorsInformationOptionsModel);
}
use of com.ibm.cloud.cloudant.v1.model.GetCorsInformationOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetCorsInformationWOptions.
@Test
public void testGetCorsInformationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"allow_credentials\": true, \"enable_cors\": true, \"origins\": [\"origins\"]}";
String getCorsInformationPath = "/_api/v2/user/config/cors";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetCorsInformationOptions model
GetCorsInformationOptions getCorsInformationOptionsModel = new GetCorsInformationOptions();
// Invoke operation with valid options model (positive test)
Response<CorsInformation> response = cloudantService.getCorsInformation(getCorsInformationOptionsModel).execute();
assertNotNull(response);
CorsInformation responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getCorsInformationPath);
}
Aggregations