Merge pull request #5566 from ShvaykaD/rest-client/widget-type-methods
[3.3.3] fixed/added widget type methods in rest client
This commit is contained in:
commit
1f8ccfae38
@ -134,6 +134,8 @@ import org.thingsboard.server.common.data.security.model.SecuritySettings;
|
|||||||
import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
|
import org.thingsboard.server.common.data.security.model.UserPasswordPolicy;
|
||||||
import org.thingsboard.server.common.data.sms.config.TestSmsRequest;
|
import org.thingsboard.server.common.data.sms.config.TestSmsRequest;
|
||||||
import org.thingsboard.server.common.data.widget.WidgetType;
|
import org.thingsboard.server.common.data.widget.WidgetType;
|
||||||
|
import org.thingsboard.server.common.data.widget.WidgetTypeDetails;
|
||||||
|
import org.thingsboard.server.common.data.widget.WidgetTypeInfo;
|
||||||
import org.thingsboard.server.common.data.widget.WidgetsBundle;
|
import org.thingsboard.server.common.data.widget.WidgetsBundle;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@ -2423,11 +2425,11 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}).getBody();
|
}).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<WidgetType> getWidgetTypeById(WidgetTypeId widgetTypeId) {
|
public Optional<WidgetTypeDetails> getWidgetTypeById(WidgetTypeId widgetTypeId) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<WidgetType> widgetType =
|
ResponseEntity<WidgetTypeDetails> widgetTypeDetails =
|
||||||
restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetType.class, widgetTypeId.getId());
|
restTemplate.getForEntity(baseURL + "/api/widgetType/{widgetTypeId}", WidgetTypeDetails.class, widgetTypeId.getId());
|
||||||
return Optional.ofNullable(widgetType.getBody());
|
return Optional.ofNullable(widgetTypeDetails.getBody());
|
||||||
} catch (HttpClientErrorException exception) {
|
} catch (HttpClientErrorException exception) {
|
||||||
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
if (exception.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@ -2437,8 +2439,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidgetType saveWidgetType(WidgetType widgetType) {
|
public WidgetTypeDetails saveWidgetType(WidgetTypeDetails widgetTypeDetails) {
|
||||||
return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetType, WidgetType.class).getBody();
|
return restTemplate.postForEntity(baseURL + "/api/widgetType", widgetTypeDetails, WidgetTypeDetails.class).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteWidgetType(WidgetTypeId widgetTypeId) {
|
public void deleteWidgetType(WidgetTypeId widgetTypeId) {
|
||||||
@ -2456,6 +2458,28 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
|||||||
bundleAlias).getBody();
|
bundleAlias).getBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<WidgetTypeDetails> getBundleWidgetTypesDetails(boolean isSystem, String bundleAlias) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypesDetails?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<WidgetTypeDetails>>() {
|
||||||
|
},
|
||||||
|
isSystem,
|
||||||
|
bundleAlias).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<WidgetTypeInfo> getBundleWidgetTypesInfos(boolean isSystem, String bundleAlias) {
|
||||||
|
return restTemplate.exchange(
|
||||||
|
baseURL + "/api/widgetTypesInfos?isSystem={isSystem}&bundleAlias={bundleAlias}",
|
||||||
|
HttpMethod.GET,
|
||||||
|
HttpEntity.EMPTY,
|
||||||
|
new ParameterizedTypeReference<List<WidgetTypeInfo>>() {
|
||||||
|
},
|
||||||
|
isSystem,
|
||||||
|
bundleAlias).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
public Optional<WidgetType> getWidgetType(boolean isSystem, String bundleAlias, String alias) {
|
public Optional<WidgetType> getWidgetType(boolean isSystem, String bundleAlias, String alias) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<WidgetType> widgetType =
|
ResponseEntity<WidgetType> widgetType =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user