From 6606e1947a3beee8b2b3a1bc778535bbd1b6a7c3 Mon Sep 17 00:00:00 2001 From: Eric Wittmann Date: Fri, 9 Feb 2024 09:42:53 -0500 Subject: [PATCH] Updated the REST API to allow updating group metadata (with labels) --- .../impl/SchemagroupsResourceImpl.java | 12 +- .../events/EventSourcedRegistryStorage.java | 10 +- .../registry/rest/v2/GroupsResourceImpl.java | 4 +- .../registry/rest/v3/GroupsResourceImpl.java | 27 ++- .../registry/storage/RegistryStorage.java | 17 +- .../ReadOnlyRegistryStorageDecorator.java | 16 +- .../RegistryStorageDecoratorBase.java | 13 +- .../storage/dto/EditableGroupMetaDataDto.java | 26 +++ .../AbstractReadOnlyRegistryStorage.java | 9 +- .../kafkasql/KafkaSqlRegistryStorage.java | 20 +- .../impl/kafkasql/KafkaSqlSubmitter.java | 69 ++++-- .../impl/kafkasql/sql/KafkaSqlSink.java | 76 ++++-- .../impl/kafkasql/values/GroupValue.java | 4 +- .../impl/sql/AbstractSqlRegistryStorage.java | 76 ++++-- .../storage/impl/sql/CommonSqlStatements.java | 10 +- .../storage/impl/sql/SqlStatements.java | 6 + .../registry/auth/SimpleAuthTest.java | 7 +- .../apicurio/registry/limits/LimitsTest.java | 6 +- .../noprofile/ArtifactSearchTest.java | 4 +- .../registry/noprofile/ArtifactStateTest.java | 2 +- .../noprofile/rest/v3/GroupsResourceTest.java | 6 +- .../noprofile/rest/v3/SearchResourceTest.java | 6 +- .../registry/rbac/RegistryClientTest.java | 8 +- .../readonly/ReadOnlyRegistryStorageTest.java | 3 +- .../src/main/resources/META-INF/openapi.json | 219 +++++++++++------- ...tem_artifacts_item_meta_request_builder.go | 4 +- ...item_versions_item_meta_request_builder.go | 4 +- .../groups/with_group_item_request_builder.go | 40 ++++ go-sdk/pkg/registryclient-v3/kiota-lock.json | 2 +- ...data.go => editable_artifact_meta_data.go} | 40 ++-- .../models/editable_group_meta_data.go | 116 ++++++++++ .../tests/smokeTests/apicurio/MetadataIT.java | 6 +- 32 files changed, 643 insertions(+), 225 deletions(-) create mode 100644 app/src/main/java/io/apicurio/registry/storage/dto/EditableGroupMetaDataDto.java rename go-sdk/pkg/registryclient-v3/models/{editable_meta_data.go => editable_artifact_meta_data.go} (68%) create mode 100644 go-sdk/pkg/registryclient-v3/models/editable_group_meta_data.go diff --git a/app/src/main/java/io/apicurio/registry/cncf/schemaregistry/impl/SchemagroupsResourceImpl.java b/app/src/main/java/io/apicurio/registry/cncf/schemaregistry/impl/SchemagroupsResourceImpl.java index 370b9f3cce..11f33acf29 100644 --- a/app/src/main/java/io/apicurio/registry/cncf/schemaregistry/impl/SchemagroupsResourceImpl.java +++ b/app/src/main/java/io/apicurio/registry/cncf/schemaregistry/impl/SchemagroupsResourceImpl.java @@ -96,14 +96,12 @@ public void createGroup(String groupId, SchemaGroup data) { storage.createGroup(group.build()); } catch (GroupAlreadyExistsException e) { - GroupMetaDataDto existing = storage.getGroupMetaData(groupId); + EditableGroupMetaDataDto dto = EditableGroupMetaDataDto.builder() + .description(data.getDescription()) + .labels(data.getGroupProperties()) + .build(); - group.createdBy(existing.getCreatedBy()) - .createdOn(existing.getCreatedOn()) - .modifiedBy(user) - .modifiedOn(new Date().getTime()); - - storage.updateGroupMetaData(group.build()); + storage.updateGroupMetaData(groupId, dto); } } diff --git a/app/src/main/java/io/apicurio/registry/events/EventSourcedRegistryStorage.java b/app/src/main/java/io/apicurio/registry/events/EventSourcedRegistryStorage.java index 9b555add38..1905a8306c 100644 --- a/app/src/main/java/io/apicurio/registry/events/EventSourcedRegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/events/EventSourcedRegistryStorage.java @@ -251,14 +251,14 @@ public void createGroup(GroupMetaDataDto group) throws GroupAlreadyExistsExcepti } /** - * @see io.apicurio.registry.storage.RegistryStorage#updateGroupMetaData(io.apicurio.registry.storage.dto.GroupMetaDataDto) + * @see io.apicurio.registry.storage.decorator.RegistryStorageDecoratorBase#updateGroupMetaData(java.lang.String, io.apicurio.registry.storage.dto.EditableGroupMetaDataDto) */ @Override - public void updateGroupMetaData(GroupMetaDataDto group) throws GroupNotFoundException, RegistryStorageException { - delegate.updateGroupMetaData(group); + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto) throws GroupNotFoundException, RegistryStorageException { + delegate.updateGroupMetaData(groupId, dto); ArtifactId data = new ArtifactId(); - data.setGroupId(group.getGroupId()); - fireEvent(RegistryEventType.GROUP_UPDATED, group.getGroupId(), data, null); + data.setGroupId(groupId); + fireEvent(RegistryEventType.GROUP_UPDATED, groupId, data, null); } /** diff --git a/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java b/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java index 75e78734ff..011edfbb4a 100644 --- a/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java +++ b/app/src/main/java/io/apicurio/registry/rest/v2/GroupsResourceImpl.java @@ -211,7 +211,7 @@ public ArtifactMetaData getArtifactMetaData(String groupId, String artifactId) { @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", KEY_EDITABLE_METADATA}) @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) public void updateArtifactMetaData(String groupId, String artifactId, EditableMetaData data) { - v3.updateArtifactMetaData(groupId, artifactId, io.apicurio.registry.rest.v3.beans.EditableMetaData.builder() + v3.updateArtifactMetaData(groupId, artifactId, io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData.builder() .description(data.getDescription()) .labels(V2ApiUtil.toV3Labels(data.getLabels(), data.getProperties())) .name(data.getName()) @@ -538,7 +538,7 @@ public VersionMetaData getArtifactVersionMetaData(String groupId, String artifac @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", KEY_VERSION, "3", KEY_EDITABLE_METADATA}) @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) public void updateArtifactVersionMetaData(String groupId, String artifactId, String version, EditableMetaData data) { - v3.updateArtifactVersionMetaData(groupId, artifactId, version, io.apicurio.registry.rest.v3.beans.EditableMetaData.builder() + v3.updateArtifactVersionMetaData(groupId, artifactId, version, io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData.builder() .description(data.getDescription()) .labels(V2ApiUtil.toV3Labels(data.getLabels(), data.getProperties())) .name(data.getName()) diff --git a/app/src/main/java/io/apicurio/registry/rest/v3/GroupsResourceImpl.java b/app/src/main/java/io/apicurio/registry/rest/v3/GroupsResourceImpl.java index 39e1a9a15b..3a2b9c2757 100644 --- a/app/src/main/java/io/apicurio/registry/rest/v3/GroupsResourceImpl.java +++ b/app/src/main/java/io/apicurio/registry/rest/v3/GroupsResourceImpl.java @@ -34,7 +34,6 @@ import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.interceptor.Interceptors; -import jakarta.validation.constraints.NotNull; import jakarta.ws.rs.BadRequestException; import jakarta.ws.rs.HttpMethod; import jakarta.ws.rs.NotAllowedException; @@ -216,7 +215,7 @@ public ArtifactMetaData getArtifactMetaData(String groupId, String artifactId) { @Override @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", KEY_EDITABLE_METADATA}) @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) - public void updateArtifactMetaData(String groupId, String artifactId, EditableMetaData data) { + public void updateArtifactMetaData(String groupId, String artifactId, EditableArtifactMetaData data) { requireParameter("groupId", groupId); requireParameter("artifactId", artifactId); @@ -267,6 +266,19 @@ public GroupMetaData getGroupById(String groupId) { public void deleteGroupById(String groupId) { storage.deleteGroup(groupId); } + + /** + * @see io.apicurio.registry.rest.v3.GroupsResource#updateGroupById(java.lang.String, io.apicurio.registry.rest.v3.beans.EditableGroupMetaData) + */ + @Override + public void updateGroupById(String groupId, EditableGroupMetaData data) { + requireParameter("groupId", groupId); + + EditableGroupMetaDataDto dto = new EditableGroupMetaDataDto(); + dto.setDescription(data.getDescription()); + dto.setLabels(data.getLabels()); + storage.updateGroupMetaData(new GroupId(groupId).getRawGroupIdWithNull(), dto); + } @Override @Authorized(style = AuthorizedStyle.None, level = AuthorizedLevel.Read) @@ -551,12 +563,12 @@ public VersionMetaData getArtifactVersionMetaData(String groupId, String artifac } /** - * @see io.apicurio.registry.rest.v3.GroupsResource#updateArtifactVersionMetaData(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.EditableMetaData) + * @see io.apicurio.registry.rest.v3.GroupsResource#updateArtifactVersionMetaData(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData) */ @Override @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", KEY_VERSION, "3", KEY_EDITABLE_METADATA}) @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) - public void updateArtifactVersionMetaData(String groupId, String artifactId, String versionExpression, EditableMetaData data) { + public void updateArtifactVersionMetaData(String groupId, String artifactId, String versionExpression, EditableArtifactMetaData data) { requireParameter("groupId", groupId); requireParameter("artifactId", artifactId); requireParameter("versionExpression", versionExpression); @@ -1022,10 +1034,13 @@ public ArtifactBranch getArtifactBranch(String groupId, String artifactId, Strin } + /** + * @see io.apicurio.registry.rest.v3.GroupsResource#createOrUpdateArtifactBranch(java.lang.String, java.lang.String, java.lang.String, java.lang.String) + */ @Override @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", "branch_id", "3", KEY_VERSION}) // TODO @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) - public ArtifactBranch createOrUpdateArtifactBranch(String groupId, String artifactId, String rawBranchId, @NotNull String version) { + public ArtifactBranch createOrUpdateArtifactBranch(String groupId, String artifactId, String rawBranchId, String version) { requireParameter("groupId", groupId); requireParameter("artifactId", artifactId); requireParameter("branchId", rawBranchId); @@ -1053,7 +1068,7 @@ public ArtifactBranch createOrUpdateArtifactBranch(String groupId, String artifa @Override @Audited(extractParameters = {"0", KEY_GROUP_ID, "1", KEY_ARTIFACT_ID, "2", "branch_id", "3", "branch"}) // TODO @Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Write) - public ArtifactBranch createOrReplaceArtifactBranch(String groupId, String artifactId, String rawBranchId, @NotNull ArtifactBranch branch) { + public ArtifactBranch createOrReplaceArtifactBranch(String groupId, String artifactId, String rawBranchId, ArtifactBranch branch) { requireParameter("groupId", groupId); requireParameter("artifactId", artifactId); requireParameter("branchId", rawBranchId); diff --git a/app/src/main/java/io/apicurio/registry/storage/RegistryStorage.java b/app/src/main/java/io/apicurio/registry/storage/RegistryStorage.java index 01536fcab2..3f5bf6feaf 100644 --- a/app/src/main/java/io/apicurio/registry/storage/RegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/storage/RegistryStorage.java @@ -559,14 +559,6 @@ void updateArtifactRule(String groupId, String artifactId, RuleType rule, RuleCo */ void createGroup(GroupMetaDataDto group) throws GroupAlreadyExistsException, RegistryStorageException; - /** - * Updates the metadata of an existent group. - * - * @param group - * @throws RegistryStorageException - */ - void updateGroupMetaData(GroupMetaDataDto group) throws GroupNotFoundException, RegistryStorageException; - /** * Deletes a group identified by the given groupId and DELETES ALL resources related to this group * @@ -576,6 +568,14 @@ void updateArtifactRule(String groupId, String artifactId, RuleType rule, RuleCo */ void deleteGroup(String groupId) throws GroupNotFoundException, RegistryStorageException; + /** + * Updates the metadata for a group. + * @param groupId + * @param dto + */ + void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto); + void updateGroupMetaData(String groupId, String description, Map labels, String modifiedBy, Date modifiedOn); + /** * Get all groupIds * @@ -950,4 +950,5 @@ enum ArtifactRetrievalBehavior { */ SKIP_DISABLED_LATEST } + } diff --git a/app/src/main/java/io/apicurio/registry/storage/decorator/ReadOnlyRegistryStorageDecorator.java b/app/src/main/java/io/apicurio/registry/storage/decorator/ReadOnlyRegistryStorageDecorator.java index af6224be22..b2caff27aa 100644 --- a/app/src/main/java/io/apicurio/registry/storage/decorator/ReadOnlyRegistryStorageDecorator.java +++ b/app/src/main/java/io/apicurio/registry/storage/decorator/ReadOnlyRegistryStorageDecorator.java @@ -21,6 +21,7 @@ import java.util.Date; import java.util.List; +import java.util.Map; import java.util.function.Supplier; @ApplicationScoped @@ -241,11 +242,20 @@ public void createGroup(GroupMetaDataDto group) throws GroupAlreadyExistsExcepti delegate.createGroup(group); } - + + @Override + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto) { + checkReadOnly(); + delegate.updateGroupMetaData(groupId, dto); + } + + /** + * @see io.apicurio.registry.storage.RegistryStorage#updateGroupMetaData(java.lang.String, java.lang.String, java.util.Map, java.lang.String, java.util.Date) + */ @Override - public void updateGroupMetaData(GroupMetaDataDto group) throws GroupNotFoundException, RegistryStorageException { + public void updateGroupMetaData(String groupId, String description, Map labels, String modifiedBy, Date modifiedOn) { checkReadOnly(); - delegate.updateGroupMetaData(group); + delegate.updateGroupMetaData(groupId, description, labels, modifiedBy, modifiedOn); } diff --git a/app/src/main/java/io/apicurio/registry/storage/decorator/RegistryStorageDecoratorBase.java b/app/src/main/java/io/apicurio/registry/storage/decorator/RegistryStorageDecoratorBase.java index b527c84758..2af1dd53ee 100644 --- a/app/src/main/java/io/apicurio/registry/storage/decorator/RegistryStorageDecoratorBase.java +++ b/app/src/main/java/io/apicurio/registry/storage/decorator/RegistryStorageDecoratorBase.java @@ -16,6 +16,7 @@ import java.util.Date; import java.util.List; +import java.util.Map; /** * Forwards all method calls to the delegate, extends the read-only base. @@ -188,9 +189,15 @@ public void createGroup(GroupMetaDataDto group) @Override - public void updateGroupMetaData(GroupMetaDataDto group) - throws GroupNotFoundException, RegistryStorageException { - delegate.updateGroupMetaData(group); + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto) throws GroupNotFoundException, RegistryStorageException { + delegate.updateGroupMetaData(groupId, dto); + } + + + @Override + public void updateGroupMetaData(String groupId, String description, Map labels, + String modifiedBy, Date modifiedOn) { + delegate.updateGroupMetaData(groupId, description, labels, modifiedBy, modifiedOn); } diff --git a/app/src/main/java/io/apicurio/registry/storage/dto/EditableGroupMetaDataDto.java b/app/src/main/java/io/apicurio/registry/storage/dto/EditableGroupMetaDataDto.java new file mode 100644 index 0000000000..f03f8885a8 --- /dev/null +++ b/app/src/main/java/io/apicurio/registry/storage/dto/EditableGroupMetaDataDto.java @@ -0,0 +1,26 @@ +package io.apicurio.registry.storage.dto; + +import java.util.Map; + +import io.quarkus.runtime.annotations.RegisterForReflection; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@NoArgsConstructor +@AllArgsConstructor +@Builder +@Getter +@Setter +@EqualsAndHashCode +@ToString +@RegisterForReflection +public class EditableGroupMetaDataDto { + + private String description; + private Map labels; +} diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/gitops/AbstractReadOnlyRegistryStorage.java b/app/src/main/java/io/apicurio/registry/storage/impl/gitops/AbstractReadOnlyRegistryStorage.java index bf124116de..b70f7cefe6 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/gitops/AbstractReadOnlyRegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/gitops/AbstractReadOnlyRegistryStorage.java @@ -18,6 +18,7 @@ import java.util.Date; import java.util.List; +import java.util.Map; public abstract class AbstractReadOnlyRegistryStorage implements RegistryStorage { @@ -187,7 +188,13 @@ public void createGroup(GroupMetaDataDto group) throws RegistryStorageException @Override - public void updateGroupMetaData(GroupMetaDataDto group) throws RegistryStorageException { + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto) { + readOnlyViolation(); + } + + @Override + public void updateGroupMetaData(String groupId, String description, Map labels, + String modifiedBy, Date modifiedOn) { readOnlyViolation(); } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlRegistryStorage.java b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlRegistryStorage.java index fc28c2c097..a7e3164181 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlRegistryStorage.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlRegistryStorage.java @@ -597,8 +597,24 @@ public void createGroup(GroupMetaDataDto group) { @Override - public void updateGroupMetaData(GroupMetaDataDto group) { - UUID reqId = ConcurrentUtil.get(submitter.submitGroup(ActionType.UPDATE, group)); + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto edto) { + String modifiedBy = securityIdentity.getPrincipal().getName(); + Date modifiedOn = new Date(); + + updateGroupMetaData(groupId, edto.getDescription(), edto.getLabels(), modifiedBy, modifiedOn); + } + + @Override + public void updateGroupMetaData(String groupId, String description, Map labels, + String modifiedBy, Date modifiedOn) { + // Note: the next line will throw GroupNotFoundException if the group does not exist, so there is no need for an extra check. + GroupMetaDataDto dto = delegate.getGroupMetaData(groupId); + dto.setModifiedBy(modifiedBy); + dto.setModifiedOn(modifiedOn.getTime()); + dto.setDescription(description); + dto.setLabels(labels); + + UUID reqId = ConcurrentUtil.get(submitter.submitGroup(ActionType.UPDATE, dto)); coordinator.waitForResponse(reqId); } diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlSubmitter.java b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlSubmitter.java index 304e1f6694..ebfea62ede 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlSubmitter.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/KafkaSqlSubmitter.java @@ -1,5 +1,16 @@ package io.apicurio.registry.storage.impl.kafkasql; +import static java.util.stream.Collectors.toList; + +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; + +import org.apache.kafka.clients.producer.ProducerRecord; +import org.apache.kafka.common.header.internals.RecordHeader; + import io.apicurio.common.apps.logging.Logged; import io.apicurio.registry.content.ContentHandle; import io.apicurio.registry.model.BranchId; @@ -10,8 +21,46 @@ import io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto; import io.apicurio.registry.storage.dto.GroupMetaDataDto; import io.apicurio.registry.storage.dto.RuleConfigurationDto; -import io.apicurio.registry.storage.impl.kafkasql.keys.*; -import io.apicurio.registry.storage.impl.kafkasql.values.*; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactBranchKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactOwnerKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactRuleKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactRulesKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactVersionKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.BootstrapKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.CommentIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.CommentKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ConfigPropertyKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ContentIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ContentKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.DownloadKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalActionKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalRuleKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalRulesKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GroupKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.MessageKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.RoleMappingKey; +import io.apicurio.registry.storage.impl.kafkasql.values.ActionType; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactBranchValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactOwnerValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactRuleValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactRulesValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactVersionValue; +import io.apicurio.registry.storage.impl.kafkasql.values.CommentIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.CommentValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ConfigPropertyValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ContentIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ContentValue; +import io.apicurio.registry.storage.impl.kafkasql.values.DownloadValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalActionValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalRuleValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalRulesValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GroupValue; +import io.apicurio.registry.storage.impl.kafkasql.values.MessageValue; +import io.apicurio.registry.storage.impl.kafkasql.values.RoleMappingValue; import io.apicurio.registry.types.ArtifactState; import io.apicurio.registry.types.RuleType; import io.apicurio.registry.utils.impexp.ArtifactBranchEntity; @@ -20,16 +69,6 @@ import jakarta.enterprise.event.Observes; import jakarta.enterprise.event.Shutdown; import jakarta.inject.Inject; -import org.apache.kafka.clients.producer.ProducerRecord; -import org.apache.kafka.common.header.internals.RecordHeader; - -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -import static java.util.stream.Collectors.toList; @ApplicationScoped @Logged @@ -81,9 +120,9 @@ public CompletableFuture submitContent(long contentId, String contentHash, /* ****************************************************************************************** * Group * ****************************************************************************************** */ - public CompletableFuture submitGroup(ActionType action, GroupMetaDataDto meta) { - GroupKey key = GroupKey.create(meta.getGroupId()); - GroupValue value = GroupValue.create(action, meta); + public CompletableFuture submitGroup(ActionType action, GroupMetaDataDto dto) { + GroupKey key = GroupKey.create(dto.getGroupId()); + GroupValue value = GroupValue.create(action, dto); return send(key, value); } public CompletableFuture submitGroup(String groupId, ActionType action, boolean onlyArtifacts) { diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/sql/KafkaSqlSink.java b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/sql/KafkaSqlSink.java index 64acf8e9e5..d1748f7ece 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/sql/KafkaSqlSink.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/sql/KafkaSqlSink.java @@ -1,5 +1,16 @@ package io.apicurio.registry.storage.impl.kafkasql.sql; +import static java.util.stream.Collectors.toList; + +import java.util.Date; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Supplier; + +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.common.header.Header; +import org.slf4j.Logger; + import io.apicurio.common.apps.config.DynamicConfigPropertyDto; import io.apicurio.common.apps.logging.Logged; import io.apicurio.registry.exception.RuntimeAssertionFailedException; @@ -17,24 +28,58 @@ import io.apicurio.registry.storage.impl.kafkasql.KafkaSqlRegistryStorage; import io.apicurio.registry.storage.impl.kafkasql.KafkaSqlSubmitter; import io.apicurio.registry.storage.impl.kafkasql.MessageType; -import io.apicurio.registry.storage.impl.kafkasql.keys.*; -import io.apicurio.registry.storage.impl.kafkasql.values.*; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactBranchKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactOwnerKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactRuleKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactRulesKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ArtifactVersionKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.CommentIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.CommentKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ConfigPropertyKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ContentIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.ContentKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.DownloadKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalActionKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalIdKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalRuleKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GlobalRulesKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.GroupKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.MessageKey; +import io.apicurio.registry.storage.impl.kafkasql.keys.RoleMappingKey; +import io.apicurio.registry.storage.impl.kafkasql.values.AbstractMessageValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactBranchValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactOwnerValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactRuleValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactRulesValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ArtifactVersionValue; +import io.apicurio.registry.storage.impl.kafkasql.values.CommentIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.CommentValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ConfigPropertyValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ContentIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.ContentValue; +import io.apicurio.registry.storage.impl.kafkasql.values.DownloadValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalActionValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalIdValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalRuleValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GlobalRulesValue; +import io.apicurio.registry.storage.impl.kafkasql.values.GroupValue; +import io.apicurio.registry.storage.impl.kafkasql.values.MessageValue; +import io.apicurio.registry.storage.impl.kafkasql.values.RoleMappingValue; import io.apicurio.registry.storage.impl.sql.IdGenerator; import io.apicurio.registry.storage.impl.sql.SqlRegistryStorage; import io.apicurio.registry.types.RegistryException; -import io.apicurio.registry.utils.impexp.*; +import io.apicurio.registry.utils.impexp.ArtifactBranchEntity; +import io.apicurio.registry.utils.impexp.ArtifactRuleEntity; +import io.apicurio.registry.utils.impexp.ArtifactVersionEntity; +import io.apicurio.registry.utils.impexp.CommentEntity; +import io.apicurio.registry.utils.impexp.ContentEntity; +import io.apicurio.registry.utils.impexp.GlobalRuleEntity; +import io.apicurio.registry.utils.impexp.GroupEntity; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.control.ActivateRequestContext; import jakarta.inject.Inject; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.apache.kafka.common.header.Header; -import org.slf4j.Logger; - -import java.util.Optional; -import java.util.UUID; -import java.util.function.Supplier; - -import static java.util.stream.Collectors.toList; @ApplicationScoped @Logged @@ -226,12 +271,15 @@ private Object processGroupMessage(GroupKey key, GroupValue value) { .labels(value.getLabels()) .build(); }; + GroupMetaDataDto dto = buildGroup.get(); + switch (value.getAction()) { case CREATE: - sqlStore.createGroup(buildGroup.get()); + sqlStore.createGroup(dto); return null; case UPDATE: - sqlStore.updateGroupMetaData(buildGroup.get()); + sqlStore.updateGroupMetaData(dto.getGroupId(), dto.getDescription(), dto.getLabels(), + dto.getModifiedBy(), new Date(dto.getModifiedOn())); return null; case DELETE: if (value.isOnlyArtifacts()) { diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/values/GroupValue.java b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/values/GroupValue.java index 3c1a6fa98c..2e6a0fc244 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/values/GroupValue.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/kafkasql/values/GroupValue.java @@ -1,12 +1,12 @@ package io.apicurio.registry.storage.impl.kafkasql.values; +import java.util.Map; + import io.apicurio.registry.storage.dto.GroupMetaDataDto; import io.apicurio.registry.storage.impl.kafkasql.MessageType; import io.quarkus.runtime.annotations.RegisterForReflection; import lombok.ToString; -import java.util.Map; - @RegisterForReflection @ToString public class GroupValue extends AbstractMessageValue { 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 e45b22c9ae..c7446539b3 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 @@ -62,6 +62,7 @@ import io.apicurio.registry.storage.dto.ContentWrapperDto; import io.apicurio.registry.storage.dto.DownloadContextDto; import io.apicurio.registry.storage.dto.EditableArtifactMetaDataDto; +import io.apicurio.registry.storage.dto.EditableGroupMetaDataDto; import io.apicurio.registry.storage.dto.GroupMetaDataDto; import io.apicurio.registry.storage.dto.GroupSearchResultsDto; import io.apicurio.registry.storage.dto.OrderBy; @@ -1653,7 +1654,7 @@ private void updateArtifactVersionMetadataRaw(long globalId, String groupId, Str } - // Delete all appropriate rows in the "labels" table + // Delete all appropriate rows in the "version_labels" table handle.createUpdate(sqlStatements.deleteVersionLabelsByGlobalId()) .bind(0, globalId) .execute(); @@ -1783,7 +1784,7 @@ public List getArtifactVersionComments(String groupId, String artifa @Override @Transactional public void deleteArtifactVersionComment(String groupId, String artifactId, String version, String commentId) { - log.debug("Deleting an artifact rule for artifact: {} {} @ {}", groupId, artifactId, version); + log.debug("Deleting a version comment for artifact: {} {} @ {}", groupId, artifactId, version); String deletedBy = securityIdentity.getPrincipal().getName(); handles.withHandle(handle -> { @@ -2053,26 +2054,6 @@ public void createGroup(GroupMetaDataDto group) throws GroupAlreadyExistsExcepti } - @Override - @Transactional - public void updateGroupMetaData(GroupMetaDataDto group) throws GroupNotFoundException, RegistryStorageException { - handles.withHandleNoException(handle -> { - int rows = handle.createUpdate(sqlStatements.updateGroup()) - .bind(0, group.getDescription()) - .bind(1, group.getArtifactsType()) - .bind(2, group.getModifiedBy()) - .bind(3, group.getModifiedOn()) - .bind(4, SqlUtil.serializeLabels(group.getLabels())) - .bind(5, group.getGroupId()) - .execute(); - if (rows == 0) { - throw new GroupNotFoundException(group.getGroupId()); - } - return null; - }); - } - - /** * Deletes a group and all artifacts in that group. * @see io.apicurio.registry.storage.RegistryStorage#deleteGroup(java.lang.String) @@ -2102,7 +2083,58 @@ public void deleteGroup(String groupId) throws GroupNotFoundException, RegistryS return null; }); } + + /** + * @see io.apicurio.registry.storage.RegistryStorage#updateGroupMetaData(java.lang.String, io.apicurio.registry.storage.dto.EditableGroupMetaDataDto) + */ + @Override + @Transactional + public void updateGroupMetaData(String groupId, EditableGroupMetaDataDto dto) { + String modifiedBy = securityIdentity.getPrincipal().getName(); + Date modifiedOn = new Date(); + updateGroupMetaData(groupId, dto.getDescription(), dto.getLabels(), modifiedBy, modifiedOn); + } + + /** + * @see io.apicurio.registry.storage.RegistryStorage#updateGroupMetaData(java.lang.String, java.lang.String, java.util.Map, java.lang.String, java.util.Date) + */ + @Override + @Transactional + public void updateGroupMetaData(String groupId, String description, Map labels, String modifiedBy, Date modifiedOn) { + log.debug("Updating metadata for group {}.", groupId); + handles.withHandleNoException(handle -> { + int rows = handle.createUpdate(sqlStatements.updateGroup()) + .bind(0, description) + .bind(1, modifiedBy) + .bind(2, modifiedOn) + .bind(3, SqlUtil.serializeLabels(labels)) + .bind(4, groupId) + .execute(); + if (rows == 0) { + throw new GroupNotFoundException(groupId); + } + + // Delete all appropriate rows in the "group_labels" table + handle.createUpdate(sqlStatements.deleteGroupLabelsByGroupId()) + .bind(0, groupId) + .execute(); + + // Insert new labels into the "group_labels" table + if (labels != null && !labels.isEmpty()) { + labels.forEach((k, v) -> { + String sqli = sqlStatements.insertGroupLabel(); + handle.createUpdate(sqli) + .bind(0, groupId) + .bind(1, limitStr(k.toLowerCase(), 256)) + .bind(2, limitStr(asLowerCase(v), 512)) + .execute(); + }); + } + + return null; + }); + } @Override @Transactional diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java index fe1909a605..e5e755b4e2 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/CommonSqlStatements.java @@ -321,6 +321,14 @@ public String deleteAllArtifactRules() { public String updateArtifactVersionMetaData() { return "UPDATE versions SET name = ?, description = ?, labels = ? WHERE groupId = ? AND artifactId = ? AND version = ?"; } + + /** + * @see io.apicurio.registry.storage.impl.sql.SqlStatements#deleteGroupLabelsByGroupId() + */ + @Override + public String deleteGroupLabelsByGroupId() { + return "DELETE FROM group_labels WHERE groupId = ?"; + } /** * @see io.apicurio.registry.storage.impl.sql.SqlStatements#deleteVersionLabelsByGlobalId() @@ -562,7 +570,7 @@ public String insertGroup() { */ @Override public String updateGroup() { - return "UPDATE groups SET description = ? , artifactsType = ? , modifiedBy = ? , modifiedOn = ? , labels = ? WHERE groupId = ?"; + return "UPDATE groups SET description = ? , modifiedBy = ? , modifiedOn = ? , labels = ? WHERE groupId = ?"; } /** diff --git a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java index 659e74ebc2..7acc00e95f 100644 --- a/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java +++ b/app/src/main/java/io/apicurio/registry/storage/impl/sql/SqlStatements.java @@ -228,6 +228,11 @@ public interface SqlStatements { * A statement to update the meta-data of a specific artifact version. */ public String updateArtifactVersionMetaData(); + + /** + * A statement to delete all rows in the group_labels table for a given group. + */ + public String deleteGroupLabelsByGroupId(); /** * A statement to delete the labels for a single artifact version. @@ -556,4 +561,5 @@ public interface SqlStatements { public String deleteAllArtifactBranches(); public String selectVersionsWithoutArtifactBranch(); + } diff --git a/app/src/test/java/io/apicurio/registry/auth/SimpleAuthTest.java b/app/src/test/java/io/apicurio/registry/auth/SimpleAuthTest.java index c21de4f151..b63849e014 100644 --- a/app/src/test/java/io/apicurio/registry/auth/SimpleAuthTest.java +++ b/app/src/test/java/io/apicurio/registry/auth/SimpleAuthTest.java @@ -6,7 +6,7 @@ import io.apicurio.registry.rest.client.models.ArtifactContent; import io.apicurio.registry.rest.client.models.ArtifactMetaData; import io.apicurio.registry.rest.client.models.ArtifactOwner; -import io.apicurio.registry.rest.client.models.EditableMetaData; +import io.apicurio.registry.rest.client.models.EditableArtifactMetaData; import io.apicurio.registry.rest.client.models.IfExists; import io.apicurio.registry.rest.client.models.Rule; import io.apicurio.registry.rest.client.models.RuleType; @@ -260,7 +260,7 @@ public void testOwnerOnlyAuthorization() throws Exception { config.headers.add("X-Registry-ArtifactType", ArtifactType.JSON); }); - EditableMetaData updatedMetaData = new EditableMetaData(); + EditableArtifactMetaData updatedMetaData = new EditableArtifactMetaData(); updatedMetaData.setName("Updated Name"); // Dev user cannot edit the same artifact because Dev user is not the owner var exception1 = Assertions.assertThrows(Exception.class, () -> { @@ -295,10 +295,7 @@ public void testGetArtifactOwner() throws Exception { //Preparation final String groupId = "testGetArtifactOwner"; final String artifactId = generateArtifactId(); - final String version = "1"; - final String name = "testGetArtifactOwnerName"; - final String description = "testGetArtifactOwnerDescription"; //Execution var artifactContent = new ArtifactContent(); diff --git a/app/src/test/java/io/apicurio/registry/limits/LimitsTest.java b/app/src/test/java/io/apicurio/registry/limits/LimitsTest.java index ac67fa03f2..763518a924 100644 --- a/app/src/test/java/io/apicurio/registry/limits/LimitsTest.java +++ b/app/src/test/java/io/apicurio/registry/limits/LimitsTest.java @@ -16,7 +16,7 @@ import io.apicurio.registry.AbstractResourceTestBase; import io.apicurio.registry.model.GroupId; import io.apicurio.registry.rest.client.models.ArtifactContent; -import io.apicurio.registry.rest.client.models.EditableMetaData; +import io.apicurio.registry.rest.client.models.EditableArtifactMetaData; import io.apicurio.registry.rest.client.models.Labels; import io.apicurio.registry.storage.RegistryStorage; import io.apicurio.registry.types.ArtifactType; @@ -56,7 +56,7 @@ public void testLimits() throws Exception { createArtifactVersion(artifactId, ArtifactType.JSON, content); //valid metadata - EditableMetaData meta = new EditableMetaData(); + EditableArtifactMetaData meta = new EditableArtifactMetaData(); meta.setName(StringUtils.repeat('a', 512)); meta.setDescription(StringUtils.repeat('a', 1024)); String fourBytesText = StringUtils.repeat('a', 4); @@ -78,7 +78,7 @@ public void testLimits() throws Exception { ; //invalid metadata - EditableMetaData invalidmeta = new EditableMetaData(); + EditableArtifactMetaData invalidmeta = new EditableArtifactMetaData(); invalidmeta.setName(StringUtils.repeat('a', 513)); invalidmeta.setDescription(StringUtils.repeat('a', 1025)); String fiveBytesText = StringUtils.repeat('a', 5); diff --git a/app/src/test/java/io/apicurio/registry/noprofile/ArtifactSearchTest.java b/app/src/test/java/io/apicurio/registry/noprofile/ArtifactSearchTest.java index 72b82a0461..7d2e5f5f71 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/ArtifactSearchTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/ArtifactSearchTest.java @@ -9,7 +9,7 @@ import io.apicurio.registry.AbstractResourceTestBase; import io.apicurio.registry.rest.client.models.ArtifactContent; import io.apicurio.registry.rest.client.models.ArtifactSearchResults; -import io.apicurio.registry.rest.client.models.EditableMetaData; +import io.apicurio.registry.rest.client.models.EditableArtifactMetaData; import io.apicurio.registry.rest.client.models.Labels; import io.apicurio.registry.rest.client.models.SortBy; import io.apicurio.registry.rest.client.models.SortOrder; @@ -59,7 +59,7 @@ void testCaseInsensitiveSearch() throws Exception { Assertions.assertEquals(1, results.getCount()); // Update the meta-data for the artifact - EditableMetaData metaData = new EditableMetaData(); + EditableArtifactMetaData metaData = new EditableArtifactMetaData(); metaData.setName(title); metaData.setDescription(description); Labels labels = new Labels(); diff --git a/app/src/test/java/io/apicurio/registry/noprofile/ArtifactStateTest.java b/app/src/test/java/io/apicurio/registry/noprofile/ArtifactStateTest.java index 1c187dffb4..3cf3068e1a 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/ArtifactStateTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/ArtifactStateTest.java @@ -57,7 +57,7 @@ public void testSmoke() throws Exception { Assertions.assertEquals(ArtifactState.ENABLED, tamd.getState()); Assertions.assertNull(tamd.getDescription()); - EditableMetaData emd = new EditableMetaData(); + EditableArtifactMetaData emd = new EditableArtifactMetaData(); String description = "Testing artifact state"; emd.setDescription(description); diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/GroupsResourceTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/GroupsResourceTest.java index 9ac33a7e48..dc91a4688b 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/GroupsResourceTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/GroupsResourceTest.java @@ -56,7 +56,7 @@ import io.apicurio.registry.rest.v3.beans.ArtifactOwner; import io.apicurio.registry.rest.v3.beans.ArtifactReference; import io.apicurio.registry.rest.v3.beans.Comment; -import io.apicurio.registry.rest.v3.beans.EditableMetaData; +import io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData; import io.apicurio.registry.rest.v3.beans.IfExists; import io.apicurio.registry.rest.v3.beans.NewComment; import io.apicurio.registry.rest.v3.beans.Rule; @@ -1871,7 +1871,7 @@ public void testArtifactMetaData() throws Exception { .body("message", equalTo("No artifact with ID 'testGetArtifactMetaData/MissingAPI' in group 'GroupsResourceTest' was found.")); // Update the artifact meta-data - EditableMetaData amd = EditableMetaData.builder() + EditableArtifactMetaData amd = EditableArtifactMetaData.builder() .name("Empty API Name") .description("Empty API description.") .labels(Map.of("additionalProp1", "Empty API additional property")) @@ -1962,7 +1962,7 @@ public void testLabelWithNullValue() throws Exception { labels.put("test-key", null); // Update the artifact meta-data - EditableMetaData metaData = new EditableMetaData(); + EditableArtifactMetaData metaData = new EditableArtifactMetaData(); metaData.setName(title); metaData.setDescription("Some description of an API"); metaData.setLabels(labels); diff --git a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchResourceTest.java b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchResourceTest.java index d8d280f780..ef204abca1 100644 --- a/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchResourceTest.java +++ b/app/src/test/java/io/apicurio/registry/noprofile/rest/v3/SearchResourceTest.java @@ -10,7 +10,7 @@ import org.junit.jupiter.api.Test; import io.apicurio.registry.AbstractResourceTestBase; -import io.apicurio.registry.rest.v3.beans.EditableMetaData; +import io.apicurio.registry.rest.v3.beans.EditableArtifactMetaData; import io.apicurio.registry.types.ArtifactType; import io.quarkus.test.junit.QuarkusTest; @@ -116,7 +116,7 @@ public void testSearchByLabels() throws Exception { labels.put("extra-key-" + (idx % 2), "lorem ipsum"); // Update the artifact meta-data - EditableMetaData metaData = new EditableMetaData(); + EditableArtifactMetaData metaData = new EditableArtifactMetaData(); metaData.setName(title); metaData.setDescription("Some description of an API"); metaData.setLabels(labels); @@ -243,7 +243,7 @@ public void testSearchByPropertyKey() throws Exception { labels.put("extra-key-" + (idx % 2), "lorem ipsum"); // Update the artifact meta-data - EditableMetaData metaData = new EditableMetaData(); + EditableArtifactMetaData metaData = new EditableArtifactMetaData(); metaData.setName(title); metaData.setDescription("Some description of an API"); metaData.setLabels(labels); diff --git a/app/src/test/java/io/apicurio/registry/rbac/RegistryClientTest.java b/app/src/test/java/io/apicurio/registry/rbac/RegistryClientTest.java index 6ac6b78d7f..c65c705d7d 100644 --- a/app/src/test/java/io/apicurio/registry/rbac/RegistryClientTest.java +++ b/app/src/test/java/io/apicurio/registry/rbac/RegistryClientTest.java @@ -306,7 +306,7 @@ public void testAsyncCRUD() throws Exception { Thread.sleep(2000); - EditableMetaData emd = new EditableMetaData(); + EditableArtifactMetaData emd = new EditableArtifactMetaData(); emd.setName("testAsyncCRUD"); clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).meta().put(emd); @@ -728,7 +728,7 @@ public void testLabels() throws Exception { config.headers.add("Content-Type", "application/create.extended+json"); }); - EditableMetaData emd = new EditableMetaData(); + EditableArtifactMetaData emd = new EditableArtifactMetaData(); emd.setName("testProperties"); final Map artifactLabels = new HashMap<>(); @@ -1522,8 +1522,8 @@ public void testRoleMappings() throws Exception { clientV3.admin().roleMappings().byPrincipalId("TestUser2").get(); }); // RoleMappingNotFoundException - Assertions.assertEquals(404, exception.getErrorCode()); - Assertions.assertEquals("RoleMappingNotFoundException", exception.getName()); + Assertions.assertEquals(404, exception2.getErrorCode()); + Assertions.assertEquals("RoleMappingNotFoundException", exception2.getName()); }); // Get the list of mappings (should be 1 of them) diff --git a/app/src/test/java/io/apicurio/registry/storage/impl/readonly/ReadOnlyRegistryStorageTest.java b/app/src/test/java/io/apicurio/registry/storage/impl/readonly/ReadOnlyRegistryStorageTest.java index 28fbb0a107..515cc17173 100644 --- a/app/src/test/java/io/apicurio/registry/storage/impl/readonly/ReadOnlyRegistryStorageTest.java +++ b/app/src/test/java/io/apicurio/registry/storage/impl/readonly/ReadOnlyRegistryStorageTest.java @@ -153,7 +153,8 @@ public class ReadOnlyRegistryStorageTest { entry("updateArtifactWithMetadata9", new State(true, s -> s.updateArtifactWithMetadata(null, null, null, null, null, null, null, null, null))), entry("updateContentCanonicalHash3", new State(true, s -> s.updateContentCanonicalHash(null, 0, null))), entry("updateGlobalRule2", new State(true, s -> s.updateGlobalRule(null, null))), - entry("updateGroupMetaData1", new State(true, s -> s.updateGroupMetaData(null))), + entry("updateGroupMetaData2", new State(true, s -> s.updateGroupMetaData(null, null))), + entry("updateGroupMetaData5", new State(true, s -> s.updateGroupMetaData(null, null, null, null, null))), entry("updateRoleMapping2", new State(true, s -> s.updateRoleMapping(null, null))) ); diff --git a/common/src/main/resources/META-INF/openapi.json b/common/src/main/resources/META-INF/openapi.json index 9f6a91b277..5409356854 100644 --- a/common/src/main/resources/META-INF/openapi.json +++ b/common/src/main/resources/META-INF/openapi.json @@ -690,7 +690,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EditableMetaData" + "$ref": "#/components/schemas/EditableArtifactMetaData" } } }, @@ -2042,65 +2042,6 @@ } ] }, - "/groups/{groupId}": { - "summary": "Collection to manage a single group in the registry.", - "get": { - "tags": [ - "Groups" - ], - "responses": { - "200": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GroupMetaData" - } - } - }, - "description": "The group's metadata." - }, - "404": { - "$ref": "#/components/responses/NotFound" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "operationId": "getGroupById", - "summary": "Get a group by the specified ID.", - "description": "Returns a group using the specified id.\n\nThis operation can fail for the following reasons:\n\n* No group exists with the specified ID (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" - }, - "delete": { - "tags": [ - "Groups" - ], - "responses": { - "204": { - "description": "Empty content indicates a successful deletion." - }, - "404": { - "$ref": "#/components/responses/NotFound" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "operationId": "deleteGroupById", - "summary": "Delete a group by the specified ID.", - "description": "Deletes a group by identifier. This operation also deletes all artifacts within\nthe group, so should be used very carefully.\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n* The group does not exist (HTTP error `404`)\n" - }, - "parameters": [ - { - "name": "groupId", - "description": "The artifact group ID. Must be a string provided by the client, representing the name of the grouping of artifacts. Must follow the \".{1,512}\" pattern.", - "schema": { - "$ref": "#/components/schemas/GroupId" - }, - "in": "path", - "required": true - } - ] - }, "/groups": { "summary": "Collection of the groups in the registry.", "get": { @@ -2231,7 +2172,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/EditableMetaData" + "$ref": "#/components/schemas/EditableArtifactMetaData" } } }, @@ -3396,35 +3337,99 @@ } ] }, - "x-codegen-contextRoot": "/apis/registry/v3" - }, - "components": { - "schemas": { - "EditableMetaData": { - "title": "Root Type for EditableArtifactMetaData", - "description": "", - "type": "object", - "properties": { - "name": { - "type": "string" + "/groups/{groupId}": { + "summary": "Collection to manage a single group in the registry.", + "get": { + "tags": [ + "Groups" + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GroupMetaData" + } + } + }, + "description": "The group's metadata." }, - "description": { - "type": "string" + "404": { + "$ref": "#/components/responses/NotFound" }, - "labels": { - "$ref": "#/components/schemas/Labels", - "description": "" + "500": { + "$ref": "#/components/responses/ServerError" } }, - "example": { - "name": "Artifact Name", - "description": "The description of the artifact.", - "labels": { - "custom-1": "foo", - "custom-2": "bar" + "operationId": "getGroupById", + "summary": "Get a group by the specified ID.", + "description": "Returns a group using the specified id.\n\nThis operation can fail for the following reasons:\n\n* No group exists with the specified ID (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" + }, + "put": { + "requestBody": { + "description": "The new group metadata.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EditableGroupMetaData" + } + } + }, + "required": true + }, + "tags": [ + "Groups" + ], + "responses": { + "204": { + "description": "Empty response when the metadata is successfully updated." + }, + "404": { + "$ref": "#/components/responses/NotFound" + }, + "500": { + "$ref": "#/components/responses/ServerError" } - } + }, + "operationId": "updateGroupById", + "summary": "Update group metadata", + "description": "Updates the metadata of a group using the specified id.\n\nThis operation can fail for the following reasons:\n\n* No group exists with the specified ID (HTTP error `404`)\n* A server error occurred (HTTP error `500`)" }, + "delete": { + "tags": [ + "Groups" + ], + "responses": { + "204": { + "description": "Empty content indicates a successful deletion." + }, + "404": { + "$ref": "#/components/responses/NotFound" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + }, + "operationId": "deleteGroupById", + "summary": "Delete a group by the specified ID.", + "description": "Deletes a group by identifier. This operation also deletes all artifacts within\nthe group, so should be used very carefully.\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n* The group does not exist (HTTP error `404`)\n" + }, + "parameters": [ + { + "name": "groupId", + "description": "The artifact group ID. Must be a string provided by the client, representing the name of the grouping of artifacts. Must follow the \".{1,512}\" pattern.", + "schema": { + "$ref": "#/components/schemas/GroupId" + }, + "in": "path", + "required": true + } + ] + }, + "x-codegen-contextRoot": "/apis/registry/v3" + }, + "components": { + "schemas": { "Rule": { "title": "Root Type for Rule", "description": "", @@ -4847,6 +4852,52 @@ }, "x-codegen-inline": true, "x-codegen-type": "StringMap" + }, + "EditableArtifactMetaData": { + "title": "Root Type for EditableArtifactMetaData", + "description": "", + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/Labels", + "description": "" + } + }, + "example": { + "name": "Artifact Name", + "description": "The description of the artifact.", + "labels": { + "custom-1": "foo", + "custom-2": "bar" + } + } + }, + "EditableGroupMetaData": { + "title": "Root Type for EditableArtifactMetaData", + "description": "", + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "labels": { + "$ref": "#/components/schemas/Labels", + "description": "" + } + }, + "example": { + "description": "The description of the group.", + "labels": { + "custom-1": "foo", + "custom-2": "bar" + } + } } }, "responses": { diff --git a/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_meta_request_builder.go b/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_meta_request_builder.go index 3ff7be65f4..9f5dbc233c 100644 --- a/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_meta_request_builder.go +++ b/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_meta_request_builder.go @@ -99,7 +99,7 @@ func (m *ItemArtifactsItemMetaRequestBuilder) Post(ctx context.Context, body i00 } // Put updates the editable parts of the artifact's metadata. Not all metadata fields canbe updated. For example, `createdOn` and `createdBy` are both read-only properties.This operation can fail for the following reasons:* No artifact with the `artifactId` exists (HTTP error `404`)* A server error occurred (HTTP error `500`) -func (m *ItemArtifactsItemMetaRequestBuilder) Put(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableMetaDataable, requestConfiguration *ItemArtifactsItemMetaRequestBuilderPutRequestConfiguration) error { +func (m *ItemArtifactsItemMetaRequestBuilder) Put(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableArtifactMetaDataable, requestConfiguration *ItemArtifactsItemMetaRequestBuilderPutRequestConfiguration) error { requestInfo, err := m.ToPutRequestInformation(ctx, body, requestConfiguration) if err != nil { return err @@ -145,7 +145,7 @@ func (m *ItemArtifactsItemMetaRequestBuilder) ToPostRequestInformation(ctx conte } // ToPutRequestInformation updates the editable parts of the artifact's metadata. Not all metadata fields canbe updated. For example, `createdOn` and `createdBy` are both read-only properties.This operation can fail for the following reasons:* No artifact with the `artifactId` exists (HTTP error `404`)* A server error occurred (HTTP error `500`) -func (m *ItemArtifactsItemMetaRequestBuilder) ToPutRequestInformation(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableMetaDataable, requestConfiguration *ItemArtifactsItemMetaRequestBuilderPutRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { +func (m *ItemArtifactsItemMetaRequestBuilder) ToPutRequestInformation(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableArtifactMetaDataable, requestConfiguration *ItemArtifactsItemMetaRequestBuilderPutRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.PUT, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) if requestConfiguration != nil { requestInfo.Headers.AddAll(requestConfiguration.Headers) diff --git a/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_versions_item_meta_request_builder.go b/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_versions_item_meta_request_builder.go index 9f6f64a4f6..1a2b8b31c5 100644 --- a/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_versions_item_meta_request_builder.go +++ b/go-sdk/pkg/registryclient-v3/groups/item_artifacts_item_versions_item_meta_request_builder.go @@ -90,7 +90,7 @@ func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) Get(ctx context.Contex } // Put updates the user-editable portion of the artifact version's metadata. Only some of the metadata fields are editable by the user. For example, `description` is editable, but `createdOn` is not.This operation can fail for the following reasons:* No artifact with this `artifactId` exists (HTTP error `404`)* No version with this `version` exists (HTTP error `404`)* A server error occurred (HTTP error `500`) -func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) Put(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableMetaDataable, requestConfiguration *ItemArtifactsItemVersionsItemMetaRequestBuilderPutRequestConfiguration) error { +func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) Put(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableArtifactMetaDataable, requestConfiguration *ItemArtifactsItemVersionsItemMetaRequestBuilderPutRequestConfiguration) error { requestInfo, err := m.ToPutRequestInformation(ctx, body, requestConfiguration) if err != nil { return err @@ -130,7 +130,7 @@ func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) ToGetRequestInformatio } // ToPutRequestInformation updates the user-editable portion of the artifact version's metadata. Only some of the metadata fields are editable by the user. For example, `description` is editable, but `createdOn` is not.This operation can fail for the following reasons:* No artifact with this `artifactId` exists (HTTP error `404`)* No version with this `version` exists (HTTP error `404`)* A server error occurred (HTTP error `500`) -func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) ToPutRequestInformation(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableMetaDataable, requestConfiguration *ItemArtifactsItemVersionsItemMetaRequestBuilderPutRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { +func (m *ItemArtifactsItemVersionsItemMetaRequestBuilder) ToPutRequestInformation(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableArtifactMetaDataable, requestConfiguration *ItemArtifactsItemVersionsItemMetaRequestBuilderPutRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.PUT, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) if requestConfiguration != nil { requestInfo.Headers.AddAll(requestConfiguration.Headers) diff --git a/go-sdk/pkg/registryclient-v3/groups/with_group_item_request_builder.go b/go-sdk/pkg/registryclient-v3/groups/with_group_item_request_builder.go index 00a9d5b7be..ed4ab798bd 100644 --- a/go-sdk/pkg/registryclient-v3/groups/with_group_item_request_builder.go +++ b/go-sdk/pkg/registryclient-v3/groups/with_group_item_request_builder.go @@ -27,6 +27,14 @@ type WithGroupItemRequestBuilderGetRequestConfiguration struct { Options []i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestOption } +// WithGroupItemRequestBuilderPutRequestConfiguration configuration for the request such as headers, query parameters, and middleware options. +type WithGroupItemRequestBuilderPutRequestConfiguration struct { + // Request headers + Headers *i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestHeaders + // Request options + Options []i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestOption +} + // Artifacts manage the collection of artifacts within a single group in the registry. func (m *WithGroupItemRequestBuilder) Artifacts() *ItemArtifactsRequestBuilder { return NewItemArtifactsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter) @@ -84,6 +92,23 @@ func (m *WithGroupItemRequestBuilder) Get(ctx context.Context, requestConfigurat return res.(i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.GroupMetaDataable), nil } +// Put updates the metadata of a group using the specified id.This operation can fail for the following reasons:* No group exists with the specified ID (HTTP error `404`)* A server error occurred (HTTP error `500`) +func (m *WithGroupItemRequestBuilder) Put(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableGroupMetaDataable, requestConfiguration *WithGroupItemRequestBuilderPutRequestConfiguration) error { + requestInfo, err := m.ToPutRequestInformation(ctx, body, requestConfiguration) + if err != nil { + return err + } + errorMapping := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.ErrorMappings{ + "404": i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.CreateErrorFromDiscriminatorValue, + "500": i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.CreateErrorFromDiscriminatorValue, + } + err = m.BaseRequestBuilder.RequestAdapter.SendNoContent(ctx, requestInfo, errorMapping) + if err != nil { + return err + } + return nil +} + // ToDeleteRequestInformation deletes a group by identifier. This operation also deletes all artifacts withinthe group, so should be used very carefully.This operation can fail for the following reasons:* A server error occurred (HTTP error `500`)* The group does not exist (HTTP error `404`) func (m *WithGroupItemRequestBuilder) ToDeleteRequestInformation(ctx context.Context, requestConfiguration *WithGroupItemRequestBuilderDeleteRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.DELETE, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) @@ -106,6 +131,21 @@ func (m *WithGroupItemRequestBuilder) ToGetRequestInformation(ctx context.Contex return requestInfo, nil } +// ToPutRequestInformation updates the metadata of a group using the specified id.This operation can fail for the following reasons:* No group exists with the specified ID (HTTP error `404`)* A server error occurred (HTTP error `500`) +func (m *WithGroupItemRequestBuilder) ToPutRequestInformation(ctx context.Context, body i00eb2e63d156923d00d8e86fe16b5d74daf30e363c9f185a8165cb42aa2f2c71.EditableGroupMetaDataable, requestConfiguration *WithGroupItemRequestBuilderPutRequestConfiguration) (*i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.RequestInformation, error) { + requestInfo := i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.NewRequestInformationWithMethodAndUrlTemplateAndPathParameters(i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f.PUT, m.BaseRequestBuilder.UrlTemplate, m.BaseRequestBuilder.PathParameters) + if requestConfiguration != nil { + requestInfo.Headers.AddAll(requestConfiguration.Headers) + requestInfo.AddRequestOptions(requestConfiguration.Options) + } + requestInfo.Headers.TryAdd("Accept", "application/json") + err := requestInfo.SetContentFromParsable(ctx, m.BaseRequestBuilder.RequestAdapter, "application/json", body) + if err != nil { + return nil, err + } + return requestInfo, nil +} + // WithUrl returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. func (m *WithGroupItemRequestBuilder) WithUrl(rawUrl string) *WithGroupItemRequestBuilder { return NewWithGroupItemRequestBuilder(rawUrl, m.BaseRequestBuilder.RequestAdapter) diff --git a/go-sdk/pkg/registryclient-v3/kiota-lock.json b/go-sdk/pkg/registryclient-v3/kiota-lock.json index 2feed30402..5f3ad5a703 100644 --- a/go-sdk/pkg/registryclient-v3/kiota-lock.json +++ b/go-sdk/pkg/registryclient-v3/kiota-lock.json @@ -1,5 +1,5 @@ { - "descriptionHash": "1FB19133CDF6A530F8E974A8D5FECEC2DEC0B5B12DA83F26A7F9FE87F307BD02E14F0FD6506F49B2FF9DF2BD7D0F5F3C13A0C348907901F2BE3BC23ACE26A9EC", + "descriptionHash": "A082EB30389D82AC8245967203939E539DDA246F24242BC166080749D16B8E6592DD2F8F2FD727D03E7BE82B30E9764D3763B050205E7E82F8847E24D4BB0517", "descriptionLocation": "../../v3.json", "lockFileVersion": "1.0.0", "kiotaVersion": "1.10.1", diff --git a/go-sdk/pkg/registryclient-v3/models/editable_meta_data.go b/go-sdk/pkg/registryclient-v3/models/editable_artifact_meta_data.go similarity index 68% rename from go-sdk/pkg/registryclient-v3/models/editable_meta_data.go rename to go-sdk/pkg/registryclient-v3/models/editable_artifact_meta_data.go index 51178aae85..8850d20d48 100644 --- a/go-sdk/pkg/registryclient-v3/models/editable_meta_data.go +++ b/go-sdk/pkg/registryclient-v3/models/editable_artifact_meta_data.go @@ -4,8 +4,8 @@ import ( i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" ) -// EditableMetaData -type EditableMetaData struct { +// EditableArtifactMetaData +type EditableArtifactMetaData struct { // Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. additionalData map[string]any // The description property @@ -16,30 +16,30 @@ type EditableMetaData struct { name *string } -// NewEditableMetaData instantiates a new EditableMetaData and sets the default values. -func NewEditableMetaData() *EditableMetaData { - m := &EditableMetaData{} +// NewEditableArtifactMetaData instantiates a new EditableArtifactMetaData and sets the default values. +func NewEditableArtifactMetaData() *EditableArtifactMetaData { + m := &EditableArtifactMetaData{} m.SetAdditionalData(make(map[string]any)) return m } -// CreateEditableMetaDataFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value -func CreateEditableMetaDataFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) (i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) { - return NewEditableMetaData(), nil +// CreateEditableArtifactMetaDataFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value +func CreateEditableArtifactMetaDataFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) (i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) { + return NewEditableArtifactMetaData(), nil } // GetAdditionalData gets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. -func (m *EditableMetaData) GetAdditionalData() map[string]any { +func (m *EditableArtifactMetaData) GetAdditionalData() map[string]any { return m.additionalData } // GetDescription gets the description property value. The description property -func (m *EditableMetaData) GetDescription() *string { +func (m *EditableArtifactMetaData) GetDescription() *string { return m.description } // GetFieldDeserializers the deserialization information for the current model -func (m *EditableMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { +func (m *EditableArtifactMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error) res["description"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { val, err := n.GetStringValue() @@ -75,17 +75,17 @@ func (m *EditableMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e } // GetLabels gets the labels property value. User-defined name-value pairs. Name and value must be strings. -func (m *EditableMetaData) GetLabels() Labelsable { +func (m *EditableArtifactMetaData) GetLabels() Labelsable { return m.labels } // GetName gets the name property value. The name property -func (m *EditableMetaData) GetName() *string { +func (m *EditableArtifactMetaData) GetName() *string { return m.name } // Serialize serializes information the current object -func (m *EditableMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter) error { +func (m *EditableArtifactMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter) error { { err := writer.WriteStringValue("description", m.GetDescription()) if err != nil { @@ -114,27 +114,27 @@ func (m *EditableMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b } // SetAdditionalData sets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. -func (m *EditableMetaData) SetAdditionalData(value map[string]any) { +func (m *EditableArtifactMetaData) SetAdditionalData(value map[string]any) { m.additionalData = value } // SetDescription sets the description property value. The description property -func (m *EditableMetaData) SetDescription(value *string) { +func (m *EditableArtifactMetaData) SetDescription(value *string) { m.description = value } // SetLabels sets the labels property value. User-defined name-value pairs. Name and value must be strings. -func (m *EditableMetaData) SetLabels(value Labelsable) { +func (m *EditableArtifactMetaData) SetLabels(value Labelsable) { m.labels = value } // SetName sets the name property value. The name property -func (m *EditableMetaData) SetName(value *string) { +func (m *EditableArtifactMetaData) SetName(value *string) { m.name = value } -// EditableMetaDataable -type EditableMetaDataable interface { +// EditableArtifactMetaDataable +type EditableArtifactMetaDataable interface { i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.AdditionalDataHolder i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable GetDescription() *string diff --git a/go-sdk/pkg/registryclient-v3/models/editable_group_meta_data.go b/go-sdk/pkg/registryclient-v3/models/editable_group_meta_data.go new file mode 100644 index 0000000000..0f49e90a5a --- /dev/null +++ b/go-sdk/pkg/registryclient-v3/models/editable_group_meta_data.go @@ -0,0 +1,116 @@ +package models + +import ( + i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91 "github.com/microsoft/kiota-abstractions-go/serialization" +) + +// EditableGroupMetaData +type EditableGroupMetaData struct { + // Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + additionalData map[string]any + // The description property + description *string + // User-defined name-value pairs. Name and value must be strings. + labels Labelsable +} + +// NewEditableGroupMetaData instantiates a new EditableGroupMetaData and sets the default values. +func NewEditableGroupMetaData() *EditableGroupMetaData { + m := &EditableGroupMetaData{} + m.SetAdditionalData(make(map[string]any)) + return m +} + +// CreateEditableGroupMetaDataFromDiscriminatorValue creates a new instance of the appropriate class based on discriminator value +func CreateEditableGroupMetaDataFromDiscriminatorValue(parseNode i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) (i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable, error) { + return NewEditableGroupMetaData(), nil +} + +// GetAdditionalData gets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. +func (m *EditableGroupMetaData) GetAdditionalData() map[string]any { + return m.additionalData +} + +// GetDescription gets the description property value. The description property +func (m *EditableGroupMetaData) GetDescription() *string { + return m.description +} + +// GetFieldDeserializers the deserialization information for the current model +func (m *EditableGroupMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { + res := make(map[string]func(i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error) + res["description"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error { + val, err := n.GetStringValue() + if err != nil { + return err + } + if val != nil { + m.SetDescription(val) + } + 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 + } + return res +} + +// GetLabels gets the labels property value. User-defined name-value pairs. Name and value must be strings. +func (m *EditableGroupMetaData) GetLabels() Labelsable { + return m.labels +} + +// Serialize serializes information the current object +func (m *EditableGroupMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.SerializationWriter) error { + { + err := writer.WriteStringValue("description", m.GetDescription()) + if err != nil { + return err + } + } + { + err := writer.WriteObjectValue("labels", m.GetLabels()) + if err != nil { + return err + } + } + { + err := writer.WriteAdditionalData(m.GetAdditionalData()) + if err != nil { + return err + } + } + return nil +} + +// SetAdditionalData sets the AdditionalData property value. Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. +func (m *EditableGroupMetaData) SetAdditionalData(value map[string]any) { + m.additionalData = value +} + +// SetDescription sets the description property value. The description property +func (m *EditableGroupMetaData) SetDescription(value *string) { + m.description = value +} + +// SetLabels sets the labels property value. User-defined name-value pairs. Name and value must be strings. +func (m *EditableGroupMetaData) SetLabels(value Labelsable) { + m.labels = value +} + +// EditableGroupMetaDataable +type EditableGroupMetaDataable interface { + i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.AdditionalDataHolder + i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.Parsable + GetDescription() *string + GetLabels() Labelsable + SetDescription(value *string) + SetLabels(value Labelsable) +} diff --git a/integration-tests/src/test/java/io/apicurio/tests/smokeTests/apicurio/MetadataIT.java b/integration-tests/src/test/java/io/apicurio/tests/smokeTests/apicurio/MetadataIT.java index ebbbfbf44e..490c9ac25c 100644 --- a/integration-tests/src/test/java/io/apicurio/tests/smokeTests/apicurio/MetadataIT.java +++ b/integration-tests/src/test/java/io/apicurio/tests/smokeTests/apicurio/MetadataIT.java @@ -3,7 +3,7 @@ import io.apicurio.tests.ApicurioRegistryBaseIT; import io.apicurio.tests.utils.Constants; import io.apicurio.registry.rest.client.models.ArtifactMetaData; -import io.apicurio.registry.rest.client.models.EditableMetaData; +import io.apicurio.registry.rest.client.models.EditableArtifactMetaData; import io.apicurio.registry.rest.client.models.VersionMetaData; import io.apicurio.registry.types.ArtifactType; import io.apicurio.registry.utils.tests.TestUtils; @@ -48,7 +48,7 @@ void getAndUpdateMetadataOfArtifact() throws Exception { assertThat(artifactMetaData.getVersion(), is("1")); assertThat(artifactMetaData.getType(), is("AVRO")); - EditableMetaData emd = new EditableMetaData(); + EditableArtifactMetaData emd = new EditableArtifactMetaData(); emd.setName("Artifact Updated Name"); emd.setDescription("The description of the artifact."); @@ -92,7 +92,7 @@ void getAndUpdateMetadataOfArtifactSpecificVersion() throws Exception { assertThat(versionMetaData.getVersion(), is("2")); assertThat(versionMetaData.getType(), is("AVRO")); - EditableMetaData emd = new EditableMetaData(); + EditableArtifactMetaData emd = new EditableArtifactMetaData(); emd.setName("Artifact Updated Name"); emd.setDescription("The description of the artifact.");