Skip to content

Commit 3f1ae53

Browse files
authored
[REST API v3] Invert the metadata and content API endpoints for versions (#4581)
* Invert the metadata and content API endpoints for versions * Fix artifact util * Build examples in verify workflow. Fix broken examples * Remove examples build from verify * Fix UI usage of rest api * Fix failing python test * Fix python sdk basic test * Fix linting issue in python sdk test
1 parent 20b526c commit 3f1ae53

File tree

42 files changed

+351
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+351
-376
lines changed

.github/workflows/verify.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ env:
2727
jobs:
2828
build-verify:
2929
name: Verify Application Build
30-
runs-on: ubuntu-20.04
30+
runs-on: ubuntu-latest
3131
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
3232
steps:
3333
- name: Checkout Code with Ref '${{ github.ref }}'
@@ -109,7 +109,7 @@ jobs:
109109

110110
build-verify-ui:
111111
name: Verify UI Build
112-
runs-on: ubuntu-20.04
112+
runs-on: ubuntu-latest
113113
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
114114
steps:
115115
- name: Checkout Code with Ref '${{ github.ref }}'
@@ -201,7 +201,7 @@ jobs:
201201

202202
build-native-images:
203203
name: Build and Test Native images
204-
runs-on: ubuntu-20.04
204+
runs-on: ubuntu-latest
205205
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
206206
steps:
207207
- name: Checkout Code with Ref '${{ github.ref }}'
@@ -305,7 +305,7 @@ jobs:
305305

306306
build-verify-python-sdk:
307307
name: Verify Python SDK
308-
runs-on: ubuntu-20.04
308+
runs-on: ubuntu-latest
309309
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
310310
steps:
311311
- name: Checkout Code with Ref '${{ github.ref }}'
@@ -342,7 +342,7 @@ jobs:
342342

343343
build-verify-go-sdk:
344344
name: Verify Go SDK
345-
runs-on: ubuntu-20.04
345+
runs-on: ubuntu-latest
346346
# if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
347347
steps:
348348
- name: Checkout Code with Ref '${{ github.ref }}'
@@ -369,7 +369,7 @@ jobs:
369369

370370
notify-sdk:
371371
if: github.repository_owner == 'Apicurio' && github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
372-
runs-on: ubuntu-20.04
372+
runs-on: ubuntu-latest
373373
strategy:
374374
matrix:
375375
language: [ js ]

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ public void testUpdateArtifact(String groupId, String artifactId, InputStream da
453453
}
454454

455455
/**
456-
* @see io.apicurio.registry.rest.v3.GroupsResource#getArtifactVersion(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.HandleReferencesType)
456+
* @see io.apicurio.registry.rest.v3.GroupsResource#getArtifactVersionContent(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.HandleReferencesType)
457457
*/
458458
@Override
459459
@Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Read)
460-
public Response getArtifactVersion(String groupId, String artifactId, String versionExpression, HandleReferencesType references) {
460+
public Response getArtifactVersionContent(String groupId, String artifactId, String versionExpression, HandleReferencesType references) {
461461
requireParameter("groupId", groupId);
462462
requireParameter("artifactId", artifactId);
463463
requireParameter("versionExpression", versionExpression);

app/src/test/java/io/apicurio/registry/auth/SimpleAuthTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void testDevRole() throws Exception {
137137
});
138138
TestUtils.retry(() -> client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).get());
139139

140-
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get().readAllBytes().length > 0);
140+
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").content().get().readAllBytes().length > 0);
141141

142142
Rule ruleConfig = new Rule();
143143
ruleConfig.setType(RuleType.VALIDITY);
@@ -175,7 +175,7 @@ public void testAdminRole() throws Exception {
175175
});
176176
TestUtils.retry(() -> client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).get());
177177

178-
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get().readAllBytes().length > 0);
178+
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").content().get().readAllBytes().length > 0);
179179

180180
Rule ruleConfig = new Rule();
181181
ruleConfig.setType(RuleType.VALIDITY);
@@ -210,7 +210,7 @@ public void testAdminRoleBasicAuth() throws Exception {
210210
});
211211
TestUtils.retry(() -> client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).get());
212212

