/** * Test if after registration of service they can be found in registry. */ @Test public void testRegister() { Response response1 = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service1/abbaasd") .request(MediaType.APPLICATION_JSON).put(Entity.text("")); Assert.assertTrue(response1.getStatus() == Response.Status.OK.getStatusCode()); Response response2 = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service1/abbaasd2") .request(MediaType.APPLICATION_JSON).put(Entity.text("")); Assert.assertTrue(response2.getStatus() == Response.Status.OK.getStatusCode()); Response response = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service1").request(MediaType.APPLICATION_JSON).get(); Assert.assertTrue(response.getStatus() == Response.Status.OK.getStatusCode()); List<String> list = response.readEntity(new GenericType<List<String>>() { }); Assert.assertTrue(list != null); Assert.assertTrue(list.size() == 2); Assert.assertTrue(list.get(0).equals("abbaasd")); Assert.assertTrue(list.get(1).equals("abbaasd2")); }
@Test public void shouldSuccessfullyCreateRequestWithCustomRange() { final String symbol = "IBM"; final SplitsRange splitsRange = SplitsRange.ONE_YEAR; final RestRequest<List<Split>> request = new SplitsRequestBuilder() .withSymbol(symbol) .withSplitsRange(splitsRange) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/splits/{range}"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<Split>>() {}); assertThat(request.getPathParams()).containsExactly( entry("symbol", symbol), entry("range", splitsRange.getCode())); assertThat(request.getQueryParams()).isEmpty(); }
/** * Deserialize response body to Java object according to the Content-Type. * @param <T> Type * @param response Response * @param returnType Return type * @return Deserialize object * @throws ApiException API exception */ @SuppressWarnings("unchecked") public <T> T deserialize(Response response, GenericType<T> returnType) throws ApiException { if (response == null || returnType == null) { return null; } if ("byte[]".equals(returnType.toString())) { // Handle binary response (byte array). return (T) response.readEntity(byte[].class); } else if (returnType.getRawType() == File.class) { // Handle file downloading. T file = (T) downloadFileFromResponse(response); return file; } String contentType = null; List<Object> contentTypes = response.getHeaders().get("Content-Type"); if (contentTypes != null && !contentTypes.isEmpty()) contentType = String.valueOf(contentTypes.get(0)); if (contentType == null) throw new ApiException(500, "missing Content-Type in response"); return response.readEntity(returnType); }
@Test public void shouldReturnFibonacciNos() { List<Sequence> first10FibonacciNos = ImmutableList.of( new Sequence(new BigInteger("1"), new BigInteger("0")), new Sequence(new BigInteger("2"), new BigInteger("1")), new Sequence(new BigInteger("3"), new BigInteger("1")), new Sequence(new BigInteger("4"), new BigInteger("2")), new Sequence(new BigInteger("5"), new BigInteger("3")), new Sequence(new BigInteger("6"), new BigInteger("5")), new Sequence(new BigInteger("7"), new BigInteger("8")), new Sequence(new BigInteger("8"), new BigInteger("13")), new Sequence(new BigInteger("9"), new BigInteger("21")), new Sequence(new BigInteger("10"), new BigInteger("34")) ); List<Sequence> evenNos = resources.client().target("/fibonacci?limit=100").request().get(new GenericType<List<Sequence>>(){}); assertThat(evenNos).hasSize(100); assertThat(evenNos).containsAll(first10FibonacciNos); assertThat(evenNos).contains(new Sequence(new BigInteger("100"), new BigInteger("218922995834555169026"))); }
/** * Test if unregistering a service actually removes it from the registry. */ @Test public void testUnregisterSuccess() { Response response1 = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service2/abbaasd") .request(MediaType.APPLICATION_JSON).put(Entity.text("")); Assert.assertTrue(response1.getStatus() == Response.Status.OK.getStatusCode()); Response response2 = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service2/abbaasd") .request(MediaType.APPLICATION_JSON).delete(); Assert.assertTrue(response2.getStatus() == Response.Status.OK.getStatusCode()); Response response = ClientBuilder.newBuilder().build().target("http://localhost:" + getTomcatPort() + "/test/rest/services/service2").request(MediaType.APPLICATION_JSON).get(); Assert.assertTrue(response.getStatus() == Response.Status.OK.getStatusCode()); List<String> list = response.readEntity(new GenericType<List<String>>() { }); Assert.assertTrue(list != null); Assert.assertTrue(list.size() == 0); }
/** * Retrieves a series of web image. * @param names list of name of image. * @param size target size * @throws NotFoundException If 404 was returned. * @throws LoadBalancerTimeoutException On receiving the 408 status code * and on repeated load balancer socket timeouts. * @return HashMap containing requested images. */ public static HashMap<String, String> getWebImages(List<String> names, ImageSize size) throws NotFoundException, LoadBalancerTimeoutException { HashMap<String, String> img = new HashMap<>(); for (String name : names) { img.put(name, size.toString()); } Response r = ServiceLoadBalancer.loadBalanceRESTOperation(Service.IMAGE, "image", HashMap.class, client -> client.getService().path(client.getApplicationURI()) .path(client.getEndpointURI()).path("getWebImages").request(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON).post(Entity.entity(img, MediaType.APPLICATION_JSON))); if (r == null) { return new HashMap<String, String>(); } HashMap<String, String> result = r.readEntity(new GenericType<HashMap<String, String>>() { }); if (result == null) { return new HashMap<String, String>(); } return result; }
@Test public void testBeanParameter() throws Exception { WebTarget webTarget = client.target(server.getURI().toString()); Invocation.Builder invocationBuilder = webTarget.path("/book") .queryParam("author", "Scott Oaks") .request(MediaType.APPLICATION_JSON); Response response = invocationBuilder.get(); Map<String, String> entity = response.readEntity(new GenericType<Map<String, String>>() {}); assertThat(response.getStatus(), equalTo(OK.getStatusCode())); assertThat(entity.get("author"), equalTo("Scott Oaks")); }
/** * Lists all of a location's item categories. * Lists all of a location's item categories. * @param locationId The ID of the location to list categories for. (required) * @return CompleteResponse<List<V1Category>> * @throws ApiException if fails to make API call */ public CompleteResponse<List<V1Category>>listCategoriesWithHttpInfo(String locationId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'locationId' is set if (locationId == null) { throw new ApiException(400, "Missing the required parameter 'locationId' when calling listCategories"); } // create path and map variables String localVarPath = "/v1/{location_id}/categories" .replaceAll("\\{" + "location_id" + "\\}", apiClient.escapeString(locationId.toString())); // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1Category>> localVarReturnType = new GenericType<List<V1Category>>() {}; return (CompleteResponse<List<V1Category>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
/** * Provides non-confidential details for all of a location's associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API. * Provides non-confidential details for all of a location's associated bank accounts. This endpoint does not provide full bank account numbers, and there is no way to obtain a full bank account number with the Connect API. * @param locationId The ID of the location to list bank accounts for. (required) * @return List<V1BankAccount> * @throws ApiException if fails to make API call */ public List<V1BankAccount> listBankAccounts(String locationId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'locationId' is set if (locationId == null) { throw new ApiException(400, "Missing the required parameter 'locationId' when calling listBankAccounts"); } // create path and map variables String localVarPath = "/v1/{location_id}/bank-accounts" .replaceAll("\\{" + "location_id" + "\\}", apiClient.escapeString(locationId.toString())); // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1BankAccount>> localVarReturnType = new GenericType<List<V1BankAccount>>() {}; CompleteResponse<List<V1BankAccount>> completeResponse = (CompleteResponse<List<V1BankAccount>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
@Test public void doubleInMapTest() { MapTest response = client.target(SERVER_URI) .path("/doubleInMapTest") .request() .accept(MediaType.APPLICATION_JSON_TYPE) .get(new GenericType<MapTest>() {}); check(response.mapDouble().values()).isOf(5.0d); }
public List<String> getOpenShiftClusters(String authHeader) { URI targetURI = UriBuilder.fromUri(missionControlOpenShiftURI).path("/clusters").build(); try { return perform(client -> client .target(targetURI) .request(MediaType.APPLICATION_JSON_TYPE) .header(HttpHeaders.AUTHORIZATION, authHeader) .get().readEntity(new GenericType<List<String>>() { })); } catch (Exception e) { log.log(Level.SEVERE, "Error while returning openshift clusters", e); return Collections.emptyList(); } }
/** * Get a business's information. * Get a business's information. * @return V1Merchant * @throws ApiException if fails to make API call */ public V1Merchant retrieveBusiness() throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v1/me"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<V1Merchant> localVarReturnType = new GenericType<V1Merchant>() {}; CompleteResponse<V1Merchant> completeResponse = (CompleteResponse<V1Merchant>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<Map<String, SsrStatus>> request = new SsrStatusRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/deep/ssr-status"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Map<String, SsrStatus>>() {}); assertThat(request.getPathParams()).isEmpty(); assertThat(request.getQueryParams()).contains(entry("symbols", symbol)); }
@Override public <U> U readEntity(GenericType<U> entityType) { if (!entityType.getRawType().equals(bodyClass)) { throw new IllegalArgumentException( "Raw generic type is not the same type as the body entity"); } return rawResponse.readEntity(entityType); }
@Override public <U> U readEntity(GenericType<U> entityType, Annotation[] annotations) { if (!entityType.getRawType().equals(bodyClass)) { throw new IllegalArgumentException( "Raw generic type is not the same type as the body entity"); } return rawResponse.readEntity(entityType, annotations); }
@Override public RestRequest<Map<String, SsrStatus>> build() { return RestRequestBuilder.<Map<String, SsrStatus>>builder() .withPath("/deep/ssr-status").get() .withResponse(new GenericType<Map<String, SsrStatus>>() {}) .addQueryParam(getSymbols()) .addQueryParam(getFilterParams()) .build(); }
@Override public RestRequest<List<News>> build() { return RestRequestBuilder.<List<News>>builder() .withPath("/stock/{symbol}/news/last/{range}") .addPathParam("symbol", getSymbol()) .addPathParam("range", String.valueOf(last)).get() .withResponse(new GenericType<List<News>>() {}) .build(); }
@Override public RestRequest<Map<String, SecurityEvent>> build() { return RestRequestBuilder.<Map<String, SecurityEvent>>builder() .withPath("/deep/security-event").get() .withResponse(new GenericType<Map<String, SecurityEvent>>() {}) .addQueryParam(getSymbols()) .addQueryParam(getFilterParams()) .build(); }
protected List<T> getList(String routerId) { URI uri = getApiUrl().clone() .build(routerId); return getClient() .target(uri) .request(MediaType.APPLICATION_JSON_TYPE) .get(new GenericType<List<T>>() {}); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<BigDecimal> request = new PriceRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/price"); assertThat(request.getResponseType()).isEqualTo(new GenericType<BigDecimal>() {}); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
@Override public RestRequest<List<HistoricalStats>> build() { return RestRequestBuilder.<List<HistoricalStats>>builder() .withPath("/stats/historical").get() .withResponse(new GenericType<List<HistoricalStats>>() {}) .addQueryParam(getDateParams()) .addQueryParam(getFilterParams()) .build(); }
/** * DeleteCatalogObject * Deletes a single [CatalogObject](#type-catalogobject) based on the provided ID and returns the set of successfully deleted IDs in the response. Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a [CatalogItem](#type-catalogitem) will also delete all of its [CatalogItemVariation](#type-catalogitemvariation) children. * @param objectId The ID of the [CatalogObject](#type-catalogobject) to be deleted. When an object is deleted, other objects in the graph that depend on that object will be deleted as well (for example, deleting a [CatalogItem](#type-catalogitem) will delete its [CatalogItemVariation](#type-catalogitemvariation)s). (required) * @return CompleteResponse<DeleteCatalogObjectResponse> * @throws ApiException if fails to make API call */ public CompleteResponse<DeleteCatalogObjectResponse>deleteCatalogObjectWithHttpInfo(String objectId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'objectId' is set if (objectId == null) { throw new ApiException(400, "Missing the required parameter 'objectId' when calling deleteCatalogObject"); } // create path and map variables String localVarPath = "/v2/catalog/object/{object_id}" .replaceAll("\\{" + "object_id" + "\\}", apiClient.escapeString(objectId.toString())); // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<DeleteCatalogObjectResponse> localVarReturnType = new GenericType<DeleteCatalogObjectResponse>() {}; return (CompleteResponse<DeleteCatalogObjectResponse>)apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
@Test public void shouldSuccessfullyCreateRequestWithYearMonthDate() { final RestRequest<RecordsStats> request = new RecordStatsRequestBuilder().build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stats/records"); assertThat(request.getResponseType()).isEqualTo(new GenericType<RecordsStats>() {}); assertThat(request.getPathParams()).isEmpty(); assertThat(request.getQueryParams()).isEmpty(); }
/** * Gets flows dump through Northbound service. * * @return The JSON document of the dump flows */ public static List<FlowPayload> getFlowDump() { System.out.println("\n==> Northbound Get Flow Dump"); long current = System.currentTimeMillis(); Client client = clientFactory(); Response response = client .target(northboundEndpoint) .path("/api/v1/flows") .request(MediaType.APPLICATION_JSON) .header(HttpHeaders.AUTHORIZATION, authHeaderValue) .header(Utils.CORRELATION_ID, String.valueOf(System.currentTimeMillis())) .get(); System.out.println(String.format("===> Response = %s", response.toString())); System.out.println(String.format("===> Northbound Get Flow Dump Time: %,.3f", getTimeDuration(current))); int responseCode = response.getStatus(); if (responseCode == 200) { List<FlowPayload> flows = response.readEntity(new GenericType<List<FlowPayload>>() {}); System.out.println(String.format("====> Northbound Get Flow Dump = %d", flows.size())); return flows; } else { System.out.println(String.format("====> Error: Northbound Get Flow Dump = %s", response.readEntity(MessageError.class))); return Collections.emptyList(); } }
/** * SearchCatalogObjects * Queries the targeted catalog using a variety of query types: [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute), [CatalogQueryExact](#type-catalogqueryexact), [CatalogQueryRange](#type-catalogqueryrange), [CatalogQueryText](#type-catalogquerytext), [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist). * @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required) * @return CompleteResponse<SearchCatalogObjectsResponse> * @throws ApiException if fails to make API call */ public CompleteResponse<SearchCatalogObjectsResponse>searchCatalogObjectsWithHttpInfo(SearchCatalogObjectsRequest body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing the required parameter 'body' when calling searchCatalogObjects"); } // create path and map variables String localVarPath = "/v2/catalog/search"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<SearchCatalogObjectsResponse> localVarReturnType = new GenericType<SearchCatalogObjectsResponse>() {}; return (CompleteResponse<SearchCatalogObjectsResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
@Test public void shouldSuccessfullyCreateRequest() { final RestRequest<List<ExchangeSymbol>> request = new SymbolsRequestBuilder().build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/ref-data/symbols"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<ExchangeSymbol>>() {}); assertThat(request.getQueryParams()).isEmpty(); }
@Test public void shouldSuccessfullyCreateRequestWithYearMonthDate() { final RestRequest<List<RecentStats>> request = new RecentStatsRequestBuilder().build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stats/recent"); assertThat(request.getResponseType()).isEqualTo(new GenericType<List<RecentStats>>() {}); assertThat(request.getPathParams()).isEmpty(); assertThat(request.getQueryParams()).isEmpty(); }
/** * Provides details for a business's locations, including their IDs. * Provides details for a business's locations, including their IDs. * @return CompleteResponse<List<V1Merchant>> * @throws ApiException if fails to make API call */ public CompleteResponse<List<V1Merchant>>listLocationsWithHttpInfo() throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v1/me/locations"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1Merchant>> localVarReturnType = new GenericType<List<V1Merchant>>() {}; return (CompleteResponse<List<V1Merchant>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
/** * UpsertCatalogObject * Creates or updates the target [CatalogObject](#type-catalogobject). * @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required) * @return CompleteResponse<UpsertCatalogObjectResponse> * @throws ApiException if fails to make API call */ public CompleteResponse<UpsertCatalogObjectResponse>upsertCatalogObjectWithHttpInfo(UpsertCatalogObjectRequest body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing the required parameter 'body' when calling upsertCatalogObject"); } // create path and map variables String localVarPath = "/v2/catalog/object"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<UpsertCatalogObjectResponse> localVarReturnType = new GenericType<UpsertCatalogObjectResponse>() {}; return (CompleteResponse<UpsertCatalogObjectResponse>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
@Override public RestRequest<Map<String, OpHaltStatus>> build() { return RestRequestBuilder.<Map<String, OpHaltStatus>>builder() .withPath("/deep/op-halt-status").get() .withResponse(new GenericType<Map<String, OpHaltStatus>>() {}) .addQueryParam(getSymbols()) .addQueryParam(getFilterParams()) .build(); }
@Override public EsCommonsResultResponse removeIndexByName(final RemoveIndexByNameRequest request) { assertRequest(request); return getBaseWebTarget("remove-index-by-name") .request(MediaType.APPLICATION_JSON_TYPE) .header(CONTENT_TYPE, APPLICATION_JSON) .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE), new GenericType<EsCommonsResultResponse>() { }); }
/** * Creates an employee for a business. * Creates an employee for a business. * @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required) * @return CompleteResponse<V1Employee> * @throws ApiException if fails to make API call */ public CompleteResponse<V1Employee>createEmployeeWithHttpInfo(V1Employee body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing the required parameter 'body' when calling createEmployee"); } // create path and map variables String localVarPath = "/v1/me/employees"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<V1Employee> localVarReturnType = new GenericType<V1Employee>() {}; return (CompleteResponse<V1Employee>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }
@Override public RestRequest<List<String>> build() { return RestRequestBuilder.<List<String>>builder() .withPath("/stock/{symbol}/peers") .addPathParam("symbol", getSymbol()).get() .withResponse(new GenericType<List<String>>() {}) .build(); }
/** * Creates a timecard for an employee. Each timecard corresponds to a single shift. * Creates a timecard for an employee. Each timecard corresponds to a single shift. * @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. (required) * @return V1Timecard * @throws ApiException if fails to make API call */ public V1Timecard createTimecard(V1Timecard body) throws ApiException { Object localVarPostBody = body; // verify the required parameter 'body' is set if (body == null) { throw new ApiException(400, "Missing the required parameter 'body' when calling createTimecard"); } // create path and map variables String localVarPath = "/v1/me/timecards"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<V1Timecard> localVarReturnType = new GenericType<V1Timecard>() {}; CompleteResponse<V1Timecard> completeResponse = (CompleteResponse<V1Timecard>)apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
@Test public void shouldSuccessfullyCreateRequest() { final String symbol = "IBM"; final RestRequest<Company> request = new CompanyRequestBuilder() .withSymbol(symbol) .build(); assertThat(request.getMethodType()).isEqualTo(MethodType.GET); assertThat(request.getPath()).isEqualTo("/stock/{symbol}/company"); assertThat(request.getResponseType()).isEqualTo(new GenericType<Company>() {}); assertThat(request.getPathParams()).containsExactly(entry("symbol", symbol)); assertThat(request.getQueryParams()).isEmpty(); }
/** * Deletes a timecard. Deleted timecards are still accessible from Connect API endpoints, but the value of their deleted field is set to true. See Handling deleted timecards for more information. * Deletes a timecard. Deleted timecards are still accessible from Connect API endpoints, but the value of their deleted field is set to true. See Handling deleted timecards for more information. * @param timecardId The ID of the timecard to delete. (required) * @return Object * @throws ApiException if fails to make API call */ public Object deleteTimecard(String timecardId) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'timecardId' is set if (timecardId == null) { throw new ApiException(400, "Missing the required parameter 'timecardId' when calling deleteTimecard"); } // create path and map variables String localVarPath = "/v1/me/timecards/{timecard_id}" .replaceAll("\\{" + "timecard_id" + "\\}", apiClient.escapeString(timecardId.toString())); // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<Object> localVarReturnType = new GenericType<Object>() {}; CompleteResponse<Object> completeResponse = (CompleteResponse<Object>)apiClient.invokeAPI(localVarPath, "DELETE", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
/** * Provides the details for all of a location's cash drawer shifts during a date range. The date range you specify cannot exceed 90 days. * Provides the details for all of a location's cash drawer shifts during a date range. The date range you specify cannot exceed 90 days. * @param locationId The ID of the location to list cash drawer shifts for. (required) * @param order The order in which cash drawer shifts are listed in the response, based on their created_at field. Default value: ASC (optional) * @param beginTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time minus 90 days. (optional) * @param endTime The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time. (optional) * @return List<V1CashDrawerShift> * @throws ApiException if fails to make API call */ public List<V1CashDrawerShift> listCashDrawerShifts(String locationId, String order, String beginTime, String endTime) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'locationId' is set if (locationId == null) { throw new ApiException(400, "Missing the required parameter 'locationId' when calling listCashDrawerShifts"); } // create path and map variables String localVarPath = "/v1/{location_id}/cash-drawer-shifts" .replaceAll("\\{" + "location_id" + "\\}", apiClient.escapeString(locationId.toString())); // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "begin_time", beginTime)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "end_time", endTime)); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1CashDrawerShift>> localVarReturnType = new GenericType<List<V1CashDrawerShift>>() {}; CompleteResponse<List<V1CashDrawerShift>> completeResponse = (CompleteResponse<List<V1CashDrawerShift>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
@Test public void testCardGenOnEmptyTable() throws Exception { InitialPreviewResponse previewDataset = createDatasetFromSQL("select * from sys.version where commit_id = ''", Lists.newArrayList("cp")); Selection sel = new Selection("commit_id", "unused in test", 0, 3); expectSuccess( getBuilder(getAPIv2().path(versionedResourcePath(previewDataset.getDataset()) + "/keeponly")) .buildPost(entity(sel, JSON)), new GenericType<ReplaceCards>() {} ); }
/** * Provides summary information for all of a business's employee roles. * Provides summary information for all of a business's employee roles. * @param order The order in which employees are listed in the response, based on their created_at field.Default value: ASC (optional) * @param limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. (optional) * @param batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. (optional) * @return List<V1EmployeeRole> * @throws ApiException if fails to make API call */ public List<V1EmployeeRole> listEmployeeRoles(String order, Integer limit, String batchToken) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v1/me/roles"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "batch_token", batchToken)); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1EmployeeRole>> localVarReturnType = new GenericType<List<V1EmployeeRole>>() {}; CompleteResponse<List<V1EmployeeRole>> completeResponse = (CompleteResponse<List<V1EmployeeRole>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); return completeResponse.getData(); }
/** * Provides summary information for all of a business's employee roles. * Provides summary information for all of a business's employee roles. * @param order The order in which employees are listed in the response, based on their created_at field.Default value: ASC (optional) * @param limit The maximum integer number of employee entities to return in a single response. Default 100, maximum 200. (optional) * @param batchToken A pagination cursor to retrieve the next set of results for your original query to the endpoint. (optional) * @return CompleteResponse<List<V1EmployeeRole>> * @throws ApiException if fails to make API call */ public CompleteResponse<List<V1EmployeeRole>>listEmployeeRolesWithHttpInfo(String order, Integer limit, String batchToken) throws ApiException { Object localVarPostBody = null; // create path and map variables String localVarPath = "/v1/me/roles"; // query params List<Pair> localVarQueryParams = new ArrayList<Pair>(); Map<String, String> localVarHeaderParams = new HashMap<String, String>(); Map<String, Object> localVarFormParams = new HashMap<String, Object>(); localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "batch_token", batchToken)); final String[] localVarAccepts = { "application/json" }; final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); final String[] localVarContentTypes = { "application/json" }; final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); String[] localVarAuthNames = new String[] { "oauth2" }; GenericType<List<V1EmployeeRole>> localVarReturnType = new GenericType<List<V1EmployeeRole>>() {}; return (CompleteResponse<List<V1EmployeeRole>>)apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); }