Search in sources :

Example 1 with BasicProfile

use of com.amazonaws.auth.profile.internal.BasicProfile in project intellij-idea-plugin-connector-for-aws-lambda by satr.

the class FunctionConnectorModel method getCredentialProfiles.

public OperationValueResult<List<CredentialProfileEntity>> getCredentialProfiles() {
    OperationValueResult<List<CredentialProfileEntity>> valueResult = new OperationValueResultImpl<>();
    ArrayList<CredentialProfileEntity> credentialProfilesEntries = new ArrayList<>();
    valueResult.setValue(credentialProfilesEntries);
    if (!validateCredentialProfilesExist()) {
        valueResult.addWarning("No credential profiles file found.\n To create one - please follow the instruction:\n https://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html ");
        return valueResult;
    }
    ProfilesConfigFile profilesConfigFile = new ProfilesConfigFile();
    Map<String, BasicProfile> profiles = profilesConfigFile.getAllBasicProfiles();
    for (String credentialProfileName : profiles.keySet()) {
        credentialProfilesEntries.add(new CredentialProfileEntity(credentialProfileName, profiles.get(credentialProfileName)));
    }
    valueResult.addInfo("Found %d credential profiles.", credentialProfilesEntries.size());
    return valueResult;
}
Also used : OperationValueResultImpl(io.github.satr.common.OperationValueResultImpl) BasicProfile(com.amazonaws.auth.profile.internal.BasicProfile) ProfilesConfigFile(com.amazonaws.auth.profile.ProfilesConfigFile)

Example 2 with BasicProfile

use of com.amazonaws.auth.profile.internal.BasicProfile in project intellij-idea-plugin-connector-for-aws-lambda by satr.

the class ConnectorPresenterImpl method setCredentialProfile.

@Override
public void setCredentialProfile(CredentialProfileEntity credentialProfileEntity) {
    BasicProfile basicProfile = credentialProfileEntity.getBasicProfile();
    Regions lastSelectedRegion = getLastSelectedRegion();
    Regions region = lastSelectedRegion;
    if (!isEmpty(basicProfile.getRegion())) {
        region = tryGetRegionBy(basicProfile.getRegion());
    }
    if (region == null) {
        region = lastSelectedRegion;
    }
    String credentialProfile = credentialProfileEntity.getName();
    getConnectorSettings().setLastSelectedCredentialProfile(credentialProfile);
    setRegionAndProfile(region, credentialProfile);
    if (!lastSelectedRegion.getName().equals(region.getName())) {
        view.setRegion(region);
    }
    CredentialProfileEntity profileEntity = view.getSelectedCredentialProfileEntity();
    if (profileEntity == null) {
        getLogger().logInfo("Credential profile is not selected.");
    } else {
        getLogger().logInfo("Selected Credential profile: \"%s\"", profileEntity.getName());
    }
    refreshStatus();
}
Also used : BasicProfile(com.amazonaws.auth.profile.internal.BasicProfile) Regions(com.amazonaws.regions.Regions)

Aggregations

BasicProfile (com.amazonaws.auth.profile.internal.BasicProfile)2 ProfilesConfigFile (com.amazonaws.auth.profile.ProfilesConfigFile)1 Regions (com.amazonaws.regions.Regions)1 OperationValueResultImpl (io.github.satr.common.OperationValueResultImpl)1