class AwsPublicKeyConnector implements PublicKeyConnector {

    @Override
    public void register(PublicKeyRegisterRequest request) {
        LOGGER.debug("Importing public key {} to {} region on AWS", request.getPublicKeyId(), request.getRegion());
        AwsCredentialView awsCredential = new AwsCredentialView(request.getCredential());
        try {
            AmazonEC2Client client = awsClient.createAccess(awsCredential, request.getRegion());
            if (!exists(client, request.getPublicKeyId())) {
                ImportKeyPairRequest importKeyPairRequest = new ImportKeyPairRequest(request.getPublicKeyId(), request.getPublicKey());
                client.importKeyPair(importKeyPairRequest);
            }
        } catch (Exception e) {
            String errorMessage = String.format("Failed to import public key [%s:'%s', region: '%s'], detailed message: %s",
                    getType(awsCredential), getAwsId(awsCredential), request.getRegion(), e.getMessage());
            LOGGER.error(errorMessage, e);
            throw new CloudConnectorException(e.getMessage(), e);
        }
    }

    public  AwsPublicKeyConnector(AwsClient awsClient);

}