def search_buckets()

in api/streamlit_experiments/s3.py [0:0]


def search_buckets():
    search = st.text_input('Search S3 bucket in your account', '')
    response = s3_client.list_buckets()
    if search:
        buckets_found = 0
        for bucket in response['Buckets']:
            if search:
                if search in bucket["Name"]:
                    buckets_found = buckets_found + 1
                    st.write(f'{bucket["Name"]}')
        if buckets_found:
            st.success(f'Listing existing **{buckets_found}** buckets containing **{search}** string')
        else:
            st.warning(f'No matching buckets found containing **{search}** string')

    else:   
        st.info('Provide string to search for listing buckets')