Skip to content

Commit c6b404b

Browse files
authored
Add modifiedBy and modifiedOn to version metadata. (#5376)
1 parent 26360ef commit c6b404b

File tree

7 files changed

+132
-1
lines changed

7 files changed

+132
-1
lines changed

app/src/main/java/io/apicurio/registry/rest/v3/V3ApiUtil.java

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public static VersionMetaData dtoToVersionMetaData(ArtifactVersionMetaDataDto dt
7777
metaData.setArtifactId(dto.getArtifactId());
7878
metaData.setOwner(dto.getOwner());
7979
metaData.setCreatedOn(new Date(dto.getCreatedOn()));
80+
metaData.setModifiedBy(dto.getModifiedBy());
81+
metaData.setModifiedOn(new Date(dto.getModifiedOn()));
8082
metaData.setDescription(dto.getDescription());
8183
metaData.setName(dto.getName());
8284
metaData.setArtifactType(dto.getArtifactType());

app/src/main/java/io/apicurio/registry/storage/dto/ArtifactVersionMetaDataDto.java

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class ArtifactVersionMetaDataDto {
3030
private String description;
3131
private String owner;
3232
private long createdOn;
33+
private String modifiedBy;
34+
private long modifiedOn;
3335
private String artifactType;
3436
private VersionState state;
3537
private Map<String, String> labels;

app/src/main/java/io/apicurio/registry/storage/impl/sql/mappers/ArtifactVersionMetaDataDtoMapper.java

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public ArtifactVersionMetaDataDto map(ResultSet rs) throws SQLException {
4040
dto.setVersionOrder(rs.getInt("versionOrder"));
4141
dto.setArtifactType(rs.getString("type"));
4242
dto.setLabels(RegistryContentUtils.deserializeLabels(rs.getString("labels")));
43+
dto.setModifiedBy(rs.getString("modifiedBy"));
44+
dto.setCreatedOn(rs.getTimestamp("modifiedOn").getTime());
4345
return dto;
4446
}
4547

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.apicurio.registry.noprofile.rest.v3;
2+
3+
import io.apicurio.registry.AbstractResourceTestBase;
4+
import io.apicurio.registry.rest.client.models.SearchedVersion;
5+
import io.apicurio.registry.rest.client.models.VersionMetaData;
6+
import io.apicurio.registry.rest.client.models.VersionSearchResults;
7+
import io.apicurio.registry.types.ArtifactType;
8+
import io.apicurio.registry.types.ContentTypes;
9+
import io.apicurio.registry.utils.tests.TestUtils;
10+
import io.quarkus.test.junit.QuarkusTest;
11+
import org.junit.jupiter.api.Assertions;
12+
import org.junit.jupiter.api.Test;
13+
14+
@QuarkusTest
15+
public class VersionModifiedByOnTest extends AbstractResourceTestBase {
16+
17+
@Test
18+
public void testSearchVersionsWithModified() throws Exception {
19+
String artifactContent = resourceToString("openapi-empty.json");
20+
String groupId = TestUtils.generateGroupId();
21+
22+
// Create 5 artifacts
23+
for (int idx = 0; idx < 5; idx++) {
24+
String artifactId = TestUtils.generateArtifactId();
25+
createArtifact(groupId, artifactId, ArtifactType.OPENAPI, artifactContent,
26+
ContentTypes.APPLICATION_JSON);
27+
}
28+
29+
VersionSearchResults results = clientV3.search().versions().get(config -> {
30+
config.queryParameters.groupId = groupId;
31+
});
32+
Assertions.assertEquals(5, results.getCount());
33+
for (SearchedVersion version : results.getVersions()) {
34+
Assertions.assertNotNull(version.getModifiedOn());
35+
}
36+
}
37+
38+
@Test
39+
public void testVersionMetaDataWithModified() throws Exception {
40+
String artifactContent = resourceToString("openapi-empty.json");
41+
String groupId = TestUtils.generateGroupId();
42+
String artifactId = TestUtils.generateArtifactId();
43+
44+
createArtifact(groupId, artifactId, ArtifactType.OPENAPI, artifactContent,
45+
ContentTypes.APPLICATION_JSON, (ca) -> {
46+
ca.getFirstVersion().setVersion("1.0");
47+
});
48+
49+
VersionMetaData vmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1.0").get();
50+
Assertions.assertNotNull(vmd);
51+
Assertions.assertNotNull(vmd.getModifiedOn());
52+
}
53+
54+
}

common/src/main/resources/META-INF/openapi.json

+9
Original file line numberDiff line numberDiff line change
@@ -4007,6 +4007,15 @@
40074007
"artifactId": {
40084008
"$ref": "#/components/schemas/ArtifactId",
40094009
"description": ""
4010+
},
4011+
"modifiedBy": {
4012+
"description": "",
4013+
"type": "string"
4014+
},
4015+
"modifiedOn": {
4016+
"format": "date-time",
4017+
"description": "",
4018+
"type": "string"
40104019
}
40114020
},
40124021
"example": {

go-sdk/pkg/registryclient-v3/kiota-lock.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"descriptionHash": "0DD5D7FB5AB616D59BD7C21D29C19401ADA735DD30E366CE1946E44209EFEFA3896C1AE4B2F3204F00EE2E6B58AE47F43F999A27E251F2FE5D5C9C65E34380EC",
2+
"descriptionHash": "00581DCACB1B1D7CFE571A59235CDC2AE7CA2C5158E25D26D03F23337D82CC23EFFD219AFAF562BB50AA94EFB196FFED7150C31C23BBB22910B7AD366AC7FF2D",
33
"descriptionLocation": "../../v3.json",
44
"lockFileVersion": "1.0.0",
55
"kiotaVersion": "1.19.1",

go-sdk/pkg/registryclient-v3/models/version_meta_data.go

+62
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type VersionMetaData struct {
2424
groupId *string
2525
// User-defined name-value pairs. Name and value must be strings.
2626
labels Labelsable
27+
// The modifiedBy property
28+
modifiedBy *string
29+
// The modifiedOn property
30+
modifiedOn *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time
2731
// The name property
2832
name *string
2933
// The owner property
@@ -167,6 +171,26 @@ func (m *VersionMetaData) GetFieldDeserializers() map[string]func(i878a80d2330e8
167171
}
168172
return nil
169173
}
174+
res["modifiedBy"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
175+
val, err := n.GetStringValue()
176+
if err != nil {
177+
return err
178+
}
179+
if val != nil {
180+
m.SetModifiedBy(val)
181+
}
182+
return nil
183+
}
184+
res["modifiedOn"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
185+
val, err := n.GetTimeValue()
186+
if err != nil {
187+
return err
188+
}
189+
if val != nil {
190+
m.SetModifiedOn(val)
191+
}
192+
return nil
193+
}
170194
res["name"] = func(n i878a80d2330e89d26896388a3f487eef27b0a0e6c010c493bf80be1452208f91.ParseNode) error {
171195
val, err := n.GetStringValue()
172196
if err != nil {
@@ -228,6 +252,18 @@ func (m *VersionMetaData) GetLabels() Labelsable {
228252
return m.labels
229253
}
230254

255+
// GetModifiedBy gets the modifiedBy property value. The modifiedBy property
256+
// returns a *string when successful
257+
func (m *VersionMetaData) GetModifiedBy() *string {
258+
return m.modifiedBy
259+
}
260+
261+
// GetModifiedOn gets the modifiedOn property value. The modifiedOn property
262+
// returns a *Time when successful
263+
func (m *VersionMetaData) GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time {
264+
return m.modifiedOn
265+
}
266+
231267
// GetName gets the name property value. The name property
232268
// returns a *string when successful
233269
func (m *VersionMetaData) GetName() *string {
@@ -302,6 +338,18 @@ func (m *VersionMetaData) Serialize(writer i878a80d2330e89d26896388a3f487eef27b0
302338
return err
303339
}
304340
}
341+
{
342+
err := writer.WriteStringValue("modifiedBy", m.GetModifiedBy())
343+
if err != nil {
344+
return err
345+
}
346+
}
347+
{
348+
err := writer.WriteTimeValue("modifiedOn", m.GetModifiedOn())
349+
if err != nil {
350+
return err
351+
}
352+
}
305353
{
306354
err := writer.WriteStringValue("name", m.GetName())
307355
if err != nil {
@@ -381,6 +429,16 @@ func (m *VersionMetaData) SetLabels(value Labelsable) {
381429
m.labels = value
382430
}
383431

432+
// SetModifiedBy sets the modifiedBy property value. The modifiedBy property
433+
func (m *VersionMetaData) SetModifiedBy(value *string) {
434+
m.modifiedBy = value
435+
}
436+
437+
// SetModifiedOn sets the modifiedOn property value. The modifiedOn property
438+
func (m *VersionMetaData) SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time) {
439+
m.modifiedOn = value
440+
}
441+
384442
// SetName sets the name property value. The name property
385443
func (m *VersionMetaData) SetName(value *string) {
386444
m.name = value
@@ -412,6 +470,8 @@ type VersionMetaDataable interface {
412470
GetGlobalId() *int64
413471
GetGroupId() *string
414472
GetLabels() Labelsable
473+
GetModifiedBy() *string
474+
GetModifiedOn() *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time
415475
GetName() *string
416476
GetOwner() *string
417477
GetState() *VersionState
@@ -424,6 +484,8 @@ type VersionMetaDataable interface {
424484
SetGlobalId(value *int64)
425485
SetGroupId(value *string)
426486
SetLabels(value Labelsable)
487+
SetModifiedBy(value *string)
488+
SetModifiedOn(value *i336074805fc853987abe6f7fe3ad97a6a6f3077a16391fec744f671a015fbd7e.Time)
427489
SetName(value *string)
428490
SetOwner(value *string)
429491
SetState(value *VersionState)

0 commit comments

Comments
 (0)