Menghapus pengguna - Amazon Rekognition

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Menghapus pengguna

Anda dapat menggunakan DeleteUseroperasi untuk menghapus pengguna dari koleksi, berdasarkan userID yang disediakan. Perhatikan bahwa setiap wajah yang terkait dengan userID dipisahkan dari userID sebelum userID yang ditentukan dihapus.

Untuk menghapus pengguna (SDK)
  1. Jika belum:

    1. Buat atau perbarui akun pengguna IAM dengan AmazonRekognitionFullAccess izin. Untuk informasi selengkapnya, lihat Langkah 1: Siapkan akun AWS dan buat Pengguna.

    2. Instal dan konfigurasikan AWS CLI dan AWS SDKs. Untuk informasi selengkapnya, lihat Langkah 2: Mengatur AWS CLI dan AWS SDKs.

  2. Gunakan contoh berikut untuk memanggil operasi DeleteUser.

    Java

    Contoh kode Java ini menghapus pengguna.

    import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.DeleteUserRequest; import com.amazonaws.services.rekognition.model.DeleteUserResult; public class DeleteUser { public static void main(String[] args) throws Exception { AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); //Replace collectionId and userId with the name of the user that you want to delete from that target collection. String collectionId = "MyCollection"; String userId = "demoUser"; System.out.println("Deleting existing user: " + userId); DeleteUserRequest request = new DeleteUserRequest() .withCollectionId(collectionId) .withUserId(userId); rekognitionClient.deleteUser(request); } }
    AWS CLI

    AWS CLI Perintah ini menghapus pengguna, menggunakan operasi create-user CLI.

    aws rekognition delete-user --collection-id MyCollection --user-id user-id --collection-id collection-name --region region-name
    Python

    Contoh kode Python ini menghapus pengguna.

    # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-developer-guide/blob/master/LICENSE-SAMPLECODE.) import boto3 from botocore.exceptions import ClientError import logging logger = logging.getLogger(__name__) session = boto3.Session(profile_name='profile-name') client = session.client('rekognition') def delete_user(collection_id, user_id): """ Delete the user from the given collection :param collection_id: The ID of the collection where user is stored. :param user_id: The ID of the user in the collection to delete. """ logger.info(f'Deleting user: {collection_id}, {user_id}') try: client.delete_user( CollectionId=collection_id, UserId=user_id ) except ClientError: logger.exception(f'Failed to delete user with given user id: {user_id}') raise def main(): collection_id = "collection-id" user_id = "user-id" delete_user(collection_id, user_id) if __name__ == "__main__": main()