aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

identitystore describe-user: get enabled/disabled status #628

Closed jk2l closed 8 months ago

jk2l commented 8 months ago

More or less follow up on https://github.com/aws/aws-sdk/issues/477, as that ticket is closed and AWS team may not see it. I am trying to start a new conversation here.

as AWS console's API provide the Active field information but not accessible via official AWS API. what is aws-sdk stand on integrate with that side of API by pulling in the information from that? there are example codes on how to achieve it, but it will be great to be built in officially into AWS sdk

jk2l commented 8 months ago

Here is my example code on how to pull in that information

from botocore.auth import SigV4Auth
import requests
from botocore.awsrequest import AWSRequest
import botocore.session
import json

def fetch_all_users(identity_store_id, region):
    session = botocore.session.Session()
    sigv4 = SigV4Auth(session.get_credentials(), 'identitystore', region)
    endpoint = f'https://up.sso.{region}.amazonaws.com/identitystore/'
    data = json.dumps( {"IdentityStoreId":identity_store_id, "MaxResults":100 })
    headers = {
        'Content-Type': 'application/x-amz-json-1.1',
        'X-Amz-Target': 'AWSIdentityStoreService.SearchUsers'
    }
    request = AWSRequest(method='POST', url=endpoint, data=data, headers=headers)

    sigv4.add_auth(request)
    prepped = request.prepare()

    response = requests.post(prepped.url, headers=prepped.headers, data=data)
    return response
tim-finnigan commented 8 months ago

I provide an updated here on the issue you linked: https://github.com/aws/aws-sdk/issues/477#issuecomment-1785761496. Going to close this one as a duplicate.

github-actions[bot] commented 8 months ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.