use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class SecretServiceImpl method decryptString.
@Override
public String decryptString(Context ctx, String instanceId, String s) throws Exception {
byte[] input;
try {
input = DatatypeConverter.parseBase64Binary(s);
} catch (Exception e) {
throw new IllegalArgumentException("Invalid encrypted string value, please verify that it was specified/copied correctly: " + e.getMessage());
}
ApiClient c = clientFactory.create(ctx);
String path = "/api/v1/process/" + instanceId + "/decrypt";
ApiResponse<byte[]> r = ClientUtils.withRetry(RETRY_COUNT, RETRY_INTERVAL, () -> {
Type returnType = new TypeToken<byte[]>() {
}.getType();
return ClientUtils.postData(c, path, input, returnType);
});
return new String(r.getData());
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class ApiClientFactoryImpl method create.
@Override
public ApiClient create(ApiClientConfiguration overrides) {
String baseUrl = overrides.baseUrl() != null ? overrides.baseUrl() : cfg.getBaseUrl();
String sessionToken = null;
if (overrides.apiKey() == null) {
sessionToken = overrides.sessionToken();
Context ctx = overrides.context();
if (sessionToken == null && ctx != null) {
sessionToken = cfg.getSessionToken(ctx);
}
}
String apiKey = overrides.apiKey();
if (apiKey != null) {
sessionToken = null;
}
if (sessionToken == null && apiKey == null) {
throw new IllegalArgumentException("Session token or an API key is required");
}
ApiClient client = new ConcordApiClient(baseUrl, httpClient).setSessionToken(sessionToken).setApiKey(apiKey).addDefaultHeader("Accept", "*/*").setTempFolderPath(tmpDir.toString());
UUID txId = getTxId(overrides);
if (txId != null) {
client = client.setUserAgent("Concord-Runner: txId=" + txId);
}
return client;
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class Main method main.
public static void main(String[] args) throws Exception {
RunnerConfiguration runnerCfg = readRunnerConfiguration(args);
// create the inject with all dependencies and services available before
// the actual process' working directory is ready. It allows us to load
// all dependencies and have them available in "pre-fork" situations
Injector injector = InjectorFactory.createDefault(runnerCfg);
try {
ProcessConfiguration processCfg = injector.getInstance(ProcessConfiguration.class);
ApiClient apiClient = injector.getInstance(ApiClient.class);
ProcessHeartbeat heartbeat = new ProcessHeartbeat(apiClient, processCfg.instanceId(), runnerCfg.api().maxNoHeartbeatInterval());
heartbeat.start();
Main main = injector.getInstance(Main.class);
main.execute();
System.exit(0);
} catch (MultiException e) {
log.error(e.getMessage());
System.exit(1);
} catch (Throwable t) {
log.error("", t);
System.exit(1);
}
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class GitHubNonOrgEventIt method githubEvent.
private void githubEvent(String eventFile, String repoName, String eventName) throws Exception {
String event = new String(Files.readAllBytes(Paths.get(GitHubNonOrgEventIt.class.getResource(eventFile).toURI())));
if (repoName != null) {
event = event.replace("org-repo", repoName);
}
ApiClient client = getApiClient();
client.addDefaultHeader("X-Hub-Signature", "sha1=" + GitHubUtils.sign(event));
GitHubEventsApi gitHubEvents = new GitHubEventsApi(client);
String result = gitHubEvents.onEvent(event, "abc", eventName);
assertEquals("ok", result);
}
use of com.walmartlabs.concord.ApiClient in project concord by walmartlabs.
the class InventoryQueryIT method testDifferentContentTypes.
@Test
public void testDifferentContentTypes() throws Exception {
ApiClient client = getApiClient();
OrganizationsApi organizationsApi = new OrganizationsApi(getApiClient());
String orgName = "org_" + randomString();
organizationsApi.createOrUpdate(new OrganizationEntry().setName(orgName));
InventoriesApi inventoriesApi = new InventoriesApi(getApiClient());
String inventoryName = "inventory_" + randomString();
inventoriesApi.createOrUpdate(orgName, new InventoryEntry().setName(inventoryName));
// ---
assertQuery(client, orgName, inventoryName, "q1_" + randomString(), "text/plain");
assertQuery(client, orgName, inventoryName, "q2_" + randomString(), "application/json");
}
Aggregations