From f73284dbcb308a3f7949cc006e260aa878d46157 Mon Sep 17 00:00:00 2001 From: Eric Wittmann Date: Wed, 23 Oct 2024 10:11:10 -0400 Subject: [PATCH] feat(REST API): Added labels to all search results (#5385) * Added labels to all search results. The # of labels is capped to avoid overly large REST responses * Fixed issues with labels on branches (branches do not have labels). --- .../io/apicurio/registry/rest/RestConfig.java | 8 +++ .../apicurio/registry/rest/v3/V3ApiUtil.java | 3 + .../storage/dto/SearchedArtifactDto.java | 3 + .../storage/dto/SearchedGroupDto.java | 3 + .../storage/dto/SearchedVersionDto.java | 3 + .../impl/sql/AbstractSqlRegistryStorage.java | 57 ++++++++++++++++ .../sql/mappers/SearchedArtifactMapper.java | 1 + .../impl/sql/mappers/SearchedGroupMapper.java | 2 + .../sql/mappers/SearchedVersionMapper.java | 1 + app/src/main/resources/application.properties | 1 + .../v3/CappedLabelsInSearchResultsTest.java | 52 +++++++++++++++ .../rest/v3/SearchArtifactsTest.java | 18 ++++- .../noprofile/rest/v3/SearchGroupsTest.java | 5 +- .../noprofile/rest/v3/SearchVersionsTest.java | 66 +++++++++++++++++++ .../src/main/resources/META-INF/openapi.json | 12 ++++ .../ref-registry-all-configs.adoc | 5 ++ go-sdk/pkg/registryclient-v3/kiota-lock.json | 2 +- .../models/searched_artifact.go | 31 +++++++++ .../models/searched_group.go | 31 +++++++++ .../models/searched_version.go | 31 +++++++++ pom.xml | 5 -- 21 files changed, 332 insertions(+), 8 deletions(-) create mode 100644 app/src/test/java/io/apicurio/registry/noprofile/rest/v3/CappedLabelsInSearchResultsTest.java diff --git a/app/src/main/java/io/apicurio/registry/rest/RestConfig.java b/app/src/main/java/io/apicurio/registry/rest/RestConfig.java index 1761cc1fa7..a518b7441f 100644 --- a/app/src/main/java/io/apicurio/registry/rest/RestConfig.java +++ b/app/src/main/java/io/apicurio/registry/rest/RestConfig.java @@ -14,6 +14,10 @@ public class RestConfig { @Info(category = "rest", description = "Max size of the artifact allowed to be downloaded from URL", availableSince = "2.2.6") int downloadMaxSize; + @ConfigProperty(name = "apicurio.rest.search-results.labels.max-size.bytes", defaultValue = "512") + @Info(category = "rest", description = "Max size of the labels (in bytes) per item from within search results", availableSince = "3.0.3") + int labelsInSearchResultsMaxSize; + @ConfigProperty(name = "apicurio.rest.artifact.download.ssl-validation.disabled", defaultValue = "false") @Info(category = "rest", description = "Skip SSL validation when downloading artifacts from URL", availableSince = "2.2.6") boolean downloadSkipSSLValidation; @@ -42,6 +46,10 @@ public int getDownloadMaxSize() { return this.downloadMaxSize; } + public int getLabelsInSearchResultsMaxSize() { + return this.labelsInSearchResultsMaxSize; + } + public boolean getDownloadSkipSSLValidation() { return this.downloadSkipSSLValidation; } diff --git a/app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java b/app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java index 2227926f2d..90df1c8c75 100644 --- a/app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java +++ b/app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java @@ -144,6 +144,7 @@ public static ArtifactSearchResults dtoToSearchResults(ArtifactSearchResultsDto sa.setModifiedOn(artifact.getModifiedOn()); sa.setName(artifact.getName()); sa.setArtifactType(artifact.getArtifactType()); + sa.setLabels(artifact.getLabels()); results.getArtifacts().add(sa); }); return results; @@ -161,6 +162,7 @@ public static GroupSearchResults dtoToSearchResults(GroupSearchResultsDto dto) { sg.setGroupId(group.getId()); sg.setModifiedBy(group.getModifiedBy()); sg.setModifiedOn(group.getModifiedOn()); + sg.setLabels(group.getLabels()); results.getGroups().add(sg); }); return results; @@ -203,6 +205,7 @@ public static VersionSearchResults dtoToSearchResults(VersionSearchResultsDto dt sv.setName(version.getName()); sv.setState(version.getState()); sv.setArtifactType(version.getArtifactType()); + sv.setLabels(version.getLabels()); results.getVersions().add(sv); }); return results; diff --git a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedArtifactDto.java b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedArtifactDto.java index 19f55d3bbd..6f357a7c29 100644 --- a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedArtifactDto.java +++ b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedArtifactDto.java @@ -9,6 +9,7 @@ import lombok.ToString; import java.util.Date; +import java.util.Map; @NoArgsConstructor @AllArgsConstructor @@ -28,4 +29,6 @@ public class SearchedArtifactDto { private String artifactType; private Date modifiedOn; private String modifiedBy; + private Map labels; + } diff --git a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedGroupDto.java b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedGroupDto.java index dadb8e09fd..65989a419d 100644 --- a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedGroupDto.java +++ b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedGroupDto.java @@ -3,6 +3,7 @@ import lombok.*; import java.util.Date; +import java.util.Map; @NoArgsConstructor @AllArgsConstructor @@ -19,4 +20,6 @@ public class SearchedGroupDto { private String owner; private Date modifiedOn; private String modifiedBy; + private Map labels; + } diff --git a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedVersionDto.java b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedVersionDto.java index be50a026a4..f1f40f85b8 100644 --- a/app/src/main/java/io/apicurio/registry/storage/dto/SearchedVersionDto.java +++ b/app/src/main/java/io/apicurio/registry/storage/dto/SearchedVersionDto.java @@ -10,6 +10,7 @@ import lombok.ToString; import java.util.Date; +import java.util.Map; @NoArgsConstructor @AllArgsConstructor @@ -34,4 +35,6 @@ public class SearchedVersionDto { private long globalId; private long contentId; private int versionOrder; + private Map labels; + } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java index 93401300a0..970740e4b9 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/AbstractSqlRegistryStorage.java @@ -23,6 +23,7 @@ import io.apicurio.registry.model.GA; import io.apicurio.registry.model.GAV; import io.apicurio.registry.model.VersionId; +import io.apicurio.registry.rest.RestConfig; import io.apicurio.registry.rules.compatibility.CompatibilityLevel; import io.apicurio.registry.rules.integrity.IntegrityLevel; import io.apicurio.registry.rules.validity.ValidityLevel; @@ -219,6 +220,9 @@ public abstract class AbstractSqlRegistryStorage implements RegistryStorage { @Inject SemVerConfigProperties semVerConfigProps; + @Inject + RestConfig restConfig; + @Inject protected SqlStatements sqlStatements() { @@ -1112,6 +1116,7 @@ public ArtifactSearchResultsDto searchArtifacts(Set filters, Order // Execute artifact query List artifacts = artifactsQuery.map(SearchedArtifactMapper.instance).list(); + limitReturnedLabelsInArtifacts(artifacts); // Execute count query Integer count = countQuery.mapTo(Integer.class).one(); @@ -1736,6 +1741,7 @@ public VersionSearchResultsDto searchVersions(Set filters, OrderBy // Execute query List versions = versionsQuery.map(SearchedVersionMapper.instance).list(); + limitReturnedLabelsInVersions(versions); // Execute count query Integer count = countQuery.mapTo(Integer.class).one(); @@ -2907,6 +2913,8 @@ public GroupSearchResultsDto searchGroups(Set filters, OrderBy ord // Execute query List groups = groupsQuery.map(SearchedGroupMapper.instance).list(); + limitReturnedLabelsInGroups(groups); + // Execute count query Integer count = countQuery.mapTo(Integer.class).one(); @@ -3539,6 +3547,7 @@ public VersionSearchResultsDto getBranchVersions(GA ga, BranchId branchId, int o // Execute query List versions = versionsQuery.map(SearchedVersionMapper.instance).list(); + limitReturnedLabelsInVersions(versions); // Execute count query Integer count = countQuery.mapTo(Integer.class).one(); @@ -3788,4 +3797,52 @@ private boolean isMssql() { private boolean isH2() { return sqlStatements.dbType().equals("h2"); } + + /* + * Ensures that only a reasonable number/size of labels for each item in the list are returned. This is to + * guard against an unexpectedly enormous response size to a REST API search operation. + */ + + private Map limitReturnedLabels(Map labels) { + int maxBytes = restConfig.getLabelsInSearchResultsMaxSize(); + if (labels != null && !labels.isEmpty()) { + Map cappedLabels = new HashMap<>(); + int totalBytes = 0; + for (String key : labels.keySet()) { + if (totalBytes < maxBytes) { + String value = labels.get(key); + cappedLabels.put(key, value); + totalBytes += key.length() + (value != null ? value.length() : 0); + } + } + return cappedLabels; + } + + return null; + } + + private void limitReturnedLabelsInGroups(List groups) { + groups.forEach(group -> { + Map labels = group.getLabels(); + Map cappedLabels = limitReturnedLabels(labels); + group.setLabels(cappedLabels); + }); + } + + private void limitReturnedLabelsInArtifacts(List artifacts) { + artifacts.forEach(artifact -> { + Map labels = artifact.getLabels(); + Map cappedLabels = limitReturnedLabels(labels); + artifact.setLabels(cappedLabels); + }); + } + + private void limitReturnedLabelsInVersions(List versions) { + versions.forEach(version -> { + Map labels = version.getLabels(); + Map cappedLabels = limitReturnedLabels(labels); + version.setLabels(cappedLabels); + }); + } + } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedArtifactMapper.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedArtifactMapper.java index ef95cf0ce2..831d046ae3 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedArtifactMapper.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedArtifactMapper.java @@ -32,6 +32,7 @@ public SearchedArtifactDto map(ResultSet rs) throws SQLException { dto.setModifiedBy(rs.getString("modifiedBy")); dto.setModifiedOn(rs.getTimestamp("modifiedOn")); dto.setArtifactType(rs.getString("type")); + dto.setLabels(RegistryContentUtils.deserializeLabels(rs.getString("labels"))); return dto; } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedGroupMapper.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedGroupMapper.java index 22d608813c..1d64908a20 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedGroupMapper.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedGroupMapper.java @@ -1,6 +1,7 @@ package io.apicurio.registry.storage.impl.sql.mappers; import io.apicurio.registry.storage.dto.SearchedGroupDto; +import io.apicurio.registry.storage.impl.sql.RegistryContentUtils; import io.apicurio.registry.storage.impl.sql.jdb.RowMapper; import java.sql.ResultSet; @@ -28,6 +29,7 @@ public SearchedGroupDto map(ResultSet rs) throws SQLException { dto.setDescription(rs.getString("description")); dto.setModifiedBy(rs.getString("modifiedBy")); dto.setModifiedOn(rs.getTimestamp("modifiedOn")); + dto.setLabels(RegistryContentUtils.deserializeLabels(rs.getString("labels"))); return dto; } } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedVersionMapper.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedVersionMapper.java index ef97a07bed..ee4cc948a2 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedVersionMapper.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/SearchedVersionMapper.java @@ -38,6 +38,7 @@ public SearchedVersionDto map(ResultSet rs) throws SQLException { dto.setName(rs.getString("name")); dto.setDescription(rs.getString("description")); dto.setArtifactType(rs.getString("type")); + dto.setLabels(RegistryContentUtils.deserializeLabels(rs.getString("labels"))); return dto; } diff --git a/app/src/main/resources/application.properties b/app/src/main/resources/application.properties index 7da8640561..fdeed7fd64 100644 --- a/app/src/main/resources/application.properties +++ b/app/src/main/resources/application.properties @@ -150,6 +150,7 @@ apicurio.redirects.root=/,/apis apicurio.rest.artifact.download.max-size.bytes=1000000 apicurio.rest.artifact.download.ssl-validation.disabled=false apicurio.rest.artifact.deletion.enabled=false +apicurio.rest.search-results.labels.max-size.bytes=512 # Api date format apicurio.apis.date-format=yyyy-MM-dd'T'HH:mm:ss'Z' apicurio.apis.date-format-timezone=UTC diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/CappedLabelsInSearchResultsTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/CappedLabelsInSearchResultsTest.java new file mode 100644 index 0000000000..d68d551289 --- /dev/null +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/CappedLabelsInSearchResultsTest.java @@ -0,0 +1,52 @@ +package io.apicurio.registry.noprofile.rest.v3; + +import io.apicurio.registry.AbstractResourceTestBase; +import io.apicurio.registry.rest.client.models.CreateGroup; +import io.apicurio.registry.rest.client.models.GroupMetaData; +import io.apicurio.registry.rest.client.models.GroupSearchResults; +import io.apicurio.registry.rest.client.models.Labels; +import io.apicurio.registry.utils.tests.TestUtils; +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; + +@QuarkusTest +public class CappedLabelsInSearchResultsTest extends AbstractResourceTestBase { + + @Test + public void testCappedLabelsInGroupSearch() throws Exception { + String groupId = TestUtils.generateGroupId(); + + // Lots of labels! Too many labels. + Labels labels = new Labels(); + labels.setAdditionalData(new HashMap<>()); + for (int idx = 1000; idx < 1500; idx++) { + labels.getAdditionalData().put("test-key-" + idx, "test-value-" + idx); + } + + // Create a group with all these labels. + CreateGroup createGroup = new CreateGroup(); + createGroup.setGroupId(groupId); + createGroup.setLabels(labels); + clientV3.groups().post(createGroup); + + // Get the group meta data + GroupMetaData gmd = clientV3.groups().byGroupId(groupId).get(); + Assertions.assertNotNull(gmd); + Assertions.assertEquals(groupId, gmd.getGroupId()); + Assertions.assertNotNull(gmd.getLabels()); + Assertions.assertEquals(500, gmd.getLabels().getAdditionalData().size()); + + // Search for the group. + GroupSearchResults results = clientV3.search().groups().get(request -> { + request.queryParameters.groupId = groupId; + }); + Assertions.assertEquals(1, results.getGroups().size()); + + Assertions.assertNotNull(results.getGroups().get(0).getLabels()); + // Only 19 labels are returned due to the cap/limit enforced on returning labels in searches + Assertions.assertEquals(19, results.getGroups().get(0).getLabels().getAdditionalData().size()); + } +} diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchArtifactsTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchArtifactsTest.java index 6ebc7499d7..28fe63f66c 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchArtifactsTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchArtifactsTest.java @@ -1,10 +1,13 @@ package io.apicurio.registry.noprofile.rest.v3; import io.apicurio.registry.AbstractResourceTestBase; +import io.apicurio.registry.rest.client.models.ArtifactSearchResults; import io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData; import io.apicurio.registry.types.ArtifactType; import io.apicurio.registry.types.ContentTypes; +import io.apicurio.registry.utils.tests.TestUtils; import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.HashMap; @@ -95,7 +98,7 @@ public void testSearchArtifactsByDescription() throws Exception { @Test public void testSearchArtifactsByLabels() throws Exception { - String group = UUID.randomUUID().toString(); + String group = TestUtils.generateGroupId(); String artifactContent = resourceToString("openapi-empty.json"); // Create 5 artifacts with various labels @@ -152,6 +155,19 @@ public void testSearchArtifactsByLabels() throws Exception { .statusCode(400); given().when().queryParam("labels", "all-key:").get("/registry/v3/search/artifacts").then() .statusCode(400); + + // Test that search results contain the labels + ArtifactSearchResults results = clientV3.search().artifacts().get(conf -> { + conf.queryParameters.groupId = group; + conf.queryParameters.labels = new String[] { "key-1:value-1" }; + }); + Assertions.assertNotNull(results); + Assertions.assertEquals(1, results.getArtifacts().size()); + Assertions.assertNotNull(results.getArtifacts().get(0).getLabels()); + Assertions.assertEquals( + Map.of("key-1", "value-1", "another-key-1", "another-value-1", "all-key", "all-value", + "a-key-1", "lorem ipsum", "extra-key-1", "lorem ipsum"), + results.getArtifacts().get(0).getLabels().getAdditionalData()); } @Test diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchGroupsTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchGroupsTest.java index 9b4731009c..e715a759f7 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchGroupsTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchGroupsTest.java @@ -79,6 +79,10 @@ public void testSearchGroupsByLabels() throws Exception { request.queryParameters.groupId = groupId + "1"; }); Assertions.assertEquals(1, results.getGroups().size()); + // Note: ensure that labels are returned in the search results + Assertions.assertNotNull(results.getGroups().get(0).getLabels()); + Assertions.assertEquals(Map.of("byLabels", "byLabels-value-1", "byLabels-1", "byLabels-value-1"), + results.getGroups().get(0).getLabels().getAdditionalData()); results = clientV3.search().groups().get(request -> { request.queryParameters.labels = new String[] { "byLabels" }; @@ -109,5 +113,4 @@ public void testSearchGroupsByLabels() throws Exception { Assertions.assertEquals(1, results.getGroups().size()); Assertions.assertEquals("testSearchGroupsByLabels3", results.getGroups().get(0).getGroupId()); } - } diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchVersionsTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchVersionsTest.java index bef834c604..0bcced4dde 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchVersionsTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchVersionsTest.java @@ -2,6 +2,8 @@ import io.apicurio.registry.AbstractResourceTestBase; import io.apicurio.registry.rest.client.models.CreateArtifactResponse; +import io.apicurio.registry.rest.client.models.EditableVersionMetaData; +import io.apicurio.registry.rest.client.models.Labels; import io.apicurio.registry.rest.client.models.SearchedVersion; import io.apicurio.registry.rest.client.models.VersionSearchResults; import io.apicurio.registry.types.ArtifactType; @@ -11,6 +13,8 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.util.Map; + @QuarkusTest public class SearchVersionsTest extends AbstractResourceTestBase { @@ -237,4 +241,66 @@ public void testSearchVersionsByIds() throws Exception { Assertions.assertEquals(1, results.getCount()); } + @Test + public void testSearchVersionsByLabels() throws Exception { + String artifactContent = "testSearchVersionsByLabels-content"; + String group1 = TestUtils.generateGroupId(); + String group2 = TestUtils.generateGroupId(); + + CreateArtifactResponse car = null; + + // Create 5 artifacts in group 1 (two versions each) + for (int idx = 0; idx < 5; idx++) { + String artifactId = "testSearchVersionsByIds_Group1_Artifact_" + idx; + car = createArtifact(group1, artifactId, ArtifactType.OPENAPI, artifactContent, + ContentTypes.APPLICATION_JSON); + createArtifactVersion(group1, artifactId, artifactContent, ContentTypes.APPLICATION_JSON); + + // Add labels to some versions + EditableVersionMetaData emd = new EditableVersionMetaData(); + emd.setLabels(new Labels()); + emd.getLabels().setAdditionalData(Map.of("id", artifactId, "key-" + idx, "value-" + idx)); + clientV3.groups().byGroupId(group1).artifacts().byArtifactId(artifactId).versions() + .byVersionExpression(car.getVersion().getVersion()).put(emd); + } + + // Create 3 artifacts in group 2 + for (int idx = 0; idx < 3; idx++) { + String artifactId = "testSearchVersionsByIds_Group2_Artifact_" + idx; + car = createArtifact(group2, artifactId, ArtifactType.OPENAPI, artifactContent, + ContentTypes.APPLICATION_JSON); + + // Add labels to some versions + EditableVersionMetaData emd = new EditableVersionMetaData(); + emd.setLabels(new Labels()); + emd.getLabels().setAdditionalData(Map.of("id", artifactId, "key-" + idx, "value-" + idx)); + clientV3.groups().byGroupId(group2).artifacts().byArtifactId(artifactId).versions() + .byVersionExpression(car.getVersion().getVersion()).put(emd); + } + + VersionSearchResults results = clientV3.search().versions().get(config -> { + config.queryParameters.labels = new String[] { "key-1" }; + }); + Assertions.assertEquals(2, results.getCount()); + + results = clientV3.search().versions().get(config -> { + config.queryParameters.labels = new String[] { "key-1:value-1" }; + }); + Assertions.assertEquals(2, results.getCount()); + + results = clientV3.search().versions().get(config -> { + config.queryParameters.labels = new String[] { "key-1:value-2" }; + }); + Assertions.assertEquals(0, results.getCount()); + + results = clientV3.search().versions().get(config -> { + config.queryParameters.labels = new String[] { "id:testSearchVersionsByIds_Group1_Artifact_1" }; + }); + Assertions.assertEquals(1, results.getCount()); + // Check that labels are return in search results. + Assertions.assertNotNull(results.getVersions().get(0).getLabels()); + Assertions.assertEquals(Map.of("key-1", "value-1", "id", "testSearchVersionsByIds_Group1_Artifact_1"), + results.getVersions().get(0).getLabels().getAdditionalData()); + } + } diff --git a/common/src/main/resources/META-INF/openapi.json b/common/src/main/resources/META-INF/openapi.json index 01f25f3144..b3f39d737b 100644 --- a/common/src/main/resources/META-INF/openapi.json +++ b/common/src/main/resources/META-INF/openapi.json @@ -3934,6 +3934,10 @@ "artifactId": { "$ref": "#/components/schemas/ArtifactId", "description": "" + }, + "labels": { + "$ref": "#/components/schemas/Labels", + "description": "" } }, "example": { @@ -4104,6 +4108,10 @@ "format": "date-time", "description": "", "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/Labels", + "description": "" } }, "example": { @@ -4351,6 +4359,10 @@ "groupId": { "$ref": "#/components/schemas/GroupId", "description": "" + }, + "labels": { + "$ref": "#/components/schemas/Labels", + "description": "" } }, "example": { diff --git a/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc b/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc index ba89c145ed..82679453f9 100644 --- a/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc +++ b/docs/modules/ROOT/partials/getting-started/ref-registry-all-configs.adoc @@ -557,6 +557,11 @@ The following {registry} configuration options are available for each component |`false` |`3.0.2` |Enables artifact version mutability +|`apicurio.rest.search-results.labels.max-size.bytes` +|`int` +|`512` +|`3.0.3` +|Max size of the labels (in bytes) per item from within search results |=== == semver diff --git a/go-sdk/pkg/registryclient-v3/kiota-lock.json b/go-sdk/pkg/registryclient-v3/kiota-lock.json index f4afc6c6b1..3dadd4f107 100644 --- a/go-sdk/pkg/registryclient-v3/kiota-lock.json +++ b/go-sdk/pkg/registryclient-v3/kiota-lock.json @@ -1,5 +1,5 @@ { - "descriptionHash": "00581DCACB1B1D7CFE571A59235CDC2AE7CA2C5158E25D26D03F23337D82CC23EFFD219AFAF562BB50AA94EFB196FFED7150C31C23BBB22910B7AD366AC7FF2D", + "descriptionHash": "D346A2A9A40F1B86E55F338BFB56645B0AE0D95EF3B3E66B14920108B20F119845B8EF22305D5C70D8DFDCC4BA0E39B5A78BD1F19D81AB90587F206B2470163D", "descriptionLocation": "../../v3.json", "lockFileVersion": "1.0.0", "kiotaVersion": "1.19.1", diff --git a/go-sdk/pkg/registryclient-v3/models/searched_artifact.go b/go-sdk/pkg/registryclient-v3/models/searched_artifact.go index 9f32bb61dd..4b4269b33f 100644 --- a/go-sdk/pkg/registryclient-v3/models/searched_artifact.go +++ b/go-sdk/pkg/registryclient-v3/models/searched_artifact.go @@ -19,6 +19,8 @@ type SearchedArtifact struct { description *string // An ID of a single artifact group. groupId *string + // User-defined name-value pairs. Name and value must be strings. + labels Labelsable // The modifiedBy property modifiedBy *string // The modifiedOn property @@ -126,6 +128,16 @@ func (m *SearchedArtifact) GetFieldDeserializers() map[string]func(i878a80d2330e } return nil } + res["labels"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { + val, err := n.GetObjectValue(CreateLabelsFromDiscriminatorValue) + if err != nil { + return err + } + if val != nil { + m.SetLabels(val.(Labelsable)) + } + return nil + } res["modifiedBy"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetStringValue() if err != nil { @@ -175,6 +187,12 @@ func (m *SearchedArtifact) GetGroupId() *string { return m.groupId } +// GetLabels gets the labels property value. User-defined name-value pairs. Name and value must be strings. +// returns a Labelsable when successful +func (m *SearchedArtifact) GetLabels() Labelsable { + return m.labels +} + // GetModifiedBy gets the modifiedBy property value. The modifiedBy property // returns a *string when successful func (m *SearchedArtifact) GetModifiedBy() *string { @@ -231,6 +249,12 @@ func (m *SearchedArtifact) Serialize(writer i878a80d2330e89d26896388a3f487eef27b return err } } + { + err := writer.WriteObjectValue("labels", m.GetLabels()) + if err != nil { + return err + } + } { err := writer.WriteStringValue("modifiedBy", m.GetModifiedBy()) if err != nil { @@ -294,6 +318,11 @@ func (m *SearchedArtifact) SetGroupId(value *string) { m.groupId = value } +// SetLabels sets the labels property value. User-defined name-value pairs. Name and value must be strings. +func (m *SearchedArtifact) SetLabels(value Labelsable) { + m.labels = value +} + // SetModifiedBy sets the modifiedBy property value. The modifiedBy property func (m *SearchedArtifact) SetModifiedBy(value *string) { m.modifiedBy = value @@ -322,6 +351,7 @@ type SearchedArtifactable interface { GetCreatedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time GetDescription() *string GetGroupId() *string + GetLabels() Labelsable GetModifiedBy() *string GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time GetName() *string @@ -331,6 +361,7 @@ type SearchedArtifactable interface { SetCreatedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) SetDescription(value *string) SetGroupId(value *string) + SetLabels(value Labelsable) SetModifiedBy(value *string) SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) SetName(value *string) diff --git a/go-sdk/pkg/registryclient-v3/models/searched_group.go b/go-sdk/pkg/registryclient-v3/models/searched_group.go index c1424294b0..7deba27a42 100644 --- a/go-sdk/pkg/registryclient-v3/models/searched_group.go +++ b/go-sdk/pkg/registryclient-v3/models/searched_group.go @@ -15,6 +15,8 @@ type SearchedGroup struct { description *string // An ID of a single artifact group. groupId *string + // User-defined name-value pairs. Name and value must be strings. + labels Labelsable // The modifiedBy property modifiedBy *string // The modifiedOn property @@ -88,6 +90,16 @@ func (m *SearchedGroup) GetFieldDeserializers() map[string]func(i878a80d2330e89d } return nil } + res["labels"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { + val, err := n.GetObjectValue(CreateLabelsFromDiscriminatorValue) + if err != nil { + return err + } + if val != nil { + m.SetLabels(val.(Labelsable)) + } + return nil + } res["modifiedBy"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetStringValue() if err != nil { @@ -127,6 +139,12 @@ func (m *SearchedGroup) GetGroupId() *string { return m.groupId } +// GetLabels gets the labels property value. User-defined name-value pairs. Name and value must be strings. +// returns a Labelsable when successful +func (m *SearchedGroup) GetLabels() Labelsable { + return m.labels +} + // GetModifiedBy gets the modifiedBy property value. The modifiedBy property // returns a *string when successful func (m *SearchedGroup) GetModifiedBy() *string { @@ -165,6 +183,12 @@ func (m *SearchedGroup) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0 return err } } + { + err := writer.WriteObjectValue("labels", m.GetLabels()) + if err != nil { + return err + } + } { err := writer.WriteStringValue("modifiedBy", m.GetModifiedBy()) if err != nil { @@ -212,6 +236,11 @@ func (m *SearchedGroup) SetGroupId(value *string) { m.groupId = value } +// SetLabels sets the labels property value. User-defined name-value pairs. Name and value must be strings. +func (m *SearchedGroup) SetLabels(value Labelsable) { + m.labels = value +} + // SetModifiedBy sets the modifiedBy property value. The modifiedBy property func (m *SearchedGroup) SetModifiedBy(value *string) { m.modifiedBy = value @@ -233,12 +262,14 @@ type SearchedGroupable interface { GetCreatedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time GetDescription() *string GetGroupId() *string + GetLabels() Labelsable GetModifiedBy() *string GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time GetOwner() *string SetCreatedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) SetDescription(value *string) SetGroupId(value *string) + SetLabels(value Labelsable) SetModifiedBy(value *string) SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) SetOwner(value *string) diff --git a/go-sdk/pkg/registryclient-v3/models/searched_version.go b/go-sdk/pkg/registryclient-v3/models/searched_version.go index 366986021d..f12248592c 100644 --- a/go-sdk/pkg/registryclient-v3/models/searched_version.go +++ b/go-sdk/pkg/registryclient-v3/models/searched_version.go @@ -23,6 +23,8 @@ type SearchedVersion struct { globalId *int64 // An ID of a single artifact group. groupId *string + // User-defined name-value pairs. Name and value must be strings. + labels Labelsable // The modifiedBy property modifiedBy *string // The modifiedOn property @@ -160,6 +162,16 @@ func (m *SearchedVersion) GetFieldDeserializers() map[string]func(i878a80d2330e8 } return nil } + res["labels"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { + val, err := n.GetObjectValue(CreateLabelsFromDiscriminatorValue) + if err != nil { + return err + } + if val != nil { + m.SetLabels(val.(Labelsable)) + } + return nil + } res["modifiedBy"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetStringValue() if err != nil { @@ -235,6 +247,12 @@ func (m *SearchedVersion) GetGroupId() *string { return m.groupId } +// GetLabels gets the labels property value. User-defined name-value pairs. Name and value must be strings. +// returns a Labelsable when successful +func (m *SearchedVersion) GetLabels() Labelsable { + return m.labels +} + // GetModifiedBy gets the modifiedBy property value. The modifiedBy property // returns a *string when successful func (m *SearchedVersion) GetModifiedBy() *string { @@ -315,6 +333,12 @@ func (m *SearchedVersion) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0 return err } } + { + err := writer.WriteObjectValue("labels", m.GetLabels()) + if err != nil { + return err + } + } { err := writer.WriteStringValue("modifiedBy", m.GetModifiedBy()) if err != nil { @@ -401,6 +425,11 @@ func (m *SearchedVersion) SetGroupId(value *string) { m.groupId = value } +// SetLabels sets the labels property value. User-defined name-value pairs. Name and value must be strings. +func (m *SearchedVersion) SetLabels(value Labelsable) { + m.labels = value +} + // SetModifiedBy sets the modifiedBy property value. The modifiedBy property func (m *SearchedVersion) SetModifiedBy(value *string) { m.modifiedBy = value @@ -441,6 +470,7 @@ type SearchedVersionable interface { GetDescription() *string GetGlobalId() *int64 GetGroupId() *string + GetLabels() Labelsable GetModifiedBy() *string GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time GetName() *string @@ -454,6 +484,7 @@ type SearchedVersionable interface { SetDescription(value *string) SetGlobalId(value *int64) SetGroupId(value *string) + SetLabels(value Labelsable) SetModifiedBy(value *string) SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) SetName(value *string) diff --git a/pom.xml b/pom.xml index 9ba3179358..8cfeee507e 100644 --- a/pom.xml +++ b/pom.xml @@ -923,11 +923,6 @@ maven-clean-plugin ${version.clean.plugin} - - io.gatling - gatling-maven-plugin - ${version.gatling.plugin} - net.alchim31.maven scala-maven-plugin