下面列出了怎么用com.amazonaws.services.devicefarm.AWSDeviceFarmClient的API类实例代码及写法,或者点击链接到github查看源代码。
public AWSDeviceFarmClient initializeApiClient(final DeviceFarmExtension extension) {
final String roleArn = extension.getAuthentication().getRoleArn();
AWSCredentials credentials = extension.getAuthentication();
if (roleArn != null) {
final STSAssumeRoleSessionCredentialsProvider sts = new STSAssumeRoleSessionCredentialsProvider
.Builder(roleArn, RandomStringUtils.randomAlphanumeric(8))
.build();
credentials = sts.getCredentials();
}
final ClientConfiguration clientConfiguration = new ClientConfiguration()
.withUserAgent(String.format(extension.getUserAgent(), pluginVersion));
AWSDeviceFarmClient apiClient = new AWSDeviceFarmClient(credentials, clientConfiguration);
apiClient.setServiceNameIntern("devicefarm");
if (extension.getEndpointOverride() != null) {
apiClient.setEndpoint(extension.getEndpointOverride());
}
return apiClient;
}
private AWSDeviceFarm buildClient(String awsAccessKey, String awsSecretKey, String awsRegion) {
LOG.debug("Building AWS Device Farm client");
LOG.debug("awsAccessKey={}", awsAccessKey);
LOG.debug("awsSecretKey={}", awsSecretKey);
LOG.debug("awsRegion={}", awsRegion);
return AWSDeviceFarmClient.builder()
.withCredentials(
new AWSStaticCredentialsProvider(new BasicAWSCredentials(awsAccessKey, awsSecretKey)))
.withRegion(awsRegion)
.build();
}
public DeviceFarmServer(final DeviceFarmExtension extension,
final Logger logger, final AWSDeviceFarmClient deviceFarmClient) throws IOException {
this(extension, logger, deviceFarmClient,
new DeviceFarmUploader(deviceFarmClient, logger),
new DeviceFarmUtils(deviceFarmClient, extension));
}
/**
* Private AWSDeviceFarm constructor. Uses the roleArn to generate STS creds if the roleArn isn't null; otherwise
* just uses the AWSCredentials creds.
*
* @param creds AWSCredentials creds to use for authentication.
* @param roleArn Role ARN to use for authentication.
*/
private AWSDeviceFarm(AWSCredentials creds, String roleArn) {
if (roleArn != null) {
STSAssumeRoleSessionCredentialsProvider sts = new STSAssumeRoleSessionCredentialsProvider
.Builder(roleArn, RandomStringUtils.randomAlphanumeric(8))
.withRoleSessionDurationSeconds(MAX_ROLE_SESSION_TIMEOUT)
.build();
creds = sts.getCredentials();
}
ClientConfiguration clientConfiguration = new ClientConfiguration().withUserAgent("AWS Device Farm - Jenkins v1.0");
api = new AWSDeviceFarmClient(creds, clientConfiguration);
api.setServiceNameIntern("devicefarm");
}
public DeviceFarmUploader(final AWSDeviceFarmClient api, final Logger logger) {
this.api = api;
this.logger = logger;
this.uploadExecutor = Executors.newCachedThreadPool();
}