Example usage for com.amazonaws.services.ecr.model GetAuthorizationTokenResult getAuthorizationData

List of usage examples for com.amazonaws.services.ecr.model GetAuthorizationTokenResult getAuthorizationData

Introduction

In this page you can find the example usage for com.amazonaws.services.ecr.model GetAuthorizationTokenResult getAuthorizationData.

Prototype


public java.util.List<AuthorizationData> getAuthorizationData() 

Source Link

Document

A list of authorization token data objects that correspond to the registryIds values in the request.

Usage

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

License:Open Source License

@NonNull
@Override/*  w w  w  . ja  v  a2s  .com*/
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());
}

From source file:jp.classmethod.aws.gradle.ecr.AmazonECRGetAuthorizationTokenTask.java

License:Apache License

@TaskAction
public void createRepository() {
    List<String> repositoryIds = getRepositoryIds();

    if (repositoryIds == null || repositoryIds.isEmpty()) {
        throw new GradleException("Must specify ECR repositoryIds");
    }/*from  w  w w.  j a v  a2s  .  co  m*/

    AmazonECRPluginExtension ext = getProject().getExtensions().getByType(AmazonECRPluginExtension.class);
    AmazonECR ecr = ext.getClient();

    GetAuthorizationTokenResult result = ecr
            .getAuthorizationToken(new GetAuthorizationTokenRequest().withRegistryIds(repositoryIds));
    authorizationData = result.getAuthorizationData();
}