Skip to content

Commit d1266af

Browse files
committed
Update the REST API endpoint for creating snapshots
1 parent 2ab68fa commit d1266af

File tree

10 files changed

+256
-277
lines changed

10 files changed

+256
-277
lines changed

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

+32-30
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
package io.apicurio.registry.rest.v3;
22

3-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_FOR_BROWSER;
4-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_NAME;
5-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_PRINCIPAL_ID;
6-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_ROLE_MAPPING;
7-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_RULE;
8-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_RULE_TYPE;
9-
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_UPDATE_ROLE;
10-
import static io.apicurio.registry.util.DtoUtil.appAuthPropertyToRegistry;
11-
import static io.apicurio.registry.util.DtoUtil.registryAuthPropertyToApp;
12-
13-
import java.io.IOException;
14-
import java.io.InputStream;
15-
import java.math.BigInteger;
16-
import java.nio.charset.StandardCharsets;
17-
import java.util.HashMap;
18-
import java.util.List;
19-
import java.util.Map;
20-
import java.util.function.Supplier;
21-
import java.util.stream.Collectors;
22-
import java.util.stream.Stream;
23-
import java.util.zip.ZipInputStream;
24-
25-
import org.eclipse.microprofile.config.Config;
26-
import org.eclipse.microprofile.config.inject.ConfigProperty;
27-
import org.slf4j.Logger;
28-
293
import io.apicurio.common.apps.config.Dynamic;
304
import io.apicurio.common.apps.config.DynamicConfigPropertyDef;
315
import io.apicurio.common.apps.config.DynamicConfigPropertyDto;
@@ -42,10 +16,12 @@
4216
import io.apicurio.registry.rest.MissingRequiredParameterException;
4317
import io.apicurio.registry.rest.v3.beans.ArtifactTypeInfo;
4418
import io.apicurio.registry.rest.v3.beans.ConfigurationProperty;
19+
import io.apicurio.registry.rest.v3.beans.CreateSnapshot;
4520
import io.apicurio.registry.rest.v3.beans.DownloadRef;
4621
import io.apicurio.registry.rest.v3.beans.RoleMapping;
4722
import io.apicurio.registry.rest.v3.beans.RoleMappingSearchResults;
4823
import io.apicurio.registry.rest.v3.beans.Rule;
24+
import io.apicurio.registry.rest.v3.beans.SnapshotMetaData;
4925
import io.apicurio.registry.rest.v3.beans.UpdateConfigurationProperty;
5026
import io.apicurio.registry.rest.v3.beans.UpdateRole;
5127
import io.apicurio.registry.rest.v3.shared.DataExporter;
@@ -73,6 +49,31 @@
7349
import jakarta.ws.rs.core.Context;
7450
import jakarta.ws.rs.core.MediaType;
7551
import jakarta.ws.rs.core.Response;
52+
import org.eclipse.microprofile.config.Config;
53+
import org.eclipse.microprofile.config.inject.ConfigProperty;
54+
import org.slf4j.Logger;
55+
56+
import java.io.IOException;
57+
import java.io.InputStream;
58+
import java.math.BigInteger;
59+
import java.nio.charset.StandardCharsets;
60+
import java.util.HashMap;
61+
import java.util.List;
62+
import java.util.Map;
63+
import java.util.function.Supplier;
64+
import java.util.stream.Collectors;
65+
import java.util.stream.Stream;
66+
import java.util.zip.ZipInputStream;
67+
68+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_FOR_BROWSER;
69+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_NAME;
70+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_PRINCIPAL_ID;
71+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_ROLE_MAPPING;
72+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_RULE;
73+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_RULE_TYPE;
74+
import static io.apicurio.common.apps.logging.audit.AuditingConstants.KEY_UPDATE_ROLE;
75+
import static io.apicurio.registry.util.DtoUtil.appAuthPropertyToRegistry;
76+
import static io.apicurio.registry.util.DtoUtil.registryAuthPropertyToApp;
7677

