protected HttpRequest put(String path) { log.info("[PUT] {}", (origin + path)); return Unirest.put(origin + path); }
protected String putBodyString(String path) throws Exception { log.info("[PUT] {}", (origin + path)); return Unirest.put(origin + path).asString().getBody(); }
public static HttpRequestWithBody put(String url) { return Unirest.put(url); }
public static HttpRequestWithBody put(String url) { return Unirest.put(ClientManager.lookup(url)); }
public JSONObject put(String url, JSONObject body) { return toObject(addHeaders(Unirest.put(url)).body(body.toString())); }
private static int registerServiceHttpClient(String body) throws UnirestException { HttpResponse<JsonNode> jsonResponse = Unirest.put(consulURL().toString() + "/" + CONSUL_URL_REGISTER_SERVICE) .header("accept", "application/json") .body(body) .asJson(); return jsonResponse.getStatus(); }
private HttpRequest buildUnirest(WorkingContext workingContext) { String url = String.format("%s%s", PROJECTOXFORD_AI, workingContext.getPathBuilt()); switch (workingContext.getHttpMethod()) { case GET: return Unirest.get(url); case PUT: return Unirest.put(url); case DELETE: return Unirest.delete(url); case PATCH: return Unirest.patch(url); } return Unirest.post(url); }
private BaseRequest executePut(String baseUrl, Object urlMap, Object bodyMap) { return Unirest.put(baseUrl + urlTemplate.execute(urlMap)).header("Content-type", "application/json").body(bodyTemplate.execute(bodyMap)); }
checkoutEntity("run", currentRunId); HttpResponse<String> response = Unirest.put(serverUrl + "/rest/domains/{domain}/projects/{project}/runs/{runId}") .routeParam("runId", currentRunId) .routeParam(PROJECT_NAME, project)
.toString(); HttpRequestWithBody request = Unirest.put(createContentUrl).header("Content-Type", "application/json; charset=utf-8"); addSecurityTo(request); HttpResponse<JsonNode> response = request.body(requestBody).asJson();
break; case PUT: response = Unirest.put(url).fields(parameters).asJson(); break; case PATCH:
/** * @see io.apicurio.hub.api.connectors.ISourceConnector#createResourceContent(java.lang.String, java.lang.String, java.lang.String) */ @Override public void createResourceContent(String repositoryUrl, String commitMessage, String content) throws SourceConnectorException { try { String b64Content = Base64.encodeBase64String(content.getBytes(StandardCharsets.UTF_8)); GitHubResource resource = GitHubResourceResolver.resolve(repositoryUrl); GitHubCreateFileRequest requestBody = new GitHubCreateFileRequest(); requestBody.setMessage(commitMessage); requestBody.setContent(b64Content); requestBody.setBranch(resource.getBranch()); String createContentUrl = this.endpoint("/repos/:org/:repo/contents/:path") .bind("org", resource.getOrganization()) .bind("repo", resource.getRepository()) .bind("path", resource.getResourcePath()) .toString(); HttpRequestWithBody request = Unirest.put(createContentUrl).header("Content-Type", "application/json; charset=utf-8"); addSecurityTo(request); HttpResponse<InputStream> response = request.body(requestBody).asBinary(); if (response.getStatus() != 201) { throw new UnirestException("Unexpected response from GitHub: " + response.getStatus() + "::" + response.getStatusText()); } } catch (UnirestException e) { logger.error("Error creating Github resource content.", e); throw new SourceConnectorException("Error creating Github resource content.", e); } }
break; case PUT: request = Unirest.put(url); break; case GET:
default HttpResponse<RDeployUnit> updateDu(RDeployUnit du) throws UnirestException, KevoreeRegistryException { // be sure user is logged-in / refresh token if necessary / throws otherwise this.ensureLogin(); // PUT du return Unirest.put(this.baseUrl() + "/api/namespaces/{namespace}/tdefs/{tdefName}/{tdefVersion}/dus/{name}/{version}/{platform}") .header("Authorization", "Bearer " + config().getString("user.access_token")) .header("Content-Type", "application/json") .routeParam("namespace", du.getNamespace()) .routeParam("tdefName", du.getTdefName()) .routeParam("tdefVersion", du.getTdefVersion().toString()) .routeParam("name", du.getName()) .routeParam("version", du.getVersion()) .routeParam("platform", du.getPlatform()) .body(du) .asObject(RDeployUnit.class); }