213-
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get().readAllBytes().length > 0);
213+
assertTrue(client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").content().get().readAllBytes().length > 0);
214214

215215
Rule ruleConfig = new Rule();
216216
ruleConfig.setType(RuleType.VALIDITY);

app/src/test/java/io/apicurio/registry/limits/LimitsTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public void testLimits() throws Exception {
7373
.byArtifactId(artifactId)
7474
.versions()
7575
.byVersionExpression("1")
76-
.meta()
7776
.put(meta)
7877
;
7978

@@ -95,7 +94,6 @@ public void testLimits() throws Exception {
9594
.byArtifactId(artifactId)
9695
.versions()
9796
.byVersionExpression("1")
98-
.meta()
9997
.put(invalidmeta)
10098
;
10199
});

app/src/test/java/io/apicurio/registry/noprofile/VersionStateTest.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@ public void testSmoke() throws Exception {
4242
content.setContent("{\"type\": \"float\"}");
4343
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().post(content);
4444

45-
VersionMetaData amd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
45+
VersionMetaData amd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
4646
Assertions.assertEquals("3", amd.getVersion());
4747

4848
// disable latest
4949

5050
EditableVersionMetaData evmd = toEditableVersionMetaData(VersionState.DISABLED);
51-
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression(amd.getVersion()).meta().put(evmd);
51+
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression(amd.getVersion()).put(evmd);
5252

53-
VersionMetaData tvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().get();
53+
VersionMetaData tvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").get();
5454
Assertions.assertEquals("3", tvmd.getVersion());
5555
Assertions.assertEquals(VersionState.DISABLED, tvmd.getState());
5656

5757
// Latest artifact version (3) is disabled, this will return a previous version
58-
VersionMetaData tamd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
58+
VersionMetaData tamd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
5959
Assertions.assertEquals("2", tamd.getVersion());
6060
Assertions.assertNull(tamd.getDescription());
6161

62-
// cannot get a disabled artifact version
62+
// cannot get a disabled artifact version *content*
6363

6464
var exception = assertThrows(io.apicurio.registry.rest.client.models.Error.class, () -> {
65-
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").get();
65+
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").content().get();
6666
});
6767
Assertions.assertEquals(404, exception.getErrorCode());
6868
Assertions.assertEquals("VersionNotFoundException", exception.getName());
@@ -71,42 +71,42 @@ public void testSmoke() throws Exception {
7171
EditableVersionMetaData emd = new EditableVersionMetaData();
7272
String description = "Testing artifact state";
7373
emd.setDescription(description);
74-
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().put(emd);
74+
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").put(emd);
7575

7676
{
77-
VersionMetaData innerAvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().get();
77+
VersionMetaData innerAvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").get();
7878
Assertions.assertEquals("3", innerAvmd.getVersion());
7979
Assertions.assertEquals(description, innerAvmd.getDescription());
8080
}
8181

82-
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().put(toEditableVersionMetaData(VersionState.DEPRECATED));
82+
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").put(toEditableVersionMetaData(VersionState.DEPRECATED));
8383

84-
tamd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
84+
tamd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
8585
Assertions.assertEquals("3", tamd.getVersion()); // should be back to v3
8686
Assertions.assertEquals(tamd.getDescription(), description);
8787

88-
InputStream latestArtifact = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
88+
InputStream latestArtifact = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").content().get();
8989
Assertions.assertNotNull(latestArtifact);
9090
latestArtifact.close();
91-
InputStream version = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("2").get();
91+
InputStream version = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("2").content().get();
9292
Assertions.assertNotNull(version);
9393
version.close();
9494

9595
{
96-
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
96+
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
9797
Assertions.assertEquals("3", innerAmd.getVersion());
9898
Assertions.assertEquals(description, innerAmd.getDescription());
9999
}
100100

101101
// can revert back to enabled from deprecated
102-
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().put(toEditableVersionMetaData(VersionState.ENABLED));
102+
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").put(toEditableVersionMetaData(VersionState.ENABLED));
103103

104104
{
105-
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
105+
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
106106
Assertions.assertEquals("3", innerAmd.getVersion()); // should still be latest (aka 3)
107107
Assertions.assertEquals(description, innerAmd.getDescription());
108108

109-
VersionMetaData innerVmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1").meta().get();
109+
VersionMetaData innerVmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1").get();
110110
Assertions.assertNull(innerVmd.getDescription());
111111
}
112112
}

app/src/test/java/io/apicurio/registry/noprofile/maven/RegistryMojoWithAutoReferencesTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void autoRegisterJsonSchemaWithReferences() throws Exception {
152152
}
153153

154154
private void validateStructure(String groupId, String artifactId, int expectedMainReferences, int expectedTotalArtifacts, Set<String> originalContents) throws Exception {
155-
final VersionMetaData artifactWithReferences = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
155+
final VersionMetaData artifactWithReferences = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
156156
final String mainContent =
157157
new String(
158158
clientV3
@@ -162,6 +162,7 @@ private void validateStructure(String groupId, String artifactId, int expectedMa
162162
.byArtifactId(artifactId)
163163
.versions()
164164
.byVersionExpression(artifactWithReferences.getVersion())
165+
.content()
165166
.get()
166167
.readAllBytes(), StandardCharsets.UTF_8);
167168

@@ -189,6 +190,7 @@ private void validateReferences(List<ArtifactReference> artifactReferences, Set<
189190
.byArtifactId(artifactReference.getArtifactId())
190191
.versions()
191192
.byVersionExpression(artifactReference.getVersion())
193+
.content()
192194
.get()
193195
.readAllBytes(), StandardCharsets.UTF_8);
194196
VersionMetaData referenceMetadata = clientV3
@@ -198,7 +200,6 @@ private void validateReferences(List<ArtifactReference> artifactReferences, Set<
198200
.byArtifactId(artifactReference.getArtifactId())
199201
.versions()
200202
.byVersionExpression("branch=latest")
201-
.meta()
202203
.get()
203204
;
204205
Assertions.assertTrue(loadedContents.contains(referenceContent.trim()));

app/src/test/java/io/apicurio/registry/noprofile/maven/RegistryMojoWithMinifyTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public void testMinify() throws Exception {
4747
registerMojo.execute();
4848

4949
// Wait for the artifact to be created.
50-
InputStream artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoMinified").versions().byVersionExpression("branch=latest").get();
50+
InputStream artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoMinified").versions().byVersionExpression("branch=latest").content().get();
5151
String artifactContent = new String(artifactInputStream.readAllBytes(), StandardCharsets.UTF_8);
5252
Assertions.assertEquals("{\"type\":\"record\",\"name\":\"userInfo\",\"namespace\":\"my.example\",\"fields\":[{\"name\":\"age\",\"type\":\"int\"}]}", artifactContent);
5353

5454
// Wait for the artifact to be created.
55-
artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoNotMinified").versions().byVersionExpression("branch=latest").get();
55+
artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoNotMinified").versions().byVersionExpression("branch=latest").content().get();
5656
artifactContent = new String(artifactInputStream.readAllBytes(), StandardCharsets.UTF_8);
5757
Assertions.assertEquals("{\n" +
5858
" \"type\" : \"record\",\n" +

app/src/test/java/io/apicurio/registry/noprofile/rest/v3/CustomizeDateFormatTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void testOpenApiCompliantDateFormat() throws Exception {
4141
.when()
4242
.pathParam("groupId", GROUP)
4343
.pathParam("artifactId", "testGetArtifactMetaData/EmptyAPI")
44-
.get("/registry/v3/groups/{groupId}/artifacts/{artifactId}/versions/branch=latest/meta")
44+
.get("/registry/v3/groups/{groupId}/artifacts/{artifactId}/versions/branch=latest")
4545
.then()
4646
.statusCode(200)
4747
.body("createdOn", new BaseMatcher<Object>() {

0 commit comments

Comments
 (0)