Closed hshyamh4 closed 9 years ago
You can make a request to /automation/secrets?name=<secret name>
. Here's the method.
This service is working fine for secret without version. 1.How can i make it works for secret with version ?
if i create a secret without version and trying to call then i am getting,
Exception in thread "main" keywhiz.client.KeywhizClient$NotFoundException: Resource not found (404)
at keywhiz.client.KeywhizClient.throwOnCommonError(KeywhizClient.java:274)
at keywhiz.client.KeywhizClient.httpGet(KeywhizClient.java:296)
at keywhiz.client.KeywhizClient.getSecretDetailsByName(KeywhizClient.java:177)
at com.cybermoney.keywhiz.Application.testCreateNewSecret(Application.java:56)
at com.cybermoney.keywhiz.Application.main(Application.java:41)
2.Even if i call a secret(no version) i am getting error like,
Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of keywhiz.api.AutomationSecretResponse, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information
at [Source: [{"secret":"AAcddvvdo5e/jWaE=.............","creationDate":"2015-06-11T12:40:24.513Z","isVersioned":false,"secretLength":2474,"name":"cybermoney_key_store111","groups":[],"id":15,"client":"client","group":"Security"}]; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)
at com.fasterxml.jackson.databind.DeserializationContext.instantiationException(DeserializationContext.java:857)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:139)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3560)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2576)
at keywhiz.client.KeywhizClient.getSecretDetailsByName(KeywhizClient.java:178)
at com.cybermoney.keywhiz.Application.testCreateNewSecret(Application.java:56)
at com.cybermoney.keywhiz.Application.main(Application.java:41)
I am using this call like,
public AutomationSecretResponse getSecretDetailsByName(String secretName) throws IOException {
String response = httpGet(String.format("/automation/secrets?name=%s", secretName));
return mapper.readValue(response, AutomationSecretResponse.class);
}
please help me.
For 1) what is the URL? It says 404, but not where your request went.
For 2) The error is coming from your method and it's deserializing JSON to the wrong type. Keep in mind /secret/<secret_name>
and /automation/secrets?name=<secret_name>
are different endpoints with different JSON responses. GET /automation/secrets?name=<secret_name>
returns List<AutomationSecretResponse>
.
I gone through the link http://square.github.io/keywhiz/apidocs/#!/secrets-admin/createSecret and found
It is mentioned as 'Implementation Notes 'Returns a single secret or a set of all secrets'
So i want to access this service by name.