com.nepxion.discovery.console.rest.ConfigUpdateRestInvoker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-console Show documentation
Show all versions of discovery-console Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
package com.nepxion.discovery.console.rest;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import java.util.List;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
public class ConfigUpdateRestInvoker extends AbstractRestInvoker {
private String config;
public ConfigUpdateRestInvoker(List serviceInstances, RestTemplate restTemplate, String config, boolean async) {
super(serviceInstances, restTemplate, async);
this.config = config;
}
@Override
protected String getInfo() {
return "Config updated";
}
@Override
protected String getSuffixPath() {
return "config/update-" + getInvokeType();
}
@Override
protected String doRest(String url) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity entity = new HttpEntity(config, headers);
return restTemplate.postForEntity(url, entity, String.class).getBody();
}
@Override
protected void checkPermission(ServiceInstance serviceInstance) throws Exception {
checkDiscoveryControlPermission(serviceInstance);
checkConfigRestControlPermission(serviceInstance);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy