@Test public void createClientConfig() { AwsClientFactory factory = new AwsClientFactory(config); ClientOverrideConfiguration settings = factory.createClientConfig(null); Assert.assertEquals("default", getUserAgentPrefix(settings)); }
ClientOverrideConfiguration createClientConfig(String name) { final Config cfg = getConfig(name, "client"); ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder(); setIfPresent(cfg, "api-call-timeout", builder::apiCallTimeout); setIfPresent(cfg, "api-call-attempt-timeout", builder::apiCallAttemptTimeout); setIfPresent(cfg, "user-agent-prefix", SdkAdvancedClientOption.USER_AGENT_PREFIX, builder); setIfPresent(cfg, "user-agent-suffix", SdkAdvancedClientOption.USER_AGENT_SUFFIX, builder); if (cfg.hasPath("headers")) { for (String header : cfg.getStringList("headers")) { String[] parts = header.split(":", 2); if (parts.length == 2) { builder.putHeader(parts[0].trim(), parts[1].trim()); } else { LOGGER.warn("ignoring invalid header string: '{}'", header); } } } return builder.build(); }
AwsClientFactory implements AutoCloseable { ClientOverrideConfiguration createClientConfig(String name) { final Config cfg = getConfig(name, "client"); ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder(); setIfPresent(cfg, "api-call-timeout", builder::apiCallTimeout); setIfPresent(cfg, "api-call-attempt-timeout", builder::apiCallAttemptTimeout); setIfPresent(cfg, "user-agent-prefix", SdkAdvancedClientOption.USER_AGENT_PREFIX, builder); setIfPresent(cfg, "user-agent-suffix", SdkAdvancedClientOption.USER_AGENT_SUFFIX, builder); if (cfg.hasPath("headers")) { for (String header : cfg.getStringList("headers")) { String[] parts = header.split(":", 2); if (parts.length == 2) { builder.putHeader(parts[0].trim(), parts[1].trim()); } else { LOGGER.warn("ignoring invalid header string: '{}'", header); } } } return builder.build(); } }
AwsClientFactory implements AutoCloseable { ClientOverrideConfiguration createClientConfig(String name) { final Config cfg = getConfig(name, "client"); ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder(); setIfPresent(cfg, "api-call-timeout", builder::apiCallTimeout); setIfPresent(cfg, "api-call-attempt-timeout", builder::apiCallAttemptTimeout); setIfPresent(cfg, "user-agent-prefix", SdkAdvancedClientOption.USER_AGENT_PREFIX, builder); setIfPresent(cfg, "user-agent-suffix", SdkAdvancedClientOption.USER_AGENT_SUFFIX, builder); if (cfg.hasPath("headers")) { for (String header : cfg.getStringList("headers")) { String[] parts = header.split(":", 2); if (parts.length == 2) { builder.putHeader(parts[0].trim(), parts[1].trim()); } else { LOGGER.warn("ignoring invalid header string: '{}'", header); } } } return builder.build(); } @Inject  AwsClientFactory(Config config); }
AwsClientFactory implements AutoCloseable { ClientOverrideConfiguration createClientConfig(String name) { final Config cfg = getConfig(name, "client"); ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder(); setIfPresent(cfg, "api-call-timeout", builder::apiCallTimeout); setIfPresent(cfg, "api-call-attempt-timeout", builder::apiCallAttemptTimeout); setIfPresent(cfg, "user-agent-prefix", SdkAdvancedClientOption.USER_AGENT_PREFIX, builder); setIfPresent(cfg, "user-agent-suffix", SdkAdvancedClientOption.USER_AGENT_SUFFIX, builder); if (cfg.hasPath("headers")) { for (String header : cfg.getStringList("headers")) { String[] parts = header.split(":", 2); if (parts.length == 2) { builder.putHeader(parts[0].trim(), parts[1].trim()); } else { LOGGER.warn("ignoring invalid header string: '{}'", header); } } } return builder.build(); } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close(); }
AwsClientFactory implements AutoCloseable { ClientOverrideConfiguration createClientConfig(String name) { final Config cfg = getConfig(name, "client"); ClientOverrideConfiguration.Builder builder = ClientOverrideConfiguration.builder(); setIfPresent(cfg, "api-call-timeout", builder::apiCallTimeout); setIfPresent(cfg, "api-call-attempt-timeout", builder::apiCallAttemptTimeout); setIfPresent(cfg, "user-agent-prefix", SdkAdvancedClientOption.USER_AGENT_PREFIX, builder); setIfPresent(cfg, "user-agent-suffix", SdkAdvancedClientOption.USER_AGENT_SUFFIX, builder); if (cfg.hasPath("headers")) { for (String header : cfg.getStringList("headers")) { String[] parts = header.split(":", 2); if (parts.length == 2) { builder.putHeader(parts[0].trim(), parts[1].trim()); } else { LOGGER.warn("ignoring invalid header string: '{}'", header); } } } return builder.build(); } @Inject  AwsClientFactory(Config config); T newInstance(Class<T> cls); T newInstance(String name, Class<T> cls); T newInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T newInstance(String name, Class<T> cls, String accountId); T getInstance(Class<T> cls); T getInstance(String name, Class<T> cls); T getInstance(Class<T> cls, String accountId); @SuppressWarnings("unchecked") T getInstance(String name, Class<T> cls, String accountId); @Override void close();  }