All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bxt.command.cognitoidentity.Module Maven / Gradle / Ivy

The newest version!
package bxt.command.cognitoidentity;

import bxt.annotation.Interactive;
import bxt.command.CommandInfo;
import bxt.command.CommandInfoBuilder;
import bxt.util.Prompts;
import com.amazonaws.services.cognitoidentity.model.CreateIdentityPoolRequest;
import com.amazonaws.services.cognitoidentity.model.ListIdentityPoolsRequest;
import com.google.common.collect.ImmutableCollection;
import dagger.Provides;

import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;

@dagger.Module
public final class Module {
    @Provides
    @Singleton
    @Named("cognitoidentity")
    ImmutableCollection provideCommands(
            CreateIdentityPool createIdentityPool,
            ListIdentityPools listIdentityPools,
            @Interactive Provider createIdentityPoolInteractively) {
        return new CommandInfoBuilder()
                .add(
                        createIdentityPool,
                        new bxt.request.cli.cognitoidentity.CreateIdentityPool(),
                        createIdentityPoolInteractively)
                .add(
                        listIdentityPools,
                        new bxt.request.cli.cognitoidentity.ListIdentityPools(),
                        () -> new ListIdentityPoolsRequest().withMaxResults(60))
                .build();
    }

    @Provides
    @Interactive
    CreateIdentityPoolRequest createIdentityPool() {
        String name = Prompts.input("pool name:").get();
        boolean allowUnauthenticatedIdentities = Prompts.yesNo("allow unauthenticated identities?");
        return new CreateIdentityPoolRequest()
                .withIdentityPoolName(name)
                .withAllowUnauthenticatedIdentities(allowUnauthenticatedIdentities);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy