Skip to content

Cognito: User Attributes: expose as a HashMap #1309

@antonio-hickey

Description

@antonio-hickey

Describe the feature

Currently the user attributes are provided as a vector of key value pairs, for example the user_attributes field on GetUserOutput https://docs.rs/aws-sdk-cognitoidentityprovider/latest/aws_sdk_cognitoidentityprovider/operation/get_user/struct.GetUserOutput.html#structfield.user_attributes

Wouldn't this be better exposed as a HashMap rather than a Vector of key value pairs (AttributeType)?

The key or name in AttributeType is a String and the value is an Option<String>, so this could be a HashMap<String, Option<String>> right?

To avoid breaking changes we could just expose an additional method and field, something like user_attributes_map() and user_attributes_map. This way current implementations around user_attributes remain stable, and users can opt into this feature by choosing to use the new user_attributes_map instead.

Use Case

Currently I have to loop through these attributes to find the one I'm looking for, something like:

let some_attr = cognito_user
    .user_attributes
    .iter()
    .find(|attr| attr.name == "custom:SomeAttribute");

This feels verbose and something we can abstract away on the library level, so users could do something like:

let some_attr = cognito_user
    .user_attributes_map
    .get("custom:SomeAttribute");

Proposed Solution

No response

Other Information

I believe this is a feature I can add myself, but wanted to open discussion before working on it in case I'm missing something.

Context:

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

A note for the community

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue, please leave a comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.service-apiThis issue is due to a problem in a service API, not the SDK implementation.wontfixWe have determined that we will not resolve the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions