added queue to rest client
This commit is contained in:
parent
4dd2310a53
commit
a5c1cce884
@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.thingsboard.server.controller;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@ -38,14 +35,7 @@ import org.thingsboard.server.service.entitiy.queue.TbQueueService;
|
||||
import org.thingsboard.server.service.security.permission.Operation;
|
||||
import org.thingsboard.server.service.security.permission.Resource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.thingsboard.server.controller.ControllerConstants.QUEUE_SERVICE_TYPE_ALLOWABLE_VALUES;
|
||||
import static org.thingsboard.server.controller.ControllerConstants.QUEUE_SERVICE_TYPE_DESCRIPTION;
|
||||
import static org.thingsboard.server.controller.ControllerConstants.TENANT_AUTHORITY_PARAGRAPH;
|
||||
|
||||
@RestController
|
||||
@TbCoreComponent
|
||||
|
||||
@ -37,7 +37,6 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.thingsboard.common.util.ThingsBoardExecutors;
|
||||
import org.thingsboard.rest.client.utils.RestJsonConverter;
|
||||
import org.thingsboard.server.common.data.AdminSettings;
|
||||
@ -91,6 +90,7 @@ import org.thingsboard.server.common.data.id.EntityId;
|
||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||
import org.thingsboard.server.common.data.id.OAuth2ClientRegistrationTemplateId;
|
||||
import org.thingsboard.server.common.data.id.OtaPackageId;
|
||||
import org.thingsboard.server.common.data.id.QueueId;
|
||||
import org.thingsboard.server.common.data.id.RuleChainId;
|
||||
import org.thingsboard.server.common.data.id.RuleNodeId;
|
||||
import org.thingsboard.server.common.data.id.TbResourceId;
|
||||
@ -119,6 +119,7 @@ import org.thingsboard.server.common.data.query.AlarmDataQuery;
|
||||
import org.thingsboard.server.common.data.query.EntityCountQuery;
|
||||
import org.thingsboard.server.common.data.query.EntityData;
|
||||
import org.thingsboard.server.common.data.query.EntityDataQuery;
|
||||
import org.thingsboard.server.common.data.queue.Queue;
|
||||
import org.thingsboard.server.common.data.relation.EntityRelation;
|
||||
import org.thingsboard.server.common.data.relation.EntityRelationInfo;
|
||||
import org.thingsboard.server.common.data.relation.EntityRelationsQuery;
|
||||
@ -146,7 +147,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Collectors;
|
||||
@ -2904,7 +2904,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/resource/{resourceId}/download",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<>() {},
|
||||
new ParameterizedTypeReference<>() {
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
@ -2917,7 +2918,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/resource/info/{resourceId}",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<TbResourceInfo>() {},
|
||||
new ParameterizedTypeReference<TbResourceInfo>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
@ -2930,7 +2932,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/resource/{resourceId}",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<TbResource>() {},
|
||||
new ParameterizedTypeReference<TbResource>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
@ -2950,7 +2953,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/resource?" + getUrlParams(pageLink),
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<PageData<TbResourceInfo>>() {},
|
||||
new ParameterizedTypeReference<PageData<TbResourceInfo>>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
@ -2967,7 +2971,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/otaPackage/{otaPackageId}/download",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<>() {},
|
||||
new ParameterizedTypeReference<>() {
|
||||
},
|
||||
params
|
||||
);
|
||||
}
|
||||
@ -2980,7 +2985,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/otaPackage/info/{otaPackageId}",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<OtaPackageInfo>() {},
|
||||
new ParameterizedTypeReference<OtaPackageInfo>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
@ -2993,7 +2999,8 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
baseURL + "/api/otaPackage/{otaPackageId}",
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<OtaPackage>() {},
|
||||
new ParameterizedTypeReference<OtaPackage>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
@ -3004,13 +3011,13 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
return restTemplate.postForEntity(baseURL + "/api/otaPackage?isUrl={isUrl}", otaPackageInfo, OtaPackageInfo.class, params).getBody();
|
||||
}
|
||||
|
||||
public OtaPackageInfo saveOtaPackageData(OtaPackageId otaPackageId, String checkSum, ChecksumAlgorithm checksumAlgorithm, MultipartFile file) throws Exception {
|
||||
public OtaPackageInfo saveOtaPackageData(OtaPackageId otaPackageId, String checkSum, ChecksumAlgorithm checksumAlgorithm, String fileName, byte[] fileBytes) throws Exception {
|
||||
HttpHeaders header = new HttpHeaders();
|
||||
header.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||
|
||||
MultiValueMap<String, String> fileMap = new LinkedMultiValueMap<>();
|
||||
fileMap.add(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=file; filename=" + file.getName());
|
||||
HttpEntity<ByteArrayResource> fileEntity = new HttpEntity<>(new ByteArrayResource(file.getBytes()), fileMap);
|
||||
fileMap.add(HttpHeaders.CONTENT_DISPOSITION, "form-data; name=file; filename=" + fileName);
|
||||
HttpEntity<ByteArrayResource> fileEntity = new HttpEntity<>(new ByteArrayResource(fileBytes), fileMap);
|
||||
|
||||
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
|
||||
body.add("file", fileEntity);
|
||||
@ -3068,6 +3075,39 @@ public class RestClient implements ClientHttpRequestInterceptor, Closeable {
|
||||
restTemplate.delete(baseURL + "/api/otaPackage/{otaPackageId}", otaPackageId.getId().toString());
|
||||
}
|
||||
|
||||
public PageData<Queue> getQueuesByServiceType(String serviceType, PageLink pageLink) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("serviceType", serviceType);
|
||||
addPageLinkToParam(params, pageLink);
|
||||
|
||||
return restTemplate.exchange(
|
||||
baseURL + "/api/queues?{serviceType}&" + getUrlParams(pageLink),
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<PageData<Queue>>() {
|
||||
},
|
||||
params
|
||||
).getBody();
|
||||
}
|
||||
|
||||
public Queue getQueueById(QueueId queueId) {
|
||||
return restTemplate.exchange(
|
||||
baseURL + "/api/queue/" + queueId,
|
||||
HttpMethod.GET,
|
||||
HttpEntity.EMPTY,
|
||||
new ParameterizedTypeReference<Queue>() {
|
||||
}
|
||||
).getBody();
|
||||
}
|
||||
|
||||
public Queue saveQueue(Queue queue, String serviceType) {
|
||||
return restTemplate.postForEntity(baseURL + "/api/queues?serviceType=" + serviceType, queue, Queue.class).getBody();
|
||||
}
|
||||
|
||||
public void deleteQueue(QueueId queueId) {
|
||||
restTemplate.delete(baseURL + "/api/queues/" + queueId);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Optional<JsonNode> getAttributes(String accessToken, String clientKeys, String sharedKeys) {
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user