use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class ElasticSearchTemplateRepository method findById.
@Override
public Optional<Template> findById(String namespace, String id) {
BoolQueryBuilder bool = this.defaultFilter().must(QueryBuilders.termQuery("namespace", namespace)).must(QueryBuilders.termQuery("id", id));
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder().query(bool).size(1);
List<Template> query = this.query(INDEX_NAME, sourceBuilder);
return query.size() > 0 ? Optional.of(query.get(0)) : Optional.empty();
}
use of io.kestra.core.models.templates.Template in project kestra by kestra-io.
the class TemplateControllerTest method listDistinctNamespace.
@Test
void listDistinctNamespace() {
List<String> namespaces = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/distinct-namespaces"), Argument.listOf(String.class));
assertThat(namespaces.size(), is(0));
Template t1 = Template.builder().id(IdUtils.create()).namespace("kestra.template.custom").tasks(Arrays.asList(Return.builder().id("task").type(Return.class.getName()).format("test").build())).build();
client.toBlocking().retrieve(POST("/api/v1/templates", t1), Template.class);
client.toBlocking().retrieve(POST("/api/v1/templates", createTemplate()), Template.class);
client.toBlocking().retrieve(POST("/api/v1/templates", createTemplate()), Template.class);
namespaces = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/templates/distinct-namespaces"), Argument.listOf(String.class));
assertThat(namespaces.size(), is(2));
}
Aggregations