

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

# 프로젝트 설명(SDK)
<a name="md-describing-project-sdk"></a>

`DescribeProjects` API를 사용하여 프로젝트에 대한 정보를 가져올 수 있습니다.

**프로젝트를 설명하려면(SDK)**

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

1. 프로젝트를 설명하려면 다음 예제 코드를 사용하세요. `project_name`을 설명하려는 프로젝트 이름으로 바꿉니다. `--project-names`를 지정하지 않은 경우 모든 프로젝트에 대한 설명이 반환됩니다.

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

   ```
   aws rekognition describe-projects --project-names project_name \
     --profile custom-labels-access
   ```

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

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + project\$1name ``: 설명하고자 하는 프로젝트의 이름입니다. 이름을 지정하지 않은 경우 모든 프로젝트에 대한 설명이 반환됩니다.

   ```
   # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
   # SPDX-License-Identifier: Apache-2.0
   
   """
   Purpose
   Shows how to describe an Amazon Rekognition Custom Labels project.
   """
   import argparse
   import logging
   import json
   import boto3
   from botocore.exceptions import ClientError
   
   logger = logging.getLogger(__name__)
   
   
   def display_project_info(project):
       """
       Displays information about a Custom Labels project.
       :param project: The project that you want to display information about.
       """
       print(f"Arn: {project['ProjectArn']}")
       print(f"Status: {project['Status']}")
   
       if len(project['Datasets']) == 0:
           print("Datasets: None")
       else:
           print("Datasets:")
   
       for dataset in project['Datasets']:
           print(f"\tCreated: {str(dataset['CreationTimestamp'])}")
           print(f"\tType: {dataset['DatasetType']}")
           print(f"\tARN: {dataset['DatasetArn']}")
           print(f"\tStatus: {dataset['Status']}")
           print(f"\tStatus message: {dataset['StatusMessage']}")
           print(f"\tStatus code: {dataset['StatusMessageCode']}")
           print()
       print()
   
   
   def describe_projects(rek_client, project_name):
       """
       Describes an Amazon Rekognition Custom Labels project, or all projects.
       :param rek_client: The Amazon Rekognition Custom Labels Boto3 client.
       :param project_name: The project you want to describe. Pass None to describe all projects.
       """
   
       try:
           # Describe the project
           if project_name is None:
               logger.info("Describing all projects.")
           else:
               logger.info("Describing project: %s.",project_name)
   
           if project_name is None:
               response = rek_client.describe_projects()
           else:
               project_names = json.loads('["' + project_name + '"]')
               response = rek_client.describe_projects(ProjectNames=project_names)
   
           print('Projects\n--------')
           if len(response['ProjectDescriptions']) == 0:
               print("Project(s) not found.")
           else:
               for project in response['ProjectDescriptions']:
                   display_project_info(project)
   
           logger.info("Finished project description.")
   
       except ClientError as err:
           logger.exception(
               "Couldn't describe project - %s: %s",
               project_name,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_name",  help="The name of the project that you want to describe.", 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"Describing projects: {args.project_name}")
   
           # Describe the project.
           session = boto3.Session(profile_name='custom-labels-access')
           rekognition_client = session.client("rekognition")
   
           describe_projects(rekognition_client,
                             args.project_name)
   
           if args.project_name is None:
               print("Finished describing all projects.")
           else:
               print("Finished describing project %s.", args.project_name)
   
       except ClientError as err:
           error_message = f"Problem describing project: {err}"
           logger.exception(error_message)
           print(error_message)
   
   
   if __name__ == "__main__":
       main()
   ```

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

   다음 코드를 사용합니다. 다음 명령줄 파라미터를 제공하세요.
   + `project_name`: 설명하고자 하는 프로젝트의 ARN 이름을 지정하지 않은 경우 모든 프로젝트에 대한 설명이 반환됩니다.

   ```
   /*
      Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
      SPDX-License-Identifier: Apache-2.0
   */
   
   package com.example.rekognition;
   
   import java.util.ArrayList;
   import java.util.List;
   import java.util.logging.Level;
   import java.util.logging.Logger;
   
   import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
   import software.amazon.awssdk.services.rekognition.RekognitionClient;
   import software.amazon.awssdk.services.rekognition.model.DatasetMetadata;
   import software.amazon.awssdk.services.rekognition.model.DescribeProjectsRequest;
   import software.amazon.awssdk.services.rekognition.model.DescribeProjectsResponse;
   import software.amazon.awssdk.services.rekognition.model.ProjectDescription;
   import software.amazon.awssdk.services.rekognition.model.RekognitionException;
   
   public class DescribeProjects {
   
       public static final Logger logger = Logger.getLogger(DescribeProjects.class.getName());
   
       public static void describeMyProjects(RekognitionClient rekClient, String projectName) {
   
           DescribeProjectsRequest descProjects = null;
   
           // If a single project name is supplied, build projectNames argument
   
           List<String> projectNames = new ArrayList<String>();
   
           if (projectName == null) {
               descProjects = DescribeProjectsRequest.builder().build();
           } else {
               projectNames.add(projectName);
               descProjects = DescribeProjectsRequest.builder().projectNames(projectNames).build();
           }
   
           // Display useful information for each project.
   
           DescribeProjectsResponse resp = rekClient.describeProjects(descProjects);
   
           for (ProjectDescription projectDescription : resp.projectDescriptions()) {
   
               System.out.println("ARN: " + projectDescription.projectArn());
               System.out.println("Status: " + projectDescription.statusAsString());
               if (projectDescription.hasDatasets()) {
                   for (DatasetMetadata datasetDescription : projectDescription.datasets()) {
                       System.out.println("\tdataset Type: " + datasetDescription.datasetTypeAsString());
                       System.out.println("\tdataset ARN: " + datasetDescription.datasetArn());
                       System.out.println("\tdataset Status: " + datasetDescription.statusAsString());
                   }
               }
               System.out.println();
           }
   
       }
   
       public static void main(String[] args) {
   
           String projectArn = null;
   
           // Get command line arguments
   
           final String USAGE = "\n" + "Usage: " + "<project_name>\n\n" + "Where:\n"
                   + "   project_name - (Optional) The name of the project that you want to describe. If not specified, all projects "
                   + "are described.\n\n";
   
           if (args.length > 1) {
               System.out.println(USAGE);
               System.exit(1);
           }
   
           if (args.length == 1) {
               projectArn = args[0];
           }
   
           try {
   
               // Get the Rekognition client
               RekognitionClient rekClient = RekognitionClient.builder()
                   .credentialsProvider(ProfileCredentialsProvider.create("custom-labels-access"))
                   .region(Region.US_WEST_2)
                   .build();
               
               // Describe projects
   
               describeMyProjects(rekClient, projectArn);
   
               rekClient.close();
   
           } catch (RekognitionException rekError) {
               logger.log(Level.SEVERE, "Rekognition client error: {0}", rekError.getMessage());
               System.exit(1);
           }
   
       }
   
   }
   ```

------