use of com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest in project spring-cloud-config by spring-cloud.
the class AwsParameterStoreEnvironmentRepository method getPropertiesByParameterPath.
private Map<String, String> getPropertiesByParameterPath(String path) {
Map<String, String> result = new HashMap<>();
GetParametersByPathRequest request = new GetParametersByPathRequest().withPath(path).withRecursive(environmentProperties.isRecursive()).withWithDecryption(environmentProperties.isDecryptValues()).withMaxResults(environmentProperties.getMaxResults());
GetParametersByPathResult response = awsSsmClient.getParametersByPath(request);
if (response != null) {
addParametersToProperties(path, response.getParameters(), result);
while (StringUtils.hasLength(response.getNextToken())) {
response = awsSsmClient.getParametersByPath(request.withNextToken(response.getNextToken()));
addParametersToProperties(path, response.getParameters(), result);
}
}
return result;
}
use of com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest in project spring-cloud-config by spring-cloud.
the class AwsParameterStoreEnvironmentRepositoryTests method setupAwsSsmClientMocks.
private void setupAwsSsmClientMocks(Environment environment, boolean withSlashesForPropertyName, boolean paginatedResponse) {
for (PropertySource ps : environment.getPropertySources()) {
String path = StringUtils.delete(ps.getName(), environmentProperties.getOrigin());
GetParametersByPathRequest request = new GetParametersByPathRequest().withPath(path).withRecursive(environmentProperties.isRecursive()).withWithDecryption(environmentProperties.isDecryptValues()).withMaxResults(environmentProperties.getMaxResults());
Set<Parameter> parameters = getParameters(ps, path, withSlashesForPropertyName);
GetParametersByPathResult response = new GetParametersByPathResult().withParameters(parameters);
if (paginatedResponse && environmentProperties.getMaxResults() < parameters.size()) {
List<Set<Parameter>> chunks = splitParametersIntoChunks(parameters);
String nextToken = null;
for (int i = 0; i < chunks.size(); i++) {
Set<Parameter> chunk = chunks.get(i);
if (i == 0) {
nextToken = generateNextToken();
GetParametersByPathResult responseClone = response.clone().withParameters(chunk).withNextToken(nextToken);
when(awsSsmClientMock.getParametersByPath(eq(request))).thenReturn(responseClone);
} else if (i == chunks.size() - 1) {
GetParametersByPathRequest requestClone = request.clone().withNextToken(nextToken);
GetParametersByPathResult responseClone = response.clone().withParameters(chunk);
when(awsSsmClientMock.getParametersByPath(eq(requestClone))).thenReturn(responseClone);
} else {
String newNextToken = generateNextToken();
GetParametersByPathRequest requestClone = request.clone().withNextToken(nextToken);
GetParametersByPathResult responseClone = response.clone().withParameters(chunk).withNextToken(newNextToken);
when(awsSsmClientMock.getParametersByPath(eq(requestClone))).thenReturn(responseClone);
nextToken = newNextToken;
}
}
} else {
when(awsSsmClientMock.getParametersByPath(eq(request))).thenReturn(response);
}
}
}
use of com.amazonaws.services.simplesystemsmanagement.model.GetParametersByPathRequest in project spring-cloud-aws by awspring.
the class AwsParamStorePropertySource method init.
public void init() {
GetParametersByPathRequest paramsRequest = new GetParametersByPathRequest().withPath(context).withRecursive(true).withWithDecryption(true);
getParameters(paramsRequest);
}
Aggregations