Example usage for com.amazonaws.services.ecr AmazonECRClient AmazonECRClient

List of usage examples for com.amazonaws.services.ecr AmazonECRClient AmazonECRClient

Introduction

In this page you can find the example usage for com.amazonaws.services.ecr AmazonECRClient AmazonECRClient.

Prototype

AmazonECRClient(AwsSyncClientParams clientParams, boolean endpointDiscoveryEnabled) 

Source Link

Document

Constructs a new client to invoke service methods on Amazon ECR using the specified parameters.

Usage

From source file:com.cloudbees.jenkins.plugins.amazonecr.AmazonECSRegistryCredential.java

License:Open Source License

@NonNull
@Override/*from w w w.  j av  a  2 s. co  m*/
public Secret getPassword() {
    final AmazonWebServicesCredentials credentials = getCredentials();
    if (credentials == null)
        throw new IllegalStateException("Invalid credentials");

    final AmazonECRClient client = new AmazonECRClient(credentials.getCredentials(), new ClientConfiguration());
    final GetAuthorizationTokenResult authorizationToken = client
            .getAuthorizationToken(new GetAuthorizationTokenRequest());
    final List<AuthorizationData> authorizationData = authorizationToken.getAuthorizationData();
    if (authorizationData == null || authorizationData.isEmpty()) {
        throw new IllegalStateException("Failed to retreive authorization token for Amazon ECR");
    }
    return Secret.fromString(authorizationData.get(0).getAuthorizationToken());
}