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

[REST API v3] Invert the metadata and content API endpoints for versions #4581

Merged
merged 8 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ env:
jobs:
build-verify:
name: Verify Application Build
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
steps:
- name: Checkout Code with Ref '${{ github.ref }}'
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:

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

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

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

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

notify-sdk:
if: github.repository_owner == 'Apicurio' && github.event_name == 'push' && github.ref == 'refs/heads/main' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
matrix:
language: [ js ]
Expand Down
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ public void testUpdateArtifact(String groupId, String artifactId, InputStream da
}

/**
* @see io.apicurio.registry.rest.v3.GroupsResource#getArtifactVersion(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.HandleReferencesType)
* @see io.apicurio.registry.rest.v3.GroupsResource#getArtifactVersionContent(java.lang.String, java.lang.String, java.lang.String, io.apicurio.registry.rest.v3.beans.HandleReferencesType)
*/
@Override
@Authorized(style = AuthorizedStyle.GroupAndArtifact, level = AuthorizedLevel.Read)
public Response getArtifactVersion(String groupId, String artifactId, String versionExpression, HandleReferencesType references) {
public Response getArtifactVersionContent(String groupId, String artifactId, String versionExpression, HandleReferencesType references) {
requireParameter("groupId", groupId);
requireParameter("artifactId", artifactId);
requireParameter("versionExpression", versionExpression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void testDevRole() throws Exception {
});
TestUtils.retry(() -> client.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).get());

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

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

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

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

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

Rule ruleConfig = new Rule();
ruleConfig.setType(RuleType.VALIDITY);
Expand Down
2 changes: 0 additions & 2 deletions app/src/test/java/io/apicurio/registry/limits/LimitsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void testLimits() throws Exception {
.byArtifactId(artifactId)
.versions()
.byVersionExpression("1")
.meta()
.put(meta)
;

Expand All @@ -95,7 +94,6 @@ public void testLimits() throws Exception {
.byArtifactId(artifactId)
.versions()
.byVersionExpression("1")
.meta()
.put(invalidmeta)
;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ public void testSmoke() throws Exception {
content.setContent("{\"type\": \"float\"}");
clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().post(content);

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

// disable latest

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

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

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

// cannot get a disabled artifact version
// cannot get a disabled artifact version *content*

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

{
VersionMetaData innerAvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").meta().get();
VersionMetaData innerAvmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("3").get();
Assertions.assertEquals("3", innerAvmd.getVersion());
Assertions.assertEquals(description, innerAvmd.getDescription());
}

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

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

InputStream latestArtifact = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
InputStream latestArtifact = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").content().get();
Assertions.assertNotNull(latestArtifact);
latestArtifact.close();
InputStream version = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("2").get();
InputStream version = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("2").content().get();
Assertions.assertNotNull(version);
version.close();

{
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
VersionMetaData innerAmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
Assertions.assertEquals("3", innerAmd.getVersion());
Assertions.assertEquals(description, innerAmd.getDescription());
}

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

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

VersionMetaData innerVmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1").meta().get();
VersionMetaData innerVmd = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("1").get();
Assertions.assertNull(innerVmd.getDescription());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void autoRegisterJsonSchemaWithReferences() throws Exception {
}

private void validateStructure(String groupId, String artifactId, int expectedMainReferences, int expectedTotalArtifacts, Set<String> originalContents) throws Exception {
final VersionMetaData artifactWithReferences = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").meta().get();
final VersionMetaData artifactWithReferences = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId(artifactId).versions().byVersionExpression("branch=latest").get();
final String mainContent =
new String(
clientV3
Expand All @@ -162,6 +162,7 @@ private void validateStructure(String groupId, String artifactId, int expectedMa
.byArtifactId(artifactId)
.versions()
.byVersionExpression(artifactWithReferences.getVersion())
.content()
.get()
.readAllBytes(), StandardCharsets.UTF_8);

Expand Down Expand Up @@ -189,6 +190,7 @@ private void validateReferences(List<ArtifactReference> artifactReferences, Set<
.byArtifactId(artifactReference.getArtifactId())
.versions()
.byVersionExpression(artifactReference.getVersion())
.content()
.get()
.readAllBytes(), StandardCharsets.UTF_8);
VersionMetaData referenceMetadata = clientV3
Expand All @@ -198,7 +200,6 @@ private void validateReferences(List<ArtifactReference> artifactReferences, Set<
.byArtifactId(artifactReference.getArtifactId())
.versions()
.byVersionExpression("branch=latest")
.meta()
.get()
;
Assertions.assertTrue(loadedContents.contains(referenceContent.trim()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void testMinify() throws Exception {
registerMojo.execute();

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

// Wait for the artifact to be created.
artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoNotMinified").versions().byVersionExpression("branch=latest").get();
artifactInputStream = clientV3.groups().byGroupId(groupId).artifacts().byArtifactId("userInfoNotMinified").versions().byVersionExpression("branch=latest").content().get();
artifactContent = new String(artifactInputStream.readAllBytes(), StandardCharsets.UTF_8);
Assertions.assertEquals("{\n" +
" \"type\" : \"record\",\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testOpenApiCompliantDateFormat() throws Exception {
.when()
.pathParam("groupId", GROUP)
.pathParam("artifactId", "testGetArtifactMetaData/EmptyAPI")
.get("/registry/v3/groups/{groupId}/artifacts/{artifactId}/versions/branch=latest/meta")
.get("/registry/v3/groups/{groupId}/artifacts/{artifactId}/versions/branch=latest")
.then()
.statusCode(200)
.body("createdOn", new BaseMatcher<Object>() {
Expand Down
Loading
Loading