컬렉션 삭제 - Amazon Rekognition

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

컬렉션 삭제

DeleteCollection 작업을 사용하여 모음을 삭제할 수 있습니다.

자세한 설명은 컬렉션 관리 섹션을 참조하세요.

모음을 삭제하려면(SDK)
  1. 아직 설정하지 않았다면 다음과 같이 하세요.

    1. AmazonRekognitionFullAccess 권한이 있는 사용자를 생성하거나 업데이트합니다. 자세한 설명은 1단계: AWS 계정 설정 및 사용자 생성 섹션을 참조하세요.

    2. 및 AWS SDK를 설치 AWS CLI 및 구성합니다. 자세한 설명은 2단계: AWS CLI 및 AWS SDK 설정 섹션을 참조하세요.

  2. 다음 예제를 사용하여 DeleteCollection 작업을 호출합니다.

    Java

    이 예제는 모음을 삭제합니다.

    collectionId 값을, 삭제하려는 모음으로 변경합니다.

    //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.) package aws.example.rekognition.image; import com.amazonaws.services.rekognition.AmazonRekognition; import com.amazonaws.services.rekognition.AmazonRekognitionClientBuilder; import com.amazonaws.services.rekognition.model.DeleteCollectionRequest; import com.amazonaws.services.rekognition.model.DeleteCollectionResult; public class DeleteCollection { public static void main(String[] args) throws Exception { AmazonRekognition rekognitionClient = AmazonRekognitionClientBuilder.defaultClient(); String collectionId = "MyCollection"; System.out.println("Deleting collections"); DeleteCollectionRequest request = new DeleteCollectionRequest() .withCollectionId(collectionId); DeleteCollectionResult deleteCollectionResult = rekognitionClient.deleteCollection(request); System.out.println(collectionId + ": " + deleteCollectionResult.getStatusCode() .toString()); } }
    Java V2

    이 코드는 AWS 문서 SDK 예제 GitHub 저장소에서 가져왔습니다. 전체 예제는 여기에서 확인하세요.

    // snippet-start:[rekognition.java2.delete_collection.import] import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rekognition.RekognitionClient; import software.amazon.awssdk.services.rekognition.model.DeleteCollectionRequest; import software.amazon.awssdk.services.rekognition.model.DeleteCollectionResponse; import software.amazon.awssdk.services.rekognition.model.RekognitionException; // snippet-end:[rekognition.java2.delete_collection.import] /** * Before running this Java V2 code example, set up your development environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DeleteCollection { public static void main(String[] args) { final String usage = "\n" + "Usage: " + " <collectionId> \n\n" + "Where:\n" + " collectionId - The id of the collection to delete. \n\n"; if (args.length != 1) { System.out.println(usage); System.exit(1); } String collectionId = args[0]; Region region = Region.US_EAST_1; RekognitionClient rekClient = RekognitionClient.builder() .region(region) .credentialsProvider(ProfileCredentialsProvider.create("profile-name")) .build(); System.out.println("Deleting collection: " + collectionId); deleteMyCollection(rekClient, collectionId); rekClient.close(); } // snippet-start:[rekognition.java2.delete_collection.main] public static void deleteMyCollection(RekognitionClient rekClient,String collectionId ) { try { DeleteCollectionRequest deleteCollectionRequest = DeleteCollectionRequest.builder() .collectionId(collectionId) .build(); DeleteCollectionResponse deleteCollectionResponse = rekClient.deleteCollection(deleteCollectionRequest); System.out.println(collectionId + ": " + deleteCollectionResponse.statusCode().toString()); } catch(RekognitionException e) { System.out.println(e.getMessage()); System.exit(1); } } // snippet-end:[rekognition.java2.delete_collection.main] }
    AWS CLI

    이 AWS CLI 명령은 delete-collection CLI 작업에 대한 JSON 출력을 표시합니다. collection-id의 값을, 삭제하려는 모음의 이름으로 바꿉니다. Rekognition 세션을 생성하는 라인에서 profile_name의 값을 개발자 프로필의 이름으로 대체합니다.

    aws rekognition delete-collection --collection-id collection-name --profile profile-name
    Python

    이 예제는 모음을 삭제합니다.

    collection_id 값을, 삭제하려는 모음으로 변경합니다. Rekognition 세션을 생성하는 라인에서 profile_name의 값을 개발자 프로필의 이름으로 대체합니다.

    # 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 def delete_collection(collection_id): print('Attempting to delete collection ' + collection_id) session = boto3.Session(profile_name='default') client = session.client('rekognition') status_code = 0 try: response = client.delete_collection(CollectionId=collection_id) status_code = response['StatusCode'] except ClientError as e: if e.response['Error']['Code'] == 'ResourceNotFoundException': print('The collection ' + collection_id + ' was not found ') else: print('Error other than Not Found occurred: ' + e.response['Error']['Message']) status_code = e.response['ResponseMetadata']['HTTPStatusCode'] return (status_code) def main(): collection_id = 'collection-name' status_code = delete_collection(collection_id) print('Status code: ' + str(status_code)) if __name__ == "__main__": main()
    .NET

    이 예제는 모음을 삭제합니다.

    collectionId 값을, 삭제하려는 모음으로 변경합니다.

    //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.) using System; using Amazon.Rekognition; using Amazon.Rekognition.Model; public class DeleteCollection { public static void Example() { AmazonRekognitionClient rekognitionClient = new AmazonRekognitionClient(); String collectionId = "MyCollection"; Console.WriteLine("Deleting collection: " + collectionId); DeleteCollectionRequest deleteCollectionRequest = new DeleteCollectionRequest() { CollectionId = collectionId }; DeleteCollectionResponse deleteCollectionResponse = rekognitionClient.DeleteCollection(deleteCollectionRequest); Console.WriteLine(collectionId + ": " + deleteCollectionResponse.StatusCode); } }
    Node.js

    Rekognition 세션을 생성하는 라인에서 profile_name의 값을 개발자 프로필의 이름으로 대체합니다.

    //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 { DeleteCollectionCommand } from "@aws-sdk/client-rekognition"; import { RekognitionClient } from "@aws-sdk/client-rekognition"; import {fromIni} from '@aws-sdk/credential-providers'; // Set the AWS Region. const REGION = "region-name"; //e.g. "us-east-1" // Set the profile name const profileName = "profile-name" // Name the collection const rekogClient = new RekognitionClient({region: REGION, credentials: fromIni({profile: profileName,}), }); // Name the collection const collection_name = "collection-name" const deleteCollection = async (collectionName) => { try { console.log(`Attempting to delete collection named - ${collectionName}`) var response = await rekogClient.send(new DeleteCollectionCommand({CollectionId: collectionName})) var status_code = response.StatusCode if (status_code = 200){ console.log("Collection successfully deleted.") } return response; // For unit tests. } catch (err) { console.log("Error", err.stack); } }; deleteCollection(collection_name)

DeleteCollection 작업 요청

DeleteCollection에 대한 입력은 삭제할 모음의 ID입니다. 다음 JSON 예제를 참조하십시오.

{ "CollectionId": "MyCollection" }

DeleteCollection 운영 응답

DeleteCollection 응답에는 작업의 성공 또는 실패를 나타내는 HTTP 상태 코드가 들어 있습니다. 모음이 성공적으로 삭제되면 200이 반환됩니다.

{"StatusCode":200}