GetRestApisOR와 함께 사용 AWS SDK CLI - AWS SDK코드 예제

AWS 문서 AWS SDK SDK 예제 GitHub 리포지토리에 더 많은 예제가 있습니다.

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

GetRestApisOR와 함께 사용 AWS SDK CLI

다음 코드 예제는 GetRestApis의 사용 방법을 보여 줍니다.

작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.

CLI
AWS CLI

목록을 가져오려면 REST APIs

명령:

aws apigateway get-rest-apis

출력:

{ "items": [ { "createdDate": 1438884790, "id": "12s44z21rb", "name": "My First API" } ] }
  • 자세한 API 내용은 AWS CLI 명령 GetRestApis참조를 참조하십시오.

Python
SDK파이썬용 (보토3)
참고

더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

class ApiGatewayToService: """ Encapsulates Amazon API Gateway functions that are used to create a REST API that integrates with another AWS service. """ def __init__(self, apig_client): """ :param apig_client: A Boto3 API Gateway client. """ self.apig_client = apig_client self.api_id = None self.root_id = None self.stage = None def get_rest_api_id(self, api_name): """ Gets the ID of a REST API from its name by searching the list of REST APIs for the current account. Because names need not be unique, this returns only the first API with the specified name. :param api_name: The name of the API to look up. :return: The ID of the specified API. """ try: rest_api = None paginator = self.apig_client.get_paginator("get_rest_apis") for page in paginator.paginate(): rest_api = next( (item for item in page["items"] if item["name"] == api_name), None ) if rest_api is not None: break self.api_id = rest_api["id"] logger.info("Found ID %s for API %s.", rest_api["id"], api_name) except ClientError: logger.exception("Couldn't find ID for API %s.", api_name) raise else: return rest_api["id"]
  • 자세한 API AWS SDK내용은 Python (Boto3) API 참조를 참조하십시오 GetRestApis.

Rust
SDK러스트의 경우
참고

더 많은 정보가 있습니다 GitHub. AWS 코드 예시 리포지토리에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요.

리전의 Amazon API 게이트웨이를 REST APIs 표시합니다.

async fn show_apis(client: &Client) -> Result<(), Error> { let resp = client.get_rest_apis().send().await?; for api in resp.items() { println!("ID: {}", api.id().unwrap_or_default()); println!("Name: {}", api.name().unwrap_or_default()); println!("Description: {}", api.description().unwrap_or_default()); println!("Version: {}", api.version().unwrap_or_default()); println!( "Created: {}", api.created_date().unwrap().to_chrono_utc()? ); println!(); } Ok(()) }
  • 자세한 API 내용은 Rust GetRestApisAPI참조에서AWS SDK 을 참조하십시오.