

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

# Amazon Rekognition Custom Labels 모델 복사(SDK)
<a name="md-copy-model-overview"></a>

[CopyProjectVersion](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_CopyProjectVersion) 작업을 사용하여 Amazon Rekognition Custom Labels 모델 버전을 원본 Amazon Rekognition Custom Labels 프로젝트에서 대상 프로젝트로 복사할 수 있습니다. 대상 프로젝트는 다른 AWS 계정 또는 동일한 계정에 있을 수 AWS 있습니다. 일반적인 시나리오는 테스트된 모델을 개발 AWS 계정에서 프로덕션 AWS 계정으로 복사하는 것입니다.



또는 소스 데이터 세트를 사용하여 대상 계정에서 모델을 훈련할 수도 있습니다. 이 `CopyProjectVersion` 작업을 사용하면 다음과 같은 이점이 있습니다.
+ 모델 동작이 일관적입니다. 모델 훈련은 비결정적이며, 동일한 데이터 세트로 훈련된 두 모델이 동일한 예측을 내린다고 보장할 수 없습니다. `CopyProjectVersion`을 사용하여 모델을 복사하면 복사된 모델의 동작이 소스 모델과 일치하는지 확인할 수 있으므로 모델을 다시 테스트할 필요가 없습니다.
+ 모델 훈련이 필요하지 않습니다. 모델을 성공적으로 훈련할 때마다 비용이 청구되므로 이렇게 하면 비용이 절약됩니다.

모델을 다른 AWS 계정에 복사하려면 대상 AWS 계정에 Amazon Rekognition Custom Labels 프로젝트가 있어야 합니다. 프로젝트 생성에 대한 자세한 내용은 [프로젝트 생성](mp-create-project.md) 항목을 참조하세요. 대상 AWS 계정에서 프로젝트를 생성해야 합니다.

[프로젝트 정책](md-create-project-policy-document.md)은 복사하려는 모델 버전에 대한 복사 권한을 설정하는 리소스 기반 정책입니다. 대상 프로젝트가 소스 프로젝트와 다른 AWS 계정에 있는 경우 프로젝트 [정책을](md-create-project-policy-document.md) 사용해야 합니다.

동일한 계정 내에서 모델 버전을 복사할 때는 [프로젝트 정책](md-create-project-policy-document.md)을 사용할 필요가 없습니다. 하지만 이러한 리소스를 더 잘 제어하려면 계정 간 프로젝트에 [프로젝트 정책](md-create-project-policy-document.md)을 사용하도록 선택할 수 있습니다.

[PutProjectPolicy](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_PutProjectPolicy) 작업을 직접 호출하여 프로젝트 정책을 소스 프로젝트에 연결합니다.

`CopyProjectVersion`를 사용하여 모델을 다른 AWS 리전의 프로젝트에 복사할 수 없습니다. 또한 Amazon Rekognition Custom Labels 콘솔에서는 모델을 복사할 수 없습니다. 이 경우 소스 모델을 훈련하는 데 사용된 데이터 세트를 사용하여 대상 프로젝트에서 모델을 훈련할 수 있습니다. 자세한 내용은 [Amazon Rekognition Custom Labels 모델 훈련](training-model.md) 단원을 참조하십시오.

소스 프로젝트에서 대상 프로젝트로 모델을 복사하려면 다음을 수행하세요.

**모델을 복사하려면**

1. [프로젝트 정책 문서를 생성합니다](md-create-project-policy-document.md).

1. [프로젝트 정책을 소스 프로젝트에 연결합니다](md-attach-project-policy.md).

1. [`CopyProjectVersion` 작업으로 모델을 복사합니다](md-copy-model-sdk.md).

프로젝트에서 프로젝트 정책을 제거하려면 [DeleteProjectPolicy](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteProjectPolicy)를 직접 호출하세요. 프로젝트에 첨부된 프로젝트 정책 목록을 가져오려면 [ListProjectPolicies](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListProjectPolicies)를 직접 호출하세요.

**Topics**
+ [프로젝트 정책 문서 생성](md-create-project-policy-document.md)
+ [프로젝트 정책(SDK) 연결](md-attach-project-policy.md)
+ [모델 복사(SDK)](md-copy-model-sdk.md)
+ [프로젝트 정책 나열(SDK)](md-list-project-policies.md)
+ [프로젝트 정책 삭제(SDK)](md-delete-project-policy.title.md)

# 프로젝트 정책 문서 생성
<a name="md-create-project-policy-document"></a>

Rekognition Custom Labels는 프로젝트 정책**이라고 하는 리소스 기반 정책을 사용하여 모델 버전의 복사 권한을 관리합니다. 프로젝트 정책은 JSON 형식 문서입니다.

