Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modifiedBy and modifiedOn to version metadata #5376

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java
Original file line number Diff line number Diff line change
@@ -77,6 +77,8 @@ public static VersionMetaData dtoToVersionMetaData(ArtifactVersionMetaDataDto dt
metaData.setArtifactId(dto.getArtifactId());
metaData.setOwner(dto.getOwner());
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
metaData.setModifiedBy(dto.getModifiedBy());
metaData.setModifiedOn(new Date(dto.getModifiedOn()));
metaData.setDescription(dto.getDescription());
metaData.setName(dto.getName());
metaData.setArtifactType(dto.getArtifactType());
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ public class ArtifactVersionMetaDataDto {
private String description;
private String owner;
private long createdOn;
private String modifiedBy;
private long modifiedOn;
private String artifactType;
private VersionState state;
private Map<String, String> labels;
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ public ArtifactVersionMetaDataDto map(ResultSet rs) throws SQLException {
dto.setVersionOrder(rs.getInt("versionOrder"));
dto.setArtifactType(rs.getString("type"));
dto.setLabels(RegistryContentUtils.deserializeLabels(rs.getString("labels")));
dto.setModifiedBy(rs.getString("modifiedBy"));
dto.setCreatedOn(rs.getTimestamp("modifiedOn").getTime());
return dto;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.apicurio.registry.noprofile.rest.v3;

import io.apicurio.registry.AbstractResourceTestBase;
import io.apicurio.registry.rest.client.models.SearchedVersion;
import io.apicurio.registry.rest.client.models.VersionMetaData;
import io.apicurio.registry.rest.client.models.VersionSearchResults;
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;

@QuarkusTest
public class VersionModifiedByOnTest extends AbstractResourceTestBase {

@Test
public void testSearchVersionsWithModified() throws Exception {
String artifactContent = resourceToString("openapi-empty.json");
String groupId = TestUtils.generateGroupId();

// Create 5 artifacts
for (int idx = 0; idx < 5; idx++) {
String artifactId = TestUtils.generateArtifactId();
createArtifact(groupId, artifactId, ArtifactType.OPENAPI, artifactContent,
ContentTypes.APPLICATION_JSON);
}

VersionSearchResults results = clientV3.search().versions().get(config -> {
config.queryParameters.groupId = groupId;
});
Assertions.assertEquals(5, results.getCount());
for (SearchedVersion version : results.getVersions()) {
Assertions.assertNotNull(version.getModifiedOn());
}
}

@Test
public void testVersionMetaDataWithModified() throws Exception {
String artifactContent = resourceToString("openapi-empty.json");
String groupId = TestUtils.generateGroupId();
String artifactId = TestUtils.generateArtifactId();

createArtifact(groupId, artifactId, ArtifactType.OPENAPI, artifactContent,
ContentTypes.APPLICATION_JSON, (ca) -> {
ca.getFirstVersion().setVersion("1.0");
});

VersionMetaData vmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1.0").get();
Assertions.assertNotNull(vmd);
Assertions.assertNotNull(vmd.getModifiedOn());
}

}
9 changes: 9 additions & 0 deletions common/src/main/resources/META-INF/openapi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{

Check warning on line 1 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-api-servers

Check warning on line 1 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

rhoas-servers-config
"openapi": "3.0.3",
"info": {
"title": "Apicurio Registry API [v3]",
@@ -14,7 +14,7 @@
"url": "https://www.apache.org/licenses/LICENSE-2.0"
}
},
"paths": {

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-media-example "value" property type must be string

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-media-example "value" property must have required property "title"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "version" property type must be string

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "example" property must match pattern "^[a-zA-Z0-9._\-+]{1,256}$"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "example" property must be equal to one of the allowed values: "OUTBOUND", "INBOUND". Did you mean "INBOUND"?

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "content" property must have required property "contentType"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "example" property must have required property "title"

Check warning on line 17 in common/src/main/resources/META-INF/openapi.json

GitHub Actions / Validate

oas3-valid-schema-example "createdOn" property must match format "date-time"
"/ids/globalIds/{globalId}": {
"summary": "Access artifact content utilizing an artifact version's globally unique identifier.",
"get": {
@@ -4007,6 +4007,15 @@
"artifactId": {
"$ref": "#/components/schemas/ArtifactId",
"description": ""
},
"modifiedBy": {
"description": "",
"type": "string"
},
"modifiedOn": {
"format": "date-time",
"description": "",
"type": "string"
}
},
"example": {
2 changes: 1 addition & 1 deletion go-sdk/pkg/registryclient-v3/kiota-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"descriptionHash": "0DD5D7FB5AB616D59BD7C21D29C19401ADA735DD30E366CE1946E44209EFEFA3896C1AE4B2F3204F00EE2E6B58AE47F43F999A27E251F2FE5D5C9C65E34380EC",
"descriptionHash": "00581DCACB1B1D7CFE571A59235CDC2AE7CA2C5158E25D26D03F23337D82CC23EFFD219AFAF562BB50AA94EFB196FFED7150C31C23BBB22910B7AD366AC7FF2D",
"descriptionLocation": "../../v3.json",
"lockFileVersion": "1.0.0",
"kiotaVersion": "1.19.1",
62 changes: 62 additions & 0 deletions go-sdk/pkg/registryclient-v3/models/version_meta_data.go
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@ type VersionMetaData struct {
groupId *string
// User-defined name-value pairs. Name and value must be strings.
labels Labelsable
// The modifiedBy property
modifiedBy *string
// The modifiedOn property
modifiedOn *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time
// The name property
name *string
// The owner property
@@ -167,6 +171,26 @@ func (m *VersionMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e8
}
return nil
}
res["modifiedBy"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetStringValue()
if err != nil {
return err
}
if val != nil {
m.SetModifiedBy(val)
}
return nil
}
res["modifiedOn"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetTimeValue()
if err != nil {
return err
}
if val != nil {
m.SetModifiedOn(val)
}
return nil
}
res["name"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
val, err := n.GetStringValue()
if err != nil {
@@ -228,6 +252,18 @@ func (m *VersionMetaData) GetLabels() Labelsable {
return m.labels
}

// GetModifiedBy gets the modifiedBy property value. The modifiedBy property
// returns a *string when successful
func (m *VersionMetaData) GetModifiedBy() *string {
return m.modifiedBy
}

// GetModifiedOn gets the modifiedOn property value. The modifiedOn property
// returns a *Time when successful
func (m *VersionMetaData) GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time {
return m.modifiedOn
}

// GetName gets the name property value. The name property
// returns a *string when successful
func (m *VersionMetaData) GetName() *string {
@@ -302,6 +338,18 @@ func (m *VersionMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0
return err
}
}
{
err := writer.WriteStringValue("modifiedBy", m.GetModifiedBy())
if err != nil {
return err
}
}
{
err := writer.WriteTimeValue("modifiedOn", m.GetModifiedOn())
if err != nil {
return err
}
}
{
err := writer.WriteStringValue("name", m.GetName())
if err != nil {
@@ -381,6 +429,16 @@ func (m *VersionMetaData) SetLabels(value Labelsable) {
m.labels = value
}

// SetModifiedBy sets the modifiedBy property value. The modifiedBy property
func (m *VersionMetaData) SetModifiedBy(value *string) {
m.modifiedBy = value
}

// SetModifiedOn sets the modifiedOn property value. The modifiedOn property
func (m *VersionMetaData) SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) {
m.modifiedOn = value
}

// SetName sets the name property value. The name property
func (m *VersionMetaData) SetName(value *string) {
m.name = value
@@ -412,6 +470,8 @@ type VersionMetaDataable interface {
GetGlobalId() *int64
GetGroupId() *string
GetLabels() Labelsable
GetModifiedBy() *string
GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time
GetName() *string
GetOwner() *string
GetState() *VersionState
@@ -424,6 +484,8 @@ type VersionMetaDataable interface {
SetGlobalId(value *int64)
SetGroupId(value *string)
SetLabels(value Labelsable)
SetModifiedBy(value *string)
SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time)
SetName(value *string)
SetOwner(value *string)
SetState(value *VersionState)
Loading