Search in sources :

Example 1 with S3ObjectManagerImplementation

use of com.amazonaws.mobileconnectors.appsync.S3ObjectManagerImplementation in project aws-mobile-appsync-sdk-android by awslabs.

the class AWSAppSyncClients method withAPIKEYFromAWSConfiguration.

@NonNull
public static AWSAppSyncClient withAPIKEYFromAWSConfiguration(boolean subscriptionsAutoReconnect, long credentialsDelay) {
    AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
    JSONObject ccpConfig = awsConfiguration.optJsonObject("CredentialsProvider");
    String cognitoIdentityPoolID = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.PoolId");
    String cognitoRegion = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.Region");
    DelayedCognitoCredentialsProvider credentialsProvider = new DelayedCognitoCredentialsProvider(cognitoIdentityPoolID, Regions.fromName(cognitoRegion), credentialsDelay);
    AmazonS3Client s3Client = new AmazonS3Client(credentialsProvider, Region.getRegion("us-west-2"));
    S3ObjectManager s3ObjectManager = new S3ObjectManagerImplementation((s3Client));
    return AWSAppSyncClient.builder().context(getTargetContext()).awsConfiguration(awsConfiguration).conflictResolver(new TestConflictResolver()).s3ObjectManager(s3ObjectManager).subscriptionsAutoReconnect(subscriptionsAutoReconnect).mutationQueueExecutionTimeout(TimeUnit.SECONDS.toMillis(30)).persistentMutationsCallback(LoggingPersistentMutationsCallback.instance()).useClientDatabasePrefix(true).build();
}
Also used : S3ObjectManager(com.apollographql.apollo.api.S3ObjectManager) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) JSONObject(org.json.JSONObject) DelayedCognitoCredentialsProvider(com.amazonaws.mobileconnectors.appsync.identity.DelayedCognitoCredentialsProvider) AWSConfiguration(com.amazonaws.mobile.config.AWSConfiguration) S3ObjectManagerImplementation(com.amazonaws.mobileconnectors.appsync.S3ObjectManagerImplementation) NonNull(androidx.annotation.NonNull)

Example 2 with S3ObjectManagerImplementation

use of com.amazonaws.mobileconnectors.appsync.S3ObjectManagerImplementation in project aws-mobile-appsync-sdk-android by awslabs.

the class AWSAppSyncClients method withIAMFromAWSConfiguration.

@NonNull
public static AWSAppSyncClient withIAMFromAWSConfiguration(boolean subscriptionsAutoReconnect, long credentialsDelay) {
    AWSConfiguration awsConfiguration = new AWSConfiguration(getTargetContext());
    awsConfiguration.setConfiguration("MultiAuthAndroidIntegTestApp_AWS_IAM");
    JSONObject ccpConfig = awsConfiguration.optJsonObject("CredentialsProvider");
    String cognitoIdentityPoolID = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.PoolId");
    String cognitoRegion = JsonExtract.stringValue(ccpConfig, "CognitoIdentity.Default.Region");
    DelayedCognitoCredentialsProvider credentialsProvider = new DelayedCognitoCredentialsProvider(cognitoIdentityPoolID, Regions.fromName(cognitoRegion), credentialsDelay);
    AmazonS3Client s3Client = new AmazonS3Client(credentialsProvider, Region.getRegion("us-west-2"));
    S3ObjectManager s3ObjectManager = new S3ObjectManagerImplementation(s3Client);
    return AWSAppSyncClient.builder().context(getTargetContext()).credentialsProvider(credentialsProvider).awsConfiguration(awsConfiguration).conflictResolver(new TestConflictResolver()).s3ObjectManager(s3ObjectManager).subscriptionsAutoReconnect(subscriptionsAutoReconnect).mutationQueueExecutionTimeout(TimeUnit.SECONDS.toMillis(30)).persistentMutationsCallback(LoggingPersistentMutationsCallback.instance()).useClientDatabasePrefix(true).build();
}
Also used : S3ObjectManager(com.apollographql.apollo.api.S3ObjectManager) AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) JSONObject(org.json.JSONObject) DelayedCognitoCredentialsProvider(com.amazonaws.mobileconnectors.appsync.identity.DelayedCognitoCredentialsProvider) AWSConfiguration(com.amazonaws.mobile.config.AWSConfiguration) S3ObjectManagerImplementation(com.amazonaws.mobileconnectors.appsync.S3ObjectManagerImplementation) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)2 AWSConfiguration (com.amazonaws.mobile.config.AWSConfiguration)2 S3ObjectManagerImplementation (com.amazonaws.mobileconnectors.appsync.S3ObjectManagerImplementation)2 DelayedCognitoCredentialsProvider (com.amazonaws.mobileconnectors.appsync.identity.DelayedCognitoCredentialsProvider)2 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)2 S3ObjectManager (com.apollographql.apollo.api.S3ObjectManager)2 JSONObject (org.json.JSONObject)2