프로젝트 정책은 소스 프로젝트에서 대상 프로젝트로 모델 버전을 복사할 수 있는 [보안 주체](https://docs.aws.amazon.com/IAM/latest/UserGuide/intro-structure.html#intro-structure-principal) 권한을 허용하거나 거부합니다. 대상 프로젝트가 다른 AWS 계정에 있는 경우 프로젝트 정책이 필요합니다. 대상 프로젝트가 원본 프로젝트와 동일한 AWS 계정에 있고 특정 모델 버전에 대한 액세스를 제한하려는 경우에도 마찬가지입니다. 예를 들어 AWS 계정 내의 특정 IAM 역할에 대한 복사 권한을 거부할 수 있습니다.

다음 예제는 보안 주체 `arn:aws:iam::111111111111:role/Admin`이 모델 버전 `arn:aws:rekognition:us-east-1:123456789012:project/my_project/version/test_1/1627045542080`을 복사할 수 있도록 허용합니다.

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement":[
    {
      "Effect":"Allow",
      "Principal":{
        "AWS":"arn:aws:iam::111111111111:role/Admin"
      },
      "Action":"rekognition:CopyProjectVersion",
      "Resource":"arn:aws:rekognition:us-east-1:111111111111:project/my_project/version/test_1/1627045542080"
    }
  ]
}
```

------

**참고**  
`Action`, `Resource`, `Principal`, 및 `Effect`는 프로젝트 정책 문서의 필수 필드입니다.  
유일하게 지원되는 `action`은 `rekognition:CopyProjectVersion`입니다.  
`NotAction`, `NotResource`, 및 `NotPrincipal`은 금지된 필드이므로 프로젝트 정책 문서에 없어야 합니다.

프로젝트 정책을 지정하지 않으면 소스 프로젝트와 동일한 AWS 계정의 보안 주체가를 호출할 수 있는 권한을 부여하는와 같은 자격 증명 기반 정책이 보안 주체에 ` AmazonRekognitionCustomLabelsFullAccess`있는 경우에도 모델을 복사할 수 있습니다`CopyProjectVersion`.

다음 절차는 [프로젝트 정책(SDK) 연결](md-attach-project-policy.md)의 Python 예제와 함께 사용할 수 있는 프로젝트 정책 문서 파일을 만듭니다. `put-project-policy` AWS CLI 명령을 사용하는 경우 프로젝트 정책을 JSON 문자열로 제공합니다.

**프로젝트 정책 문서를 생성하려면**

1. 텍스트 편집기에서 다음 문서를 생성합니다. 다음 값을 변경합니다.
   + 효과: 복사 권한을 부여하려면 `ALLOW`를 지정하세요. 복사 권한을 거부하려면 `DENY`를 지정하세요.
   + 보안 주체: `Resource`에서 지정한 모델 버전의 권한을 허용하거나 거부하고 싶은 보안 주체로 변경하세요. 예를 들어 다른 [계정의 AWS 계정 보안 주체](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#principal-accounts)를 지정할 수 AWS 있습니다. 사용할 수 있는 보안 주체에는 제한이 없습니다. 자세한 내용은 [보안 주체 지정](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html#Principal_specifying)을 참조하세요.
   + 리소스: 복사 권한을 지정하려는 모델 버전의 Amazon 리소스 이름(ARN)입니다. 소스 프로젝트 내의 모든 모델 버전에 권한을 부여하려면 다음 `arn:aws:rekognition:region:account:project/source project/version/* ` 형식을 사용하세요.

1. 프로젝트 정책을 컴퓨터에 저장합니다.

1. [프로젝트 정책(SDK) 연결](md-attach-project-policy.md)의 지침에 따라 프로젝트 정책을 소스 프로젝트에 연결합니다.

# 프로젝트 정책(SDK) 연결
<a name="md-attach-project-policy"></a>

[PutProjectPolicy](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_PutProjectPolicy) 작업을 직접 호출하여 Amazon Rekognition Custom Labels 프로젝트에 프로젝트 정책을 연결합니다.

추가하려는 각 프로젝트 정책마다 `PutProjectPolicy`를 직접 호출하여 여러 프로젝트 정책을 프로젝트에 연결하세요. 최대 5개의 프로젝트 정책을 프로젝트에 연결할 수 있습니다. 더 많은 프로젝트 정책을 추가해야 하는 경우 [한도](limits.md) 증가를 요청할 수 있습니다.

고유한 프로젝트 정책을 프로젝트에 처음 첨부할 때는 `PolicyRevisionId` 입력 파라미터에 수정 ID를 지정하지 마세요. `PutProjectPolicy`의 응답은 Amazon Rekognition Custom Labels가 사용자를 위해 생성하는 프로젝트 정책의 수정 ID입니다. 수정 ID를 사용하여 프로젝트 정책의 최신 개정 버전을 업데이트하거나 삭제할 수 있습니다. Amazon Rekognition Custom Labels는 프로젝트 정책의 최신 개정 버전만 보관합니다. 프로젝트 정책의 이전 개정 버전을 업데이트하거나 삭제하려고 하면 `InvalidPolicyRevisionIdException` 오류가 발생합니다.

기존 프로젝트 정책을 업데이트하려면 `PolicyRevisionId` 입력 파라미터에 프로젝트 정책의 개정 ID를 지정합니다. [ListProjectPolicies](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListProjectPolicies)를 직접 호출하여 프로젝트의 프로젝트 정책에 대한 개정 ID를 가져올 수 있습니다.

프로젝트 정책을 소스 프로젝트에 연결한 후 소스 프로젝트에서 대상 프로젝트로 모델을 복사할 수 있습니다. 자세한 내용은 [모델 복사(SDK)](md-copy-model-sdk.md) 단원을 참조하십시오.

프로젝트에서 프로젝트 정책을 제거하려면 [DeleteProjectPolicy](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteProjectPolicy)를 직접 호출하세요. 프로젝트에 첨부된 프로젝트 정책 목록을 가져오려면 [ListProjectPolicies](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListProjectPolicies)를 직접 호출하세요.

**프로젝트 정책을 프로젝트에 연결하려면(SDK)**

1. 아직 설치하지 않은 경우 및 AWS SDKs AWS CLI 를 설치하고 구성합니다. 자세한 내용은 [4단계: AWS CLI 및 AWS SDKs 설정](su-awscli-sdk.md) 단원을 참조하십시오.

1. [프로젝트 정책 문서를 생성합니다](md-create-project-policy-document.md).

1. 다음 코드를 사용하여 복사하려는 모델 버전이 포함된 신뢰할 수 있는 AWS 계정의 프로젝트에 프로젝트 정책을 연결합니다. 프로젝트 ARN을 가져오려면 [DescribeProjects](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-describing-project-sdk.html)를 직접 호출하세요. 모델 버전 ARN을 가져오려면 [DescribeProjectVersions](https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-describing-model-sdk.html)를 직접 호출하세요.

------
#### [ AWS CLI ]

   다음 값을 변경합니다.
   + `project-arn`를 복사하려는 모델 버전이 포함된 신뢰할 수 있는 AWS 계정의 소스 프로젝트의 ARN으로 바꿉니다.
   + `policy-name`을 선택한 정책 이름으로 변경합니다.
   + `principal`을 `Model version ARN`에서 지정한 모델 버전에 대한 액세스를 허용하거나 거부하려는 보안 주체로 변경합니다.
   + `project-version-arn`을 복사하려는 모델 버전의 ARN으로 변경합니다.

   기존 프로젝트 정책을 업데이트하려면 `policy-revision-id` 파라미터를 지정하고 원하는 프로젝트 정책의 개정 ID를 제공하세요.

   ```
   aws rekognition put-project-policy \
     --project-arn project-arn \
     --policy-name policy-name \
     --policy-document '{ "Version": "2012-10-17",		 	 	  "Statement":[{ "Effect":"ALLOW or DENY", "Principal":{ "AWS":"principal" }, "Action":"rekognition:CopyProjectVersion", "Resource":"project-version-arn" }]}' \
     --profile custom-labels-access
   ```

------
#### [ Python ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `project_arn`: 프로젝트 정책을 연결할 소스 프로젝트의 ARN 
   + `policy_name`: 사용자가 선택한 정책 이름 
   + `project_policy`: 프로젝트 정책 문서가 들어 있는 파일
   + `policy_revision_id`: (선택 사항) 기존 프로젝트 정책의 개정 버전을 업데이트하려면 프로젝트 정책의 개정 ID를 지정하세요.

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   """
   Purpose
   Amazon Rekognition Custom Labels model example used in the service documentation:
   https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-copy-model-sdk.html
   Shows how to attach a project policy to an Amazon Rekognition Custom Labels project.
   """
   
   import boto3
   import argparse
   import logging
   import json
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def put_project_policy(rek_client, project_arn, policy_name, policy_document_file, policy_revision_id=None):
       """
       Attaches a project policy to an Amazon Rekognition Custom Labels project.
       :param rek_client: The Amazon Rekognition Custom Labels Boto3 client.
       :param policy_name: A name for the project policy.
       :param project_arn: The Amazon Resource Name (ARN) of the source project
       that you want to attach the project policy to.
       :param policy_document_file: The JSON project policy document to
       attach to the source project.
       :param policy_revision_id: (Optional) The revision of an existing policy to update.
       Pass None to attach new policy.
       :return The revision ID for the project policy.
       """
   
       try:
   
           policy_document_json = ""
           response = None
   
           with open(policy_document_file, 'r') as policy_document:
               policy_document_json = json.dumps(json.load(policy_document))
   
           logger.info(
               "Attaching %s project_policy to project %s.", 
               policy_name, project_arn)
   
           if policy_revision_id is None:
               response = rek_client.put_project_policy(ProjectArn=project_arn,
                                                        PolicyName=policy_name,
                                                        PolicyDocument=policy_document_json)
   
           else:
               response = rek_client.put_project_policy(ProjectArn=project_arn,
                                                        PolicyName=policy_name,
                                                        PolicyDocument=policy_document_json,
                                                        PolicyRevisionId=policy_revision_id)
   
           new_revision_id = response['PolicyRevisionId']
   
           logger.info(
               "Finished creating project policy %s. Revision ID: %s",
               policy_name, new_revision_id)
   
           return new_revision_id
   
       except ClientError as err:
           logger.exception(
               "Couldn't attach %s project policy to project %s: %s }",
               policy_name, project_arn, err.response['Error']['Message'] )
           raise
   
   
   def add_arguments(parser):
       """
       Adds command line arguments to the parser.
       :param parser: The command line parser.
       """
   
       parser.add_argument(
           "project_arn",  help="The Amazon Resource Name (ARN) of the project "
           "that you want to attach the project policy to."
       )
       parser.add_argument(
           "policy_name",  help="A name for the project policy."
   
       )
   
       parser.add_argument(
           "project_policy",  help="The file containing the project policy JSON"
       )
   
       parser.add_argument(
           "--policy_revision_id",  help="The revision of an existing policy to update. "
           "If you don't supply a value, a new project policy is created.",
           required=False
       )
   
   
   def main():
   
       logging.basicConfig(level=logging.INFO,
                           format="%(levelname)s: %(message)s")
   
       try:
   
           # get command line arguments
           parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
           add_arguments(parser)
   
           args = parser.parse_args()
   
           print(f"Attaching policy to {args.project_arn}")
   
           session = boto3.Session(profile_name='custom-labels-access')
           rekognition_client = session.client("rekognition")
   
   
           # Attach a new policy or update an existing policy.
   
           response = put_project_policy(rekognition_client,
                                         args.project_arn,
                                         args.policy_name,
                                         args.project_policy,
                                         args.policy_revision_id)
   
           print(
               f"project policy {args.policy_name} attached to project {args.project_arn}")
           print(f"Revision ID: {response}")
   
       except ClientError as err:
           print("Problem attaching project policy: %s", err)
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ Java V2 ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `project_arn`: 프로젝트 정책을 연결할 소스 프로젝트의 ARN 
   + `project_policy_name`: 사용자가 선택한 정책 이름 
   + `project_policy_document`: 프로젝트 정책 문서가 들어 있는 파일
   + `project_policy_revision_id`: (선택 사항) 기존 프로젝트 정책의 개정 버전을 업데이트하려면 프로젝트 정책의 개정 ID를 지정하세요.

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   
   import java.io.IOException;
   import java.nio.file.Files;
   import java.nio.file.Path;
   import java.util.logging.Level;
   import java.util.logging.Logger;
   
   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.PutProjectPolicyRequest;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   public class PutProjectPolicy {
   
       public static final Logger logger = Logger.getLogger(PutProjectPolicy.class.getName());
   
       public static void putMyProjectPolicy(RekognitionClient rekClient, String projectArn, String projectPolicyName,
                String projectPolicyFileName, String projectPolicyRevisionId) throws IOException {
   
           try {
   
               Path filePath = Path.of(projectPolicyFileName);
   
               
   
               String policyDocument = Files.readString(filePath);
   
               String[] logArguments = new String[] { projectPolicyFileName, projectPolicyName };
   
               PutProjectPolicyRequest putProjectPolicyRequest = null;
   
               logger.log(Level.INFO, "Attaching Project policy: {0} to project: {1}", logArguments);
   
               // Attach the project policy.
   
               if (projectPolicyRevisionId == null) {
                   putProjectPolicyRequest = PutProjectPolicyRequest.builder().projectArn(projectArn)
                           .policyName(projectPolicyName).policyDocument(policyDocument).build();
               } else {
                   putProjectPolicyRequest = PutProjectPolicyRequest.builder().projectArn(projectArn)
                           .policyName(projectPolicyName).policyRevisionId(projectPolicyRevisionId)
                           .policyDocument(policyDocument)
   
                           .build();
               }
   
               rekClient.putProjectPolicy(putProjectPolicyRequest);
   
               logger.log(Level.INFO, "Attached Project policy: {0} to project: {1}", logArguments);
   
           } catch (
   
           RekognitionException e) {
               logger.log(Level.SEVERE, "Client error occurred: {0}", e.getMessage());
               throw e;
           }
   
       }
   
       public static void main(String args[]) {
   
           final String USAGE = "\n" + "Usage: "
                   + "<project_arn> <project_policy_name> <policy_document> <project_policy_revision_id>\n\n" + "Where:\n"
                   + "   project_arn - The ARN of the project that you want to attach the project policy to.\n\n"
                   + "   project_policy_name - A name for the project policy.\n\n"
                   + "   project_policy_document - The file name of the project policy.\n\n"
                   + "   project_policy_revision_id - (Optional) The revision ID of the project policy that you want to update.\n\n";
   
           if (args.length < 3 || args.length > 4) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           String projectArn = args[0];
           String projectPolicyName = args[1];
           String projectPolicyDocument = args[2];
           String projectPolicyRevisionId = null;
   
           if (args.length == 4) {
               projectPolicyRevisionId = args[3];
           }
   
           try {
   
               RekognitionClient rekClient = RekognitionClient.builder()
               .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
               .region(Region.US_WEST_2)
               .build();
   
           
               // Attach the project policy.
               putMyProjectPolicy(rekClient, projectArn, projectPolicyName, projectPolicyDocument,
                       projectPolicyRevisionId);
   
               System.out.println(
                       String.format("project policy %s: attached to project: %s", projectPolicyName, projectArn));
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           }
   
           catch (IOException intError) {
               logger.log(Level.SEVERE, "Exception while reading policy document: {0}", intError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------

1. [모델 복사(SDK)](md-copy-model-sdk.md)의 지침에 따라 모델 버전을 복사하세요.

# 모델 복사(SDK)
<a name="md-copy-model-sdk"></a>

`CopyProjectVersion` API를 사용하여 소스 프로젝트에서 대상 프로젝트로 모델 버전을 복사할 수 있습니다. 대상 프로젝트는 다른 AWS 계정에 있을 수 있지만 동일한 AWS 리전이어야 합니다. 대상 프로젝트가 다른 AWS 계정에 있는 경우(또는 AWS 계정 내에서 복사된 모델 버전에 대한 특정 권한을 부여하려는 경우) 소스 프로젝트에 프로젝트 정책을 연결해야 합니다. 자세한 내용은 [프로젝트 정책 문서 생성](md-create-project-policy-document.md) 단원을 참조하십시오. `CopyProjectVersion` API를 사용하려면 Amazon S3 버킷에 대한 액세스 권한이 필요합니다.

복사된 모델에는 원본 모델의 훈련 결과가 포함되지만 원본 데이터 세트는 포함되지 않습니다.

적절한 권한을 설정하지 않는 한 소스 AWS 계정은 대상 계정으로 복사된 모델에 대한 소유권이 없습니다.

**모델을 복사하려면(SDK)**

1. 아직 설치하지 않은 경우 및 AWS SDKs AWS CLI 를 설치하고 구성합니다. 자세한 내용은 [4단계: AWS CLI 및 AWS SDKs 설정](su-awscli-sdk.md) 단원을 참조하십시오.

1. [프로젝트 정책(SDK) 연결](md-attach-project-policy.md)의 지침에 따라 프로젝트 정책을 소스 프로젝트에 연결합니다.

1. 모델을 다른 AWS 계정에 복사하는 경우 대상 AWS 계정에 프로젝트가 있는지 확인합니다.

1. 다음 코드를 사용하여 모델 버전을 대상 프로젝트에 복사하세요.

------
#### [ AWS CLI ]

   다음 값을 변경합니다.
   + `source-project-arn`을 복사하려는 모델 버전이 포함된 소스 프로젝트 ARN으로 변경합니다.
   + `source-project-version-arn`을 복사하려는 모델 버전의 ARN으로 변경합니다.
   + `destination-project-arn`을 모델을 복사할 대상 프로젝트의 ARN으로 변경합니다.
   + `version-name`을 대상 프로젝트에 있는 모델의 버전 이름으로 변경합니다.
   + `bucket`을 소스 모델의 훈련 결과를 복사할 S3 버킷으로 변경합니다.
   + `folder`를 소스 모델의 훈련 결과를 복사하려는 `bucket` 내의 폴더로 변경합니다.
   + (선택 사항) `kms-key-id`를 모델의 AWS Key Management Service 키 ID로 변경합니다.
   + (선택 사항) `key`을 선택한 태그 키로 변경합니다.
   + (선택 사항) `value`를 선택한 태그 값으로 변경합니다.

   ```
   aws rekognition copy-project-version \
     --source-project-arn source-project-arn \
     --source-project-version-arn source-project-version-arn \
     --destination-project-arn destination-project-arn \
     --version-name version-name \
     --output-config '{"S3Bucket":"bucket","S3KeyPrefix":"folder"}' \
     --kms-key-id arn:myKey \
     --tags '{"key":"key"}' \
     --profile custom-labels-access
   ```

------
#### [ Python ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `source_project_arn` - 복사하려는 모델 버전이 포함된 소스 AWS 계정의 소스 프로젝트의 ARN입니다.
   + `source_project_version-arn` - 복사하려는 소스 AWS 계정에서 모델 버전의 ARN입니다.
   + `destination_project_arn`: 모델을 복사할 대상 프로젝트의 ARN 
   + `destination_version_name`: 대상 프로젝트에 있는 모델의 버전 이름 
   + `training_results`: 소스 모델의 훈련 결과를 복사할 S3 위치 
   + (선택 사항) `kms_key_id`를 모델의 AWS Key Management Service 키 ID로 변경합니다.
   + (선택 사항) `tag_name`을 선택한 태그 키로 변경합니다.
   + (선택 사항) `tag_value`를 선택한 태그 값으로 변경합니다.

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   import argparse
   import logging
   import time
   import boto3
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def copy_model(
       rekognition_client, source_project_arn, source_project_version_arn,
           destination_project_arn, training_results, destination_version_name):
       """
       Copies a version of a Amazon Rekognition Custom Labels model.
   
       :param rekognition_client: A Boto3 Amazon Rekognition Custom Labels client.
       :param source_project_arn: The ARN of the source project that contains the
       model that you want to copy.
       :param source_project_version_arn: The ARN of the model version that you want
       to copy.
       :param destination_project_Arn: The ARN of the project that you want to copy the model
       to.
       :param training_results: The Amazon S3 location where training results for the model
       should be stored.
       return: The model status and version.
       """
       try:
           logger.info("Copying model...%s from %s to %s ", source_project_version_arn,
                       source_project_arn,
                       destination_project_arn)
   
           output_bucket, output_folder = training_results.replace(
               "s3://", "").split("/", 1)
           output_config = {"S3Bucket": output_bucket,
                            "S3KeyPrefix": output_folder}
   
           response = rekognition_client.copy_project_version(
               DestinationProjectArn=destination_project_arn,
               OutputConfig=output_config,
               SourceProjectArn=source_project_arn,
               SourceProjectVersionArn=source_project_version_arn,
               VersionName=destination_version_name
           )
   
           destination_model_arn = response["ProjectVersionArn"]
   
           logger.info("Destination model ARN: %s", destination_model_arn)
   
           # Wait until training completes.
           finished = False
           status = "UNKNOWN"
           while finished is False:
               model_description = rekognition_client.describe_project_versions(ProjectArn=destination_project_arn,
                       VersionNames=[destination_version_name])
               status = model_description["ProjectVersionDescriptions"][0]["Status"]
   
               if status == "COPYING_IN_PROGRESS":
                   logger.info("Model copying in progress...")
                   time.sleep(60)
                   continue
   
               if status == "COPYING_COMPLETED":
                   logger.info("Model was successfully copied.")
   
               if status == "COPYING_FAILED":
                   logger.info(
                       "Model copy failed: %s ",
                       model_description["ProjectVersionDescriptions"][0]["StatusMessage"])
   
               finished = True
       except ClientError:
           logger.exception("Couldn't copy model.")
           raise
       else:
           return destination_model_arn, status
   
   
   def add_arguments(parser):
       """
       Adds command line arguments to the parser.
       :param parser: The command line parser.
       """
   
       parser.add_argument(
           "source_project_arn",
           help="The ARN of the project that contains the model that you want to copy."
       )
   
       parser.add_argument(
           "source_project_version_arn",
           help="The ARN of the model version that you want to copy."
       )
   
       parser.add_argument(
           "destination_project_arn",
           help="The ARN of the project which receives the copied model."
       )
   
       parser.add_argument(
           "destination_version_name",
           help="The version name for the model in the destination project."
       )
   
       parser.add_argument(
           "training_results",
           help="The S3 location in the destination account that receives the training results for the copied model."
       )
   
   
   def main():
   
       logging.basicConfig(level=logging.INFO,
                           format="%(levelname)s: %(message)s")
   
       try:
   
           # get command line arguments
           parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
           add_arguments(parser)
           args = parser.parse_args()
   
           print(
               f"Copying model version {args.source_project_version_arn} to project {args.destination_project_arn}")
   
           session = boto3.Session(profile_name='custom-labels-access')
           rekognition_client = session.client("rekognition")
   
           # Copy the model.
   
           model_arn, status = copy_model(rekognition_client,
                                          args.source_project_arn,
                                          args.source_project_version_arn,
                                          args.destination_project_arn,
                                          args.training_results,
                                          args.destination_version_name,
                                          )
   
           print(f"Finished copying model: {model_arn}")
           print(f"Status: {status}")
   
       except ClientError as err:
           print(f"Problem copying model: {err}")
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ Java V2 ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `source_project_arn` - 복사하려는 모델 버전이 포함된 소스 AWS 계정의 소스 프로젝트의 ARN입니다.
   + `source_project_version-arn` - 복사하려는 소스 AWS 계정에서 모델 버전의 ARN입니다.
   + `destination_project_arn`: 모델을 복사할 대상 프로젝트의 ARN 
   + `destination_version_name`: 대상 프로젝트에 있는 모델의 버전 이름 
   + `output_bucket`: 소스 모델 버전의 훈련 결과를 복사하려는 S3 버킷 
   + `output_folder`: 소스 모델 버전의 훈련 결과를 복사하려는 S3 내의 폴더 

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   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.CopyProjectVersionRequest;
   import software.amazon.awssdk.services.rekognition.model.CopyProjectVersionResponse;
   import software.amazon.awssdk.services.rekognition.model.DescribeProjectVersionsRequest;
   import software.amazon.awssdk.services.rekognition.model.DescribeProjectVersionsResponse;
   import software.amazon.awssdk.services.rekognition.model.OutputConfig;
   import software.amazon.awssdk.services.rekognition.model.ProjectVersionDescription;
   
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   import java.util.logging.Level;
   import java.util.logging.Logger;
   
   public class CopyModel {
   
       public static final Logger logger = Logger.getLogger(CopyModel.class.getName());
   
       public static ProjectVersionDescription copyMyModel(RekognitionClient rekClient,
               String sourceProjectArn,
               String sourceProjectVersionArn,
               String destinationProjectArn,
               String versionName,
               String outputBucket,
               String outputFolder) throws InterruptedException {
   
           try {
   
               OutputConfig outputConfig = OutputConfig.builder().s3Bucket(outputBucket).s3KeyPrefix(outputFolder).build();
   
               String[] logArguments = new String[] { versionName, sourceProjectArn, destinationProjectArn };
   
               logger.log(Level.INFO, "Copying model {0} for from project {1} to project {2}", logArguments);
   
               CopyProjectVersionRequest copyProjectVersionRequest = CopyProjectVersionRequest.builder()
                       .sourceProjectArn(sourceProjectArn)
                       .sourceProjectVersionArn(sourceProjectVersionArn)
                       .versionName(versionName)
                       .destinationProjectArn(destinationProjectArn)
                       .outputConfig(outputConfig)
                       .build();
   
               CopyProjectVersionResponse response = rekClient.copyProjectVersion(copyProjectVersionRequest);
   
               logger.log(Level.INFO, "Destination model ARN: {0}", response.projectVersionArn());
               logger.log(Level.INFO, "Copying model...");
   
               // wait until copying completes.
   
               boolean finished = false;
   
               ProjectVersionDescription copiedModel = null;
   
               while (Boolean.FALSE.equals(finished)) {
                   DescribeProjectVersionsRequest describeProjectVersionsRequest = DescribeProjectVersionsRequest.builder()
                           .versionNames(versionName)
                           .projectArn(destinationProjectArn)
                           .build();
   
                   DescribeProjectVersionsResponse describeProjectVersionsResponse = rekClient
                           .describeProjectVersions(describeProjectVersionsRequest);
   
                   for (ProjectVersionDescription projectVersionDescription : describeProjectVersionsResponse
                           .projectVersionDescriptions()) {
   
                       copiedModel = projectVersionDescription;
   
                       switch (projectVersionDescription.status()) {
   
                           case COPYING_IN_PROGRESS:
                               logger.log(Level.INFO, "Copying model...");
                               Thread.sleep(5000);
                               continue;
   
                           case COPYING_COMPLETED:
                               finished = true;
                               logger.log(Level.INFO, "Copying completed");
                               break;
   
                           case COPYING_FAILED:
                               finished = true;
                               logger.log(Level.INFO, "Copying failed...");
                               break;
   
                           default:
                               finished = true;
                               logger.log(Level.INFO, "Unexpected copy status %s",
                                       projectVersionDescription.statusAsString());
                               break;
   
                       }
   
                   }
   
               }
   
               logger.log(Level.INFO, "Finished copying model {0} for from project {1} to project {2}", logArguments);
   
               return copiedModel;
   
           } catch (RekognitionException e) {
               logger.log(Level.SEVERE, "Could not train model: {0}", e.getMessage());
               throw e;
           }
   
       }
   
       public static void main(String args[]) {
   
           String sourceProjectArn = null;
           String sourceProjectVersionArn = null;
           String destinationProjectArn = null;
           String versionName = null;
           String bucket = null;
           String location = null;
   
           final String USAGE = "\n" + "Usage: "
                   + "<source_project_arn> <source_project_version_arn> <destination_project_arn> <version_name> <output_bucket> <output_folder>\n\n"
                   + "Where:\n"
                   + "   source_project_arn - The ARN of the project that contains the model that you want to copy. \n\n"
                   + "   source_project_version_arn - The ARN of the project that contains the model that you want to copy. \n\n"
                   + "   destination_project_arn - The ARN of the destination project that you want to copy the model to. \n\n"
                   + "   version_name - A version name for the copied model.\n\n"
                   + "   output_bucket - The S3 bucket in which to place the training output. \n\n"
                   + "   output_folder - The folder within the bucket that the training output is stored in. \n\n";
   
           if (args.length != 6) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           sourceProjectArn = args[0];
           sourceProjectVersionArn = args[1];
           destinationProjectArn = args[2];
           versionName = args[3];
           bucket = args[4];
           location = args[5];
   
           try {
   
               // Get the Rekognition client.
               RekognitionClient rekClient = RekognitionClient.builder()
               .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
               .region(Region.US_WEST_2)
               .build();
   
               // Copy the model.
               ProjectVersionDescription copiedModel = copyMyModel(rekClient,
                       sourceProjectArn,
                       sourceProjectVersionArn,
                       destinationProjectArn,
                       versionName,
                       bucket,
                       location);
   
               System.out.println(String.format("Model copied: %s Status: %s",
                       copiedModel.projectVersionArn(),
                       copiedModel.statusMessage()));
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           } catch (InterruptedException intError) {
               logger.log(Level.SEVERE, "Exception while sleeping: {0}", intError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------

# 프로젝트 정책 나열(SDK)
<a name="md-list-project-policies"></a>

[ListProjectPolicies](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListProjectPolicies) 작업을 사용하여 Amazon Rekognition Custom Labels 프로젝트에 연결된 프로젝트 정책을 나열할 수 있습니다.

**프로젝트에 연결된 프로젝트 정책을 나열하려면(SDK)**

1. 아직 설치하지 않은 경우 및 AWS SDKs AWS CLI 를 설치하고 구성합니다. 자세한 내용은 [4단계: AWS CLI 및 AWS SDKs 설정](su-awscli-sdk.md) 단원을 참조하십시오.

1. 다음 코드를 사용하여 프로젝트 정책을 나열합니다.

------
#### [ AWS CLI ]

   `project-arn`을 첨부된 프로젝트 정책을 나열하려는 프로젝트의 Amazon 리소스 이름으로 변경합니다.

   ```
   aws rekognition list-project-policies \
     --project-arn project-arn \
     --profile custom-labels-access
   ```

------
#### [ Python ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + project\$1arn: 첨부된 프로젝트 정책을 나열하려는 프로젝트의 Amazon 리소스 이름 

   예: `python list_project_policies.py project_arn `

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   """
   Purpose
   Amazon Rekognition Custom Labels model example used in the service documentation:
   https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-copy-model-sdk.html
   Shows how to list the project policies in an Amazon Rekogntion Custom Labels project.
   """
   
   
   import argparse
   import logging
   import boto3
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def display_project_policy(project_policy):
       """
       Displays information about a Custom Labels project policy.
       :param project_policy: The project policy (ProjectPolicy)
       that you want to display information about.
       """
       print(f"Policy name: {(project_policy['PolicyName'])}")
       print(f"Project Arn: {project_policy['ProjectArn']}")
       print(f"Document: {(project_policy['PolicyDocument'])}")
       print(f"Revision ID: {(project_policy['PolicyRevisionId'])}")
       print()
   
   
   
   def list_project_policies(rek_client, project_arn):
       """
       Describes an Amazon Rekognition Custom Labels project, or all projects.
       :param rek_client: The Amazon Rekognition Custom Labels Boto3 client.
       :param project_arn: The Amazon Resource Name of the project you want to use.
       """
   
       try:
   
           max_results = 5
           pagination_token = ''
           finished = False
   
           logger.info("Listing project policies in: %s.", project_arn)
           print('Projects\n--------')
           while not finished:
   
               response = rek_client.list_project_policies(
                   ProjectArn=project_arn, MaxResults=max_results, NextToken=pagination_token)
   
               for project in response['ProjectPolicies']:
                   display_project_policy(project)
   
               if 'NextToken' in response:
                   pagination_token = response['NextToken']
               else:
                   finished = True
   
           logger.info("Finished listing project policies.")
   
       except ClientError as err:
           logger.exception(
               "Couldn't list policies for - %s: %s",
               project_arn,err.response['Error']['Message'])
           raise
   
   
   def add_arguments(parser):
       """
       Adds command line arguments to the parser.
       :param parser: The command line parser.
       """
   
       parser.add_argument(
           "project_arn",  help="The Amazon Resource Name of the project for which you want to list project policies."
       )
   
   
   def main():
   
       logging.basicConfig(level=logging.INFO,
                           format="%(levelname)s: %(message)s")
   
       try:
   
           # get command line arguments
           parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
           add_arguments(parser)
           args = parser.parse_args()
   
           print(f"Listing project policies in: {args.project_arn}")
   
           # List the project policies.
   
           session = boto3.Session(profile_name='custom-labels-access')
           rekognition_client = session.client("rekognition")
   
           list_project_policies(rekognition_client,
                                 args.project_arn)
   
       except ClientError as err:
           print(f"Problem list project_policies: {err}")
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ Java V2 ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + project\$1arn: 나열하려는 프로젝트 정책이 있는 프로젝트의 ARN

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   
   import java.util.logging.Level;
   import java.util.logging.Logger;
   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.ListProjectPoliciesRequest;
   import software.amazon.awssdk.services.rekognition.model.ListProjectPoliciesResponse;
   import software.amazon.awssdk.services.rekognition.model.ProjectPolicy;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   public class ListProjectPolicies {
   
       public static final Logger logger = Logger.getLogger(ListProjectPolicies.class.getName());
   
       public static void listMyProjectPolicies(RekognitionClient rekClient, String projectArn) {
   
           try {
   
               logger.log(Level.INFO, "Listing project policies for project: {0}", projectArn);
   
               // List the project policies.
   
               Boolean finished = false;
               String nextToken = null;
   
               while (Boolean.FALSE.equals(finished)) {
   
                   ListProjectPoliciesRequest listProjectPoliciesRequest = ListProjectPoliciesRequest.builder()
                           .maxResults(5)
                           .projectArn(projectArn)
                           .nextToken(nextToken)
                           .build();
   
                   ListProjectPoliciesResponse response = rekClient.listProjectPolicies(listProjectPoliciesRequest);
   
                   for (ProjectPolicy projectPolicy : response.projectPolicies()) {
   
                       System.out.println(String.format("Name: %s", projectPolicy.policyName()));
                       System.out.println(String.format("Revision ID: %s\n", projectPolicy.policyRevisionId()));
   
                   }
   
                   nextToken = response.nextToken();
   
                   if (nextToken == null) {
                       finished = true;
   
                   }
   
               }
   
               logger.log(Level.INFO, "Finished listing project policies for project: {0}", projectArn);
   
           } catch (
   
           RekognitionException e) {
               logger.log(Level.SEVERE, "Client error occurred: {0}", e.getMessage());
               throw e;
           }
   
       }
   
       public static void main(String args[]) {
   
           final String USAGE = "\n" + "Usage: " + "<project_arn> \n\n" + "Where:\n"
                   + "   project_arn - The ARN of the project with the project policies that you want to list.\n\n";
           ;
   
           if (args.length != 1) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           String projectArn = args[0];
   
           try {
   
               RekognitionClient rekClient = RekognitionClient.builder()
               .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
               .region(Region.US_WEST_2)
               .build();
         
               // List the project policies.
               listMyProjectPolicies(rekClient, projectArn);
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------

# 프로젝트 정책 삭제(SDK)
<a name="md-delete-project-policy.title"></a>

[DeleteProjectPolicy](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_DeleteProjectPolicy) 작업을 사용하여 Amazon Rekognition Custom Labels 프로젝트에서 기존 프로젝트 정책의 개정 버전을 삭제할 수 있습니다. 프로젝트에 연결된 프로젝트 정책의 모든 개정 버전을 삭제하려면 [ListProjectPolicies](https://docs.aws.amazon.com/rekognition/latest/APIReference/API_ListProjectPolicies)를 사용하여 프로젝트에 연결된 각 프로젝트 정책의 개정 ID를 가져오세요. 그런 다음 각 정책 이름에 `DeletePolicy`를 직접 호출합니다.

**프로젝트 정책 개정 버전을 삭제하려면(SDK)**

1. 아직 설치하지 않은 경우 및 AWS SDKs AWS CLI 를 설치하고 구성합니다. 자세한 내용은 [4단계: AWS CLI 및 AWS SDKs 설정](su-awscli-sdk.md) 단원을 참조하십시오.

1. 다음 코드를 사용하여 프로젝트 정책을 삭제합니다.

   DeletePolicy에는 `ProjectARN`, `PolicyName`, `PolicyRevisionId`가 필요합니다. `ProjectARN` 및 `PolicyName`은 이 API에 필요합니다. `PolicyRevisionId`는 선택 사항이지만, 원자성 업데이트 목적으로 넣을 수 있습니다.

------
#### [ AWS CLI ]

   다음 값을 변경합니다.
   + `policy-name`을 삭제하려는 프로젝트 정책의 이름으로 변경합니다.
   + `policy-revision-id`를 삭제하려는 프로젝트 정책의 개정 ID로 변경합니다.
   + `project-arn`을 삭제하려는 프로젝트 정책의 개정 버전이 포함된 프로젝트의 Amazon 리소스 이름으로 변경합니다.

   ```
   aws rekognition delete-project-policy \
       --policy-name policy-name \
       --policy-revision-id policy-revision-id \
       --project-arn project-arn \
     --profile custom-labels-access
   ```

------
#### [ Python ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `policy-name`: 삭제하려는 프로젝트 정책의 이름 
   + `project-arn`: 삭제하려는 프로젝트 정책이 포함된 프로젝트의 Amazon 리소스 이름
   + `policy-revision-id`: 삭제하려는 프로젝트 정책의 개정 ID 

   예: `python delete_project_policy.py policy_name project_arn` *policy\$1revision\$1id* 

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   """
   Purpose
   Amazon Rekognition Custom Labels model example used in the service documentation:
   https://docs.aws.amazon.com/rekognition/latest/customlabels-dg/md-copy-model-sdk.html
   Shows how to delete a revision of a project policy.
   """
   
   import argparse
   import logging
   import boto3
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def delete_project_policy(rekognition_client, policy_name,  project_arn, policy_revision_id=None):
       """
       Deletes a project policy.
   
       :param rekognition_client: A Boto3 Amazon Rekognition client.
       :param policy_name: The name of the project policy that you want to delete.
       :param policy_revision_id: The revsion ID for the project policy that you want to delete.
       :param project_arn: The Amazon Resource Name of the project that contains the project policy
       that you want to delete.
       """
       try:
           logger.info("Deleting project policy: %s", policy_name)
   
           if policy_revision_id is None:
               rekognition_client.delete_project_policy(
                   PolicyName=policy_name,
                   ProjectArn=project_arn)
   
           else:
               rekognition_client.delete_project_policy(
                   PolicyName=policy_name,
                   PolicyRevisionId=policy_revision_id,
                   ProjectArn=project_arn)
   
           logger.info("Deleted project policy: %s", policy_name)
       except ClientError:
           logger.exception("Couldn't delete project policy.")
           raise
   
   
   def confirm_project_policy_deletion(policy_name):
       """
       Confirms deletion of the project policy. Returns True if delete entered.
       :param model_arn: The ARN of the model that you want to delete.
       """
       print(
           f"Are you sure you wany to delete project policy {policy_name} ?\n", policy_name)
   
       delete = input("Enter delete to delete your project policy: ")
       if delete == "delete":
           return True
       else:
           return False
   
   
   def add_arguments(parser):
       """
       Adds command line arguments to the parser.
       :param parser: The command line parser.
       """
   
       parser.add_argument(
           "policy_name", help="The ARN of the project that contains the project policy that you want to delete."
       )
   
       parser.add_argument(
           "project_arn", help="The ARN of the project project policy you want to delete."
       )
   
       parser.add_argument(
           "--policy_revision_id", help="(Optional) The revision ID of the project policy that you want to delete.",
           required=False
       )
   
   
   def main():
   
       logging.basicConfig(level=logging.INFO,
                           format="%(levelname)s: %(message)s")
   
       try:
   
           # Get command line arguments.
           parser = argparse.ArgumentParser(usage=argparse.SUPPRESS)
           add_arguments(parser)
           args = parser.parse_args()
   
           if confirm_project_policy_deletion(args.policy_name) is True:
               print(f"Deleting project_policy: {args.policy_name}")
   
               session = boto3.Session(profile_name='custom-labels-access')
               rekognition_client = session.client("rekognition")
   
               # Delete the project policy.
   
               delete_project_policy(rekognition_client,
                                     args.policy_name,
                                     args.project_arn,
                                     args.policy_revision_id)
   
               print(f"Finished deleting project policy: {args.policy_name}")
           else:
               print(f"Not deleting project policy {args.policy_name}")
       except ClientError as err:
           print(f"Couldn't delete project policy in {args.policy_name}: {err}")
   
   
   
   if __name__ == "__main__":
       main()
   ```

------
#### [ Java V2 ]

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `policy-name`: 삭제하려는 프로젝트 정책의 이름 
   + `project-arn`: 삭제하려는 프로젝트 정책이 포함된 프로젝트의 Amazon 리소스 이름
   + `policy-revision-id`: 삭제하려는 프로젝트 정책의 개정 ID 

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   
   import java.util.logging.Level;
   import java.util.logging.Logger;
   
   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.DeleteProjectPolicyRequest;
   
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   public class DeleteProjectPolicy {
   
       public static final Logger logger = Logger.getLogger(DeleteProjectPolicy.class.getName());
   
       public static void deleteMyProjectPolicy(RekognitionClient rekClient, String projectArn,
               String projectPolicyName,
               String projectPolicyRevisionId)
               throws InterruptedException {
   
           try {
               String[] logArguments = new String[] { projectPolicyName, projectPolicyRevisionId };
   
               logger.log(Level.INFO, "Deleting: Project policy: {0} revision: {1}", logArguments);
   
               // Delete the project policy.
   
               DeleteProjectPolicyRequest deleteProjectPolicyRequest = DeleteProjectPolicyRequest.builder()
                       .policyName(projectPolicyName)
                       .policyRevisionId(projectPolicyRevisionId)
                       .projectArn(projectArn).build();
   
               rekClient.deleteProjectPolicy(deleteProjectPolicyRequest);
   
               logger.log(Level.INFO, "Deleted: Project policy: {0} revision: {1}", logArguments);
   
           } catch (
   
           RekognitionException e) {
               logger.log(Level.SEVERE, "Client error occurred: {0}", e.getMessage());
               throw e;
           }
   
       }
   
       public static void main(String args[]) {
   
           final String USAGE = "\n" + "Usage: " + "<project_arn> <project_policy_name> <project_policy_revision_id>\n\n"
                   + "Where:\n"
                   + "   project_arn - The ARN of the project that has the project policy that you want to delete.\n\n"
                   + "   project_policy_name - The name of the project policy that you want to delete.\n\n"
                   + "   project_policy_revision_id - The revision of the project policy that you want to delete.\n\n";
   
           if (args.length != 3) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           String projectArn = args[0];
           String projectPolicyName = args[1];
           String projectPolicyRevisionId = args[2];
   
           try {
   
               RekognitionClient rekClient = RekognitionClient.builder()
               .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
               .region(Region.US_WEST_2)
               .build();
   
               // Delete the project policy.
               deleteMyProjectPolicy(rekClient, projectArn, projectPolicyName, projectPolicyRevisionId);
   
               System.out.println(String.format("project policy deleted: %s revision: %s", projectPolicyName,
                       projectPolicyRevisionId));
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           }
   
           catch (InterruptedException intError) {
               logger.log(Level.SEVERE, "Exception while sleeping: {0}", intError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------