7778
@ApplicationScoped
7879
@Interceptors({ResponseErrorLivenessCheck.class, ResponseTimeoutReadinessCheck.class})
@@ -109,7 +110,7 @@ public class AdminResourceImpl implements AdminResource {
109110
@Info(category = "download", description = "Download link expiry", availableSince = "2.1.2.Final")
110111
Supplier<Long> downloadHrefTtl;
111112

112-
private static final void requireParameter(String parameterName, Object parameterValue) {
113+
private static void requireParameter(String parameterName, Object parameterValue) {
113114
if (parameterValue == null) {
114115
throw new MissingRequiredParameterException(parameterName);
115116
}
@@ -135,8 +136,9 @@ public List<ArtifactTypeInfo> listArtifactTypes() {
135136

136137
@Override
137138
@Authorized(style=AuthorizedStyle.None, level=AuthorizedLevel.Admin)
138-
public void triggerSnapshot() {
139+
public SnapshotMetaData triggerSnapshot(CreateSnapshot data) {
139140
storage.triggerSnapshotCreation();
141+
return SnapshotMetaData.builder().build();
140142
}
141143

142144
/**
@@ -381,7 +383,7 @@ public List<ConfigurationProperty> listConfigProperties() {
381383
// Return value is the set of all dynamic config properties, with either configured or default values (depending
382384
// on whether the value is actually configured and stored in the DB or not).
383385
return dynamicPropertyIndex.getAcceptedPropertyNames().stream()
384-
.sorted((pname1, pname2) -> pname1.compareTo(pname2))
386+
.sorted(String::compareTo)
385387
.map(pname -> propsI.containsKey(pname) ? V3ApiUtil.dtoToConfigurationProperty(dynamicPropertyIndex.getProperty(pname), propsI.get(pname)) : defToConfigurationProperty(dynamicPropertyIndex.getProperty(pname)))
386388
.collect(Collectors.toList());
387389
}
@@ -454,7 +456,7 @@ private ConfigurationProperty defToConfigurationProperty(DynamicConfigPropertyDe
454456

455457
/**
456458
* Lookup the dynamic configuration property being set. Ensure that it exists (throws
457-
* a {@link NotFoundException} if it does not.
459+
* a {@link io.apicurio.registry.storage.error.NotFoundException} if it does not.
458460
* @param propertyName the name of the dynamic property
459461
* @return the dynamic config property definition
460462
*/

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

+32-4
Original file line numberDiff line numberDiff line change
@@ -2482,18 +2482,34 @@
24822482
"description": "Gets a list of all the configured artifact types.\n\nThis operation can fail for the following reasons:\n\n* A server error occurred (HTTP error `500`)\n"
24832483
}
24842484
},
2485-
"/admin/config/triggerSnapshot": {
2485+
"/admin/snapshots": {
24862486
"summary": "Triggers a snapshot of the Registry storage. Only supported in KafkaSQL storage",
2487-
"get": {
2487+
"post": {
2488+
"requestBody": {
2489+
"content": {
2490+
"application/json": {
2491+
"schema": {
2492+
"$ref": "#/components/schemas/CreateSnapshot"
2493+
}
2494+
}
2495+
},
2496+
"required": true
2497+
},
24882498
"tags": [
24892499
"KafkaSQL",
24902500
"Admin",
24912501
"Snapshot"
24922502
],
24932503
"responses": {
24942504
"200": {
2495-
"content": {},
2496-
"description": "Empty content. A 200 means that the snapshot has been successfully triggered."
2505+
"content": {
2506+
"application/json": {
2507+
"schema": {
2508+
"$ref": "#/components/schemas/SnapshotMetaData"
2509+
}
2510+
}
2511+
},
2512+
"description": "The snapshot has been successfully triggered."
24972513
},
24982514
"500": {
24992515
"$ref": "#/components/responses/ServerError"
@@ -4442,6 +4458,18 @@
44424458
"createdOn"
44434459
],
44444460
"type": "string"
4461+
},
4462+
"CreateSnapshot": {
4463+
"title": "Root Type for CreateSnapshot",
4464+
"description": "",
4465+
"type": "object",
4466+
"example": {}
4467+
},
4468+
"SnapshotMetaData": {
4469+
"title": "Root Type for SnapshotMetaData",
4470+
"description": "",
4471+
"type": "object",
4472+
"example": {}
44454473
}
44464474
},
44474475
"responses": {

go-sdk/pkg/registryclient-v2/models/new_comment_escaped.go

-86
This file was deleted.

go-sdk/pkg/registryclient-v3/admin/admin_request_builder.go

+5
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,8 @@ func (m *AdminRequestBuilder) RoleMappings() *RoleMappingsRequestBuilder {
4848
func (m *AdminRequestBuilder) Rules() *RulesRequestBuilder {
4949
return NewRulesRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
5050
}
51+
52+
// Snapshots triggers a snapshot of the Registry storage. Only supported in KafkaSQL storage
53+
func (m *AdminRequestBuilder) Snapshots() *SnapshotsRequestBuilder {
54+
return NewSnapshotsRequestBuilderInternal(m.BaseRequestBuilder.PathParameters, m.BaseRequestBuilder.RequestAdapter)
55+
}

go-sdk/pkg/registryclient-v3/admin/config_trigger_snapshot_request_builder.go

-70
This file was deleted.

0 commit comments

Comments
 (0)