@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRoles() == null) ? 0 : getRoles().hashCode()); hashCode = prime * hashCode + ((getIsTruncated() == null) ? 0 : getIsTruncated().hashCode()); hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); return hashCode; }
/** * <p> * A flag that indicates whether there are more items to return. If your results were truncated, you can make a * subsequent pagination request using the <code>Marker</code> request parameter to retrieve more items. Note that * IAM might return fewer than the <code>MaxItems</code> number of results even when there are more results * available. We recommend that you check <code>IsTruncated</code> after every call to ensure that you receive all * your results. * </p> * * @param isTruncated * A flag that indicates whether there are more items to return. If your results were truncated, you can make * a subsequent pagination request using the <code>Marker</code> request parameter to retrieve more items. * Note that IAM might return fewer than the <code>MaxItems</code> number of results even when there are more * results available. We recommend that you check <code>IsTruncated</code> after every call to ensure that * you receive all your results. * @return Returns a reference to this object so that method calls can be chained together. */ public ListRolesResult withIsTruncated(Boolean isTruncated) { setIsTruncated(isTruncated); return this; }
private Set<String> loadRoles() { Set<String> result = new TreeSet<String>(); boolean done = false; String marker = null; do { final ListRolesRequest listRolesRequest = new ListRolesRequest(); listRolesRequest.setMarker(marker); final ListRolesResult listRolesResult = iam.listRoles(listRolesRequest); for (Role r : listRolesResult.getRoles()) { result.add(r.getArn()); } done = (!listRolesResult.isTruncated()); marker = listRolesResult.getMarker(); } while (!done); return result; }
/** * Fetch IAM roles. * * @param temporaryCredentials the temporary credentials * @param account the account * @return the map */ public static Map<String,List<Role>> fetchIAMRoles(BasicSessionCredentials temporaryCredentials,String account) { AmazonIdentityManagement iamClient = AmazonIdentityManagementClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(InventoryConstants.REGION_US_WEST_2).build(); List<Role> roles = new ArrayList<>(); ListRolesResult rslt; String marker = null; do{ rslt = iamClient.listRoles(new ListRolesRequest().withMarker(marker)); roles.addAll(rslt.getRoles()); marker = rslt.getMarker(); }while(marker!=null); log.debug(InventoryConstants.ACCOUNT + account +" Type : IAM Roles >> "+roles.size()); Map<String,List<Role>> iamRoles = new HashMap<>(); iamRoles.put(account, roles); return iamRoles; }
@Override public AbstractModelList<String> getEmrRolesFromAmazonAccount() { List<Role> emrRolesList = aim.listRoles().getRoles(); AbstractModelList<String> emrList; emrList = emrRolesList.stream().filter( e -> e.getAssumeRolePolicyDocument().contains( "elasticmapreduce" ) ) .map( e -> e.getRoleName() ).collect( Collectors.toCollection( AbstractModelList<String>::new ) ); return emrList; } }
public ListRolesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListRolesResult listRolesResult = new ListRolesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; listRolesResult.withRoles(new ArrayList<Role>()); continue; listRolesResult.withRoles(RoleStaxUnmarshaller.getInstance().unmarshall(context)); continue; listRolesResult.setIsTruncated(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; listRolesResult.setMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
while (true) { for (Role role : result.getRoles()) { try { ObjectNode n = convertAwsObject(role, null); if (result.isTruncated()) { result = iam.listRoles(new ListRolesRequest().withMarker(result.getMarker())); } else { break;
public ListRolesResult unmarshall(StaxUnmarshallerContext context) throws Exception { ListRolesResult listRolesResult = new ListRolesResult(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; listRolesResult.withRoles(new ArrayList<Role>()); continue; listRolesResult.withRoles(RoleStaxUnmarshaller.getInstance().unmarshall(context)); continue; listRolesResult.setIsTruncated(BooleanStaxUnmarshaller.getInstance().unmarshall(context)); continue; listRolesResult.setMarker(StringStaxUnmarshaller.getInstance().unmarshall(context)); continue;
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListRolesResult == false) return false; ListRolesResult other = (ListRolesResult) obj; if (other.getRoles() == null ^ this.getRoles() == null) return false; if (other.getRoles() != null && other.getRoles().equals(this.getRoles()) == false) return false; if (other.getIsTruncated() == null ^ this.getIsTruncated() == null) return false; if (other.getIsTruncated() != null && other.getIsTruncated().equals(this.getIsTruncated()) == false) return false; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; return true; }
/** * <p> * A flag that indicates whether there are more items to return. If your results were truncated, you can make a * subsequent pagination request using the <code>Marker</code> request parameter to retrieve more items. Note that * IAM might return fewer than the <code>MaxItems</code> number of results even when there are more results * available. We recommend that you check <code>IsTruncated</code> after every call to ensure that you receive all * your results. * </p> * * @param isTruncated * A flag that indicates whether there are more items to return. If your results were truncated, you can make * a subsequent pagination request using the <code>Marker</code> request parameter to retrieve more items. * Note that IAM might return fewer than the <code>MaxItems</code> number of results even when there are more * results available. We recommend that you check <code>IsTruncated</code> after every call to ensure that * you receive all your results. * @return Returns a reference to this object so that method calls can be chained together. */ public ListRolesResult withIsTruncated(Boolean isTruncated) { setIsTruncated(isTruncated); return this; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRoles() != null) sb.append("Roles: ").append(getRoles()).append(","); if (getIsTruncated() != null) sb.append("IsTruncated: ").append(getIsTruncated()).append(","); if (getMarker() != null) sb.append("Marker: ").append(getMarker()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getRoles() == null) ? 0 : getRoles().hashCode()); hashCode = prime * hashCode + ((getIsTruncated() == null) ? 0 : getIsTruncated().hashCode()); hashCode = prime * hashCode + ((getMarker() == null) ? 0 : getMarker().hashCode()); return hashCode; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof ListRolesResult == false) return false; ListRolesResult other = (ListRolesResult) obj; if (other.getRoles() == null ^ this.getRoles() == null) return false; if (other.getRoles() != null && other.getRoles().equals(this.getRoles()) == false) return false; if (other.getIsTruncated() == null ^ this.getIsTruncated() == null) return false; if (other.getIsTruncated() != null && other.getIsTruncated().equals(this.getIsTruncated()) == false) return false; if (other.getMarker() == null ^ this.getMarker() == null) return false; if (other.getMarker() != null && other.getMarker().equals(this.getMarker()) == false) return false; return true; }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getRoles() != null) sb.append("Roles: ").append(getRoles()).append(","); if (getIsTruncated() != null) sb.append("IsTruncated: ").append(getIsTruncated()).append(","); if (getMarker() != null) sb.append("Marker: ").append(getMarker()); sb.append("}"); return sb.toString(); }