diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataOperations.java b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataOperations.java
index 195c5558..2cc389b4 100644
--- a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataOperations.java
+++ b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataOperations.java
@@ -1,34 +1,55 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.vault.core;
+import org.springframework.lang.Nullable;
import org.springframework.vault.support.VaultMetadataRequest;
import org.springframework.vault.support.VaultMetadataResponse;
/**
- * Interface that specifies kv metadata related operations
+ * Interface that specifies kv metadata related operations.
*
* @author Zakaria Amine
- * @see kv backend metadata api docs
+ * @see Key-Value
+ * Metadata API
+ * @since 2.3
*/
public interface VaultKeyValueMetadataOperations {
- /**
- * permanently deletes the key metadata and all version data for the specified key. All version history will be removed.
- * @param path the secret path, must not be null or empty
- */
- void delete(String path);
+ /**
+ * Retrieve the metadata and versions for the secret at the specified path.
+ * @param path the secret path, must not be {@literal null} or empty.
+ * @return {@link VaultMetadataResponse}
+ */
+ @Nullable
+ VaultMetadataResponse get(String path);
- /**
- * retrieves the metadata and versions for the secret at the specified path.
- * @param path the secret path, must not be null or empty
- * @return {@link VaultMetadataResponse}
- */
- VaultMetadataResponse get(String path);
+ /**
+ * Update the secret metadata, or creates new metadata if not present.
+ *
+ * @param path the secret path, must not be {@literal null} or empty.
+ * @param body {@link VaultMetadataRequest}
+ */
+ void put(String path, VaultMetadataRequest body);
- /**
- * Updates the secret metadata, or creates new metadata if not present.
- *
- * @param path the secret path, must not be null or empty
- * @param body {@link VaultMetadataRequest}
- */
- void put(String path, VaultMetadataRequest body);
+ /**
+ * Permanently delete the key metadata and all version data for the specified key. All
+ * version history will be removed.
+ * @param path the secret path, must not be {@literal null} or empty.
+ */
+ void delete(String path);
}
diff --git a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataTemplate.java b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataTemplate.java
index 9028e865..baa90176 100644
--- a/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataTemplate.java
+++ b/spring-vault-core/src/main/java/org/springframework/vault/core/VaultKeyValueMetadataTemplate.java
@@ -1,107 +1,135 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.vault.core;
+import java.time.Duration;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
-import java.util.Spliterator;
-import java.util.Spliterators;
import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
-import org.springframework.vault.client.VaultResponses;
+import org.springframework.util.StringUtils;
+import org.springframework.vault.support.DurationParser;
import org.springframework.vault.support.VaultMetadataRequest;
import org.springframework.vault.support.VaultMetadataResponse;
+import org.springframework.vault.support.VaultResponseSupport;
import org.springframework.vault.support.Versioned;
-import org.springframework.web.client.HttpStatusCodeException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
+/**
+ * Default implementation of {@link VaultKeyValueMetadataOperations}.
+ *
+ * @author Zakaria Amine
+ * @author Mark Paluch
+ * @since 2.3
+ */
+class VaultKeyValueMetadataTemplate implements VaultKeyValueMetadataOperations {
-public class VaultKeyValueMetadataTemplate implements VaultKeyValueMetadataOperations {
+ private final VaultOperations vaultOperations;
- private final VaultOperations vaultOperations;
+ private final String basePath;
- private final String basePath;
+ VaultKeyValueMetadataTemplate(VaultOperations vaultOperations, String basePath) {
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ Assert.notNull(vaultOperations, "VaultOperations must not be null");
- public VaultKeyValueMetadataTemplate(VaultOperations vaultOperations, String basePath) {
- Assert.notNull(vaultOperations, "VaultOperations must not be null");
- this.vaultOperations = vaultOperations;
- this.basePath = basePath;
- }
+ this.vaultOperations = vaultOperations;
+ this.basePath = basePath;
+ }
- @Override
- public void delete(String path) {
- Assert.hasText(path, "Path must not be empty");
- vaultOperations.delete("/"+this.basePath+"/metadata/" + path);
- }
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public VaultMetadataResponse get(String path) {
- @Override
- public VaultMetadataResponse get(String path) {
- Assert.hasText(path, "Path must not be empty");
- Map metadataResponse =
- vaultOperations.read("/" + this.basePath + "/metadata/" + path, Map.class).getData();
+ VaultResponseSupport